diff options
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 10 | ||||
-rw-r--r-- | src/gui/itemviews/qtreeview.cpp | 11 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 32d7bca..97fd6e1 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -107,6 +107,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() delayedPendingLayout(true), moveCursorUpdatedView(false) { + keyboardInputTime.invalidate(); } QAbstractItemViewPrivate::~QAbstractItemViewPrivate() @@ -2842,17 +2843,16 @@ void QAbstractItemView::keyboardSearch(const QString &search) QModelIndex start = currentIndex().isValid() ? currentIndex() : d->model->index(0, 0, d->root); - QElapsedTimer now; - now.start(); bool skipRow = false; - if (search.isEmpty() - || (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) { + bool keyboardTimeWasValid = d->keyboardInputTime.isValid(); + qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart(); + if (search.isEmpty() || !keyboardTimeWasValid + || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) { d->keyboardInput = search; skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0) } else { d->keyboardInput += search; } - d->keyboardInputTime = now; // special case for searches with same key like 'aaaaa' bool sameKey = false; diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 063f3f4..d934683 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -962,17 +962,16 @@ void QTreeView::keyboardSearch(const QString &search) else start = d->model->index(0, 0, d->root); - QElapsedTimer now; - now.start(); bool skipRow = false; - if (search.isEmpty() - || (d->keyboardInputTime.msecsTo(now) > QApplication::keyboardInputInterval())) { + bool keyboardTimeWasValid = d->keyboardInputTime.isValid(); + qint64 keyboardInputTimeElapsed = d->keyboardInputTime.restart(); + if (search.isEmpty() || !keyboardTimeWasValid + || keyboardInputTimeElapsed > QApplication::keyboardInputInterval()) { d->keyboardInput = search; - skipRow = true; + skipRow = currentIndex().isValid(); //if it is not valid we should really start at QModelIndex(0,0) } else { d->keyboardInput += search; } - d->keyboardInputTime = now; // special case for searches with same key like 'aaaaa' bool sameKey = false; |