]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiDocument.cpp
Basic support for natbib & jurabib options
[features.git] / src / frontends / qt4 / GuiDocument.cpp
index 139bdb436671bcebb87f7655003fe8ea7005dee3..20fbd02cf91735f76440a90eb78fd1619bb8d9e6 100644 (file)
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
+#include "CiteEnginesList.h"
 #include "Color.h"
 #include "ColorCache.h"
+#include "Converter.h"
 #include "Cursor.h"
 #include "Encoding.h"
 #include "FloatPlacement.h"
@@ -453,7 +455,8 @@ PreambleModule::PreambleModule() : current_id_(0)
 {
        // This is not a memory leak. The object will be destroyed
        // with this.
-       (void) new LaTeXHighlighter(preambleTE->document());
+       // @ is letter in the LyX user preamble
+       (void) new LaTeXHighlighter(preambleTE->document(), true);
        preambleTE->setFont(guiApp->typewriterSystemFont());
        preambleTE->setWordWrapMode(QTextOption::NoWrap);
        setFocusProxy(preambleTE);
@@ -493,7 +496,7 @@ void PreambleModule::update(BufferParams const & params, BufferId id)
 
 void PreambleModule::apply(BufferParams & params)
 {
-       params.preamble = fromqstr(preambleTE->document()->toPlainText());
+       params.preamble = qstring_to_ucs4(preambleTE->document()->toPlainText());
 }
 
 
@@ -539,11 +542,21 @@ void LocalLayout::update(BufferParams const & params, BufferId id)
 
 void LocalLayout::apply(BufferParams & params)
 {
-       string const layout = fromqstr(locallayoutTE->document()->toPlainText());
+       docstring const layout =
+               qstring_to_ucs4(locallayoutTE->document()->toPlainText());
        params.setLocalLayout(layout, false);
 }
 
 
+void LocalLayout::hideConvert()
+{
+       convertPB->setEnabled(false);
+       convertLB->setText("");
+       convertPB->hide();
+       convertLB->hide();
+}
+
+
 void LocalLayout::textChanged()
 {
        static const QString message =
@@ -555,15 +568,14 @@ void LocalLayout::textChanged()
                validated_ = true;
                validatePB->setEnabled(false);
                validLB->setText("");
-               convertPB->hide();
-               convertLB->hide();
+               hideConvert();
                changed();
        } else if (!validatePB->isEnabled()) {
                // if that's already enabled, we shouldn't need to do anything.
                validated_ = false;
                validLB->setText(message);
                validatePB->setEnabled(true);
-               convertPB->setEnabled(false);
+               hideConvert();
                changed();
        }
 }
@@ -573,44 +585,52 @@ void LocalLayout::convert() {
        string const layout =
                fromqstr(locallayoutTE->document()->toPlainText().trimmed());
        string const newlayout = TextClass::convert(layout);
-       LYXERR0(newlayout);
-       if (newlayout.empty()) {
-               Alert::error(_("Conversion Failed!"),
-                     _("Failed to convert local layout to current format."));
-       } else {
+       if (!newlayout.empty())
                locallayoutTE->setPlainText(toqstr(newlayout));
-       }
        validate();
 }
 
 
 void LocalLayout::convertPressed() {
        convert();
+       hideConvert();
        changed();
 }
 
 
 void LocalLayout::validate() {
-       static const QString valid = qt_("Layout is valid!");
-       static const QString vtext =
-               toqstr("<p style=\"font-weight: bold; \">")
-                 + valid + toqstr("</p>");
-       static const QString invalid = qt_("Layout is invalid!");
-       static const QString ivtext =
-               toqstr("<p style=\"color: #c00000; font-weight: bold; \">")
-                 + invalid + toqstr("</p>");
-
+       // Bold text
+       static const QString vpar("<p style=\"font-weight: bold;\">%1</p>");
+       // Flashy red bold text
+       static const QString ivpar("<p style=\"color: #c00000; font-weight: bold; \">"
+                                  "%1</p>");
        string const layout =
                fromqstr(locallayoutTE->document()->toPlainText().trimmed());
        if (!layout.empty()) {
                TextClass::ReturnValues const ret = TextClass::validate(layout);
                validated_ = (ret == TextClass::OK) || (ret == TextClass::OK_OLDFORMAT);
                validatePB->setEnabled(false);
-               validLB->setText(validated_ ? vtext : ivtext);
+               validLB->setText(validated_ ? vpar.arg(qt_("Layout is valid!"))
+                                           : ivpar.arg(qt_("Layout is invalid!")));
                if (ret == TextClass::OK_OLDFORMAT) {
                        convertPB->show();
-                       convertPB->setEnabled(true);
-                       convertLB->setText(qt_("Convert to current format"));
+                       // Testing conversion to LYXFILE_LAYOUT_FORMAT at this point
+                       // already.
+                       if (TextClass::convert(layout).empty()) {
+                               // Conversion failed. If LAYOUT_FORMAT > LYXFILE_LAYOUT_FORMAT,
+                               // then maybe the layout is still valid, but its format is more
+                               // recent than LYXFILE_LAYOUT_FORMAT. However, if LAYOUT_FORMAT
+                               // == LYXFILE_LAYOUT_FORMAT then something is definitely wrong.
+                               convertPB->setEnabled(false);
+                               const QString text = (LAYOUT_FORMAT == LYXFILE_LAYOUT_FORMAT)
+                                       ? ivpar.arg(qt_("Conversion to current format impossible!"))
+                                       : vpar.arg(qt_("Conversion to current stable format "
+                                                      "impossible."));
+                               convertLB->setText(text);
+                       } else {
+                               convertPB->setEnabled(true);
+                               convertLB->setText(qt_("Convert to current format"));
+                       }
                        convertLB->show();
                } else {
                        convertPB->hide();
@@ -750,7 +770,7 @@ GuiDocument::GuiDocument(GuiView & lv)
        masterChildModule->childrenTW->resizeColumnToContents(2);
 
 
-       // output
+       // Formats
        outputModule = new UiWidget<Ui::OutputUi>;
 
        connect(outputModule->defaultFormatCO, SIGNAL(activated(int)),
@@ -776,6 +796,9 @@ GuiDocument::GuiDocument(GuiView & lv)
        outputModule->synccustomCB->setValidator(new NoNewLineValidator(
                outputModule->synccustomCB));
 
+       connect(outputModule->saveTransientPropertiesCB, SIGNAL(clicked()),
+               this, SLOT(change_adaptor()));
+
        // fonts
        fontModule = new FontModule;
        connect(fontModule->osFontsCB, SIGNAL(clicked()),
@@ -1024,6 +1047,8 @@ GuiDocument::GuiDocument(GuiView & lv)
                this, SLOT(change_adaptor()));
        connect(langModule->languagePackageCO, SIGNAL(currentIndexChanged(int)),
                this, SLOT(languagePackageChanged(int)));
+       connect(langModule->dynamicQuotesCB, SIGNAL(clicked()),
+               this, SLOT(change_adaptor()));
 
        langModule->languagePackageLE->setValidator(new NoNewLineValidator(
                langModule->languagePackageLE));
@@ -1045,19 +1070,6 @@ GuiDocument::GuiDocument(GuiView & lv)
        encodinglist.sort();
        langModule->encodingCO->addItems(encodinglist);
 
-       langModule->quoteStyleCO->addItem(
-               qt_("``text''"),InsetQuotes::EnglishQuotes);
-       langModule->quoteStyleCO->addItem(
-               qt_("''text''"), InsetQuotes::SwedishQuotes);
-       langModule->quoteStyleCO->addItem
-               (qt_(",,text``"), InsetQuotes::GermanQuotes);
-       langModule->quoteStyleCO->addItem(
-               qt_(",,text''"), InsetQuotes::PolishQuotes);
-       langModule->quoteStyleCO->addItem(
-               qt_("<<text>>"), InsetQuotes::FrenchQuotes);
-       langModule->quoteStyleCO->addItem(
-               qt_(">>text<<"), InsetQuotes::DanishQuotes);
-
        langModule->languagePackageCO->addItem(
                qt_("Default"), toqstr("default"));
        langModule->languagePackageCO->addItem(
@@ -1108,39 +1120,55 @@ 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)),
-               biblioModule->citeStyleCO, SLOT(setEnabled(bool)));
-       connect(biblioModule->citeDefaultRB, SIGNAL(clicked()),
-               this, SLOT(biblioChanged()));
-       connect(biblioModule->citeNatbibRB, SIGNAL(clicked()),
-               this, SLOT(biblioChanged()));
+       connect(biblioModule->citeEngineCO, SIGNAL(activated(int)),
+               this, SLOT(citeEngineChanged(int)));
        connect(biblioModule->citeStyleCO, SIGNAL(activated(int)),
-               this, SLOT(biblioChanged()));
-       connect(biblioModule->citeJurabibRB, SIGNAL(clicked()),
-               this, SLOT(biblioChanged()));
+               this, SLOT(citeStyleChanged()));
        connect(biblioModule->bibtopicCB, SIGNAL(clicked()),
                this, SLOT(biblioChanged()));
        connect(biblioModule->bibtexCO, SIGNAL(activated(int)),
                this, SLOT(bibtexChanged(int)));
        connect(biblioModule->bibtexOptionsLE, SIGNAL(textChanged(QString)),
                this, SLOT(biblioChanged()));
-       connect(biblioModule->bibtexStyleLE, SIGNAL(textChanged(QString)),
+       connect(biblioModule->citePackageOptionsLE, SIGNAL(textChanged(QString)),
+               this, SLOT(biblioChanged()));
+       connect(biblioModule->defaultBiblioCO, SIGNAL(activated(int)),
+               this, SLOT(biblioChanged()));
+       connect(biblioModule->defaultBiblioCO, SIGNAL(editTextChanged(QString)),
+               this, SLOT(biblioChanged()));
+       connect(biblioModule->defaultBiblioCO, SIGNAL(editTextChanged(QString)),
+               this, SLOT(updateResetDefaultBiblio()));
+       connect(biblioModule->biblatexBbxCO, SIGNAL(activated(int)),
+               this, SLOT(biblioChanged()));
+       connect(biblioModule->biblatexBbxCO, SIGNAL(editTextChanged(QString)),
+               this, SLOT(updateResetDefaultBiblio()));
+       connect(biblioModule->biblatexCbxCO, SIGNAL(activated(int)),
                this, SLOT(biblioChanged()));
+       connect(biblioModule->biblatexCbxCO, SIGNAL(editTextChanged(QString)),
+               this, SLOT(updateResetDefaultBiblio()));
+       connect(biblioModule->rescanBibliosPB, SIGNAL(clicked()),
+               this, SLOT(rescanBibFiles()));
+       connect(biblioModule->resetDefaultBiblioPB, SIGNAL(clicked()),
+               this, SLOT(resetDefaultBibfile()));
+       connect(biblioModule->resetCbxPB, SIGNAL(clicked()),
+               this, SLOT(resetDefaultCbxBibfile()));
+       connect(biblioModule->resetBbxPB, SIGNAL(clicked()),
+               this, SLOT(resetDefaultBbxBibfile()));
+       connect(biblioModule->matchBbxPB, SIGNAL(clicked()),
+               this, SLOT(matchBiblatexStyles()));
+
+       biblioModule->citeEngineCO->clear();
+       for (LyXCiteEngine const & cet : theCiteEnginesList) {
+               biblioModule->citeEngineCO->addItem(qt_(cet.getName()), toqstr(cet.getID()));
+               int const i = biblioModule->citeEngineCO->findData(toqstr(cet.getID()));
+               biblioModule->citeEngineCO->setItemData(i, qt_(cet.getDescription()),
+                                                       Qt::ToolTipRole);
+       }
 
        biblioModule->bibtexOptionsLE->setValidator(new NoNewLineValidator(
                biblioModule->bibtexOptionsLE));
-       biblioModule->bibtexStyleLE->setValidator(new NoNewLineValidator(
-               biblioModule->bibtexStyleLE));
-
-       biblioModule->citeStyleCO->addItem(qt_("Author-year"));
-       biblioModule->citeStyleCO->addItem(qt_("Numerical"));
-       biblioModule->citeStyleCO->setCurrentIndex(0);
+       biblioModule->defaultBiblioCO->lineEdit()->setValidator(new NoNewLineValidator(
+               biblioModule->defaultBiblioCO->lineEdit()));
 
        // NOTE: we do not provide "custom" here for security reasons!
        biblioModule->bibtexCO->clear();
@@ -1278,10 +1306,10 @@ GuiDocument::GuiDocument(GuiView & lv)
                QString tooltip = toqstr(bformat(_("%1$s [Class '%2$s']"), guiname, from_utf8(tc.latexname())));
                if (!available) {
                        docstring const output_type = (tc.outputType() == lyx::DOCBOOK) ? _("DocBook") : _("LaTeX");
-                       tooltip += '\n' + toqstr(wrap(bformat(_("Class not found by LyX. "
+                       tooltip += '\n' + toqstr(bformat(_("Class not found by LyX. "
                                                           "Please check if you have the matching %1$s class "
                                                           "and all required packages (%2$s) installed."),
-                                                        output_type, from_utf8(tc.prerequisites(", ")))));
+                                                        output_type, from_utf8(tc.prerequisites(", "))));
                }
                latexModule->classCO->addItemSort(toqstr(tc.name()),
                                                  toqstr(guiname),
@@ -1424,7 +1452,7 @@ GuiDocument::GuiDocument(GuiView & lv)
        docPS->addPanel(listingsModule, N_("Listings[[inset]]"));
        docPS->addPanel(bulletsModule, N_("Bullets"));
        docPS->addPanel(branchesModule, N_("Branches"));
-       docPS->addPanel(outputModule, N_("Output"));
+       docPS->addPanel(outputModule, N_("Formats[[output]]"));
        docPS->addPanel(preambleModule, N_("LaTeX Preamble"));
        docPS->setCurrentPanel("Document Class");
 // FIXME: hack to work around resizing bug in Qt >= 4.2
@@ -1435,6 +1463,13 @@ GuiDocument::GuiDocument(GuiView & lv)
 }
 
 
+void GuiDocument::onBufferViewChanged()
+{
+       if (isVisibleView())
+               initialiseParams("");
+}
+
+
 void GuiDocument::saveDefaultClicked()
 {
        saveDocDefault();
@@ -1476,21 +1511,10 @@ void GuiDocument::includeonlyClicked(QTreeWidgetItem * item, int)
 
 QString GuiDocument::validateListingsParameters()
 {
-       // use a cache here to avoid repeated validation
-       // of the same parameters
-       // FIXME THREAD
-       static string param_cache;
-       static QString msg_cache;
-
        if (listingsModule->bypassCB->isChecked())
                return QString();
-
        string params = fromqstr(listingsModule->listingsED->toPlainText());
-       if (params != param_cache) {
-               param_cache = params;
-               msg_cache = toqstr(InsetListingsParams(params).validate());
-       }
-       return msg_cache;
+       return toqstr(InsetListingsParams(params).validate());
 }
 
 
@@ -1746,9 +1770,41 @@ void GuiDocument::deleteBoxBackgroundColor()
 }
 
 
+void GuiDocument::updateQuoteStyles(bool const set)
+{
+       Language const * lang = lyx::languages.getLanguage(
+               fromqstr(langModule->languageCO->itemData(
+                       langModule->languageCO->currentIndex()).toString()));
+
+       InsetQuotesParams::QuoteStyle def = bp_.getQuoteStyle(lang->quoteStyle());
+
+       langModule->quoteStyleCO->clear();
+
+       bool has_default = false;
+       for (int i = 0; i < quoteparams.stylescount(); ++i) {
+               InsetQuotesParams::QuoteStyle qs = InsetQuotesParams::QuoteStyle(i);
+               if (qs == InsetQuotesParams::DynamicQuotes)
+                       continue;
+               bool const langdef = (qs == def);
+               if (langdef) {
+                       // add the default style on top
+                       langModule->quoteStyleCO->insertItem(0,
+                               toqstr(quoteparams.getGuiLabel(qs, langdef)), qs);
+                       has_default = true;
+               }
+               else
+                       langModule->quoteStyleCO->addItem(
+                               toqstr(quoteparams.getGuiLabel(qs, langdef)), qs);
+       }
+       if (set && has_default)
+               // (re)set to the default style
+               langModule->quoteStyleCO->setCurrentIndex(0);
+}
+
+
 void GuiDocument::languageChanged(int i)
 {
-       // some languages only work with polyglossia/XeTeX
+       // some languages only work with polyglossia
        Language const * lang = lyx::languages.getLanguage(
                fromqstr(langModule->languageCO->itemData(i).toString()));
        if (lang->babel().empty() && !lang->polyglossia().empty()) {
@@ -1770,10 +1826,7 @@ void GuiDocument::languageChanged(int i)
        }
 
        // set appropriate quotation mark style
-       if (!lang->quoteStyle().empty()) {
-               langModule->quoteStyleCO->setCurrentIndex(
-                       bp_.getQuoteStyle(lang->quoteStyle()));
-       }
+       updateQuoteStyles(true);
 }
 
 
@@ -2264,30 +2317,138 @@ void GuiDocument::biblioChanged()
 }
 
 
-void GuiDocument::bibtexChanged(int n)
+void GuiDocument::rescanBibFiles()
 {
-       biblioModule->bibtexOptionsLE->setEnabled(
-               biblioModule->bibtexCO->itemData(n).toString() != "default");
+       if (isBiblatex())
+               rescanTexStyles("bbx cbx");
+       else
+               rescanTexStyles("bst");
+}
+
+
+void GuiDocument::resetDefaultBibfile(string const & which)
+{
+       QString const engine =
+               biblioModule->citeEngineCO->itemData(
+                               biblioModule->citeEngineCO->currentIndex()).toString();
+
+       CiteEngineType const cet =
+               CiteEngineType(biblioModule->citeStyleCO->itemData(
+                                                         biblioModule->citeStyleCO->currentIndex()).toInt());
+
+       updateDefaultBiblio(theCiteEnginesList[fromqstr(engine)]->getDefaultBiblio(cet), which);
+}
+
+
+void GuiDocument::resetDefaultBbxBibfile()
+{
+       resetDefaultBibfile("bbx");
+}
+
+
+void GuiDocument::resetDefaultCbxBibfile()
+{
+       resetDefaultBibfile("cbx");
+}
+
+
+void GuiDocument::citeEngineChanged(int n)
+{
+       QString const engine =
+               biblioModule->citeEngineCO->itemData(n).toString();
+
+       vector<string> const engs =
+               theCiteEnginesList[fromqstr(engine)]->getEngineType();
+
+       updateCiteStyles(engs);
+       updateEngineDependends();
+       resetDefaultBibfile();
        biblioChanged();
 }
 
 
-void GuiDocument::setAuthorYear(bool authoryear)
+void GuiDocument::updateEngineDependends()
 {
-       if (authoryear)
-               biblioModule->citeStyleCO->setCurrentIndex(0);
+       bool const biblatex = isBiblatex();
+
+       // These are only useful with BibTeX
+       biblioModule->defaultBiblioCO->setEnabled(!biblatex);
+       biblioModule->bibtexStyleLA->setEnabled(!biblatex);
+       biblioModule->resetDefaultBiblioPB->setEnabled(!biblatex);
+       biblioModule->bibtopicCB->setEnabled(!biblatex);
+
+       // These are only useful with Biblatex
+       biblioModule->biblatexBbxCO->setEnabled(biblatex);
+       biblioModule->biblatexBbxLA->setEnabled(biblatex);
+       biblioModule->biblatexCbxCO->setEnabled(biblatex);
+       biblioModule->biblatexCbxLA->setEnabled(biblatex);
+       biblioModule->resetBbxPB->setEnabled(biblatex);
+       biblioModule->resetCbxPB->setEnabled(biblatex);
+       biblioModule->matchBbxPB->setEnabled(biblatex);
+
+       // These are useful with biblatex, jurabib and natbib
+       QString const engine =
+               biblioModule->citeEngineCO->itemData(
+                               biblioModule->citeEngineCO->currentIndex()).toString();
+       LyXCiteEngine const * ce = theCiteEnginesList[fromqstr(engine)];
+
+       bool const citepack = ce->requires("biblatex.sty") || ce->requires("jurabib.sty")
+                       || ce->requires("natbib.sty");
+       biblioModule->citePackageOptionsLE->setEnabled(citepack);
+       biblioModule->citePackageOptionsL->setEnabled(citepack);
+}
+
+
+void GuiDocument::citeStyleChanged()
+{
+       QString const engine =
+               biblioModule->citeEngineCO->itemData(
+                               biblioModule->citeEngineCO->currentIndex()).toString();
+       QString const currentDef = isBiblatex() ?
+               biblioModule->biblatexBbxCO->currentText()
+               : biblioModule->defaultBiblioCO->currentText();
+       if (theCiteEnginesList[fromqstr(engine)]->isDefaultBiblio(fromqstr(currentDef)))
+               resetDefaultBibfile();
+
        biblioChanged();
 }
 
 
-void GuiDocument::setNumerical(bool numerical)
+void GuiDocument::bibtexChanged(int n)
 {
-       if (numerical)
-               biblioModule->citeStyleCO->setCurrentIndex(1);
+       biblioModule->bibtexOptionsLE->setEnabled(
+               biblioModule->bibtexCO->itemData(n).toString() != "default");
        biblioChanged();
 }
 
 
+void GuiDocument::updateCiteStyles(vector<string> const & engs, CiteEngineType const & sel)
+{
+       biblioModule->citeStyleCO->clear();
+
+       vector<string>::const_iterator it  = engs.begin();
+       vector<string>::const_iterator end = engs.end();
+       for (; it != end; ++it) {
+               if (*it == "default")
+                       biblioModule->citeStyleCO->addItem(qt_("Basic numerical"),
+                                                          ENGINE_TYPE_DEFAULT);
+               else if (*it == "authoryear")
+                       biblioModule->citeStyleCO->addItem(qt_("Author-year"),
+                                                          ENGINE_TYPE_AUTHORYEAR);
+               else if (*it == "numerical")
+                       biblioModule->citeStyleCO->addItem(qt_("Author-number"),
+                                                          ENGINE_TYPE_NUMERICAL);
+       }
+       int i = biblioModule->citeStyleCO->findData(sel);
+       if (biblioModule->citeStyleCO->findData(sel) == -1)
+               i = 0;
+       biblioModule->citeStyleCO->setCurrentIndex(i);
+
+       biblioModule->citationStyleL->setEnabled(engs.size() > 1);
+       biblioModule->citeStyleCO->setEnabled(engs.size() > 1);
+}
+
+
 void GuiDocument::updateEngineType(string const & items, CiteEngineType const & sel)
 {
        engine_types_.clear();
@@ -2300,28 +2461,7 @@ void GuiDocument::updateEngineType(string const & items, CiteEngineType const &
                engine_types_.push_back(style);
        }
 
-       switch (sel) {
-               case ENGINE_TYPE_AUTHORYEAR:
-                       biblioModule->citeStyleCO->setCurrentIndex(0);
-                       break;
-               case ENGINE_TYPE_NUMERICAL:
-               case ENGINE_TYPE_DEFAULT:
-                       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);
+       updateCiteStyles(engine_types_, sel);
 }
 
 
@@ -2544,14 +2684,12 @@ void GuiDocument::updateDefaultFormat()
        outputModule->defaultFormatCO->clear();
        outputModule->defaultFormatCO->addItem(qt_("Default"),
                                QVariant(QString("default")));
-       typedef vector<Format const *> Formats;
-       Formats formats = param_copy.exportableFormats(true);
-       sort(formats.begin(), formats.end(), Format::formatSorter);
-       Formats::const_iterator cit = formats.begin();
-       Formats::const_iterator end = formats.end();
-       for (; cit != end; ++cit)
-               outputModule->defaultFormatCO->addItem(qt_((*cit)->prettyname()),
-                               QVariant(toqstr((*cit)->name())));
+       FormatList const & formats =
+                               param_copy.exportableFormats(true);
+       for (Format const * f : formats)
+               outputModule->defaultFormatCO->addItem
+                       (toqstr(translateIfPossible(f->prettyname())),
+                        QVariant(toqstr(f->name())));
        outputModule->defaultFormatCO->blockSignals(false);
 }
 
@@ -2576,24 +2714,26 @@ void GuiDocument::applyView()
        bp_.use_refstyle  = latexModule->refstyleCB->isChecked();
 
        // biblio
-       if (biblioModule->citeNatbibRB->isChecked())
-               bp_.setCiteEngine("natbib");
-       else if (biblioModule->citeJurabibRB->isChecked())
-               bp_.setCiteEngine("jurabib");
-       if (biblioModule->citeDefaultRB->isChecked()) {
-               bp_.setCiteEngine("basic");
-               bp_.setCiteEngineType(ENGINE_TYPE_DEFAULT);
-       }
-       else
-       if (biblioModule->citeStyleCO->currentIndex())
-               bp_.setCiteEngineType(ENGINE_TYPE_NUMERICAL);
+       string const engine =
+               fromqstr(biblioModule->citeEngineCO->itemData(
+                               biblioModule->citeEngineCO->currentIndex()).toString());
+       bp_.setCiteEngine(engine);
+
+       CiteEngineType const style = CiteEngineType(biblioModule->citeStyleCO->itemData(
+               biblioModule->citeStyleCO->currentIndex()).toInt());
+       if (theCiteEnginesList[engine]->hasEngineType(style))
+               bp_.setCiteEngineType(style);
        else
-               bp_.setCiteEngineType(ENGINE_TYPE_AUTHORYEAR);
+               bp_.setCiteEngineType(ENGINE_TYPE_DEFAULT);
 
        bp_.use_bibtopic =
                biblioModule->bibtopicCB->isChecked();
 
-       bp_.biblio_style = fromqstr(biblioModule->bibtexStyleLE->text());
+       bp_.setDefaultBiblioStyle(fromqstr(biblioModule->defaultBiblioCO->currentText()));
+
+       bp_.biblatex_bibstyle = fromqstr(biblioModule->biblatexBbxCO->currentText());
+       bp_.biblatex_citestyle = fromqstr(biblioModule->biblatexCbxCO->currentText());
+       bp_.biblio_opts = fromqstr(biblioModule->citePackageOptionsLE->text());
 
        string const bibtex_command =
                fromqstr(biblioModule->bibtexCO->itemData(
@@ -2642,8 +2782,9 @@ void GuiDocument::applyView()
                }
        }
 
-       bp_.quotes_language = (InsetQuotes::QuoteLanguage) langModule->quoteStyleCO->itemData(
+       bp_.quotes_style = (InsetQuotesParams::QuoteStyle) langModule->quoteStyleCO->itemData(
                langModule->quoteStyleCO->currentIndex()).toInt();
+       bp_.dynamic_quotes = langModule->dynamicQuotesCB->isChecked();
 
        QString const langname = langModule->languageCO->itemData(
                langModule->languageCO->currentIndex()).toString();
@@ -2839,7 +2980,7 @@ void GuiDocument::applyView()
        bp_.listings_params =
                InsetListingsParams(fromqstr(listingsModule->listingsED->toPlainText())).params();
 
-       // output
+       // Formats
        bp_.default_output_format = fromqstr(outputModule->defaultFormatCO->itemData(
                outputModule->defaultFormatCO->currentIndex()).toString());
 
@@ -2861,6 +3002,9 @@ void GuiDocument::applyView()
        bp_.html_math_img_scale = outputModule->mathimgSB->value();
        bp_.display_pixel_ratio = theGuiApp()->pixelRatio();
 
+       bp_.save_transient_properties =
+               outputModule->saveTransientPropertiesCB->isChecked();
+
        // fonts
        bp_.fonts_roman[nontexfonts] =
                fromqstr(fontModule->fontsRomanCO->
@@ -3000,25 +3144,27 @@ void GuiDocument::paramsToDialog()
        // biblio
        string const cite_engine = bp_.citeEngine().list().front();
 
-       biblioModule->citeDefaultRB->setChecked(
-               cite_engine == "basic");
-
-       biblioModule->citeJurabibRB->setChecked(
-               cite_engine == "jurabib");
-
-       biblioModule->citeNatbibRB->setChecked(
-               cite_engine == "natbib");
-
-       biblioModule->citeStyleCO->setCurrentIndex(
-               bp_.citeEngineType() & ENGINE_TYPE_NUMERICAL);
+       biblioModule->citeEngineCO->setCurrentIndex(
+               biblioModule->citeEngineCO->findData(toqstr(cite_engine)));
 
        updateEngineType(documentClass().opt_enginetype(),
                bp_.citeEngineType());
 
+       biblioModule->citeStyleCO->setCurrentIndex(
+               biblioModule->citeStyleCO->findData(bp_.citeEngineType()));
+
        biblioModule->bibtopicCB->setChecked(
                bp_.use_bibtopic);
 
-       biblioModule->bibtexStyleLE->setText(toqstr(bp_.biblio_style));
+       updateEngineDependends();
+
+       if (isBiblatex()) {
+               updateDefaultBiblio(bp_.biblatex_bibstyle, "bbx");
+               updateDefaultBiblio(bp_.biblatex_citestyle, "cbx");
+       } else
+               updateDefaultBiblio(bp_.defaultBiblioStyle());
+
+       biblioModule->citePackageOptionsLE->setText(toqstr(bp_.biblio_opts));
 
        string command;
        string options =
@@ -3051,8 +3197,11 @@ void GuiDocument::paramsToDialog()
                bp_.language->lang()));
        langModule->languageCO->setCurrentIndex(pos);
 
+       updateQuoteStyles();
+
        langModule->quoteStyleCO->setCurrentIndex(
-               bp_.quotes_language);
+               langModule->quoteStyleCO->findData(bp_.quotes_style));
+       langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
 
        bool default_enc = true;
        if (bp_.inputenc != "auto") {
@@ -3396,7 +3545,7 @@ void GuiDocument::paramsToDialog()
                fontModule->fontencLE->setText(toqstr(bp_.fontenc));
        }
 
-       // Output
+       // Formats
        // This must be set _after_ fonts since updateDefaultFormat()
        // checks osFontsCB settings.
        // update combobox with formats
@@ -3416,6 +3565,9 @@ void GuiDocument::paramsToDialog()
        outputModule->strictCB->setChecked(bp_.html_be_strict);
        outputModule->cssCB->setChecked(bp_.html_css_as_file);
 
+       outputModule->saveTransientPropertiesCB
+               ->setChecked(bp_.save_transient_properties);
+
        // paper
        bool const extern_geometry =
                documentClass().provides("geometry");
@@ -3600,6 +3752,154 @@ void GuiDocument::updateIncludeonlys()
 }
 
 
+bool GuiDocument::isBiblatex() const
+{
+       QString const engine =
+               biblioModule->citeEngineCO->itemData(
+                               biblioModule->citeEngineCO->currentIndex()).toString();
+
+       return theCiteEnginesList[fromqstr(engine)]->getCiteFramework() == "biblatex";
+}
+
+
+void GuiDocument::updateDefaultBiblio(string const & style,
+                                     string const & which)
+{
+       QString const bibstyle = toqstr(style);
+       biblioModule->defaultBiblioCO->clear();
+
+       int item_nr = -1;
+
+       if (isBiblatex()) {
+               if (which != "cbx") {
+                       // First the bbx styles
+                       biblioModule->biblatexBbxCO->clear();
+                       QStringList str = texFileList("bbxFiles.lst");
+                       // test whether we have a valid list, otherwise run rescan
+                       if (str.isEmpty()) {
+                               rescanTexStyles("bbx");
+                               str = texFileList("bbxFiles.lst");
+                       }
+                       for (int i = 0; i != str.size(); ++i)
+                               str[i] = onlyFileName(str[i]);
+                       // sort on filename only (no path)
+                       str.sort();
+
+                       for (int i = 0; i != str.count(); ++i) {
+                               QString item = changeExtension(str[i], "");
+                               if (item == bibstyle)
+                                       item_nr = i;
+                               biblioModule->biblatexBbxCO->addItem(item);
+                       }
+
+                       if (item_nr == -1 && !bibstyle.isEmpty()) {
+                               biblioModule->biblatexBbxCO->addItem(bibstyle);
+                               item_nr = biblioModule->biblatexBbxCO->count() - 1;
+                       }
+
+                       if (item_nr != -1)
+                               biblioModule->biblatexBbxCO->setCurrentIndex(item_nr);
+                       else
+                               biblioModule->biblatexBbxCO->clearEditText();
+               }
+
+               if (which != "bbx") {
+                       // now the cbx styles
+                       biblioModule->biblatexCbxCO->clear();
+                       QStringList str = texFileList("cbxFiles.lst");
+                       // test whether we have a valid list, otherwise run rescan
+                       if (str.isEmpty()) {
+                               rescanTexStyles("cbx");
+                               str = texFileList("cbxFiles.lst");
+                       }
+                       for (int i = 0; i != str.size(); ++i)
+                               str[i] = onlyFileName(str[i]);
+                       // sort on filename only (no path)
+                       str.sort();
+
+                       for (int i = 0; i != str.count(); ++i) {
+                               QString item = changeExtension(str[i], "");
+                               if (item == bibstyle)
+                                       item_nr = i;
+                               biblioModule->biblatexCbxCO->addItem(item);
+                       }
+
+                       if (item_nr == -1 && !bibstyle.isEmpty()) {
+                               biblioModule->biblatexCbxCO->addItem(bibstyle);
+                               item_nr = biblioModule->biblatexCbxCO->count() - 1;
+                       }
+
+                       if (item_nr != -1)
+                               biblioModule->biblatexCbxCO->setCurrentIndex(item_nr);
+                       else
+                               biblioModule->biblatexCbxCO->clearEditText();
+               }
+       } else {// BibTeX
+               biblioModule->biblatexBbxCO->clear();
+               biblioModule->biblatexCbxCO->clear();
+               QStringList str = texFileList("bstFiles.lst");
+               // test whether we have a valid list, otherwise run rescan
+               if (str.isEmpty()) {
+                       rescanTexStyles("bst");
+                       str = texFileList("bstFiles.lst");
+               }
+               for (int i = 0; i != str.size(); ++i)
+                       str[i] = onlyFileName(str[i]);
+               // sort on filename only (no path)
+               str.sort();
+
+               for (int i = 0; i != str.count(); ++i) {
+                       QString item = changeExtension(str[i], "");
+                       if (item == bibstyle)
+                               item_nr = i;
+                       biblioModule->defaultBiblioCO->addItem(item);
+               }
+
+               if (item_nr == -1 && !bibstyle.isEmpty()) {
+                       biblioModule->defaultBiblioCO->addItem(bibstyle);
+                       item_nr = biblioModule->defaultBiblioCO->count() - 1;
+               }
+
+               if (item_nr != -1)
+                       biblioModule->defaultBiblioCO->setCurrentIndex(item_nr);
+               else
+                       biblioModule->defaultBiblioCO->clearEditText();
+       }
+
+       updateResetDefaultBiblio();
+}
+
+
+void GuiDocument::updateResetDefaultBiblio()
+{
+       QString const engine =
+               biblioModule->citeEngineCO->itemData(
+                               biblioModule->citeEngineCO->currentIndex()).toString();
+       CiteEngineType const cet =
+               CiteEngineType(biblioModule->citeStyleCO->itemData(
+                                                         biblioModule->citeStyleCO->currentIndex()).toInt());
+
+       string const defbib = theCiteEnginesList[fromqstr(engine)]->getDefaultBiblio(cet);
+       if (isBiblatex()) {
+               QString const bbx = biblioModule->biblatexBbxCO->currentText();
+               QString const cbx = biblioModule->biblatexCbxCO->currentText();
+               biblioModule->resetCbxPB->setEnabled(defbib != fromqstr(cbx));
+               biblioModule->resetBbxPB->setEnabled(defbib != fromqstr(bbx));
+               biblioModule->matchBbxPB->setEnabled(bbx != cbx && !cbx.isEmpty()
+                       && biblioModule->biblatexBbxCO->findText(cbx) != -1);
+       } else
+               biblioModule->resetDefaultBiblioPB->setEnabled(
+                       defbib != fromqstr(biblioModule->defaultBiblioCO->currentText()));
+}
+
+
+void GuiDocument::matchBiblatexStyles()
+{
+       updateDefaultBiblio(fromqstr(biblioModule->biblatexCbxCO->currentText()), "bbx");
+       biblioChanged();
+}
+
+
 void GuiDocument::updateContents()
 {
        // Nothing to do here as the document settings is not cursor dependant.