From ce044d86c4e9363d6c20f98327ce13a90b13d7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Mon, 21 Jul 2003 09:08:14 +0000 Subject: [PATCH] QBibtex/QCitation ui fixes (bug 1146) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7327 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 8 +++++ src/frontends/qt2/QBibtexDialog.C | 30 ++++++++++++------- src/frontends/qt2/QCitationDialog.C | 14 +++++++-- src/frontends/qt2/ui/QBibtexAddDialogBase.ui | 6 +++- .../qt2/ui/QCitationFindDialogBase.ui | 6 +++- 5 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index fa09a720d2..7179fb2571 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,11 @@ +2003-07-21 Juergen Spitzmueller + + * QBibTeXDialog.C: + * QCitationDialog.C: + * ui/QBibTeXAddDialogBase.ui: + * ui/QCitationFindDialogBase.ui: + Allow multiple selections, forbid duplicates (bug 1146) + 2003-07-19 John Levon * ui/QTabularCreateDialogBase.ui: set a max size (bug 1152) diff --git a/src/frontends/qt2/QBibtexDialog.C b/src/frontends/qt2/QBibtexDialog.C index 326ee65d79..e4505fe4f5 100644 --- a/src/frontends/qt2/QBibtexDialog.C +++ b/src/frontends/qt2/QBibtexDialog.C @@ -119,21 +119,29 @@ void QBibtexDialog::addPressed() void QBibtexDialog::addDatabase() { + int const sel = add_->bibLB->currentItem(); QString const file = add_->bibED->text(); - 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) - present = true; + if (sel < 0 && file.isNull()) + return; - } - if (!present) { - databaseLB->insertItem(f.c_str()); - form_->changed(); + // Add the selected browser_bib keys to browser_database + // multiple selections are possible + for (unsigned int i = 0; i != add_->bibLB->count(); i++) { + if (add_->bibLB->isSelected(i)) { + // do not allow duplicates + if ((databaseLB->findItem(add_->bibLB->text(i))) == 0) + databaseLB->insertItem(add_->bibLB->text(i)); } } + + if (!file.isEmpty()) { + QString const f = toqstr(ChangeExtension(fromqstr(file), "")); + if ((databaseLB->findItem(f)) == 0) + databaseLB->insertItem(f); + } + + form_->changed(); } @@ -152,7 +160,7 @@ void QBibtexDialog::databaseChanged() void QBibtexDialog::availableChanged() { - add_->bibED->setText(add_->bibLB->currentText()); + form_->changed(); } diff --git a/src/frontends/qt2/QCitationDialog.C b/src/frontends/qt2/QCitationDialog.C index 960363b5af..4a188b647c 100644 --- a/src/frontends/qt2/QCitationDialog.C +++ b/src/frontends/qt2/QCitationDialog.C @@ -132,9 +132,17 @@ void QCitationDialog::addCitation() if (sel < 0) return; - // Add the selected browser_bib key to browser_cite - selectedLB->insertItem(toqstr(form_->bibkeys[sel])); - form_->citekeys.push_back(form_->bibkeys[sel]); + // Add the selected browser_bib keys to browser_cite + // multiple selections are possible + for (unsigned int i = 0; i != add_->availableLB->count(); i++) { + if (add_->availableLB->isSelected(i)) { + // do not allow duplicates + if ((selectedLB->findItem(add_->availableLB->text(i))) == 0) { + selectedLB->insertItem(toqstr(form_->bibkeys[i])); + form_->citekeys.push_back(form_->bibkeys[i]); + } + } + } int const n = int(form_->citekeys.size()); selectedLB->setSelected(n - 1, true); diff --git a/src/frontends/qt2/ui/QBibtexAddDialogBase.ui b/src/frontends/qt2/ui/QBibtexAddDialogBase.ui index e134de27eb..9aed5a6b05 100644 --- a/src/frontends/qt2/ui/QBibtexAddDialogBase.ui +++ b/src/frontends/qt2/ui/QBibtexAddDialogBase.ui @@ -13,7 +13,7 @@ 0 0 - 225 + 221 321 @@ -98,6 +98,10 @@ hScrollBarMode AlwaysOff + + selectionMode + Extended + toolTip Available citation keys diff --git a/src/frontends/qt2/ui/QCitationFindDialogBase.ui b/src/frontends/qt2/ui/QCitationFindDialogBase.ui index b4dc96e296..07df2948e3 100644 --- a/src/frontends/qt2/ui/QCitationFindDialogBase.ui +++ b/src/frontends/qt2/ui/QCitationFindDialogBase.ui @@ -13,7 +13,7 @@ 0 0 - 379 + 375 257 @@ -76,6 +76,10 @@ hScrollBarMode AlwaysOff + + selectionMode + Extended + toolTip Available citation keys