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:
parent
1f2a289834
commit
764c4fa8fe
@ -364,8 +364,9 @@ void QCompletionModel::setFiltered(bool filtered)
|
|||||||
{
|
{
|
||||||
if (showAll == !filtered)
|
if (showAll == !filtered)
|
||||||
return;
|
return;
|
||||||
|
beginResetModel();
|
||||||
showAll = !filtered;
|
showAll = !filtered;
|
||||||
resetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QCompletionModel::hasChildren(const QModelIndex &parent) const
|
bool QCompletionModel::hasChildren(const QModelIndex &parent) const
|
||||||
@ -410,30 +411,14 @@ void QCompletionModel::invalidate()
|
|||||||
void QCompletionModel::filter(const QStringList& parts)
|
void QCompletionModel::filter(const QStringList& parts)
|
||||||
{
|
{
|
||||||
Q_D(QCompletionModel);
|
Q_D(QCompletionModel);
|
||||||
|
beginResetModel();
|
||||||
engine->filter(parts);
|
engine->filter(parts);
|
||||||
resetModel();
|
endResetModel();
|
||||||
|
|
||||||
if (d->model->canFetchMore(engine->curParent))
|
if (d->model->canFetchMore(engine->curParent))
|
||||||
d->model->fetchMore(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)
|
void QCompletionEngine::filter(const QStringList& parts)
|
||||||
{
|
{
|
||||||
|
@ -224,7 +224,6 @@ public:
|
|||||||
int currentRow() const { return engine->curRow; }
|
int currentRow() const { return engine->curRow; }
|
||||||
bool setCurrentRow(int row);
|
bool setCurrentRow(int row);
|
||||||
QModelIndex currentIndex(bool) const;
|
QModelIndex currentIndex(bool) const;
|
||||||
void resetModel();
|
|
||||||
|
|
||||||
QModelIndex index(int row, int column, const QModelIndex & = QModelIndex()) const;
|
QModelIndex index(int row, int column, const QModelIndex & = QModelIndex()) const;
|
||||||
int rowCount(const QModelIndex &index = QModelIndex()) const;
|
int rowCount(const QModelIndex &index = QModelIndex()) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user