┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistcontroller.cpp
diff options
context:
space:
mode:
authorTranter Madi <[email protected]>2019-04-01 10:59:04 +0700
committerTranter Madi <[email protected]>2019-04-12 09:50:57 +0700
commitb7db272af2f20fbeeea6bba33f4ef89d1d735bb9 (patch)
treebd51584910733757716aac6398df6161fccf0f34 /src/kitemviews/kitemlistcontroller.cpp
parent97e9af5ceb3869b56b7aff53e06dcf1c4f3b8132 (diff)
Scroll to item if it's not visible on keyPress
Summary: Always scroll to item if it's not visible on keyPress, even if it's the current index. Test Plan: Select the last item, scroll up to make it not visible > press the `End` key > Dolphin now scrolls to that item. Reviewers: #dolphin, ngraham, elvisangelaccio Reviewed By: #dolphin, ngraham, elvisangelaccio Subscribers: elvisangelaccio, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D20152
Diffstat (limited to 'src/kitemviews/kitemlistcontroller.cpp')
-rw-r--r--src/kitemviews/kitemlistcontroller.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp
index d3dbeb35c..6fb6a5132 100644
--- a/src/kitemviews/kitemlistcontroller.cpp
+++ b/src/kitemviews/kitemlistcontroller.cpp
@@ -231,6 +231,9 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
const bool shiftPressed = event->modifiers() & Qt::ShiftModifier;
const bool controlPressed = event->modifiers() & Qt::ControlModifier;
const bool shiftOrControlPressed = shiftPressed || controlPressed;
+ const bool navigationPressed = key == Qt::Key_Home || key == Qt::Key_End ||
+ key == Qt::Key_Up || key == Qt::Key_Down ||
+ key == Qt::Key_Left || key == Qt::Key_Right;
const int itemCount = m_model->count();
@@ -246,11 +249,8 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
}
}
- const bool selectSingleItem = m_selectionBehavior != NoSelection &&
- itemCount == 1 &&
- (key == Qt::Key_Home || key == Qt::Key_End ||
- key == Qt::Key_Up || key == Qt::Key_Down ||
- key == Qt::Key_Left || key == Qt::Key_Right);
+ const bool selectSingleItem = m_selectionBehavior != NoSelection && itemCount == 1 && navigationPressed;
+
if (selectSingleItem) {
const int current = m_selectionManager->currentItem();
m_selectionManager->setSelected(current);
@@ -458,8 +458,12 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
}
break;
}
+ }
- m_view->scrollToItem(index);
+ if (navigationPressed) {
+ if (index < m_view->firstVisibleIndex() || index > m_view->lastVisibleIndex()) {
+ m_view->scrollToItem(index);
+ }
}
return true;
}