Do not change the selection when re-sorting the view

Review Request #117603 - Created April 16, 2014 and submitted

Frank Reininghaus
The user can select a range of items in the view by holding the Shift key and then pressing the arrow keys, or by shift-clicking an item. In that case, we keep track not only of the "current item", which is underlined in the view, but also the "anchor item", which is the item where the selection was started. The entire range between those two items is selected then.

If the order of the items changes, e.g., because the user switches from "Sort by Name" to "Sort by Date", then both the current and the "anchor" index are updated. However, the items between those two are not necessarily the items that were between them before the re-sorting, i.e., the selected items might change, which is unexpected, of course.

This can be fixed by finishing the "anchored selection" if the items are resorted.

A new anchored selection is then started, where the current item is the new anchor item. Without this detail, re-sorting and then pressing Shift+Arrow would not select any items. This is also why I added the new unit test, which verifies that this still works.
Fixes the bug for me. Old and new unit tests pass.
Christoph Feck
Emmanuel Pescosta
Commit Hook
This review has been submitted with commit a637e4979f109dde4165274a72384bfcb2ff5bc3 by Frank Reininghaus to branch KDE/4.13.
Frank Reininghaus
Review request changed

Status: Closed (submitted)