1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-04 16:15:35 +00:00

InfoTableProxyModel: invalidate first row cache after row insertion/deletion

This commit is contained in:
Stanislav Bas 2015-06-19 19:24:06 +03:00
parent d5bc561d17
commit 170692b480
2 changed files with 14 additions and 7 deletions

View file

@ -15,11 +15,18 @@ void CSMWorld::InfoTableProxyModel::setSourceModel(QAbstractItemModel *sourceMod
{ {
IdTableProxyModel::setSourceModel(sourceModel); IdTableProxyModel::setSourceModel(sourceModel);
mSourceModel = dynamic_cast<IdTableBase *>(sourceModel); mSourceModel = dynamic_cast<IdTableBase *>(sourceModel);
connect(mSourceModel, if (mSourceModel != NULL)
SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), {
this, connect(mSourceModel,
SLOT(modelDataChanged(const QModelIndex &, const QModelIndex &))); SIGNAL(rowsInserted(const QModelIndex &, int, int)),
mFirstRowCache.clear(); this,
SLOT(modelRowsChanged(const QModelIndex &, int, int)));
connect(mSourceModel,
SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
this,
SLOT(modelRowsChanged(const QModelIndex &, int, int)));
mFirstRowCache.clear();
}
} }
bool CSMWorld::InfoTableProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const bool CSMWorld::InfoTableProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
@ -52,7 +59,7 @@ int CSMWorld::InfoTableProxyModel::getFirstInfoRow(int currentRow) const
return currentRow + 1; return currentRow + 1;
} }
void CSMWorld::InfoTableProxyModel::modelDataChanged(const QModelIndex &/*topLeft*/, const QModelIndex &/*bottomRight*/) void CSMWorld::InfoTableProxyModel::modelRowsChanged(const QModelIndex &/*parent*/, int /*start*/, int /*end*/)
{ {
mFirstRowCache.clear(); mFirstRowCache.clear();
} }

View file

@ -31,7 +31,7 @@ namespace CSMWorld
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const; virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
private slots: private slots:
void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); void modelRowsChanged(const QModelIndex &parent, int start, int end);
}; };
} }