+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();
+}
+
+