]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBibtex.cpp
Some improvements to the graphics dialog
[lyx.git] / src / frontends / qt4 / GuiBibtex.cpp
index 92861442e72885192f1472bfe07dc852229012d4..4b4dd7e61c7dead146cf2b4ff0a85f7c606a069e 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "Buffer.h"
 #include "BufferParams.h"
+#include "CiteEnginesList.h"
 #include "FuncRequest.h"
 #include "LyXRC.h"
 #include "qt_helpers.h"
@@ -56,6 +57,7 @@ GuiBibtex::GuiBibtex(GuiView & lv)
        setupUi(this);
 
        QDialog::setModal(true);
+       setWindowModality(Qt::WindowModal);
 
        connect(okPB, SIGNAL(clicked()),
                this, SLOT(slotOK()));
@@ -81,6 +83,8 @@ GuiBibtex::GuiBibtex(GuiView & lv)
                this, SLOT(addPressed()));
        connect(rescanPB, SIGNAL(clicked()),
                this, SLOT(rescanClicked()));
+       connect(biblatexOptsLE, SIGNAL(textChanged(QString)),
+               this, SLOT(change_adaptor()));
 
        add_ = new GuiBibtexAddDialog(this);
        add_bc_.setPolicy(ButtonPolicy::OkCancelPolicy);
@@ -107,6 +111,10 @@ GuiBibtex::GuiBibtex(GuiView & lv)
        connect(add_->closePB, SIGNAL(clicked()),
                add_, SLOT(reject()));
 
+       add_->bibLW->setToolTip(formatToolTip(qt_("This list consists of all databases that are indexed by LaTeX and thus are found without a file path. "
+                                   "This is usually everything in the bib/ subdirectory of LaTeX's texmf tree. "
+                                   "If you want to reuse your own database, this is the place you should store it.")));
+
        bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
        bc().setOK(okPB);
        bc().setCancel(closePB);
@@ -295,6 +303,12 @@ void GuiBibtex::availableChanged()
 void GuiBibtex::updateContents()
 {
        bool bibtopic = usingBibtopic();
+       bool biblatex = usingBiblatex();
+
+       if (biblatex)
+               setTitle(qt_("Biblatex Bibliography"));
+       else
+               setTitle(qt_("BibTeX Bibliography"));
 
        databaseLW->clear();
 
@@ -317,47 +331,59 @@ void GuiBibtex::updateContents()
        for (int i = 0; i != bibfiles.count(); ++i)
                add_->bibLW->addItem(changeExtension(bibfiles[i], ""));
 
-       QString bibstyle = styleFile();
+       QString const bibstyle = styleFile();
 
        bibtocCB->setChecked(bibtotoc() && !bibtopic);
        bibtocCB->setEnabled(!bibtopic);
 
-       if (!bibtopic && btPrintCO->count() == 3)
-               btPrintCO->removeItem(1);
-       else if (bibtopic && btPrintCO->count() < 3)
-               btPrintCO->insertItem(1, qt_("all uncited references", 0));
+       btPrintCO->clear();
+       btPrintCO->addItem(qt_("all cited references"), toqstr("btPrintCited"));
+       if (bibtopic)
+               btPrintCO->addItem(qt_("all uncited references"), toqstr("btPrintNotCited"));
+       btPrintCO->addItem(qt_("all references"), toqstr("btPrintAll"));
+       if (usingBiblatex() && !buffer().masterParams().multibib.empty())
+               btPrintCO->addItem(qt_("all reference units"), toqstr("bibbysection"));
 
        docstring btprint = params_["btprint"];
-       int btp = 0;
-       if ((bibtopic && btprint == "btPrintNotCited") ||
-          (!bibtopic && btprint == "btPrintAll"))
-               btp = 1;
-       else if (bibtopic && btprint == "btPrintAll")
-               btp = 2;
-
-       btPrintCO->setCurrentIndex(btp);
-
-       styleCB->clear();
-
-       int item_nr = -1;
+       if (btprint.empty())
+               // default
+               btprint = from_ascii("btPrintCited");
+       btPrintCO->setCurrentIndex(btPrintCO->findData(toqstr(btprint)));
+
+       // Only useful for biblatex
+       biblatexOptsLA->setVisible(biblatex);
+       biblatexOptsLE->setVisible(biblatex);
+
+       // only useful for BibTeX
+       styleCB->setVisible(!biblatex);
+       styleLA->setVisible(!biblatex);
+       stylePB->setVisible(!biblatex);
+
+       if (!biblatex) {
+               styleCB->clear();
+
+               int item_nr = -1;
+
+               QStringList const str = bibStyles();
+               for (int i = 0; i != str.count(); ++i) {
+                       QString item = changeExtension(str[i], "");
+                       if (item == bibstyle)
+                               item_nr = i;
+                       styleCB->addItem(item);
+               }
 
-       QStringList str = bibStyles();
-       for (int i = 0; i != str.count(); ++i) {
-               QString item = changeExtension(str[i], "");
-               if (item == bibstyle)
-                       item_nr = i;
-               styleCB->addItem(item);
-       }
+               if (item_nr == -1 && !bibstyle.isEmpty()) {
+                       styleCB->addItem(bibstyle);
+                       item_nr = styleCB->count() - 1;
+               }
 
-       if (item_nr == -1 && !bibstyle.isEmpty()) {
-               styleCB->addItem(bibstyle);
-               item_nr = styleCB->count() - 1;
-       }
 
-       if (item_nr != -1)
-               styleCB->setCurrentIndex(item_nr);
-       else
-               styleCB->clearEditText();
+               if (item_nr != -1)
+                       styleCB->setCurrentIndex(item_nr);
+               else
+                       styleCB->clearEditText();
+       } else
+               biblatexOptsLE->setText(toqstr(params_["biblatexopts"]));
 }
 
 
@@ -392,35 +418,9 @@ void GuiBibtex::applyView()
                params_["options"] = bibstyle;
        }
 
-       int btp = btPrintCO->currentIndex();
-
-       if (usingBibtopic()) {
-               // bibtopic allows three kinds of sections:
-               // 1. sections that include all cited references of the database(s)
-               // 2. sections that include all uncited references of the database(s)
-               // 3. sections that include all references of the database(s), cited or not
-               switch (btp) {
-               case 0:
-                       params_["btprint"] = from_ascii("btPrintCited");
-                       break;
-               case 1:
-                       params_["btprint"] = from_ascii("btPrintNotCited");
-                       break;
-               case 2:
-                       params_["btprint"] = from_ascii("btPrintAll");
-                       break;
-               }
-       } else {
-               switch (btp) {
-               case 0:
-                       params_["btprint"] = docstring();
-                       break;
-               case 1:
-                       // use \nocite{*}
-                       params_["btprint"] = from_ascii("btPrintAll");
-                       break;
-               }
-       }
+       params_["biblatexopts"] = qstring_to_ucs4(biblatexOptsLE->text());
+
+       params_["btprint"] = qstring_to_ucs4(btPrintCO->itemData(btPrintCO->currentIndex()).toString());
 }
 
 
@@ -484,13 +484,16 @@ QStringList GuiBibtex::bibFiles() const
 
 void GuiBibtex::rescanBibStyles() const
 {
-       rescanTexStyles();
+       if (usingBiblatex())
+               rescanTexStyles("bib");
+       else
+               rescanTexStyles("bst bib");
 }
 
 
 bool GuiBibtex::usingBibtopic() const
 {
-       return buffer().params().use_bibtopic;
+       return buffer().params().useBibtopic();
 }
 
 
@@ -500,23 +503,17 @@ bool GuiBibtex::bibtotoc() const
 }
 
 
+bool GuiBibtex::usingBiblatex() const
+{
+       return buffer().masterBuffer()->params().useBiblatex();
+}
+
+
 QString GuiBibtex::styleFile() const
 {
        // the different bibtex packages have (and need) their
        // own "plain" stylefiles
-       CiteEngine const engine = buffer().params().citeEngine();
-       QString defaultstyle;
-       switch (engine) {
-       case ENGINE_BASIC:
-               defaultstyle = "plain";
-               break;
-       case ENGINE_NATBIB:
-               defaultstyle = "plainnat";
-               break;
-       case ENGINE_JURABIB:
-               defaultstyle = "jurabib";
-               break;
-       }
+       QString defaultstyle = toqstr(buffer().params().defaultBiblioStyle());
 
        QString bst = toqstr(params_["options"]);
        if (bibtotoc()){