From: Méven Car Date: Thu, 10 Oct 2019 07:28:25 +0000 (+0200) Subject: Refactoring: add shouldClearSearchIfInputTimeReached to KItemListKeyboardSearchManager X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/e7de9862022a08e1dd9204f0acd6329ac7bf5353 Refactoring: add shouldClearSearchIfInputTimeReached to KItemListKeyboardSearchManager --- diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp index 8f18b92bf..82e8aa2ff 100644 --- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp +++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.cpp @@ -34,11 +34,16 @@ KItemListKeyboardSearchManager::~KItemListKeyboardSearchManager() { } -void KItemListKeyboardSearchManager::addKeys(const QString& keys) +bool KItemListKeyboardSearchManager::shouldClearSearchIfInputTimeReached() { const bool keyboardTimeWasValid = m_keyboardInputTime.isValid(); const qint64 keyboardInputTimeElapsed = m_keyboardInputTime.restart(); - if (keyboardInputTimeElapsed > m_timeout || !keyboardTimeWasValid) { + return (keyboardInputTimeElapsed > m_timeout) || !keyboardTimeWasValid; +} + +void KItemListKeyboardSearchManager::addKeys(const QString& keys) +{ + if (shouldClearSearchIfInputTimeReached()) { m_searchedString.clear(); } diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h index 016907da6..29bec1414 100644 --- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h +++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h @@ -59,6 +59,7 @@ public: qint64 timeout() const; void cancelSearch(); + bool shouldClearSearchIfInputTimeReached(); public slots: