]> 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 655c8262a32f253ce50ea341bf343890ae246341..aa33c8f81cd9537438c804c35e8ea43b6fa544ff 100644 (file)
@@ -202,6 +202,7 @@ char const * packages_gui[][4] =
 };
 
 
+vector<string> engine_types_;
 vector<pair<string, QString> > pagestyles;
 
 
@@ -1288,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();
 
 
@@ -2065,6 +2067,42 @@ void GuiDocument::setNumerical(bool numerical)
 }
 
 
+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>
@@ -2297,12 +2335,12 @@ void GuiDocument::applyView()
        bp_.use_refstyle  = latexModule->refstyleCB->isChecked();
 
        // biblio
-       bp_.setCiteEngine(ENGINE_BASIC);
-
        if (biblioModule->citeNatbibRB->isChecked())
-               bp_.setCiteEngine(ENGINE_NATBIB);
+               bp_.setCiteEngine("natbib");
        else if (biblioModule->citeJurabibRB->isChecked())
-               bp_.setCiteEngine(ENGINE_JURABIB);
+               bp_.setCiteEngine("jurabib");
+       else
+               bp_.setCiteEngine("basic");
 
        if (biblioModule->citeStyleCO->currentIndex())
                bp_.setCiteEngineType(ENGINE_TYPE_NUMERICAL);
@@ -2707,17 +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);
+               cite_engine == "natbib");
 
        biblioModule->citeStyleCO->setCurrentIndex(
                bp_.citeEngineType() == ENGINE_TYPE_NUMERICAL);
 
-       biblioModule->citeJurabibRB->setChecked(
-               bp_.citeEngine() == ENGINE_JURABIB);
+       updateEngineType(documentClass().opt_enginetype(),
+               bp_.citeEngineType());
 
        biblioModule->bibtopicCB->setChecked(
                bp_.use_bibtopic);
@@ -2987,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);
 
@@ -3078,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");