]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Improve arrow key navigation in Details View with expanded folders
authorFrank Reininghaus <frank78ac@googlemail.com>
Wed, 30 May 2012 07:21:32 +0000 (09:21 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Wed, 30 May 2012 07:26:31 +0000 (09:26 +0200)
If the current folder is collapsed, pressing the left arrow key now
moves the focus to the parent folder.

CCBUG: 300582
(cherry picked from commit 93daadae28f7e3b5cffd7b713a2a287e4fa62ccd)

src/kitemviews/kitemlistcontroller.cpp

index 1b9c53ccffe9260e479af171a3fa745b02da3d09..1b32093034d61290fae9a042355983f7eef55c31 100644 (file)
@@ -251,7 +251,15 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
 
     case Qt::Key_Left:
         if (index > 0) {
-            --index;
+            const int expandedParentsCount = m_model->expandedParentsCount(index);
+            if (expandedParentsCount == 0) {
+                --index;
+            } else {
+                // Go to the parent of the current item.
+                do {
+                    --index;
+                } while (index > 0 && m_model->expandedParentsCount(index) == expandedParentsCount);
+            }
             m_keyboardAnchorIndex = index;
             m_keyboardAnchorPos = keyboardAnchorPos(index);
         }