Bug 201459 - Selection is wrong when using mouse, keyboard and shift-Arrow
Summary: Selection is wrong when using mouse, keyboard and shift-Arrow
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: general (show other bugs)
Version: 16.12.2
Platform: unspecified Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Peter Penz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-25 14:52 UTC by Simon
Modified: 2009-09-08 20:00 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon 2009-07-25 14:52:32 UTC
Version:           1.2.1 (using 4.2.4 (KDE 4.2.4), Debian packages)
Compiler:          cc 
OS:                Linux

Reproducing:
You've e.g. the following files in your directory:
a
b
c
d
e
f
g

* Switch the view to «Details».
* Click on a (a will be selected).
* Press f (f will be selected, and _nothing else_).
* Press Shift-Down (arrow).

Quiz: What will be selected now? No. Not f and and the next file, g, but all files.
Comment 1 Frank Reininghaus 2009-07-25 21:50:59 UTC
Thanks for the bug report! I can reproduce this and agree that this is not the expected behaviour. That should most likely be fixed in Qt - I think it's somewhat related to, but not exactly a duplicate of, bug 163451. Maybe I'll try to come up with a fix and submit this to Qt Software when I find some time.
Comment 2 Frank Reininghaus 2009-09-08 00:34:47 UTC
It seems that this is not a Qt issue after all - the simple patch below appears to fix it for me.

@Peter: was there a reason to use selectionModel()->select(...) to select the current item and not QAbstractItemView::setCurrentIndex(...), or is it OK to commit this patch? Only QAbstractItemView::setCurrentIndex updates QAbstractItemViewPrivate's pressedPosition member, which points to the item which is the starting point for the next Shift-selection.

BTW, I don't really understand at the moment why this sort of keyboard selection is handled differently in QTreeView and QListView, but there's probably a reason for that...

Index: src/dolphindetailsview.cpp
===================================================================
--- src/dolphindetailsview.cpp  (revision 1021034)
+++ src/dolphindetailsview.cpp  (working copy)
@@ -421,7 +421,7 @@
     // Stay consistent with QListView: When changing the current index by key presses,
     // also change the selection.
     if (m_keyPressed) {
-        selectionModel()->select(current, QItemSelectionModel::ClearAndSelect);
+        setCurrentIndex(current);
     }
 }
Comment 3 Peter Penz 2009-09-08 07:48:11 UTC
@Frank: Not using selectionModel()->select(...) might be a relict when we tried different versions of the autoscroller, I'm not sure... I currently have no time for coding + testing the patch, but I'd say please commit the patch as setCurrentIndex() is the obvious choice. Thanks!
Comment 4 FiNeX 2009-09-08 11:46:39 UTC
I've just tried the patch. I've tried to work a bit and to some test and I've see no side effects.
Comment 5 Frank Reininghaus 2009-09-08 19:52:54 UTC
SVN commit 1021267 by freininghaus:

Fix selection in the Details view in the following use case:

1. Ctrl-click item 1.
2. Enter the first letter of item 2, such that
   it will be selected and the new current item.
3. Shift-click item 3.

With this commit, all items between 2 and 3 will be selected, as
expected, and not all items between 1 and 3.

BUG: 201459


 M  +1 -1      dolphindetailsview.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1021267
Comment 6 Frank Reininghaus 2009-09-08 19:54:05 UTC
SVN commit 1021269 by freininghaus:

Fix selection in the Details view in the following use case:

1. Ctrl-click item 1.
2. Enter the first letter of item 2, such that
   it will be selected and the new current item.
3. Shift-click item 3.

With this commit, all items between 2 and 3 will be selected, as
expected, and not all items between 1 and 3.

Fix will be in KDE 4.3.1.

CCBUG: 201459


 M  +1 -1      dolphindetailsview.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1021269
Comment 7 Simon 2009-09-08 19:58:54 UTC
Thank you!
Comment 8 Frank Reininghaus 2009-09-08 20:00:05 UTC
(In reply to comment #6)
> Fix will be in KDE 4.3.1.

Sorry, that was 4.3.2, of course ;-)