]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Improve selection behaviour concerning the new "jump to next/previous
authorFrank Reininghaus <frank78ac@googlemail.com>
Tue, 14 Jul 2009 20:47:37 +0000 (20:47 +0000)
committerFrank Reininghaus <frank78ac@googlemail.com>
Tue, 14 Jul 2009 20:47:37 +0000 (20:47 +0000)
row using right/left arrow" and "jump to next/previous column using
down/up arrow" when using the Icon View's "Rows" and "Columns"
arrangement, respectively, in the following cases:

1. In "Columns" arrangement, if the first item is selected and
Ctrl-Down is pressed repeatedly, don't deselect the first item when
jumping to the next column.

2. In "Rows" arrangement, if the first item in the second row is
active and then Left and finally Shift-Left is pressed, don't
re-select the first item in the second row unexpectedly.

3. If an item in the middle of the second row is selected, make sure
that selection with Shift-Left/Shift-Right is reversible even if the
previous/next row is reached.

svn path=/trunk/KDE/kdebase/apps/; revision=996758

src/dolphiniconsview.cpp

index 55d70a0a22172862e4487124577656c3ee800099..c6b4f5acf0fe98a1530bcffcef6e653303e18600 100644 (file)
@@ -247,10 +247,10 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
 
 QModelIndex DolphinIconsView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
 {
-    QModelIndex current = currentIndex();
+    const QModelIndex oldCurrent = currentIndex();
 
     QModelIndex newCurrent = QListView::moveCursor(cursorAction, modifiers);
-    if (newCurrent != current) {
+    if (newCurrent != oldCurrent) {
         return newCurrent;
     }
 
@@ -274,7 +274,7 @@ QModelIndex DolphinIconsView::moveCursor(CursorAction cursorAction, Qt::Keyboard
                 return newCurrent;
             }
             newCurrent = QListView::moveCursor(MovePageUp, modifiers);
-            selectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::Clear);
+            selectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::NoUpdate);
             newCurrent = QListView::moveCursor(MoveRight, modifiers);
             break;
 
@@ -282,6 +282,7 @@ QModelIndex DolphinIconsView::moveCursor(CursorAction cursorAction, Qt::Keyboard
             break;
         }
     } else {
+        QModelIndex current = oldCurrent;
         switch (cursorAction) {
         case MoveLeft:
             if (newCurrent.row() == 0) {
@@ -293,15 +294,6 @@ QModelIndex DolphinIconsView::moveCursor(CursorAction cursorAction, Qt::Keyboard
                 current = newCurrent;
                 newCurrent = QListView::moveCursor(MoveRight, modifiers);
             } while (newCurrent != current);
-
-            if (!(modifiers & Qt::ControlModifier)) {
-                // Ctrl is not pressed -> selection is updated
-                if (!(modifiers & Qt::ShiftModifier)) {
-                    // Shift is not pressed -> previous selection is lost
-                    selectionModel()->clearSelection();
-                }
-                selectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::Select);
-            }
             break;
 
         case MoveRight:
@@ -321,6 +313,8 @@ QModelIndex DolphinIconsView::moveCursor(CursorAction cursorAction, Qt::Keyboard
         }
     }
 
+    // Revert all changes of the current item to make sure that item selection works correctly
+    selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate);
     return newCurrent;
 }