Use the currentItemChanged() signal instead of itemSelectionChanged()

because in Qt 4.2 the current item has not been updated yet when
itemSelectionChanged() is emitted.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22544 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2008-01-13 21:35:48 +00:00
parent 0572822ec9
commit 58a0626e80

View File

@ -66,7 +66,7 @@ GuiBibtex::GuiBibtex(GuiView & lv)
this, SLOT(downPressed())); this, SLOT(downPressed()));
connect(styleCB, SIGNAL(editTextChanged(QString)), connect(styleCB, SIGNAL(editTextChanged(QString)),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
connect(databaseLW, SIGNAL(itemSelectionChanged()), connect(databaseLW, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(databaseChanged())); this, SLOT(databaseChanged()));
connect(bibtocCB, SIGNAL(clicked()), connect(bibtocCB, SIGNAL(clicked()),
this, SLOT(change_adaptor())); this, SLOT(change_adaptor()));
@ -91,7 +91,7 @@ GuiBibtex::GuiBibtex(GuiView & lv)
this, SLOT(addDatabase())); this, SLOT(addDatabase()));
connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)), connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
add_, SLOT(accept())); add_, SLOT(accept()));
connect(add_->bibLW, SIGNAL(itemSelectionChanged()), connect(add_->bibLW, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(availableChanged())); this, SLOT(availableChanged()));
connect(add_->browsePB, SIGNAL(clicked()), connect(add_->browsePB, SIGNAL(clicked()),
this, SLOT(browseBibPressed())); this, SLOT(browseBibPressed()));
@ -265,11 +265,12 @@ void GuiBibtex::downPressed()
void GuiBibtex::databaseChanged() void GuiBibtex::databaseChanged()
{ {
deletePB->setEnabled(!isBufferReadonly() && databaseLW->currentRow() != -1); bool readOnly = isBufferReadonly();
upPB->setEnabled(!isBufferReadonly() && databaseLW->count() > 1 && int count = databaseLW->count();
databaseLW->currentRow() > 0); int row = databaseLW->currentRow();
downPB->setEnabled(!isBufferReadonly() && databaseLW->count() > 1 && deletePB->setEnabled(!readOnly && row != -1);
databaseLW->currentRow() < databaseLW->count() - 1); upPB->setEnabled(!readOnly && count > 1 && row > 0);
downPB->setEnabled(!readOnly && count > 1 && row < count - 1);
} }