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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <qwidget.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qcombobox.h>
|
|
|
|
#include <qlistbox.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qfiledialog.h>
|
|
|
|
|
|
|
|
#include "QBibtexDialog.h"
|
|
|
|
#include "QBibtex.h"
|
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "ControlBibtex.h"
|
|
|
|
#include "gettext.h"
|
2001-08-27 01:19:32 +00:00
|
|
|
#include "debug.h"
|
2001-08-26 03:20:52 +00:00
|
|
|
|
|
|
|
#include "support/filetools.h"
|
|
|
|
|
|
|
|
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()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QBibtexDialog::change_adaptor()
|
|
|
|
{
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QBibtexDialog::browsePressed()
|
|
|
|
{
|
2001-08-27 01:19:32 +00:00
|
|
|
QString file = QFileDialog::getOpenFileName(QString::null,
|
|
|
|
_("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()
|
|
|
|
{
|
2001-08-27 20:41:45 +00:00
|
|
|
QString file = QFileDialog::getOpenFileName(QString::null,
|
|
|
|
_("BibTeX database files (*.bib)"), this, 0, _("Select a BibTeX database to add"));
|
|
|
|
if (!file.isNull()) {
|
2001-08-26 03:20:52 +00:00
|
|
|
// FIXME: check duplicates
|
2001-08-27 20:41:45 +00:00
|
|
|
databaseLB->insertItem(ChangeExtension(file.latin1(), "").c_str());
|
2001-08-26 03:20:52 +00:00
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-27 20:41:45 +00:00
|
|
|
void QBibtexDialog::deletePressed()
|
|
|
|
{
|
|
|
|
databaseLB->removeItem(databaseLB->currentItem());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-26 03:20:52 +00:00
|
|
|
void QBibtexDialog::styleChanged(const QString & sel)
|
|
|
|
{
|
2001-08-27 20:41:45 +00:00
|
|
|
if (form_->readOnly())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (string(_("Other ...")) == sel.latin1()) {
|
2001-08-26 03:20:52 +00:00
|
|
|
styleED->setEnabled(true);
|
|
|
|
stylePB->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
styleED->setEnabled(false);
|
|
|
|
stylePB->setEnabled(false);
|
|
|
|
styleED->setText("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-27 20:41:45 +00:00
|
|
|
void QBibtexDialog::databaseChanged()
|
|
|
|
{
|
|
|
|
deletePB->setEnabled(!form_->readOnly() && databaseLB->currentItem() != -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-26 03:20:52 +00:00
|
|
|
void QBibtexDialog::closeEvent(QCloseEvent *e)
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|