diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 3b425c6b3055ea7f4c7ba2ffcb3d031f81d1e00e..5a569010e5831364c22398cbe294e64bf019a044 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -476,7 +476,7 @@ void ExamplesListModel::ensureInitialized() const } ExamplesListModelFilter::ExamplesListModelFilter(ExamplesListModel *sourceModel, QObject *parent) : - QSortFilterProxyModel(parent), m_showTutorialsOnly(true), m_sourceModel(sourceModel) + QSortFilterProxyModel(parent), m_showTutorialsOnly(true), m_sourceModel(sourceModel), m_timerId(0) { connect(this, SIGNAL(showTutorialsOnlyChanged()), SLOT(updateFilter())); setSourceModel(m_sourceModel); @@ -570,6 +570,23 @@ void ExamplesListModelFilter::setShowTutorialsOnly(bool showTutorialsOnly) emit showTutorialsOnlyChanged(); } +void ExamplesListModelFilter::delayedUpdateFilter() +{ + if (m_timerId != 0) + killTimer(m_timerId); + + m_timerId = startTimer(320); +} + +void ExamplesListModelFilter::timerEvent(QTimerEvent *timerEvent) +{ + if (m_timerId == timerEvent->timerId()) { + updateFilter(); + killTimer(m_timerId); + m_timerId = 0; + } +} + struct SearchStringLexer { QString code; const QChar *codePtr; @@ -675,7 +692,7 @@ void ExamplesListModelFilter::parseSearchString(const QString &arg) setSearchStrings(searchTerms); setFilterTags(tags); - updateFilter(); + delayedUpdateFilter(); } } // namespace Internal diff --git a/src/plugins/qtsupport/exampleslistmodel.h b/src/plugins/qtsupport/exampleslistmodel.h index 8068f516dc4282d880509228142ccf40fca7783c..0de6612d1c5f027032b25910b142c495f9f6d014 100644 --- a/src/plugins/qtsupport/exampleslistmodel.h +++ b/src/plugins/qtsupport/exampleslistmodel.h @@ -141,7 +141,7 @@ public slots: if (m_searchString != arg) { m_searchString = arg; emit searchStrings(arg); - updateFilter(); + delayedUpdateFilter(); } } @@ -155,11 +155,17 @@ signals: void searchStrings(const QStringList& arg); +protected: + void timerEvent(QTimerEvent *event); + private: + void delayedUpdateFilter(); + bool m_showTutorialsOnly; QStringList m_filterTags; QStringList m_searchString; ExamplesListModel *m_sourceModel; + int m_timerId; }; } // namespace Internal