#include "idtableproxymodel.hpp" #include #include "idtable.hpp" void CSMWorld::IdTableProxyModel::updateColumnMap() { mColumnMap.clear(); if (mFilter) { std::vector columns = mFilter->getReferencedColumns(); const IdTable& table = dynamic_cast (*sourceModel()); for (std::vector::const_iterator iter (columns.begin()); iter!=columns.end(); ++iter) mColumnMap.insert (std::make_pair (*iter, table.searchColumnIndex (static_cast (*iter)))); } } bool CSMWorld::IdTableProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const { if (!mFilter) return true; std::map otherFilters; /// \todo get other filters; return mFilter->test ( dynamic_cast (*sourceModel()), sourceRow, otherFilters, mColumnMap, mUserValue); } CSMWorld::IdTableProxyModel::IdTableProxyModel (QObject *parent) : QSortFilterProxyModel (parent) {} QModelIndex CSMWorld::IdTableProxyModel::getModelIndex (const std::string& id, int column) const { return mapFromSource (dynamic_cast (*sourceModel()).getModelIndex (id, column)); } void CSMWorld::IdTableProxyModel::setFilter (const boost::shared_ptr& filter, const std::string& userValue) { mFilter = filter; mUserValue = userValue; updateColumnMap(); invalidateFilter(); }