* 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 "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()));
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 *)),
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();
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);
}
}
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) {
- FileName bibfilepath = InsetBibtex::getBibTeXPath(bibfile, buf);
- string inzipName =
- EmbeddedFile::calcInzipName(bibfilepath.absFilename(), buf.filePath());
- emb += from_utf8(inzipName);
- }
}
params_["bibfiles"] = dbs;
- params_["embed"] = emb;
docstring const bibstyle = qstring_to_ucs4(styleCB->currentText());
bool const bibtotoc = bibtocCB->isChecked();
// use \nocite{*}
params_["btprint"] = from_ascii("btPrintAll");
break;
- }
+ }
}
}
{
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;
{
// the different bibtex packages have (and need) their
// own "plain" stylefiles
- biblio::CiteEngine const engine = buffer().params().citeEngine();
+ CiteEngine const engine = buffer().params().citeEngine();
QString defaultstyle;
switch (engine) {
- case biblio::ENGINE_BASIC:
+ case ENGINE_BASIC:
defaultstyle = "plain";
break;
- case biblio::ENGINE_NATBIB_AUTHORYEAR:
+ case ENGINE_NATBIB:
defaultstyle = "plainnat";
break;
- case biblio::ENGINE_NATBIB_NUMERICAL:
- defaultstyle = "plainnat";
- break;
- case biblio::ENGINE_JURABIB:
+ case ENGINE_JURABIB:
defaultstyle = "jurabib";
break;
}
// 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"