]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiCitation.cpp
Fix bug #11748.
[lyx.git] / src / frontends / qt4 / GuiCitation.cpp
index 1af187aa281a73081e02ca6a2e45f65ed9ad5627..0a9dbbf1ee332b55b92e32f642e73d87400a1555 100644 (file)
@@ -175,6 +175,8 @@ GuiCitation::GuiCitation(GuiView & lv)
        selectedLV->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
 #endif
 
+       selectedLV->setToolTip(qt_("Ordered list of all cited references.\n"
+                                  "You can reorder, add and remove references with the buttons on the left."));
        setFocusProxy(filter_);
 }
 
@@ -202,7 +204,8 @@ void GuiCitation::applyView()
 
 void GuiCitation::showEvent(QShowEvent * e)
 {
-       filter_->clear();
+       if (!filter_->text().isEmpty())
+               filterPressed();
        availableLV->setFocus();
        DialogView::showEvent(e);
 }
@@ -281,7 +284,10 @@ void GuiCitation::updateFormatting(CitationStyle const & currentStyle)
        bool const qualified = currentStyle.hasQualifiedList
                && (rows > 1
                    || !params_["pretextlist"].empty()
-                   || !params_["posttextlist"].empty());
+                   || !params_["posttextlist"].empty()
+                   || !getPreTexts().empty()
+                   || !getPostTexts().empty());
+
        selectedLV->horizontalHeader()->setVisible(qualified);
        selectedLV->setColumnHidden(0, !qualified);
        selectedLV->setColumnHidden(2, !qualified);
@@ -353,6 +359,12 @@ void GuiCitation::updateFormatting(CitationStyle const & currentStyle)
                        starredCB->setToolTip(qt_("Always list all authors (rather than using \"et al.\"), "
                                                  "if the current citation style supports this."));
        }
+       if (availableLV->selectionModel()->selectedIndexes().isEmpty())
+               availableLV->setToolTip(qt_("All references available for citing."));
+       else
+               availableLV->setToolTip(qt_("All references available for citing.\n"
+                                           "To add the selected one, hit Add, press Enter or double-click.\n"
+                                           "Hit Ctrl-Enter to add and close the dialog."));
 }
 
 
@@ -374,6 +386,8 @@ void GuiCitation::updateStyles(BiblioInfo const & bi)
        int curr = selectedLV->model()->rowCount() - 1;
 
        if (curr < 0 || selected_keys.empty()) {
+               last_chosen_style_ =
+                       citationStyleCO->itemData(citationStyleCO->currentIndex()).toString();
                citationStyleCO->clear();
                citationStyleCO->setEnabled(false);
                citationStyleLA->setEnabled(false);
@@ -396,7 +410,10 @@ void GuiCitation::updateStyles(BiblioInfo const & bi)
        // save old style selection
        QString const curdata =
                citationStyleCO->itemData(citationStyleCO->currentIndex()).toString();
-       QString const olddata = (curdata.isEmpty()) ? style_ : curdata;
+       QString const olddata = (curdata.isEmpty()) ?
+               (last_chosen_style_.isEmpty() ? style_ : last_chosen_style_): curdata;
+       // reset this
+       last_chosen_style_.clear();
        citationStyleCO->clear();
        BiblioInfo::CiteStringMap::const_iterator cit = sty.begin();
        BiblioInfo::CiteStringMap::const_iterator end = sty.end();
@@ -730,7 +747,7 @@ vector<docstring> GuiCitation::getPostTexts()
        for (int i = 0; i != selected_model_.rowCount(); ++i) {
                QStandardItem const * key = selected_model_.item(i, 1);
                QStandardItem const * post = selected_model_.item(i, 2);
-               if (key && post)
+               if (key && post && !key->text().isEmpty() && !post->text().isEmpty())
                        res.push_back(qstring_to_ucs4(key->text()) + " " + qstring_to_ucs4(post->text()));
        }
        return res;