]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Increase the timeout in KItemListKeyboardSearchManager to 5 seconds
authorFrank Reininghaus <frank78ac@googlemail.com>
Wed, 28 Mar 2012 17:15:20 +0000 (19:15 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Wed, 28 Mar 2012 17:22:12 +0000 (19:22 +0200)
The previous timeout [QApplication::keyboardInputInterval()] was too
short to do a multi-letter search for users who do not type extremely
fast.
(cherry picked from commit 02eab49b2de51c31fe46a0d9501327b579b3648e)

src/kitemviews/kitemlistkeyboardsearchmanager.cpp
src/tests/kitemlistkeyboardsearchmanagertest.cpp

index cefedfc2c87042131240cd4488743c8fa5c88313..1ff60d09c82b77884ace5cbfe40aae6e2559cd03 100644 (file)
@@ -41,8 +41,8 @@ void KItemListKeyboardSearchManager::addKeys(const QString& keys)
 {
     const bool keyboardTimeWasValid = m_keyboardInputTime.isValid();
     const qint64 keyboardInputTimeElapsed = m_keyboardInputTime.restart();
 {
     const bool keyboardTimeWasValid = m_keyboardInputTime.isValid();
     const qint64 keyboardInputTimeElapsed = m_keyboardInputTime.restart();
-    if (keyboardInputTimeElapsed > QApplication::keyboardInputInterval()
-        || !keyboardTimeWasValid || keys.isEmpty()) {
+    const qint64 timeout = 5000;
+    if (keyboardInputTimeElapsed > timeout || !keyboardTimeWasValid || keys.isEmpty()) {
         m_searchedString.clear();
     }
 
         m_searchedString.clear();
     }
 
index be483930d9b169308891de5dc493182758ef120f..14a09a31cc82b89737bbad61c1bd1695ed922cd8 100644 (file)
@@ -75,9 +75,9 @@ void KItemListKeyboardSearchManagerTest::testAbortedKeyboardSearch()
     QCOMPARE(spy.count(), 1);
     QCOMPARE(spy.takeFirst(), QList<QVariant>() << "fi" << false);
 
     QCOMPARE(spy.count(), 1);
     QCOMPARE(spy.takeFirst(), QList<QVariant>() << "fi" << false);
 
-    // If the delay between two key presses is larger than QApplication::keyboardInputInterval(),
+    // If the delay between two key presses is larger than 5000 milliseconds,
     // a new search is started. We add a small safety margin to avoid race conditions.
     // a new search is started. We add a small safety margin to avoid race conditions.
-    QTest::qWait(QApplication::keyboardInputInterval() + 10);
+    QTest::qWait(5000 + 10);
 
     m_keyboardSearchManager.addKeys("l");
     QCOMPARE(spy.count(), 1);
 
     m_keyboardSearchManager.addKeys("l");
     QCOMPARE(spy.count(), 1);