]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistcontroller.cpp
Merge branch 'Applications/19.04'
[dolphin.git] / src / kitemviews / kitemlistcontroller.cpp
index 36d8e4671b3ad5626e77f0502bcc5ed355eb17ab..6fb6a5132964de116cfb64cff1a025ffb6946e0c 100644 (file)
@@ -210,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();
@@ -243,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();
 
@@ -258,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);
@@ -433,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
@@ -471,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;
 }