diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 960fd30899..745ce73f6c 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,12 @@ +2003-04-12 John Levon + + * ui/QBibtexDialogBase.ui: + * ui/QBibtexAddDialogBase.ui: + * Makefile.dialogs: + * QBibtex.C: + * QBibtexDialog.h: + * QBibtexDialog.C: do the same thing with bibtex + 2003-04-12 John Levon * Makefile.dialogs: diff --git a/src/frontends/qt2/QBibtex.C b/src/frontends/qt2/QBibtex.C index ba737b88d7..185eb4aeeb 100644 --- a/src/frontends/qt2/QBibtex.C +++ b/src/frontends/qt2/QBibtex.C @@ -27,6 +27,7 @@ #include #include +#include "ui/QBibtexAddDialogBase.h" #include "QBibtexDialog.h" #include "QBibtex.h" #include "Qt2BC.h" @@ -49,11 +50,10 @@ void QBibtex::build_dialog() bcview().setOK(dialog_->okPB); bcview().setCancel(dialog_->closePB); bcview().addReadOnly(dialog_->databaseLB); - bcview().addReadOnly(dialog_->databasePB); bcview().addReadOnly(dialog_->stylePB); bcview().addReadOnly(dialog_->styleCB); bcview().addReadOnly(dialog_->bibtocCB); - bcview().addReadOnly(dialog_->databasePB); + bcview().addReadOnly(dialog_->addBibPB); bcview().addReadOnly(dialog_->deletePB); } @@ -72,17 +72,15 @@ void QBibtex::update_contents() dialog_->databaseLB->insertItem(toqstr(bib)); } - dialog_->addBibCB->clear(); + dialog_->add_->bibLB->clear(); vector const bib_str = getVectorFromString( controller().getBibFiles(), "\n"); for (vector::const_iterator it = bib_str.begin(); it != bib_str.end(); ++it) { string bibItem(ChangeExtension(*it, "")); - dialog_->addBibCB->insertItem(toqstr(bibItem)); + dialog_->add_->bibLB->insertItem(toqstr(bibItem)); } - dialog_->addBibCB->clearEdit(); - string bibtotoc = "bibtotoc"; string bibstyle(controller().params().getOptions()); diff --git a/src/frontends/qt2/QBibtexDialog.C b/src/frontends/qt2/QBibtexDialog.C index 7357ef5fc6..e6eec45592 100644 --- a/src/frontends/qt2/QBibtexDialog.C +++ b/src/frontends/qt2/QBibtexDialog.C @@ -26,6 +26,7 @@ #include #include +#include "ui/QBibtexAddDialogBase.h" #include "QBibtexDialog.h" #include "QBibtex.h" @@ -40,6 +41,14 @@ QBibtexDialog::QBibtexDialog(QBibtex * form) form, SLOT(slotOK())); connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose())); + + add_ = new QBibtexAddDialogBase(this, "", true); + connect(add_->addPB, SIGNAL(clicked()), this, SLOT(addDatabase())); + connect(add_->addPB, SIGNAL(clicked()), this, SLOT(addDatabase())); + connect(add_->bibLB, SIGNAL(selected(QListBoxItem *)), this, SLOT(addDatabase())); + connect(add_->bibLB, SIGNAL(selected(QListBoxItem *)), add_, SLOT(accept())); + connect(add_->bibLB, SIGNAL(currentChanged(QListBoxItem *)), this, SLOT(availableChanged())); + connect(add_->browsePB, SIGNAL(clicked()), this, SLOT(browseBibPressed())); } @@ -77,35 +86,45 @@ void QBibtexDialog::browsePressed() } } + void QBibtexDialog::browseBibPressed() { QString const file = QFileDialog::getOpenFileName(QString::null, - qt_("BibTeX database files (*.bib)"), this, 0, qt_("Select a BibTeX database to add")); + qt_("BibTeX database files (*.bib)"), add_, 0, qt_("Select a BibTeX database to add")); if (!file.isNull()) { string const f = ChangeExtension(fromqstr(file), ""); bool present = false; - for (unsigned int i = 0; i != databaseLB->count(); i++) { - if (fromqstr(databaseLB->text(i)) == f) + for (unsigned int i = 0; i != add_->bibLB->count(); i++) { + if (fromqstr(add_->bibLB->text(i)) == f) present = true; } if (!present) { - databaseLB->insertItem(toqstr(f)); + add_->bibLB->insertItem(toqstr(f)); form_->changed(); } + + add_->bibED->setText(toqstr(f)); } } void QBibtexDialog::addPressed() { - QString const file = addBibCB->currentText(); + add_->exec(); +} + + +void QBibtexDialog::addDatabase() +{ + QString const file = add_->bibED->text(); + if (!file.isNull()) { - string const f = ChangeExtension(file.latin1(), ""); + string const f = ChangeExtension(fromqstr(file), ""); bool present = false; - for(unsigned int i = 0; i != databaseLB->count(); ++i) { - if (databaseLB->text(i).latin1() == f) + for (unsigned int i = 0; i != databaseLB->count(); ++i) { + if (fromqstr(databaseLB->text(i)) == f) present = true; } @@ -116,17 +135,13 @@ void QBibtexDialog::addPressed() } } + void QBibtexDialog::deletePressed() { databaseLB->removeItem(databaseLB->currentItem()); } -void QBibtexDialog::styleChanged(QString const & sel) -{ - styleCB->insertItem(sel,0); -} - void QBibtexDialog::databaseChanged() { @@ -134,6 +149,12 @@ void QBibtexDialog::databaseChanged() } +void QBibtexDialog::availableChanged() +{ + add_->bibED->setText(add_->bibLB->currentText()); +} + + void QBibtexDialog::closeEvent(QCloseEvent *e) { form_->slotWMHide(); diff --git a/src/frontends/qt2/QBibtexDialog.h b/src/frontends/qt2/QBibtexDialog.h index 721e1c8513..4ca83c211b 100644 --- a/src/frontends/qt2/QBibtexDialog.h +++ b/src/frontends/qt2/QBibtexDialog.h @@ -16,21 +16,29 @@ #include "ui/QBibtexDialogBase.h" class QBibtex; +class QBibtexAddDialogBase; class QBibtexDialog : public QBibtexDialogBase { Q_OBJECT + public: QBibtexDialog(QBibtex * form); + + QBibtexAddDialogBase * add_; + protected slots: virtual void change_adaptor(); virtual void browsePressed(); virtual void browseBibPressed(); virtual void addPressed(); + virtual void addDatabase(); virtual void deletePressed(); - virtual void styleChanged(const QString &); virtual void databaseChanged(); + virtual void availableChanged(); + protected: virtual void closeEvent(QCloseEvent * e); + private: QBibtex * form_; }; diff --git a/src/frontends/qt2/ui/QBibtexAddDialogBase.ui b/src/frontends/qt2/ui/QBibtexAddDialogBase.ui new file mode 100644 index 0000000000..e134de27eb --- /dev/null +++ b/src/frontends/qt2/ui/QBibtexAddDialogBase.ui @@ -0,0 +1,221 @@ + +QBibtexAddDialogBase +config.h +qt_helpers.h + + QDialog + + name + QBibtexAddDialogBase + + + geometry + + 0 + 0 + 225 + 321 + + + + sizePolicy + + 1 + 1 + + + + caption + LyX: Add BibTeX Database + + + sizeGripEnabled + true + + + + margin + 11 + + + spacing + 6 + + + QPushButton + + name + browsePB + + + text + &Browse... + + + autoDefault + false + + + default + true + + + + QLineEdit + + name + bibED + + + sizePolicy + + 7 + 0 + + + + toolTip + Search the available citations + + + + QListBox + + + text + New Item + + + + name + bibLB + + + vScrollBarMode + AlwaysOn + + + hScrollBarMode + AlwaysOff + + + toolTip + Available citation keys + + + + + name + Spacer3 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout4 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer4 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + addPB + + + text + &Add + + + autoDefault + false + + + default + true + + + + QPushButton + + name + closePB + + + text + Cancel + + + autoDefault + false + + + + + + + + + addPB + clicked() + QBibtexAddDialogBase + accept() + + + closePB + clicked() + QBibtexAddDialogBase + reject() + + + + bibLB + bibED + addPB + closePB + + diff --git a/src/frontends/qt2/ui/QBibtexDialogBase.ui b/src/frontends/qt2/ui/QBibtexDialogBase.ui index 3a6ceafe65..06305e6005 100644 --- a/src/frontends/qt2/ui/QBibtexDialogBase.ui +++ b/src/frontends/qt2/ui/QBibtexDialogBase.ui @@ -13,8 +13,8 @@ 0 0 - 322 - 338 + 306 + 279 @@ -34,123 +34,19 @@ spacing 6 - - QLabel - - name - databaseLA - - - text - Databa&ses - - - alignment - AlignTop|AlignLeft - - - buddy - addBibCB - - - toolTip - BibTeX database to use - - - vAlign - - - - QListBox - - name - databaseLB - - - enabled - true - - - toolTip - Selected BibTeX databases - - - - QPushButton - - name - addBibPB - - - text - &Add - - - toolTip - Add a BibTeX database file - - - - QPushButton - - name - databasePB - - - text - Bro&wse... - - - autoDefault - false - - - toolTip - Browse for a BibTeX database file - - - - QPushButton - - name - deletePB - - - text - &Delete - - - toolTip - Remove the selected database - - - - - name - Spacer4 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - + QLabel name styleLA + + sizePolicy + + 1 + 0 + + text St&yle @@ -164,26 +60,7 @@ The BibTeX style - - QPushButton - - name - stylePB - - - text - &Browse... - - - autoDefault - false - - - toolTip - Choose a style file - - - + QLayoutWidget name @@ -255,22 +132,106 @@ - - QCheckBox + + QLabel name - bibtocCB + databaseLA + + + sizePolicy + + 1 + 0 + text - Add bibliography to &TOC + Databa&ses + + + alignment + AlignTop|AlignLeft + + + buddy + databaseLB toolTip - Add bibliography to the table of contents + BibTeX database to use + + + vAlign - + + QListBox + + name + databaseLB + + + enabled + true + + + toolTip + Selected BibTeX databases + + + + QPushButton + + name + addBibPB + + + text + &Add... + + + toolTip + Add a BibTeX database file + + + + QPushButton + + name + deletePB + + + text + &Delete + + + toolTip + Remove the selected database + + + + + name + Spacer5 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + QComboBox name @@ -293,29 +254,61 @@ Chose a style file - - QComboBox + + QPushButton name - addBibCB + stylePB - editable - true + text + &Browse... - autoCompletion - true - - - duplicatesEnabled + autoDefault false toolTip - Select a database + Choose a style file + + QCheckBox + + name + bibtocCB + + + text + Add bibliography to &TOC + + + toolTip + Add bibliography to the table of contents + + + + + name + Spacer6 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + @@ -343,24 +336,12 @@ QBibtexDialogBase databaseChanged() - - databaseLB - selectionChanged() - QBibtexDialogBase - change_adaptor() - bibtocCB toggled(bool) QBibtexDialogBase change_adaptor() - - databasePB - clicked() - QBibtexDialogBase - browseBibPressed() - addBibPB clicked() @@ -372,14 +353,10 @@ change_adaptor() databaseChanged() deletePressed() - browseBibPressed() - styleChanged(const QString &) - addBibCB - addBibPB databaseLB - databasePB + addBibPB deletePB styleCB stylePB