Do not reset the model when new matches are added
REVIEW: 104914
This commit is contained in:
parent
0e03fc990e
commit
1eb2650cd5
@ -190,10 +190,36 @@ void RunnerModel::createManager()
|
|||||||
void RunnerModel::matchesChanged(const QList<Plasma::QueryMatch> &matches)
|
void RunnerModel::matchesChanged(const QList<Plasma::QueryMatch> &matches)
|
||||||
{
|
{
|
||||||
//kDebug() << "got matches:" << matches.count();
|
//kDebug() << "got matches:" << matches.count();
|
||||||
beginResetModel();
|
bool fullReset = false;
|
||||||
m_matches = matches;
|
int oldCount = m_matches.count();
|
||||||
endResetModel();
|
int newCount = matches.count();
|
||||||
emit countChanged();
|
if (newCount > oldCount) {
|
||||||
|
// We received more matches than we had. If all common matches are the
|
||||||
|
// same, we can just append new matches instead of resetting the whole
|
||||||
|
// model
|
||||||
|
for (int row = 0; row < oldCount; ++row) {
|
||||||
|
if (m_matches.at(row) != matches.at(row)) {
|
||||||
|
fullReset = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!fullReset) {
|
||||||
|
// Not a full reset, inserting rows
|
||||||
|
beginInsertRows(QModelIndex(), oldCount, newCount);
|
||||||
|
m_matches = matches;
|
||||||
|
endInsertRows();
|
||||||
|
emit countChanged();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fullReset = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fullReset) {
|
||||||
|
beginResetModel();
|
||||||
|
m_matches = matches;
|
||||||
|
endResetModel();
|
||||||
|
emit countChanged();
|
||||||
|
}
|
||||||
m_runningChangedTimeout->start(3000);
|
m_runningChangedTimeout->start(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user