2001-08-26 03:20:52 +00:00
|
|
|
/**
|
|
|
|
* \file QBibtexDialog.C
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
*/
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
#include <config.h>
|
2002-07-22 14:04:38 +00:00
|
|
|
#include <vector.h>
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "ControlBibtex.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#include "support/filetools.h"
|
2002-07-22 14:04:38 +00:00
|
|
|
#include "support/lyxalgo.h" // eliminate_duplicates
|
2002-06-19 03:38:44 +00:00
|
|
|
|
2001-08-26 03:20:52 +00:00
|
|
|
#include <qwidget.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qcombobox.h>
|
|
|
|
#include <qlistbox.h>
|
2001-12-01 02:24:28 +00:00
|
|
|
#include <qlineedit.h>
|
2001-08-26 03:20:52 +00:00
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qfiledialog.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 03:20:52 +00:00
|
|
|
#include "QBibtexDialog.h"
|
|
|
|
#include "QBibtex.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
|
2001-08-26 03:20:52 +00:00
|
|
|
QBibtexDialog::QBibtexDialog(QBibtex * form)
|
|
|
|
: QBibtexDialogBase(0, 0, false, 0),
|
|
|
|
form_(form)
|
|
|
|
{
|
|
|
|
connect(okPB, SIGNAL(clicked()),
|
|
|
|
form, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()),
|
|
|
|
form, SLOT(slotClose()));
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 03:20:52 +00:00
|
|
|
void QBibtexDialog::change_adaptor()
|
|
|
|
{
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QBibtexDialog::browsePressed()
|
|
|
|
{
|
2002-03-21 21:21:28 +00:00
|
|
|
QString file = QFileDialog::getOpenFileName(QString::null,
|
2001-08-27 01:19:32 +00:00
|
|
|
_("BibTeX style files (*.bst)"), this, 0, _("Select a BibTeX style"));
|
|
|
|
if (!file.isNull()) {
|
|
|
|
styleED->setText(ChangeExtension(OnlyFilename(file.latin1()), "").c_str());
|
2001-08-26 03:20:52 +00:00
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QBibtexDialog::addPressed()
|
|
|
|
{
|
2002-03-21 21:21:28 +00:00
|
|
|
QString file = QFileDialog::getOpenFileName(QString::null,
|
|
|
|
_("BibTeX database files (*.bib)"), this, 0, _("Select a BibTeX database to add"));
|
2001-08-27 20:41:45 +00:00
|
|
|
if (!file.isNull()) {
|
2002-07-22 14:04:38 +00:00
|
|
|
string const f = ChangeExtension(file.latin1(), "");
|
|
|
|
bool present = false;
|
|
|
|
for(unsigned int i = 0; i!=databaseLB->count(); i++) {
|
|
|
|
if (databaseLB->text(i).latin1()==f)
|
|
|
|
present = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!present) {
|
|
|
|
databaseLB->insertItem(f.c_str());
|
|
|
|
form_->changed();
|
|
|
|
}
|
2001-08-26 03:20:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 20:41:45 +00:00
|
|
|
void QBibtexDialog::deletePressed()
|
|
|
|
{
|
|
|
|
databaseLB->removeItem(databaseLB->currentItem());
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 03:20:52 +00:00
|
|
|
void QBibtexDialog::styleChanged(const QString & sel)
|
|
|
|
{
|
2002-07-22 14:04:38 +00:00
|
|
|
styleED->setText(sel);
|
2001-08-26 03:20:52 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-27 20:41:45 +00:00
|
|
|
void QBibtexDialog::databaseChanged()
|
|
|
|
{
|
|
|
|
deletePB->setEnabled(!form_->readOnly() && databaseLB->currentItem() != -1);
|
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-26 03:20:52 +00:00
|
|
|
void QBibtexDialog::closeEvent(QCloseEvent *e)
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|