]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiDocument.cpp
Fix handling of the add branch textfield in GuiBranches
[lyx.git] / src / frontends / qt4 / GuiDocument.cpp
index 53c9c55f1c33cf89ced2b58e2395d92025bb5e7a..aa33c8f81cd9537438c804c35e8ea43b6fa544ff 100644 (file)
@@ -186,6 +186,10 @@ char const * packages_gui[][4] =
         N_("Use math&dots package automatically"),
         N_("Use mathdo&ts package"),
         N_("The LaTeX package mathdots is only used if the command \\iddots is inserted into formulas")},
+       {"mathtools",
+        N_("Use mathtools package automatically"),
+        N_("Use mathtools package"),
+        N_("The LaTeX package mathtools is only used if some mathematical relations are inserted into formulas")},
        {"mhchem",
         N_("Use mhchem &package automatically"),
         N_("Use mh&chem package"),
@@ -198,6 +202,7 @@ char const * packages_gui[][4] =
 };
 
 
+vector<string> engine_types_;
 vector<pair<string, QString> > pagestyles;
 
 
@@ -1128,6 +1133,10 @@ GuiDocument::GuiDocument(GuiView & lv)
 
        // biblio
        biblioModule = new UiWidget<Ui::BiblioUi>;
+       connect(biblioModule->citeDefaultRB, SIGNAL(toggled(bool)),
+               this, SLOT(setNumerical(bool)));
+       connect(biblioModule->citeJurabibRB, SIGNAL(toggled(bool)),
+               this, SLOT(setAuthorYear(bool)));
        connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
                biblioModule->citationStyleL, SLOT(setEnabled(bool)));
        connect(biblioModule->citeNatbibRB, SIGNAL(toggled(bool)),
@@ -1280,6 +1289,7 @@ GuiDocument::GuiDocument(GuiView & lv)
                this, SLOT(change_adaptor()));
        connect(branchesModule, SIGNAL(renameBranches(docstring const &, docstring const &)),
                this, SLOT(branchesRename(docstring const &, docstring const &)));
+       connect(branchesModule, SIGNAL(okPressed()), this, SLOT(slotOK()));
        updateUnknownBranches();
 
 
@@ -2041,6 +2051,58 @@ void GuiDocument::bibtexChanged(int n)
 }
 
 
+void GuiDocument::setAuthorYear(bool authoryear)
+{
+       if (authoryear)
+               biblioModule->citeStyleCO->setCurrentIndex(0);
+       biblioChanged();
+}
+
+
+void GuiDocument::setNumerical(bool numerical)
+{
+       if (numerical)
+               biblioModule->citeStyleCO->setCurrentIndex(1);
+       biblioChanged();
+}
+
+
+void GuiDocument::updateEngineType(string const & items, CiteEngineType const & sel)
+{
+       engine_types_.clear();
+
+       int nn = 0;
+
+       for (int n = 0; !token(items, '|', n).empty(); ++n) {
+               nn += 1;
+               string style = token(items, '|', n);
+               engine_types_.push_back(style);
+       }
+
+       switch (sel) {
+               case ENGINE_TYPE_AUTHORYEAR:
+                       biblioModule->citeStyleCO->setCurrentIndex(0);
+                       break;
+               case ENGINE_TYPE_NUMERICAL:
+                       biblioModule->citeStyleCO->setCurrentIndex(1);
+                       break;
+       }
+
+       biblioModule->citationStyleL->setEnabled(nn > 1);
+       biblioModule->citeStyleCO->setEnabled(nn > 1);
+
+       if (nn != 1)
+               return;
+
+       // If the textclass allows only one of authoryear or numerical,
+       // we have no choice but to force that engine type.
+       if (engine_types_[0] == "authoryear")
+               biblioModule->citeStyleCO->setCurrentIndex(0);
+       else
+               biblioModule->citeStyleCO->setCurrentIndex(1);
+}
+
+
 namespace {
        // FIXME unicode
        // both of these should take a vector<docstring>
@@ -2273,18 +2335,17 @@ void GuiDocument::applyView()
        bp_.use_refstyle  = latexModule->refstyleCB->isChecked();
 
        // biblio
-       bp_.setCiteEngine(ENGINE_BASIC);
-
-       if (biblioModule->citeNatbibRB->isChecked()) {
-               bool const use_numerical_citations =
-                       biblioModule->citeStyleCO->currentIndex();
-               if (use_numerical_citations)
-                       bp_.setCiteEngine(ENGINE_NATBIB_NUMERICAL);
-               else
-                       bp_.setCiteEngine(ENGINE_NATBIB_AUTHORYEAR);
+       if (biblioModule->citeNatbibRB->isChecked())
+               bp_.setCiteEngine("natbib");
+       else if (biblioModule->citeJurabibRB->isChecked())
+               bp_.setCiteEngine("jurabib");
+       else
+               bp_.setCiteEngine("basic");
 
-       } else if (biblioModule->citeJurabibRB->isChecked())
-               bp_.setCiteEngine(ENGINE_JURABIB);
+       if (biblioModule->citeStyleCO->currentIndex())
+               bp_.setCiteEngineType(ENGINE_TYPE_NUMERICAL);
+       else
+               bp_.setCiteEngineType(ENGINE_TYPE_AUTHORYEAR);
 
        bp_.use_bibtopic =
                biblioModule->bibtopicCB->isChecked();
@@ -2684,18 +2745,22 @@ void GuiDocument::paramsToDialog()
        latexModule->refstyleCB->setChecked(bp_.use_refstyle);
 
        // biblio
+       string const cite_engine = bp_.citeEngine().list().front();
+
        biblioModule->citeDefaultRB->setChecked(
-               bp_.citeEngine() == ENGINE_BASIC);
+               cite_engine == "basic");
+
+       biblioModule->citeJurabibRB->setChecked(
+               cite_engine == "jurabib");
 
        biblioModule->citeNatbibRB->setChecked(
-               bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL ||
-               bp_.citeEngine() == ENGINE_NATBIB_AUTHORYEAR);
+               cite_engine == "natbib");
 
        biblioModule->citeStyleCO->setCurrentIndex(
-               bp_.citeEngine() == ENGINE_NATBIB_NUMERICAL);
+               bp_.citeEngineType() == ENGINE_TYPE_NUMERICAL);
 
-       biblioModule->citeJurabibRB->setChecked(
-               bp_.citeEngine() == ENGINE_JURABIB);
+       updateEngineType(documentClass().opt_enginetype(),
+               bp_.citeEngineType());
 
        biblioModule->bibtopicCB->setChecked(
                bp_.use_bibtopic);
@@ -2965,31 +3030,13 @@ void GuiDocument::paramsToDialog()
                InsetListingsParams(bp_.listings_params).separatedParams();
        listingsModule->listingsED->setPlainText(toqstr(lstparams));
 
-       // Output
-       // update combobox with formats
-       updateDefaultFormat();
-       int index = outputModule->defaultFormatCO->findData(toqstr(
-               bp_.default_output_format));
-       // set to default if format is not found
-       if (index == -1)
-               index = 0;
-       outputModule->defaultFormatCO->setCurrentIndex(index);
+       // Fonts
        bool const os_fonts_available =
                bp_.baseClass()->outputType() == lyx::LATEX
                && LaTeXFeatures::isAvailable("fontspec");
        fontModule->osFontsCB->setEnabled(os_fonts_available);
        fontModule->osFontsCB->setChecked(
                os_fonts_available && bp_.useNonTeXFonts);
-
-       outputModule->outputsyncCB->setChecked(bp_.output_sync);
-       outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro));
-
-       outputModule->mathimgSB->setValue(bp_.html_math_img_scale);
-       outputModule->mathoutCB->setCurrentIndex(bp_.html_math_output);
-       outputModule->strictCB->setChecked(bp_.html_be_strict);
-       outputModule->cssCB->setChecked(bp_.html_css_as_file);
-
-       // Fonts
        updateFontsize(documentClass().opt_fontsize(),
                        bp_.fontsize);
 
@@ -3056,6 +3103,26 @@ void GuiDocument::paramsToDialog()
                fontModule->fontencLE->setText(toqstr(bp_.fontenc));
        }
 
+       // Output
+       // This must be set _after_ fonts since updateDefaultFormat()
+       // checks osFontsCB settings.
+       // update combobox with formats
+       updateDefaultFormat();
+       int index = outputModule->defaultFormatCO->findData(toqstr(
+               bp_.default_output_format));
+       // set to default if format is not found
+       if (index == -1)
+               index = 0;
+       outputModule->defaultFormatCO->setCurrentIndex(index);
+
+       outputModule->outputsyncCB->setChecked(bp_.output_sync);
+       outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro));
+
+       outputModule->mathimgSB->setValue(bp_.html_math_img_scale);
+       outputModule->mathoutCB->setCurrentIndex(bp_.html_math_output);
+       outputModule->strictCB->setChecked(bp_.html_be_strict);
+       outputModule->cssCB->setChecked(bp_.html_css_as_file);
+
        // paper
        bool const extern_geometry =
                documentClass().provides("geometry");