From: Edwin Leuven Date: Tue, 2 May 2006 19:17:59 +0000 (+0000) Subject: Replace Q3ListBox with QListWidget: X-Git-Tag: 1.6.10~13266 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ee3e1bbba77e3ceb11832948ac859d5a5cc96185;p=features.git Replace Q3ListBox with QListWidget: * QBibtexDialog.C * QBibtex.C * QBibtexUi.ui * QBibtexAddUi.ui git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13791 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/QBibtex.C b/src/frontends/qt4/QBibtex.C index e18b6f2520..fe94be93a7 100644 --- a/src/frontends/qt4/QBibtex.C +++ b/src/frontends/qt4/QBibtex.C @@ -26,9 +26,9 @@ #include "support/filetools.h" // changeExtension #include "support/lstrings.h" -#include -#include -#include +#include +#include +#include using lyx::support::changeExtension; @@ -55,7 +55,7 @@ void QBibtex::build_dialog() bcview().setOK(dialog_->okPB); bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->databaseLB); + bcview().addReadOnly(dialog_->databaseLW); bcview().addReadOnly(dialog_->stylePB); bcview().addReadOnly(dialog_->styleCB); bcview().addReadOnly(dialog_->bibtocCB); @@ -73,7 +73,7 @@ void QBibtex::update_contents() bool bibtopic = controller().usingBibtopic(); - dialog_->databaseLB->clear(); + dialog_->databaseLW->clear(); string bibs(controller().params().getContents()); string bib; @@ -82,17 +82,17 @@ void QBibtex::update_contents() bibs = split(bibs, bib, ','); bib = trim(bib); if (!bib.empty()) - dialog_->databaseLB->insertItem(toqstr(bib)); + dialog_->databaseLW->addItem(toqstr(bib)); } - dialog_->add_->bibLB->clear(); + dialog_->add_->bibLW->clear(); vector bib_str; controller().getBibFiles(bib_str); for (vector::const_iterator it = bib_str.begin(); it != bib_str.end(); ++it) { string bibItem(changeExtension(*it, "")); - dialog_->add_->bibLB->insertItem(toqstr(bibItem)); + dialog_->add_->bibLW->addItem(toqstr(bibItem)); } string bibstyle(controller().getStylefile()); @@ -138,12 +138,12 @@ void QBibtex::update_contents() void QBibtex::apply() { - string dbs(fromqstr(dialog_->databaseLB->text(0))); + string dbs(fromqstr(dialog_->databaseLW->item(0)->text())); - unsigned int maxCount = dialog_->databaseLB->count(); + unsigned int maxCount = dialog_->databaseLW->count(); for (unsigned int i = 1; i < maxCount; i++) { dbs += ','; - dbs += fromqstr(dialog_->databaseLB->text(i)); + dbs += fromqstr(dialog_->databaseLW->item(i)->text()); } controller().params().setContents(dbs); @@ -189,7 +189,7 @@ void QBibtex::apply() bool QBibtex::isValid() { - return dialog_->databaseLB->count() != 0; + return dialog_->databaseLW->count() != 0; } } // namespace frontend diff --git a/src/frontends/qt4/QBibtexDialog.C b/src/frontends/qt4/QBibtexDialog.C index a682a65fd3..b819e6a37f 100644 --- a/src/frontends/qt4/QBibtexDialog.C +++ b/src/frontends/qt4/QBibtexDialog.C @@ -22,12 +22,13 @@ #include "controllers/ControlBibtex.h" #include "controllers/ButtonPolicies.h" +#include "debug.h" #include "support/filetools.h" #include "support/lstrings.h" -#include -#include -#include +#include +#include +#include using lyx::support::changeExtension; using lyx::support::trim; @@ -42,19 +43,26 @@ QBibtexDialog::QBibtexDialog(QBibtex * form) : form_(form) { setupUi(this); + QDialog::setModal(true); - connect(okPB, SIGNAL(clicked()), + connect( okPB, SIGNAL(clicked()), form, SLOT(slotOK())); - connect(closePB, SIGNAL(clicked()), + connect( closePB, SIGNAL(clicked()), form, SLOT(slotClose())); - - connect( stylePB, SIGNAL( clicked() ), this, SLOT( browsePressed() ) ); - connect( deletePB, SIGNAL( clicked() ), this, SLOT( deletePressed() ) ); - connect( styleCB, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); - connect( databaseLB, SIGNAL( selectionChanged() ), this, SLOT( databaseChanged() ) ); - connect( bibtocCB, SIGNAL( toggled(bool) ), this, SLOT( change_adaptor() ) ); - connect( btPrintCO, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) ); - connect( addBibPB, SIGNAL( clicked() ), this, SLOT( addPressed() ) ); + connect( stylePB, SIGNAL( clicked() ), + this, SLOT( browsePressed() ) ); + connect( deletePB, SIGNAL( clicked() ), + this, SLOT( deletePressed() ) ); + connect( styleCB, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_adaptor() ) ); + connect( databaseLW, SIGNAL( selectionChanged() ), + this, SLOT( databaseChanged() ) ); + connect( bibtocCB, SIGNAL( toggled(bool) ), + this, SLOT( change_adaptor() ) ); + connect( btPrintCO, SIGNAL( activated(int) ), + this, SLOT( change_adaptor() ) ); + connect( addBibPB, SIGNAL( clicked() ), + this, SLOT( addPressed() ) ); add_ = new UiDialog(this, true); @@ -68,21 +76,22 @@ QBibtexDialog::QBibtexDialog(QBibtex * form) add_->bibED->setValidator(new PathValidator(false, add_->bibED)); addCheckedLineEdit(add_bc_.view(), add_->bibED, 0); - connect(add_->bibED, SIGNAL(textChanged(const QString&)), + connect( add_->bibED, SIGNAL(textChanged(const QString&)), this, SLOT(bibEDChanged())); - connect(add_->addPB, SIGNAL(clicked()), + connect( add_->addPB, SIGNAL(clicked()), this, SLOT(addDatabase())); - connect(add_->bibLB, SIGNAL(selected(Q3ListBoxItem *)), + connect( add_->addPB, SIGNAL(clicked()), + add_, SLOT(accept()) ); + connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(addDatabase())); - connect(add_->bibLB, SIGNAL(selected(Q3ListBoxItem *)), + connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)), add_, SLOT(accept())); - connect(add_->bibLB, SIGNAL(currentChanged(Q3ListBoxItem *)), + connect(add_->bibLW, SIGNAL(itemChanged(QListWidgetItem *)), this, SLOT(availableChanged())); - connect(add_->browsePB, SIGNAL(clicked()), + connect( add_->browsePB, SIGNAL(clicked()), this, SLOT(browseBibPressed())); - - connect( add_->addPB, SIGNAL( clicked() ), this, SLOT( accept() ) ); - connect( add_->closePB, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( add_->closePB, SIGNAL( clicked() ), + add_, SLOT( reject() ) ); } @@ -139,13 +148,13 @@ void QBibtexDialog::browseBibPressed() string const f = changeExtension(file, ""); bool present = false; - for (unsigned int i = 0; i != add_->bibLB->count(); i++) { - if (fromqstr(add_->bibLB->text(i)) == f) + for (unsigned int i = 0; i != add_->bibLW->count(); i++) { + if (fromqstr(add_->bibLW->item(i)->text()) == f) present = true; } if (!present) { - add_->bibLB->insertItem(toqstr(f)); + add_->bibLW->addItem(toqstr(f)); form_->changed(); } @@ -163,7 +172,7 @@ void QBibtexDialog::addPressed() void QBibtexDialog::addDatabase() { - int const sel = add_->bibLB->currentItem(); + int const sel = add_->bibLW->currentRow(); string const file = trim(fromqstr(add_->bibED->text())); if (sel < 0 && file.empty()) @@ -171,18 +180,24 @@ void QBibtexDialog::addDatabase() // 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)); + for (unsigned 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 matches = + databaseLW->findItems(item->text(), Qt::MatchExactly); + if (matches.empty()) + databaseLW->addItem(item->text()); } } if (!file.empty()) { + add_->bibED->clear(); QString const f = toqstr(changeExtension(file, "")); - if ((databaseLB->findItem(f)) == 0) - databaseLB->insertItem(f); + QList matches = + databaseLW->findItems(f, Qt::MatchExactly); + if (matches.empty()) + databaseLW->addItem(f); } form_->changed(); @@ -191,14 +206,14 @@ void QBibtexDialog::addDatabase() void QBibtexDialog::deletePressed() { - databaseLB->removeItem(databaseLB->currentItem()); + databaseLW->takeItem(databaseLW->currentRow()); } void QBibtexDialog::databaseChanged() { - deletePB->setEnabled(!form_->readOnly() && databaseLB->currentItem() != -1); + deletePB->setEnabled(!form_->readOnly() && databaseLW->currentRow() != -1); } @@ -214,5 +229,6 @@ void QBibtexDialog::closeEvent(QCloseEvent *e) e->accept(); } + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/ui/QBibtexAddUi.ui b/src/frontends/qt4/ui/QBibtexAddUi.ui index ba5f3dc07a..5c7df75b04 100644 --- a/src/frontends/qt4/ui/QBibtexAddUi.ui +++ b/src/frontends/qt4/ui/QBibtexAddUi.ui @@ -28,71 +28,18 @@ - 11 + 9 6 - - - - &Browse... - - - false - - - true - - - - - - - - 7 - 0 - 0 - 0 - - - - Enter BibTeX database name - - - - - - Available BibTeX databases - - - Q3ScrollView::AlwaysOn - - - Q3ScrollView::AlwaysOff - + - Q3ListBox::Extended + QAbstractItemView::ExtendedSelection - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - @@ -142,20 +89,54 @@ + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + + 7 + 0 + 0 + 0 + + + + Enter BibTeX database name + + + + + + + &Browse... + + + false + + + true + + + qPixmapFromMimeSource - - - Q3ListBox - -
q3listbox.h
- 0 - -
-
- bibLB bibED addPB closePB diff --git a/src/frontends/qt4/ui/QBibtexUi.ui b/src/frontends/qt4/ui/QBibtexUi.ui index a68615c157..4c6cfd3b50 100644 --- a/src/frontends/qt4/ui/QBibtexUi.ui +++ b/src/frontends/qt4/ui/QBibtexUi.ui @@ -20,83 +20,26 @@ - 11 + 9 6 - - - - - 1 - 0 - 0 - 0 - - + + + + + - The BibTeX style + Add bibliography to the table of contents - St&yle - - - styleCB + Add bibliography to &TOC - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - &OK - - - false - - - true - - - - - - - Cancel - - - false - - - - - - - + + 1 @@ -106,50 +49,39 @@ - BibTeX database to use + This bibliography section contains... - Databa&ses - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + &Content: - databaseLB - - - - - - - true - - - Selected BibTeX databases - - - - - - - Add a BibTeX database file - - - &Add... + styleCB - - + + - Remove the selected database - - - &Delete + This bibliography section contains... + + + all cited references + + + + + all uncited references + + + + + all references + + - + Qt::Vertical @@ -165,36 +97,36 @@ - - + + Choose a style file - - true - - - true + + &Browse... - + false - - + + Choose a style file - - &Browse... + + true - + + true + + false - + Qt::Vertical @@ -210,30 +142,28 @@ - - + + - This bibliography section contains... + Remove the selected database + + + &Delete - - - all cited references - - - - - all uncited references - - - - - all references - - - - + + + + Add a BibTeX database file + + + &Add... + + + + + 1 @@ -243,40 +173,93 @@ - This bibliography section contains... + BibTeX database to use - &Content: + Databa&ses + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - styleCB + databaseLW - - + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + &OK + + + false + + + true + + + + + + + Cancel + + + false + + + + + + + + + + 1 + 0 + 0 + 0 + + - Add bibliography to the table of contents + The BibTeX style - Add bibliography to &TOC + St&yle + + + styleCB qPixmapFromMimeSource - - - Q3ListBox - -
q3listbox.h
- 0 - -
-
- databaseLB addBibPB deletePB styleCB