X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/1a6b3c0a2baba955259d6083c0a3f25dfb44a682..bdbcef3cff79a0e171b583036d0febf79b83d395:/src/kitemviews/kitemlistcontroller.cpp diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index 130936488..6fb6a5132 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -23,23 +23,20 @@ #include "kitemlistcontroller.h" - -#include "kitemlistview.h" #include "kitemlistselectionmanager.h" - -#include "private/kitemlistrubberband.h" +#include "kitemlistview.h" #include "private/kitemlistkeyboardsearchmanager.h" +#include "private/kitemlistrubberband.h" +#include "views/draganddrophelper.h" +#include #include #include -#include #include #include #include #include #include -#include -#include KItemListController::KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent) : QObject(parent), @@ -213,18 +210,6 @@ bool KItemListController::singleClickActivationEnforced() const return m_singleClickActivationEnforced; } -bool KItemListController::showEvent(QShowEvent* event) -{ - Q_UNUSED(event); - return false; -} - -bool KItemListController::hideEvent(QHideEvent* event) -{ - Q_UNUSED(event); - return false; -} - bool KItemListController::keyPressEvent(QKeyEvent* event) { int index = m_selectionManager->currentItem(); @@ -246,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(); @@ -261,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); @@ -436,8 +421,7 @@ bool KItemListController::keyPressEvent(QKeyEvent* event) } } } - // Fall through to the default case and add the Space to the current search string. - + Q_FALLTHROUGH(); // fall through to the default case and add the Space to the current search string. default: m_keyboardManager->addKeys(event->text()); // Make sure unconsumed events get propagated up the chain. #302329 @@ -474,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; } @@ -849,6 +837,9 @@ bool KItemListController::dragEnterEvent(QGraphicsSceneDragDropEvent* event, con { Q_UNUSED(event); Q_UNUSED(transform); + + DragAndDropHelper::clearUrlListMatchesUrlCache(); + return false; }