[PATCH] Fixing KWidgetItemDelegate::focusedIndex()

Aurélien Gâteau aurelien.gateau at free.fr
Thu Oct 16 22:24:12 BST 2008


I just experienced problems with KWidgetItemDelegate::focusedIndex(), it
do not always return the correct value. I have a list looking like this:

Item1 [-]
Item2 [-]

The [-] is a button to remove the item. When I click on the [-] button
of Item1, it is removed. My mouse button is now over the [-] button
of Item2. If I click, focusedIndex() returns an invalid index.

Investigating in the code I found out that KWidgetItemDelegate tracks 
the index under the mouse using event filters installed on the
list and on the child widgets. These event filters look for mouse
events and update KWidgetItemDelegatePrivate::focusedIndex.
This does not work in my case, because I didn't move the mouse, so I
didn't trigger any mouse event.

Attached patches use an alternative approach: instead of tracking
the focused index, I just let KWidgetItemDelegate::focusedIndex() figure 
out which one is focused when it's called. It's much simpler and seems 
to work well. Is it ok for you?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-KWidgetItemDelegate-focusedIndex.diff
Type: text/x-diff
Size: 3824 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20081016/f277d927/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-This-switch-is-no-longer-useful.diff
Type: text/x-diff
Size: 5977 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20081016/f277d927/attachment-0001.diff>

More information about the kde-core-devel mailing list