* Licence details can be found in the file COPYING.
*
* \author John Levon
- * \author Herbert Voß
+ * \author Herbert Voß
* \author Angus Leeming
- * \author Jürgen Spitzmüller
+ * \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#include "Buffer.h"
#include "BufferParams.h"
+#include "CiteEnginesList.h"
#include "FuncRequest.h"
#include "LyXRC.h"
#include "qt_helpers.h"
this, SLOT(change_adaptor()));
connect(addBibPB, SIGNAL(clicked()),
this, SLOT(addPressed()));
+ connect(rescanPB, SIGNAL(clicked()),
+ this, SLOT(rescanClicked()));
+ connect(biblatexOptsLE, SIGNAL(textChanged(QString)),
+ this, SLOT(change_adaptor()));
add_ = new GuiBibtexAddDialog(this);
add_bc_.setPolicy(ButtonPolicy::OkCancelPolicy);
this, SLOT(addDatabase()));
connect(add_->addPB, SIGNAL(clicked()),
add_, SLOT(accept()));
+ connect(add_->rescanPB, SIGNAL(clicked()),
+ this, SLOT(rescanClicked()));
connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
this, SLOT(addDatabase()));
connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
}
+void GuiBibtex::rescanClicked()
+{
+ rescanBibStyles();
+ updateContents();
+}
+
+
void GuiBibtex::databaseChanged()
{
bool readOnly = isBufferReadonly();
void GuiBibtex::updateContents()
{
bool bibtopic = usingBibtopic();
+ bool biblatex = usingBiblatex();
databaseLW->clear();
for (int i = 0; i != bibfiles.count(); ++i)
add_->bibLW->addItem(changeExtension(bibfiles[i], ""));
- QString bibstyle = styleFile();
+ QString const bibstyle = styleFile();
bibtocCB->setChecked(bibtotoc() && !bibtopic);
bibtocCB->setEnabled(!bibtopic);
else if (bibtopic && btPrintCO->count() < 3)
btPrintCO->insertItem(1, qt_("all uncited references", 0));
- docstring btprint = params_["btprint"];
+ docstring const & btprint = params_["btprint"];
int btp = 0;
- if ((bibtopic && btprint == "btPrintNotCited") ||
- (!bibtopic && btprint == "btPrintAll"))
+ if ((bibtopic && btprint == from_ascii("btPrintNotCited")) ||
+ (!bibtopic && btprint == from_ascii("btPrintAll")))
btp = 1;
- else if (bibtopic && btprint == "btPrintAll")
+ else if (bibtopic && btprint == from_ascii("btPrintAll"))
btp = 2;
btPrintCO->setCurrentIndex(btp);
- styleCB->clear();
+ // Only useful for biblatex
+ biblatexOptsLA->setVisible(biblatex);
+ biblatexOptsLE->setVisible(biblatex);
- int item_nr = -1;
+ // only useful for BibTeX
+ styleCB->setVisible(!biblatex);
+ styleLA->setVisible(!biblatex);
+ stylePB->setVisible(!biblatex);
- QStringList str = bibStyles();
- for (int i = 0; i != str.count(); ++i) {
- QString item = changeExtension(str[i], "");
- if (item == bibstyle)
- item_nr = i;
- styleCB->addItem(item);
- }
+ if (!biblatex) {
+ styleCB->clear();
- if (item_nr == -1 && !bibstyle.isEmpty()) {
- styleCB->addItem(bibstyle);
- item_nr = styleCB->count() - 1;
- }
+ int item_nr = -1;
- if (item_nr != -1)
- styleCB->setCurrentIndex(item_nr);
- else
- styleCB->clearEditText();
+ QStringList const str = bibStyles();
+ for (int i = 0; i != str.count(); ++i) {
+ QString item = changeExtension(str[i], "");
+ if (item == bibstyle)
+ item_nr = i;
+ styleCB->addItem(item);
+ }
+
+ if (item_nr == -1 && !bibstyle.isEmpty()) {
+ styleCB->addItem(bibstyle);
+ item_nr = styleCB->count() - 1;
+ }
+
+
+ if (item_nr != -1)
+ styleCB->setCurrentIndex(item_nr);
+ else
+ styleCB->clearEditText();
+ } else
+ biblatexOptsLE->setText(toqstr(params_["biblatexopts"]));
}
params_["options"] = bibstyle;
}
+ params_["biblatexopts"] = qstring_to_ucs4(biblatexOptsLE->text());
+
int btp = btPrintCO->currentIndex();
if (usingBibtopic()) {
// use \nocite{*}
params_["btprint"] = from_ascii("btPrintAll");
break;
- }
+ }
}
}
QString const label1 = qt_("Documents|#o#O");
QString const dir1 = toqstr(lyxrc.document_path);
QStringList const filter(qt_("BibTeX Databases (*.bib)"));
- return browseRelFile(in_name, bufferFilepath(),
+ return browseRelToParent(in_name, bufferFilePath(),
qt_("Select a BibTeX database to add"), filter, false, label1, dir1);
}
QString const label1 = qt_("Documents|#o#O");
QString const dir1 = toqstr(lyxrc.document_path);
QStringList const filter(qt_("BibTeX Styles (*.bst)"));
- return browseRelFile(in_name, bufferFilepath(),
+ return browseRelToParent(in_name, bufferFilePath(),
qt_("Select a BibTeX style"), filter, false, label1, dir1);
}
data = texFileList("bstFiles.lst");
}
for (int i = 0; i != data.size(); ++i)
- data[i] = onlyFilename(data[i]);
+ data[i] = onlyFileName(data[i]);
// sort on filename only (no path)
data.sort();
return data;
data = texFileList("bibFiles.lst");
}
for (int i = 0; i != data.size(); ++i)
- data[i] = onlyFilename(data[i]);
+ data[i] = onlyFileName(data[i]);
// sort on filename only (no path)
data.sort();
return data;
void GuiBibtex::rescanBibStyles() const
{
- rescanTexStyles();
+ if (usingBiblatex())
+ rescanTexStyles("bib");
+ else
+ rescanTexStyles("bst bib");
}
}
+bool GuiBibtex::usingBiblatex() const
+{
+ return buffer().masterBuffer()->params().useBiblatex();
+}
+
+
QString GuiBibtex::styleFile() const
{
// the different bibtex packages have (and need) their
// own "plain" stylefiles
- CiteEngine const engine = buffer().params().citeEngine();
- QString defaultstyle;
- switch (engine) {
- case ENGINE_BASIC:
- defaultstyle = "plain";
- break;
- case ENGINE_NATBIB_AUTHORYEAR:
- defaultstyle = "plainnat";
- break;
- case ENGINE_NATBIB_NUMERICAL:
- defaultstyle = "plainnat";
- break;
- case ENGINE_JURABIB:
- defaultstyle = "jurabib";
- break;
- }
+ QString defaultstyle = toqstr(buffer().params().defaultBiblioStyle());
QString bst = toqstr(params_["options"]);
if (bibtotoc()){
bool GuiBibtex::initialiseParams(std::string const & data)
{
- InsetCommand::string2params("bibtex", data, params_);
+ InsetCommand::string2params(data, params_);
return true;
}
void GuiBibtex::dispatchParams()
{
- std::string const lfun = InsetCommand::params2string("bibtex", params_);
+ std::string const lfun = InsetCommand::params2string(params_);
dispatch(FuncRequest(getLfun(), lfun));
}