]> cloud.milkyroute.net Git - dolphin.git/commitdiff
When Esc is pressed, clear the selection and cancel the keyboard search
authorFrank Reininghaus <frank78ac@googlemail.com>
Wed, 25 Apr 2012 07:17:30 +0000 (09:17 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Wed, 25 Apr 2012 07:17:43 +0000 (09:17 +0200)
This patch restores the Dolphin 1.x behaviour that Esc clears the
selection (Dolphin 2.0 did not have an easy way to clear the selection
using the keyboard so far). Moreover, Esc now also cancels the current
keyboard search. This fixes the problem that the only way to cancel the
search is to wait until the timeout has expired.

CCBUG: 298742
CCBUG: 297458
(cherry picked from commit d3b1312d3edc615b03fb17c1a5fa62ccb61cdabd)

src/kitemviews/kitemlistcontroller.cpp
src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp
src/kitemviews/private/kitemlistkeyboardsearchmanager.h

index 011a3b57dd97e2c6b1573347d95305952e6ba14d..1f93a6357e34f4373acb5825b81745e6c2684c01 100644 (file)
@@ -374,6 +374,13 @@ bool KItemListController::keyPressEvent(QKeyEvent* event)
         break;
     }
 
+    case Qt::Key_Escape:
+        if (m_selectionBehavior != SingleSelection) {
+            m_selectionManager->clearSelection();
+        }
+        m_keyboardManager->cancelSearch();
+        break;
+
     default:
         m_keyboardManager->addKeys(event->text());
         return false;
index cfd19f58aa17f3d13ee0280bf06fdc01e6e8380f..41ca34be46e06e054699b27819fea720f5254d95 100644 (file)
@@ -25,8 +25,6 @@
 #include <QApplication>
 #include <QElapsedTimer>
 
-#include <KDebug>
-
 KItemListKeyboardSearchManager::KItemListKeyboardSearchManager(QObject* parent) :
     QObject(parent),
     m_timeout(1000)
@@ -76,3 +74,7 @@ qint64 KItemListKeyboardSearchManager::timeout() const
     return m_timeout;
 }
 
+void KItemListKeyboardSearchManager::cancelSearch()
+{
+    m_searchedString.clear();
+}
index d6a6686dbcfb5387c2d54822c275c8cc11318da3..3f13ff4459400839971ecf24f7f5ab2664544691 100644 (file)
@@ -58,6 +58,8 @@ public:
     void setTimeout(qint64 milliseconds);
     qint64 timeout() const;
 
+    void cancelSearch();
+
 signals:
     /**
      * Is emitted if the current item should be changed corresponding