From 397f8783d98dea4f8a34b15bb0a2db82dc8b848e Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Wed, 30 May 2012 09:21:32 +0200 Subject: [PATCH] Improve arrow key navigation in Details View with expanded folders 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 1b9c53ccf..1b3209303 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -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); } -- 2.47.3