diff options
| author | Frank Reininghaus <[email protected]> | 2012-03-29 19:56:53 +0200 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2012-03-29 20:05:49 +0200 |
| commit | aced85db1f7c72268860f0368402cf97f34e55c2 (patch) | |
| tree | f0b47ebdbc5e5f6549d76d3ec23c697a6e2c9e2d /src/kitemviews/kitemlistkeyboardsearchmanager.cpp | |
| parent | bd26bf2a20fba80c33ad1e8438592bddc4bea4aa (diff) | |
KItemListKeyboardSearchManager: make it possible to choose the timeout
It's now possible to change the timeout, after which any call of
KItemListKeyboardSearchManager::addKeys(const QString&) starts a new
search, from the default value of 5000 milliseconds. This is not used
in Dolphin at the moment, but it permits to reduce the timeout to a
small value in the unit test. Before this change, the unit test took
more than 5 seconds to complete.
(cherry picked from commit 82fc1b54bd01768f50aba7d328cdcde7de1483d7)
Diffstat (limited to 'src/kitemviews/kitemlistkeyboardsearchmanager.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistkeyboardsearchmanager.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/kitemviews/kitemlistkeyboardsearchmanager.cpp b/src/kitemviews/kitemlistkeyboardsearchmanager.cpp index 1ff60d09c..f4dc1a547 100644 --- a/src/kitemviews/kitemlistkeyboardsearchmanager.cpp +++ b/src/kitemviews/kitemlistkeyboardsearchmanager.cpp @@ -28,7 +28,8 @@ #include <KDebug> KItemListKeyboardSearchManager::KItemListKeyboardSearchManager(QObject* parent) : - QObject(parent) + QObject(parent), + m_timeout(5000) { m_keyboardInputTime.invalidate(); } @@ -41,8 +42,7 @@ void KItemListKeyboardSearchManager::addKeys(const QString& keys) { const bool keyboardTimeWasValid = m_keyboardInputTime.isValid(); const qint64 keyboardInputTimeElapsed = m_keyboardInputTime.restart(); - const qint64 timeout = 5000; - if (keyboardInputTimeElapsed > timeout || !keyboardTimeWasValid || keys.isEmpty()) { + if (keyboardInputTimeElapsed > m_timeout || !keyboardTimeWasValid || keys.isEmpty()) { m_searchedString.clear(); } @@ -65,3 +65,14 @@ void KItemListKeyboardSearchManager::addKeys(const QString& keys) } m_keyboardInputTime.start(); } + +void KItemListKeyboardSearchManager::setTimeout(qint64 milliseconds) +{ + m_timeout = milliseconds; +} + +qint64 KItemListKeyboardSearchManager::timeout() const +{ + return m_timeout; +} + |
