]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistcontroller.cpp
Include "Space" in the keyboard search string
[dolphin.git] / src / kitemviews / kitemlistcontroller.cpp
index c8c0fc5f1ba3ddd4fec2982ae82a2013aad0cca3..9335ab816c334631ffa53ff6cbf78563e9399097 100644 (file)
@@ -375,19 +375,6 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
         break;
     }
 
-    case Qt::Key_Space:
-        if (m_selectionBehavior == MultiSelection) {
-            if (controlPressed) {
-                m_selectionManager->endAnchoredSelection();
-                m_selectionManager->setSelected(index, 1, KItemListSelectionManager::Toggle);
-                m_selectionManager->beginAnchoredSelection(index);
-            } else {
-                const int current = m_selectionManager->currentItem();
-                m_selectionManager->setSelected(current);
-            }
-        }
-        break;
-
     case Qt::Key_Menu: {
         // Emit the signal itemContextMenuRequested() in case if at least one
         // item is selected. Otherwise the signal viewContextMenuRequested() will be emitted.
@@ -418,6 +405,25 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
         m_keyboardManager->cancelSearch();
         break;
 
+    case Qt::Key_Space:
+        if (m_selectionBehavior == MultiSelection) {
+            if (controlPressed) {
+                // Toggle the selection state of the current item.
+                m_selectionManager->endAnchoredSelection();
+                m_selectionManager->setSelected(index, 1, KItemListSelectionManager::Toggle);
+                m_selectionManager->beginAnchoredSelection(index);
+                break;
+            } else {
+                // Select the current item if it is not selected yet.
+                const int current = m_selectionManager->currentItem();
+                if (!m_selectionManager->isSelected(current)) {
+                    m_selectionManager->setSelected(current);
+                    break;
+                }
+            }
+        }
+        // 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,9 +480,13 @@ void KItemListController::slotChangeCurrentItem(const QString& text, bool search
     }
     if (index >= 0) {
         m_selectionManager->setCurrentItem(index);
-        m_selectionManager->clearSelection();
-        m_selectionManager->setSelected(index, 1);
-        m_selectionManager->beginAnchoredSelection(index);
+
+        if (m_selectionBehavior != NoSelection) {
+            m_selectionManager->clearSelection();
+            m_selectionManager->setSelected(index, 1);
+            m_selectionManager->beginAnchoredSelection(index);
+        }
+
         m_view->scrollToItem(index);
     }
 }
@@ -869,6 +879,8 @@ bool KItemListController::dragMoveEvent(QGraphicsSceneDragDropEvent* event, cons
                 emit itemUnhovered(index);
             }
         }
+    } else {
+        m_view->hideDropIndicator();
     }
 
     return false;