On Sun, Jan 13, 2008 at 09:16:11PM +0100, Horst Schirmeier wrote:

> On Sun, 13 Jan 2008, Enrico Forestieri wrote:
> > Note that the activation of the "Up" and "Down" buttons does not work
> > correctly with Qt 4.2 (4.3 is OK). When you load the attached .lyx file,
> > open the "BibTeX Bibliography" panel and select the first entry, the
> > "Down" button is activated. But if you now select the second (and last)
> > entry, the "Down" button remains activated and "Up" button disactivated.
> > This is clearly wrong as the second entry can only be moved up.
> > 
> > Selecting again the first entry, the "Down" button is deactivated and
> > the "Up" button activated, which is again wrong. From now on, selecting
> > one of the two entries, the wrong button gets activated.
> > 
> > As said, this only happens with Qt 4.2.
> 
> Interesting. I'll look into this as soon as possible, thanks for
> reporting.

The problem here is that in Qt 4.2 and earlier the current item has
not been updated yet when itemSelectionChanged() is emitted.
The correct signal is in this case currentItemChanged(). See
http://trolltech.org/developer/task-tracker/index_html?method=entry&id=108785

The attached patch fixes the problem in trunk.
Jürgen, OK for branch, too?

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

Reply via email to