mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 20:15:32 +00:00
IdTableProxyModel refreshes the filter when the source model data or rows changed
This commit is contained in:
parent
a7b3248ee7
commit
f5b1447c92
3 changed files with 36 additions and 4 deletions
|
@ -50,6 +50,24 @@ QModelIndex CSMWorld::IdTableProxyModel::getModelIndex (const std::string& id, i
|
|||
return mapFromSource (dynamic_cast<IdTableBase&> (*sourceModel()).getModelIndex (id, column));
|
||||
}
|
||||
|
||||
void CSMWorld::IdTableProxyModel::setSourceModel(QAbstractItemModel *model)
|
||||
{
|
||||
QSortFilterProxyModel::setSourceModel(model);
|
||||
|
||||
connect(sourceModel(),
|
||||
SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
|
||||
this,
|
||||
SLOT(sourceRowsChanged(const QModelIndex &, int, int)));
|
||||
connect(sourceModel(),
|
||||
SIGNAL(rowsInserted(const QModelIndex &, int, int)),
|
||||
this,
|
||||
SLOT(sourceRowsChanged(const QModelIndex &, int, int)));
|
||||
connect(sourceModel(),
|
||||
SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
|
||||
this,
|
||||
SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &)));
|
||||
}
|
||||
|
||||
void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr<CSMFilter::Node>& filter)
|
||||
{
|
||||
beginResetModel();
|
||||
|
@ -82,3 +100,13 @@ void CSMWorld::IdTableProxyModel::refreshFilter()
|
|||
updateColumnMap();
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void CSMWorld::IdTableProxyModel::sourceRowsChanged(const QModelIndex &/*parent*/, int /*start*/, int /*end*/)
|
||||
{
|
||||
refreshFilter();
|
||||
}
|
||||
|
||||
void CSMWorld::IdTableProxyModel::sourceDataChanged(const QModelIndex &/*topLeft*/, const QModelIndex &/*bottomRight*/)
|
||||
{
|
||||
refreshFilter();
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ namespace CSMWorld
|
|||
|
||||
virtual QModelIndex getModelIndex (const std::string& id, int column) const;
|
||||
|
||||
virtual void setSourceModel(QAbstractItemModel *model);
|
||||
|
||||
void setFilter (const boost::shared_ptr<CSMFilter::Node>& filter);
|
||||
|
||||
void refreshFilter();
|
||||
|
@ -46,6 +48,12 @@ namespace CSMWorld
|
|||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
||||
|
||||
virtual bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const;
|
||||
|
||||
private slots:
|
||||
|
||||
void sourceRowsChanged(const QModelIndex &parent, int start, int end);
|
||||
|
||||
void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -653,10 +653,6 @@ void CSVWorld::Table::tableSizeUpdate()
|
|||
}
|
||||
|
||||
emit tableSizeChanged (size, deleted, modified);
|
||||
|
||||
// not really related to tableSizeUpdate() but placed here for convenience rather than
|
||||
// creating a bunch of extra connections & slot
|
||||
mProxyModel->refreshFilter();
|
||||
}
|
||||
|
||||
void CSVWorld::Table::selectionSizeUpdate()
|
||||
|
|
Loading…
Reference in a new issue