#include "kitemlistkeyboardsearchmanager.h"
-#include <QApplication>
-#include <QElapsedTimer>
KItemListKeyboardSearchManager::KItemListKeyboardSearchManager(QObject* parent) :
QObject(parent),
{
const bool keyboardTimeWasValid = m_keyboardInputTime.isValid();
const qint64 keyboardInputTimeElapsed = m_keyboardInputTime.restart();
- if (keyboardInputTimeElapsed > m_timeout || !keyboardTimeWasValid || keys.isEmpty()) {
+ if (keyboardInputTimeElapsed > m_timeout || !keyboardTimeWasValid) {
m_searchedString.clear();
}
const bool newSearch = m_searchedString.isEmpty();
+ // Do not start a new search if the user pressed Space. Only add
+ // it to the search string if a search is in progress already.
+ if (newSearch && keys == QLatin1String(" ")) {
+ return;
+ }
+
if (!keys.isEmpty()) {
m_searchedString.append(keys);
{
m_searchedString.clear();
}
+
+void KItemListKeyboardSearchManager::slotCurrentChanged(int current, int previous)
+{
+ Q_UNUSED(previous);
+
+ if (current < 0) {
+ // The current item has been removed. We should cancel the search.
+ cancelSearch();
+ }
+}