X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiBibtex.cpp;h=ff0a03e272222dfcb0b7d2c6eb41d12d9fea0154;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=946490c59da7ff292f8b9de98e2dcce0ab53249e;hpb=be624b3de0df348047ac2db05d27dbf16ec56e07;p=lyx.git diff --git a/src/frontends/qt4/GuiBibtex.cpp b/src/frontends/qt4/GuiBibtex.cpp index 946490c59d..ff0a03e272 100644 --- a/src/frontends/qt4/GuiBibtex.cpp +++ b/src/frontends/qt4/GuiBibtex.cpp @@ -4,9 +4,9 @@ * 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. */ @@ -17,15 +17,22 @@ #include "Buffer.h" #include "BufferParams.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 "frontends/alert.h" + +#include "insets/InsetBibtex.h" + #include "support/debug.h" -#include "support/FileFilterList.h" +#include "support/ExceptionMessage.h" +#include "support/FileName.h" #include "support/filetools.h" // changeExtension #include "support/gettext.h" #include "support/lstrings.h" @@ -43,7 +50,8 @@ namespace frontend { GuiBibtex::GuiBibtex(GuiView & lv) - : GuiCommand(lv, "bibtex", qt_("BibTeX Bibliography")) + : GuiDialog(lv, "bibtex", qt_("BibTeX Bibliography")), + params_(insetCode("bibtex")) { setupUi(this); @@ -71,6 +79,8 @@ GuiBibtex::GuiBibtex(GuiView & lv) 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); @@ -84,6 +94,8 @@ GuiBibtex::GuiBibtex(GuiView & lv) 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 *)), @@ -202,9 +214,7 @@ void GuiBibtex::addDatabase() 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); } } @@ -217,9 +227,7 @@ void GuiBibtex::addDatabase() 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); } } @@ -260,6 +268,13 @@ void GuiBibtex::downPressed() } +void GuiBibtex::rescanClicked() +{ + rescanBibStyles(); + updateContents(); +} + + void GuiBibtex::databaseChanged() { bool readOnly = isBufferReadonly(); @@ -284,19 +299,14 @@ void GuiBibtex::updateContents() 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); } } @@ -353,19 +363,18 @@ void GuiBibtex::updateContents() void GuiBibtex::applyView() { - QString dbs = databaseLW->item(0)->text(); - docstring emb = databaseLW->item(0)->checkState() == Qt::Checked ? _("true") : _("false"); + docstring dbs; unsigned int maxCount = databaseLW->count(); - for (unsigned int i = 1; i < maxCount; i++) { - dbs += ','; - dbs += databaseLW->item(i)->text(); - emb += ','; - emb += databaseLW->item(i)->checkState() == Qt::Checked ? _("true") : _("false"); + for (unsigned int i = 0; i < maxCount; i++) { + if (i != 0) + dbs += ','; + QString item = databaseLW->item(i)->text(); + docstring bibfile = qstring_to_ucs4(item); + dbs += bibfile; } - params_["bibfiles"] = qstring_to_ucs4(dbs); - params_["embed"] = emb; + params_["bibfiles"] = dbs; docstring const bibstyle = qstring_to_ucs4(styleCB->currentText()); bool const bibtotoc = bibtocCB->isChecked(); @@ -425,7 +434,7 @@ QString GuiBibtex::browseBib(QString const & in_name) const { QString const label1 = qt_("Documents|#o#O"); QString const dir1 = toqstr(lyxrc.document_path); - FileFilterList const filter(_("BibTeX Databases (*.bib)")); + QStringList const filter(qt_("BibTeX Databases (*.bib)")); return browseRelFile(in_name, bufferFilepath(), qt_("Select a BibTeX database to add"), filter, false, label1, dir1); } @@ -435,7 +444,7 @@ QString GuiBibtex::browseBst(QString const & in_name) const { QString const label1 = qt_("Documents|#o#O"); QString const dir1 = toqstr(lyxrc.document_path); - FileFilterList const filter(_("BibTeX Styles (*.bst)")); + QStringList const filter(qt_("BibTeX Styles (*.bst)")); return browseRelFile(in_name, bufferFilepath(), qt_("Select a BibTeX style"), filter, false, label1, dir1); } @@ -495,19 +504,19 @@ QString GuiBibtex::styleFile() const { // the different bibtex packages have (and need) their // own "plain" stylefiles - biblio::CiteEngine const engine = buffer().params().getEngine(); + 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_AUTHORYEAR: defaultstyle = "plainnat"; break; - case biblio::ENGINE_NATBIB_NUMERICAL: + case ENGINE_NATBIB_NUMERICAL: defaultstyle = "plainnat"; break; - case biblio::ENGINE_JURABIB: + case ENGINE_JURABIB: defaultstyle = "jurabib"; break; } @@ -520,7 +529,7 @@ QString GuiBibtex::styleFile() const // FIXME: check // docstring bibtotoc = from_ascii("bibtotoc"); // bst = split(bst, bibtotoc, ','); - bst = bst.mid(pos); + bst = bst.mid(pos + 1); } else { bst.clear(); } @@ -536,10 +545,25 @@ QString GuiBibtex::styleFile() const } +bool GuiBibtex::initialiseParams(std::string const & data) +{ + InsetCommand::string2params("bibtex", data, params_); + return true; +} + + +void GuiBibtex::dispatchParams() +{ + std::string const lfun = InsetCommand::params2string("bibtex", 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"