#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
+#include "CiteEnginesList.h"
#include "Color.h"
#include "ColorCache.h"
#include "Converter.h"
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));
encodinglist.sort();
langModule->encodingCO->addItems(encodinglist);
- for (int i = 0; i < quoteparams.stylescount(); ++i) {
- InsetQuotesParams::QuoteStyle qs = InsetQuotesParams::QuoteStyle(i);
- langModule->quoteStyleCO->addItem(toqstr(quoteparams.getGuiLabel(qs)), qs);
- }
-
langModule->languagePackageCO->addItem(
qt_("Default"), toqstr("default"));
langModule->languagePackageCO->addItem(
// 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->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->rescanBibliosPB, SIGNAL(clicked()),
+ this, SLOT(rescanBibFiles()));
+ connect(biblioModule->resetDefaultBiblioPB, SIGNAL(clicked()),
+ this, SLOT(resetDefaultBibfile()));
+
+ 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();
}
+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
}
// set appropriate quotation mark style
- if (!lang->quoteStyle().empty()) {
- langModule->quoteStyleCO->setCurrentIndex(
- bp_.getQuoteStyle(lang->quoteStyle()));
- }
+ updateQuoteStyles(true);
}
}
-void GuiDocument::bibtexChanged(int n)
+void GuiDocument::rescanBibFiles()
{
- biblioModule->bibtexOptionsLE->setEnabled(
- biblioModule->bibtexCO->itemData(n).toString() != "default");
+ rescanTexStyles("bst");
+}
+
+
+void GuiDocument::resetDefaultBibfile()
+{
+ 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));
+}
+
+
+void GuiDocument::citeEngineChanged(int n)
+{
+ QString const engine =
+ biblioModule->citeEngineCO->itemData(n).toString();
+
+ vector<string> const engs =
+ theCiteEnginesList[fromqstr(engine)]->getEngineType();
+
+ updateCiteStyles(engs);
+ resetDefaultBibfile();
+
biblioChanged();
}
-void GuiDocument::setAuthorYear(bool authoryear)
+void GuiDocument::citeStyleChanged()
{
- if (authoryear)
- biblioModule->citeStyleCO->setCurrentIndex(0);
+ QString const engine =
+ biblioModule->citeEngineCO->itemData(
+ biblioModule->citeEngineCO->currentIndex()).toString();
+ if (theCiteEnginesList[fromqstr(engine)]->isDefaultBiblio(
+ fromqstr(biblioModule->defaultBiblioCO->currentText())))
+ 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();
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);
}
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()));
string const bibtex_command =
fromqstr(biblioModule->bibtexCO->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();
// 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));
+ updateDefaultBiblio(bp_.defaultBiblioStyle());
string command;
string options =
bp_.language->lang()));
langModule->languageCO->setCurrentIndex(pos);
+ updateQuoteStyles();
+
langModule->quoteStyleCO->setCurrentIndex(
- bp_.quotes_style);
+ langModule->quoteStyleCO->findData(bp_.quotes_style));
+ langModule->dynamicQuotesCB->setChecked(bp_.dynamic_quotes);
bool default_enc = true;
if (bp_.inputenc != "auto") {
}
+void GuiDocument::updateDefaultBiblio(string const & style)
+{
+ QString const bibstyle = toqstr(style);
+ biblioModule->defaultBiblioCO->clear();
+
+ int item_nr = -1;
+
+ 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());
+ biblioModule->resetDefaultBiblioPB->setEnabled(
+ theCiteEnginesList[fromqstr(engine)]->getDefaultBiblio(cet)
+ != fromqstr(biblioModule->defaultBiblioCO->currentText()));
+}
+
+
void GuiDocument::updateContents()
{
// Nothing to do here as the document settings is not cursor dependant.