Increase the timeout in KItemListKeyboardSearchManager to 5 seconds

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 02eab49b2d)
This commit is contained in:
Frank Reininghaus 2012-03-28 19:15:20 +02:00
parent 88c3bd1866
commit bd26bf2a20
2 changed files with 4 additions and 4 deletions

View file

@ -41,8 +41,8 @@ void KItemListKeyboardSearchManager::addKeys(const QString& keys)
{
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();
}

View file

@ -75,9 +75,9 @@ void KItemListKeyboardSearchManagerTest::testAbortedKeyboardSearch()
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.
QTest::qWait(QApplication::keyboardInputInterval() + 10);
QTest::qWait(5000 + 10);
m_keyboardSearchManager.addKeys("l");
QCOMPARE(spy.count(), 1);