diff options
author | Stephen Kelly <stephen.kelly@kdab.com> | 2012-09-27 17:25:45 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-09-27 18:35:55 +0200 |
commit | 764c4fa8fec7bcfadec79c65319946d0c2ab292c (patch) | |
tree | a66c831c32dafb4fc35f5425840b777e662d262e /src/widgets/util | |
parent | 1f2a2898348c19e78281f639aeed32b0abb3dd1f (diff) |
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>
Diffstat (limited to 'src/widgets/util')
-rw-r--r-- | src/widgets/util/qcompleter.cpp | 23 | ||||
-rw-r--r-- | src/widgets/util/qcompleter_p.h | 1 |
2 files changed, 4 insertions, 20 deletions
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index d6a4162272..a2bce693fc 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -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) { diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h index b74122665d..dcfe489cc3 100644 --- a/src/widgets/util/qcompleter_p.h +++ b/src/widgets/util/qcompleter_p.h @@ -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; |