diff --git a/lib/sourcesmodel.h b/lib/sourcesmodel.h --- a/lib/sourcesmodel.h +++ b/lib/sourcesmodel.h @@ -88,7 +88,16 @@ void reloadConfiguration(); void setQueryString(const QString& str); void setQueryLimit(int limit); + /** + * Clears the model content and resets the runner context, i.e. no new items appear. + * Plasma 6 TODO: Replace this with bool clear(bool resetContext=true); + */ void clear(); + /** + * The contained items are removed. If resetContext is false, the runners can + * still add matches afterwards. + */ + void clearContent(bool resetContext); bool run(int index); bool runAction(int index, int actionIndex); diff --git a/lib/sourcesmodel.cpp b/lib/sourcesmodel.cpp --- a/lib/sourcesmodel.cpp +++ b/lib/sourcesmodel.cpp @@ -237,7 +237,8 @@ void SourcesModel::slotResetTimeout() { if (!m_modelPopulated) { - clear(); + // The old items are still shown, get rid of them + clearContent(false); } } @@ -313,7 +314,6 @@ return; QString matchType = m.matchCategory(); - if (!m_types.contains(matchType)) { m_types << matchType; } @@ -357,14 +357,21 @@ } void SourcesModel::clear() +{ + clearContent(true); +} + +void SourcesModel::clearContent(bool resetContext) { beginResetModel(); m_matches.clear(); m_size = 0; m_duplicates.clear(); - m_queryString.clear(); - m_manager->reset(); - m_manager->matchSessionComplete(); + if (resetContext) { + m_queryString.clear(); + m_manager->reset(); + m_manager->matchSessionComplete(); + } endResetModel(); }