forked from qt-creator/qt-creator
WelcomePage: add delay to filter
Setting the filter is now delayed to allow proper typing. Change-Id: I9faa2b9810766b2a51bf02d4a14222a9f0a81693 Reviewed-by: Alessandro Portale <alessandro.portale@nokia.com>
This commit is contained in:
committed by
Thomas Hartmann
parent
871a25ff57
commit
ca8cd6b806
@@ -476,7 +476,7 @@ void ExamplesListModel::ensureInitialized() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExamplesListModelFilter::ExamplesListModelFilter(ExamplesListModel *sourceModel, QObject *parent) :
|
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()));
|
connect(this, SIGNAL(showTutorialsOnlyChanged()), SLOT(updateFilter()));
|
||||||
setSourceModel(m_sourceModel);
|
setSourceModel(m_sourceModel);
|
||||||
@@ -570,6 +570,23 @@ void ExamplesListModelFilter::setShowTutorialsOnly(bool showTutorialsOnly)
|
|||||||
emit showTutorialsOnlyChanged();
|
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 {
|
struct SearchStringLexer {
|
||||||
QString code;
|
QString code;
|
||||||
const QChar *codePtr;
|
const QChar *codePtr;
|
||||||
@@ -675,7 +692,7 @@ void ExamplesListModelFilter::parseSearchString(const QString &arg)
|
|||||||
|
|
||||||
setSearchStrings(searchTerms);
|
setSearchStrings(searchTerms);
|
||||||
setFilterTags(tags);
|
setFilterTags(tags);
|
||||||
updateFilter();
|
delayedUpdateFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -141,7 +141,7 @@ public slots:
|
|||||||
if (m_searchString != arg) {
|
if (m_searchString != arg) {
|
||||||
m_searchString = arg;
|
m_searchString = arg;
|
||||||
emit searchStrings(arg);
|
emit searchStrings(arg);
|
||||||
updateFilter();
|
delayedUpdateFilter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,11 +155,17 @@ signals:
|
|||||||
|
|
||||||
void searchStrings(const QStringList& arg);
|
void searchStrings(const QStringList& arg);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void timerEvent(QTimerEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void delayedUpdateFilter();
|
||||||
|
|
||||||
bool m_showTutorialsOnly;
|
bool m_showTutorialsOnly;
|
||||||
QStringList m_filterTags;
|
QStringList m_filterTags;
|
||||||
QStringList m_searchString;
|
QStringList m_searchString;
|
||||||
ExamplesListModel *m_sourceModel;
|
ExamplesListModel *m_sourceModel;
|
||||||
|
int m_timerId;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user