mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-04 19:45:36 +00:00
InfoTableProxyModel: invalidate first row cache after row insertion/deletion
This commit is contained in:
parent
d5bc561d17
commit
170692b480
2 changed files with 14 additions and 7 deletions
|
@ -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);
|
||||||
|
if (mSourceModel != NULL)
|
||||||
|
{
|
||||||
connect(mSourceModel,
|
connect(mSourceModel,
|
||||||
SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
|
SIGNAL(rowsInserted(const QModelIndex &, int, int)),
|
||||||
this,
|
this,
|
||||||
SLOT(modelDataChanged(const QModelIndex &, const QModelIndex &)));
|
SLOT(modelRowsChanged(const QModelIndex &, int, int)));
|
||||||
|
connect(mSourceModel,
|
||||||
|
SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
|
||||||
|
this,
|
||||||
|
SLOT(modelRowsChanged(const QModelIndex &, int, int)));
|
||||||
mFirstRowCache.clear();
|
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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue