From: Frank Reininghaus Date: Tue, 14 Jul 2009 20:47:37 +0000 (+0000) Subject: Improve selection behaviour concerning the new "jump to next/previous X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/027bfb1789cfc47545b708e6fe1d4391c2319f68 Improve selection behaviour concerning the new "jump to next/previous 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 --- diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 55d70a0a2..c6b4f5acf 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -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; }