From 764c4fa8fec7bcfadec79c65319946d0c2ab292c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 27 Sep 2012 17:25:45 +0200 Subject: [PATCH] Fix resetting of the QCompletionModel. This model apparently pre-dates the API required to do resetting properly. Change-Id: I0ea903cef87077ca4a3d8ca2b53eba213e77cc26 Reviewed-by: Marc Mutz --- src/widgets/util/qcompleter.cpp | 23 ++++------------------- 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 d6a4162..a2bce69 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 b741226..dcfe489 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; -- 2.7.4