* 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 "EmbeddedFiles.h"
-#include "ui_BibtexAddUi.h"
+#include "CiteEnginesList.h"
+#include "FuncRequest.h"
+#include "LyXRC.h"
#include "qt_helpers.h"
#include "Validator.h"
-#include "LyXRC.h"
+
+#include "ui_BibtexAddUi.h"
#include "ButtonPolicy.h"
#include "support/debug.h"
#include "support/ExceptionMessage.h"
-#include "support/FileFilterList.h"
+#include "support/FileName.h"
#include "support/filetools.h" // changeExtension
#include "support/gettext.h"
#include "support/lstrings.h"
GuiBibtex::GuiBibtex(GuiView & lv)
- : GuiCommand(lv, "bibtex", qt_("BibTeX Bibliography"))
+ : GuiDialog(lv, "bibtex", qt_("BibTeX Bibliography")),
+ params_(insetCode("bibtex"))
{
setupUi(this);
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 *)),
connect(add_->closePB, SIGNAL(clicked()),
add_, SLOT(reject()));
+ add_->bibLW->setToolTip(formatToolTip(qt_("This list consists of all databases that are indexed by LaTeX and thus are found without a file path. "
+ "This is usually everything in the bib/ subdirectory of LaTeX's texmf tree. "
+ "If you want to reuse your own database, this is the place you should store it.")));
+
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
bc().setCancel(closePB);
if (matches.empty()) {
QString label = item->text();
QListWidgetItem * db = new QListWidgetItem(label);
- db->setFlags(db->flags() | Qt::ItemIsSelectable
- | Qt::ItemIsUserCheckable);
- db->setCheckState(Qt::Checked);
+ db->setFlags(db->flags() | Qt::ItemIsSelectable);
databaseLW->addItem(db);
}
}
databaseLW->findItems(f, Qt::MatchExactly);
if (matches.empty()) {
QListWidgetItem * db = new QListWidgetItem(f);
- db->setFlags(db->flags() | Qt::ItemIsSelectable
- | Qt::ItemIsUserCheckable);
- db->setCheckState(Qt::Checked);
+ db->setFlags(db->flags() | Qt::ItemIsSelectable);
databaseLW->addItem(db);
}
}
}
+void GuiBibtex::rescanClicked()
+{
+ rescanBibStyles();
+ updateContents();
+}
+
+
void GuiBibtex::databaseChanged()
{
bool readOnly = isBufferReadonly();
void GuiBibtex::updateContents()
{
bool bibtopic = usingBibtopic();
+ bool biblatex = usingBiblatex();
databaseLW->clear();
docstring bibs = params_["bibfiles"];
- docstring embs = params_["embed"];
docstring bib;
- docstring emb;
while (!bibs.empty()) {
bibs = split(bibs, bib, ',');
- embs = split(embs, emb, ',');
bib = trim(bib);
if (!bib.empty()) {
QListWidgetItem * db = new QListWidgetItem(toqstr(bib));
- db->setFlags(db->flags() | Qt::ItemIsSelectable
- | Qt::ItemIsUserCheckable);
- db->setCheckState(emb.empty() ? Qt::Unchecked : Qt::Checked);
+ db->setFlags(db->flags() | Qt::ItemIsSelectable);
databaseLW->addItem(db);
}
}
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);
- if (!bibtopic && btPrintCO->count() == 3)
- btPrintCO->removeItem(1);
- else if (bibtopic && btPrintCO->count() < 3)
- btPrintCO->insertItem(1, qt_("all uncited references", 0));
+ btPrintCO->clear();
+ btPrintCO->addItem(qt_("all cited references"), toqstr("btPrintCited"));
+ if (bibtopic)
+ btPrintCO->addItem(qt_("all uncited references"), toqstr("btPrintNotCited"));
+ btPrintCO->addItem(qt_("all references"), toqstr("btPrintAll"));
+ if (usingBiblatex() && !buffer().masterParams().multibib.empty())
+ btPrintCO->addItem(qt_("all reference units"), toqstr("bibbysection"));
- docstring btprint = params_["btprint"];
- int btp = 0;
- if ((bibtopic && btprint == "btPrintNotCited") ||
- (!bibtopic && btprint == "btPrintAll"))
- btp = 1;
- else if (bibtopic && btprint == "btPrintAll")
- btp = 2;
+ btPrintCO->setCurrentIndex(btPrintCO->findData(toqstr(params_["btprint"])));
- btPrintCO->setCurrentIndex(btp);
+ // Only useful for biblatex
+ biblatexOptsLA->setVisible(biblatex);
+ biblatexOptsLE->setVisible(biblatex);
- styleCB->clear();
+ // only useful for BibTeX
+ styleCB->setVisible(!biblatex);
+ styleLA->setVisible(!biblatex);
+ stylePB->setVisible(!biblatex);
- int item_nr = -1;
+ if (!biblatex) {
+ styleCB->clear();
- 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);
- }
+ int item_nr = -1;
- if (item_nr == -1 && !bibstyle.isEmpty()) {
- styleCB->addItem(bibstyle);
- item_nr = styleCB->count() - 1;
- }
+ 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)
- styleCB->setCurrentIndex(item_nr);
- else
- styleCB->clearEditText();
+ 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"]));
}
void GuiBibtex::applyView()
{
docstring dbs;
- docstring emb;
unsigned int maxCount = databaseLW->count();
- Buffer & buf = buffer();
for (unsigned int i = 0; i < maxCount; i++) {
- if (i != 0) {
+ if (i != 0)
dbs += ',';
- emb += ',';
- }
QString item = databaseLW->item(i)->text();
docstring bibfile = qstring_to_ucs4(item);
dbs += bibfile;
- if (databaseLW->item(i)->checkState() == Qt::Checked)
- emb += "embedded";
}
params_["bibfiles"] = dbs;
- params_["embed"] = emb;
docstring const bibstyle = qstring_to_ucs4(styleCB->currentText());
bool const bibtotoc = bibtocCB->isChecked();
params_["options"] = bibstyle;
}
- int btp = btPrintCO->currentIndex();
-
- if (usingBibtopic()) {
- // bibtopic allows three kinds of sections:
- // 1. sections that include all cited references of the database(s)
- // 2. sections that include all uncited references of the database(s)
- // 3. sections that include all references of the database(s), cited or not
- switch (btp) {
- case 0:
- params_["btprint"] = from_ascii("btPrintCited");
- break;
- case 1:
- params_["btprint"] = from_ascii("btPrintNotCited");
- break;
- case 2:
- params_["btprint"] = from_ascii("btPrintAll");
- break;
- }
- } else {
- switch (btp) {
- case 0:
- params_["btprint"] = docstring();
- break;
- case 1:
- // use \nocite{*}
- params_["btprint"] = from_ascii("btPrintAll");
- break;
- }
- }
+ params_["biblatexopts"] = qstring_to_ucs4(biblatexOptsLE->text());
+
+ params_["btprint"] = qstring_to_ucs4(btPrintCO->itemData(btPrintCO->currentIndex()).toString());
}
{
QString const label1 = qt_("Documents|#o#O");
QString const dir1 = toqstr(lyxrc.document_path);
- FileFilterList const filter(_("BibTeX Databases (*.bib)"));
- return browseRelFile(in_name, bufferFilepath(),
+ QStringList const filter(qt_("BibTeX Databases (*.bib)"));
+ 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);
- FileFilterList const filter(_("BibTeX Styles (*.bst)"));
- return browseRelFile(in_name, bufferFilepath(),
+ QStringList const filter(qt_("BibTeX Styles (*.bst)"));
+ 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::usingBibtopic() const
{
- return buffer().params().use_bibtopic;
+ return buffer().params().useBibtopic();
}
}
+bool GuiBibtex::usingBiblatex() const
+{
+ return buffer().masterBuffer()->params().useBiblatex();
+}
+
+
QString GuiBibtex::styleFile() const
{
// the different bibtex packages have (and need) their
// own "plain" stylefiles
- biblio::CiteEngine const engine = buffer().params().citeEngine();
- QString defaultstyle;
- switch (engine) {
- case biblio::ENGINE_BASIC:
- defaultstyle = "plain";
- break;
- case biblio::ENGINE_NATBIB_AUTHORYEAR:
- defaultstyle = "plainnat";
- break;
- case biblio::ENGINE_NATBIB_NUMERICAL:
- defaultstyle = "plainnat";
- break;
- case biblio::ENGINE_JURABIB:
- defaultstyle = "jurabib";
- break;
- }
+ QString defaultstyle = toqstr(buffer().params().defaultBiblioStyle());
QString bst = toqstr(params_["options"]);
if (bibtotoc()){
// FIXME: check
// docstring bibtotoc = from_ascii("bibtotoc");
// bst = split(bst, bibtotoc, ',');
- bst = bst.mid(pos);
+ bst = bst.mid(pos + 1);
} else {
bst.clear();
}
}
+bool GuiBibtex::initialiseParams(std::string const & data)
+{
+ InsetCommand::string2params(data, params_);
+ return true;
+}
+
+
+void GuiBibtex::dispatchParams()
+{
+ std::string const lfun = InsetCommand::params2string(params_);
+ dispatch(FuncRequest(getLfun(), lfun));
+}
+
+
+
Dialog * createGuiBibtex(GuiView & lv) { return new GuiBibtex(lv); }
} // namespace frontend
} // namespace lyx
-#include "GuiBibtex_moc.cpp"
+#include "moc_GuiBibtex.cpp"