2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
|
* \file GuiBibtex.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author John Levon
|
|
|
|
|
* \author Herbert Vo<EFBFBD>
|
2007-10-06 09:55:21 +00:00
|
|
|
|
* \author Angus Leeming
|
2006-03-05 17:24:44 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
|
#include "GuiBibtex.h"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
#include "Buffer.h"
|
|
|
|
|
#include "BufferParams.h"
|
|
|
|
|
#include "debug.h"
|
2007-08-11 15:48:15 +00:00
|
|
|
|
#include "ui_BibtexAddUi.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "qt_helpers.h"
|
2007-04-26 03:53:02 +00:00
|
|
|
|
#include "Validator.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXRC.h"
|
2007-10-06 09:55:21 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-25 08:42:22 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
#include "ButtonPolicy.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-04-09 08:42:58 +00:00
|
|
|
|
#include "support/filetools.h" // changeExtension
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2007-10-06 09:55:21 +00:00
|
|
|
|
#include "support/FileFilterList.h"
|
|
|
|
|
|
2006-05-02 19:17:59 +00:00
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QListWidget>
|
|
|
|
|
#include <QCheckBox>
|
2007-04-25 08:42:22 +00:00
|
|
|
|
#include <QCloseEvent>
|
|
|
|
|
#include <QLineEdit>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
using std::pair;
|
2007-08-31 22:16:11 +00:00
|
|
|
|
using std::string;
|
2007-10-06 09:55:21 +00:00
|
|
|
|
using std::vector;
|
2007-08-31 22:16:11 +00:00
|
|
|
|
|
2007-04-25 08:42:22 +00:00
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
|
using support::changeExtension;
|
2007-10-06 09:55:21 +00:00
|
|
|
|
using support::contains;
|
|
|
|
|
using support::FileFilterList;
|
|
|
|
|
using support::onlyFilename;
|
|
|
|
|
using support::prefixIs;
|
2007-08-31 22:16:11 +00:00
|
|
|
|
using support::split;
|
|
|
|
|
using support::trim;
|
|
|
|
|
|
2007-04-25 08:42:22 +00:00
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
|
GuiBibtex::GuiBibtex(GuiView & lv)
|
2007-10-07 18:40:01 +00:00
|
|
|
|
: GuiCommand(lv, "bibtex")
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
|
|
setViewTitle( _("BibTeX Bibliography"));
|
|
|
|
|
|
2007-04-25 08:42:22 +00:00
|
|
|
|
QDialog::setModal(true);
|
|
|
|
|
|
|
|
|
|
connect(okPB, SIGNAL(clicked()),
|
2007-09-05 20:33:29 +00:00
|
|
|
|
this, SLOT(slotOK()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
connect(closePB, SIGNAL(clicked()),
|
2007-09-05 20:33:29 +00:00
|
|
|
|
this, SLOT(slotClose()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
connect(stylePB, SIGNAL(clicked()),
|
2007-08-31 05:53:55 +00:00
|
|
|
|
this, SLOT(browsePressed()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
connect(deletePB, SIGNAL(clicked()),
|
2007-08-31 05:53:55 +00:00
|
|
|
|
this, SLOT(deletePressed()));
|
2007-10-06 09:55:21 +00:00
|
|
|
|
connect(styleCB, SIGNAL(editTextChanged(QString)),
|
2007-08-31 05:53:55 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
connect(databaseLW, SIGNAL(itemSelectionChanged()),
|
2007-08-31 05:53:55 +00:00
|
|
|
|
this, SLOT(databaseChanged()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
connect(bibtocCB, SIGNAL(clicked()),
|
2007-08-31 05:53:55 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
connect(btPrintCO, SIGNAL(activated(int)),
|
2007-08-31 05:53:55 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
connect(addBibPB, SIGNAL(clicked()),
|
2007-08-31 05:53:55 +00:00
|
|
|
|
this, SLOT(addPressed()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
add_ = new GuiBibtexAddDialog(this);
|
2007-09-02 07:53:07 +00:00
|
|
|
|
add_bc_.setPolicy(ButtonPolicy::OkCancelPolicy);
|
2007-09-03 05:59:32 +00:00
|
|
|
|
add_bc_.setOK(add_->addPB);
|
|
|
|
|
add_bc_.setCancel(add_->closePB);
|
|
|
|
|
add_bc_.addCheckedLineEdit(add_->bibED, 0);
|
2007-04-25 08:42:22 +00:00
|
|
|
|
|
2007-10-28 16:32:20 +00:00
|
|
|
|
connect(add_->bibED, SIGNAL(textChanged(QString)),
|
2007-04-25 08:42:22 +00:00
|
|
|
|
this, SLOT(bibEDChanged()));
|
|
|
|
|
connect(add_->addPB, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(addDatabase()));
|
|
|
|
|
connect(add_->addPB, SIGNAL(clicked()),
|
|
|
|
|
add_, SLOT(accept()));
|
|
|
|
|
connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
|
|
|
|
|
this, SLOT(addDatabase()));
|
|
|
|
|
connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
|
|
|
|
|
add_, SLOT(accept()));
|
|
|
|
|
connect(add_->bibLW, SIGNAL(itemSelectionChanged()),
|
|
|
|
|
this, SLOT(availableChanged()));
|
|
|
|
|
connect(add_->browsePB, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(browseBibPressed()));
|
|
|
|
|
connect(add_->closePB, SIGNAL(clicked()),
|
|
|
|
|
add_, SLOT(reject()));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
|
|
|
bc().setOK(okPB);
|
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
|
bc().addReadOnly(databaseLW);
|
|
|
|
|
bc().addReadOnly(stylePB);
|
|
|
|
|
bc().addReadOnly(styleCB);
|
|
|
|
|
bc().addReadOnly(bibtocCB);
|
|
|
|
|
bc().addReadOnly(addBibPB);
|
|
|
|
|
bc().addReadOnly(deletePB);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::bibEDChanged()
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
|
|
|
|
// Indicate to the button controller that the contents have
|
|
|
|
|
// changed. The actual test of validity is carried out by
|
|
|
|
|
// the checkedLineEdit.
|
2007-09-03 05:59:32 +00:00
|
|
|
|
add_bc_.setValid(true);
|
2007-04-25 08:42:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::change_adaptor()
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::browsePressed()
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
2007-10-06 09:55:21 +00:00
|
|
|
|
docstring const file = browseBst(docstring());
|
2007-04-25 08:42:22 +00:00
|
|
|
|
|
|
|
|
|
if (!file.empty()) {
|
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
docstring const filen = from_utf8(changeExtension(to_utf8(file), ""));
|
|
|
|
|
bool present = false;
|
|
|
|
|
unsigned int pres = 0;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i != styleCB->count(); ++i) {
|
|
|
|
|
if (qstring_to_ucs4(styleCB->itemText(i)) == filen) {
|
|
|
|
|
present = true;
|
|
|
|
|
pres = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!present)
|
|
|
|
|
styleCB->insertItem(0, toqstr(filen));
|
|
|
|
|
|
|
|
|
|
styleCB->setCurrentIndex(pres);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::browseBibPressed()
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
2007-10-06 09:55:21 +00:00
|
|
|
|
docstring const file = trim(browseBib(docstring()));
|
2007-04-25 08:42:22 +00:00
|
|
|
|
|
|
|
|
|
if (!file.empty()) {
|
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
QString const f = toqstr(changeExtension(to_utf8(file), ""));
|
|
|
|
|
bool present = false;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < add_->bibLW->count(); ++i) {
|
|
|
|
|
if (add_->bibLW->item(i)->text() == f)
|
|
|
|
|
present = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!present) {
|
|
|
|
|
add_->bibLW->addItem(f);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
add_->bibED->setText(f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::addPressed()
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
2007-09-03 05:59:32 +00:00
|
|
|
|
add_bc_.setValid(false);
|
2007-04-25 08:42:22 +00:00
|
|
|
|
add_->exec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::addDatabase()
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
|
|
|
|
int const sel = add_->bibLW->currentRow();
|
|
|
|
|
docstring const file = trim(qstring_to_ucs4(add_->bibED->text()));
|
|
|
|
|
|
|
|
|
|
if (sel < 0 && file.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Add the selected browser_bib keys to browser_database
|
|
|
|
|
// multiple selections are possible
|
|
|
|
|
for (int i = 0; i != add_->bibLW->count(); ++i) {
|
|
|
|
|
QListWidgetItem * const item = add_->bibLW->item(i);
|
|
|
|
|
if (add_->bibLW->isItemSelected(item)) {
|
|
|
|
|
add_->bibLW->setItemSelected(item, false);
|
|
|
|
|
QList<QListWidgetItem *> matches =
|
|
|
|
|
databaseLW->findItems(item->text(), Qt::MatchExactly);
|
|
|
|
|
if (matches.empty())
|
|
|
|
|
databaseLW->addItem(item->text());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!file.empty()) {
|
|
|
|
|
add_->bibED->clear();
|
|
|
|
|
QString const f = toqstr(from_utf8(changeExtension(to_utf8(file), "")));
|
|
|
|
|
QList<QListWidgetItem *> matches =
|
|
|
|
|
databaseLW->findItems(f, Qt::MatchExactly);
|
|
|
|
|
if (matches.empty())
|
|
|
|
|
databaseLW->addItem(f);
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::deletePressed()
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
|
|
|
|
databaseLW->takeItem(databaseLW->currentRow());
|
2007-09-05 20:33:29 +00:00
|
|
|
|
changed();
|
2007-04-25 08:42:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::databaseChanged()
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
2007-10-06 09:55:21 +00:00
|
|
|
|
deletePB->setEnabled(!isBufferReadonly() && databaseLW->currentRow() != -1);
|
2007-04-25 08:42:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::availableChanged()
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
2007-09-03 05:59:32 +00:00
|
|
|
|
add_bc_.setValid(true);
|
2007-04-25 08:42:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::closeEvent(QCloseEvent *e)
|
2007-04-25 08:42:22 +00:00
|
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
|
slotClose();
|
2007-04-25 08:42:22 +00:00
|
|
|
|
e->accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-10-06 09:55:21 +00:00
|
|
|
|
bool bibtopic = usingBibtopic();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
databaseLW->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-10-07 18:40:01 +00:00
|
|
|
|
docstring bibs = params_["bibfiles"];
|
2006-10-20 13:53:43 +00:00
|
|
|
|
docstring bib;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
while (!bibs.empty()) {
|
|
|
|
|
bibs = split(bibs, bib, ',');
|
|
|
|
|
bib = trim(bib);
|
|
|
|
|
if (!bib.empty())
|
2007-09-05 20:33:29 +00:00
|
|
|
|
databaseLW->addItem(toqstr(bib));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
add_->bibLW->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
vector<string> bib_str;
|
2007-10-06 09:55:21 +00:00
|
|
|
|
getBibFiles(bib_str);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
for (vector<string>::const_iterator it = bib_str.begin();
|
|
|
|
|
it != bib_str.end(); ++it) {
|
2006-04-09 08:42:58 +00:00
|
|
|
|
string bibItem(changeExtension(*it, ""));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
add_->bibLW->addItem(toqstr(bibItem));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
string bibstyle = getStylefile();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
bibtocCB->setChecked(bibtotoc() && !bibtopic);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
bibtocCB->setEnabled(!bibtopic);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-10-07 18:40:01 +00:00
|
|
|
|
docstring btprint = params_["btprint"];
|
2006-03-05 17:24:44 +00:00
|
|
|
|
int btp = 0;
|
|
|
|
|
if (btprint == "btPrintNotCited")
|
|
|
|
|
btp = 1;
|
|
|
|
|
else if (btprint == "btPrintAll")
|
|
|
|
|
btp = 2;
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
btPrintCO->setCurrentIndex(btp);
|
|
|
|
|
btPrintCO->setEnabled(bibtopic);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
styleCB->clear();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
int item_nr(-1);
|
|
|
|
|
|
|
|
|
|
vector<string> str;
|
2007-10-06 09:55:21 +00:00
|
|
|
|
getBibStyles(str);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
for (vector<string>::const_iterator it = str.begin();
|
|
|
|
|
it != str.end(); ++it) {
|
2006-04-09 08:42:58 +00:00
|
|
|
|
string item(changeExtension(*it, ""));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
if (item == bibstyle)
|
|
|
|
|
item_nr = int(it - str.begin());
|
2007-09-05 20:33:29 +00:00
|
|
|
|
styleCB->addItem(toqstr(item));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item_nr == -1 && !bibstyle.empty()) {
|
2007-09-05 20:33:29 +00:00
|
|
|
|
styleCB->addItem(toqstr(bibstyle));
|
|
|
|
|
item_nr = styleCB->count() - 1;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item_nr != -1)
|
2007-09-05 20:33:29 +00:00
|
|
|
|
styleCB->setCurrentIndex(item_nr);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
else
|
2007-09-05 20:33:29 +00:00
|
|
|
|
styleCB->clearEditText();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
void GuiBibtex::applyView()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
|
docstring dbs = qstring_to_ucs4(databaseLW->item(0)->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
unsigned int maxCount = databaseLW->count();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
for (unsigned int i = 1; i < maxCount; i++) {
|
|
|
|
|
dbs += ',';
|
2007-09-05 20:33:29 +00:00
|
|
|
|
dbs += qstring_to_ucs4(databaseLW->item(i)->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-10-07 18:40:01 +00:00
|
|
|
|
params_["bibfiles"] = dbs;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-10-07 18:40:01 +00:00
|
|
|
|
docstring const bibstyle = qstring_to_ucs4(styleCB->currentText());
|
|
|
|
|
bool const bibtotoc = bibtocCB->isChecked();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
if (bibtotoc && (!bibstyle.empty())) {
|
|
|
|
|
// both bibtotoc and style
|
2007-10-07 18:40:01 +00:00
|
|
|
|
params_["options"] = "bibtotoc," + bibstyle;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
} else if (bibtotoc) {
|
|
|
|
|
// bibtotoc and no style
|
2007-10-07 18:40:01 +00:00
|
|
|
|
params_["options"] = from_ascii("bibtotoc");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
} else {
|
|
|
|
|
// only style. An empty one is valid, because some
|
|
|
|
|
// documentclasses have an own \bibliographystyle{}
|
|
|
|
|
// command!
|
2007-10-07 18:40:01 +00:00
|
|
|
|
params_["options"] = bibstyle;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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
|
2007-09-05 20:33:29 +00:00
|
|
|
|
int btp = btPrintCO->currentIndex();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
switch (btp) {
|
|
|
|
|
case 0:
|
2007-10-07 18:40:01 +00:00
|
|
|
|
params_["btprint"] = from_ascii("btPrintCited");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2007-10-07 18:40:01 +00:00
|
|
|
|
params_["btprint"] = from_ascii("btPrintNotCited");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2007-10-07 18:40:01 +00:00
|
|
|
|
params_["btprint"] = from_ascii("btPrintAll");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
if (!usingBibtopic())
|
2007-10-07 18:40:01 +00:00
|
|
|
|
params_["btprint"] = docstring();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
bool GuiBibtex::isValid()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
|
return databaseLW->count() != 0;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-10-06 09:55:21 +00:00
|
|
|
|
|
|
|
|
|
docstring const GuiBibtex::browseBib(docstring const & in_name) const
|
|
|
|
|
{
|
|
|
|
|
// FIXME UNICODE
|
2007-10-28 16:32:20 +00:00
|
|
|
|
docstring const label1 = _("Documents|#o#O");
|
|
|
|
|
docstring const dir1 = from_utf8(lyxrc.document_path);
|
2007-10-06 09:55:21 +00:00
|
|
|
|
FileFilterList const filter(_("BibTeX Databases (*.bib)"));
|
|
|
|
|
return browseRelFile(in_name, from_utf8(bufferFilepath()),
|
2007-10-28 16:32:20 +00:00
|
|
|
|
_("Select a BibTeX database to add"), filter, false, label1, dir1);
|
2007-10-06 09:55:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docstring const GuiBibtex::browseBst(docstring const & in_name) const
|
|
|
|
|
{
|
|
|
|
|
// FIXME UNICODE
|
2007-10-28 16:32:20 +00:00
|
|
|
|
docstring const label1 = _("Documents|#o#O");
|
|
|
|
|
docstring const dir1 = from_utf8(lyxrc.document_path);
|
2007-10-06 09:55:21 +00:00
|
|
|
|
FileFilterList const filter(_("BibTeX Styles (*.bst)"));
|
|
|
|
|
return browseRelFile(in_name, from_utf8(bufferFilepath()),
|
2007-10-28 16:32:20 +00:00
|
|
|
|
_("Select a BibTeX style"), filter, false, label1, dir1);
|
2007-10-06 09:55:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GuiBibtex::getBibStyles(vector<string> & data) const
|
|
|
|
|
{
|
|
|
|
|
data.clear();
|
|
|
|
|
|
|
|
|
|
getTexFileList("bstFiles.lst", data);
|
|
|
|
|
// test, if we have a valid list, otherwise run rescan
|
|
|
|
|
if (data.empty()) {
|
|
|
|
|
rescanBibStyles();
|
|
|
|
|
getTexFileList("bstFiles.lst", data);
|
|
|
|
|
}
|
|
|
|
|
vector<string>::iterator it = data.begin();
|
|
|
|
|
vector<string>::iterator end = data.end();
|
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
|
*it = onlyFilename(*it);
|
|
|
|
|
}
|
|
|
|
|
// sort on filename only (no path)
|
|
|
|
|
std::sort(data.begin(), data.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GuiBibtex::getBibFiles(vector<string> & data) const
|
|
|
|
|
{
|
|
|
|
|
data.clear();
|
|
|
|
|
|
|
|
|
|
getTexFileList("bibFiles.lst", data);
|
|
|
|
|
// test, if we have a valid list, otherwise run rescan
|
|
|
|
|
if (data.empty()) {
|
|
|
|
|
rescanBibStyles();
|
|
|
|
|
getTexFileList("bibFiles.lst", data);
|
|
|
|
|
}
|
|
|
|
|
vector<string>::iterator it = data.begin();
|
|
|
|
|
vector<string>::iterator end = data.end();
|
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
|
*it = onlyFilename(*it);
|
|
|
|
|
}
|
|
|
|
|
// sort on filename only (no path)
|
|
|
|
|
std::sort(data.begin(), data.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GuiBibtex::rescanBibStyles() const
|
|
|
|
|
{
|
|
|
|
|
rescanTexStyles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool GuiBibtex::usingBibtopic() const
|
|
|
|
|
{
|
|
|
|
|
return buffer().params().use_bibtopic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool GuiBibtex::bibtotoc() const
|
|
|
|
|
{
|
2007-10-07 18:40:01 +00:00
|
|
|
|
return prefixIs(to_utf8(params_["options"]), "bibtotoc");
|
2007-10-06 09:55:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string const GuiBibtex::getStylefile() const
|
|
|
|
|
{
|
|
|
|
|
// the different bibtex packages have (and need) their
|
|
|
|
|
// own "plain" stylefiles
|
|
|
|
|
biblio::CiteEngine const engine = buffer().params().getEngine();
|
|
|
|
|
docstring defaultstyle;
|
|
|
|
|
switch (engine) {
|
|
|
|
|
case biblio::ENGINE_BASIC:
|
|
|
|
|
defaultstyle = from_ascii("plain");
|
|
|
|
|
break;
|
|
|
|
|
case biblio::ENGINE_NATBIB_AUTHORYEAR:
|
|
|
|
|
defaultstyle = from_ascii("plainnat");
|
|
|
|
|
break;
|
|
|
|
|
case biblio::ENGINE_NATBIB_NUMERICAL:
|
|
|
|
|
defaultstyle = from_ascii("plainnat");
|
|
|
|
|
break;
|
|
|
|
|
case biblio::ENGINE_JURABIB:
|
|
|
|
|
defaultstyle = from_ascii("jurabib");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-07 18:40:01 +00:00
|
|
|
|
docstring bst = params_["options"];
|
2007-10-06 09:55:21 +00:00
|
|
|
|
if (bibtotoc()){
|
|
|
|
|
// bibstyle exists?
|
|
|
|
|
if (contains(bst, ',')) {
|
|
|
|
|
docstring bibtotoc = from_ascii("bibtotoc");
|
|
|
|
|
bst = split(bst, bibtotoc, ',');
|
|
|
|
|
} else
|
|
|
|
|
bst.erase();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// propose default style file for new insets
|
|
|
|
|
// existing insets might have (legally) no bst files
|
|
|
|
|
// (if the class already provides a style)
|
2007-10-07 18:40:01 +00:00
|
|
|
|
if (bst.empty() && params_["bibfiles"].empty())
|
2007-10-06 09:55:21 +00:00
|
|
|
|
bst = defaultstyle;
|
|
|
|
|
|
|
|
|
|
// FIXME UNICODE
|
|
|
|
|
return to_utf8(bst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
|
Dialog * createGuiBibtex(GuiView & lv) { return new GuiBibtex(lv); }
|
2007-10-06 09:55:21 +00:00
|
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|
2007-04-25 08:42:22 +00:00
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
|
#include "GuiBibtex_moc.cpp"
|