|
|
|
@ -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();
|
|
|
|
@ -60,6 +78,20 @@ void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr<CSMFilter::
|
|
|
|
|
|
|
|
|
|
bool CSMWorld::IdTableProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
|
|
|
|
{
|
|
|
|
|
Columns::ColumnId id = static_cast<Columns::ColumnId>(left.data(ColumnBase::Role_ColumnId).toInt());
|
|
|
|
|
EnumColumnCache::const_iterator valuesIt = mEnumColumnCache.find(id);
|
|
|
|
|
if (valuesIt == mEnumColumnCache.end())
|
|
|
|
|
{
|
|
|
|
|
if (Columns::hasEnums(id))
|
|
|
|
|
{
|
|
|
|
|
valuesIt = mEnumColumnCache.insert(std::make_pair(id, Columns::getEnums(id))).first;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valuesIt != mEnumColumnCache.end())
|
|
|
|
|
{
|
|
|
|
|
return valuesIt->second[left.data().toInt()] < valuesIt->second[right.data().toInt()];
|
|
|
|
|
}
|
|
|
|
|
return QSortFilterProxyModel::lessThan(left, right);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -68,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();
|
|
|
|
|
}
|
|
|
|
|