[PATCH] QListBox ensureCurrentVisible() brokenness...
Scott Wheeler
wheeler at kde.org
Mon Sep 23 20:05:32 BST 2002
Currently with QListBox, there are calls to ensureCurrentVisible() in a few
problematic places. Specifically it is called in resizeEvent() and
refreshSlot() (which is called by triggerUpdate(true)).
There are a few basic problems that this causes when you are using a QListBox
that is larger than the view frame. First, all calls to triggerUpdate() will
artificially force the QListBox to scroll back to the selected item. This is
where I initially noticed the bug, but when looking through the source, I
noticed the same things happens with resizeEvent() and triggerUpdate(true) is
also called by removeItem(). This affects Qt 3.0.6 and 3.1 Beta.
Here's are a few examples:
*) Create a QListBox and add several items. Compile and run. Scroll down the
list and then resize the QListBox. You will be returned to the selected item
(even if it is the first item in a list of 50 and you were currently viewing
the last).
*) Remove an item while viewing a part of the list that does not contain the
current item. Again, you will be returned to viewing the selected item.
*) Call trigger update under certain circustances from the [subclass of]
QListBoxItem paint() method. This one's really nasty. If you're scrolling
through the list, items are painted as you scroll. If the condition is true
they you are returned to the selection. This was the one that I originally
noticed. I'm attaching a example of this. Just compile, run and then try to
scroll down (without selecting anything). Yuck...
So, the fix:
I added checks to see if the current item is visible *before* doLayout() is
called (which is the case in both of the affected methods) and only call
ensureCurrentVisible() if the current item was visible beforehand.
Any objections to me committing this to qt-copy? (I *hope* this isn't the
intended behavior.)
Cheers,
-Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qlistbox.diff
Type: text/x-diff
Size: 1229 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20020923/a9c39ce4/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: listbox-bug.cpp
Type: text/x-c++src
Size: 961 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20020923/a9c39ce4/attachment.cpp>
More information about the kde-core-devel
mailing list