Fix resetting of the QCompletionModel.

This model apparently pre-dates the API required to do resetting properly.

Change-Id: I0ea903cef87077ca4a3d8ca2b53eba213e77cc26
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Stephen Kelly 2012-09-27 17:25:45 +02:00 committed by The Qt Project
parent 1f2a289834
commit 764c4fa8fe
2 changed files with 4 additions and 20 deletions

View File

@ -364,8 +364,9 @@ void QCompletionModel::setFiltered(bool filtered)
{
if (showAll == !filtered)
return;
beginResetModel();
showAll = !filtered;
resetModel();
endResetModel();
}
bool QCompletionModel::hasChildren(const QModelIndex &parent) const
@ -410,30 +411,14 @@ void QCompletionModel::invalidate()
void QCompletionModel::filter(const QStringList& parts)
{
Q_D(QCompletionModel);
beginResetModel();
engine->filter(parts);
resetModel();
endResetModel();
if (d->model->canFetchMore(engine->curParent))
d->model->fetchMore(engine->curParent);
}
void QCompletionModel::resetModel()
{
if (rowCount() == 0) {
beginResetModel();
endResetModel();
return;
}
emit layoutAboutToBeChanged();
QModelIndexList piList = persistentIndexList();
QModelIndexList empty;
for (int i = 0; i < piList.size(); i++)
empty.append(QModelIndex());
changePersistentIndexList(piList, empty);
emit layoutChanged();
}
//////////////////////////////////////////////////////////////////////////////
void QCompletionEngine::filter(const QStringList& parts)
{

View File

@ -224,7 +224,6 @@ public:
int currentRow() const { return engine->curRow; }
bool setCurrentRow(int row);
QModelIndex currentIndex(bool) const;
void resetModel();
QModelIndex index(int row, int column, const QModelIndex & = QModelIndex()) const;
int rowCount(const QModelIndex &index = QModelIndex()) const;