From 5c37079f0c06d1837da2b3d6e3f3763d709550dc Mon Sep 17 00:00:00 2001 From: cc9cii Date: Fri, 5 Jun 2015 12:19:21 +1000 Subject: [PATCH] Include only the columns that are visible for sorting. Should resolve Bug #2611. --- apps/opencs/model/world/idtableproxymodel.cpp | 12 ++++++++++++ apps/opencs/model/world/idtableproxymodel.hpp | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/idtableproxymodel.cpp b/apps/opencs/model/world/idtableproxymodel.cpp index 987d27462..3697b055f 100644 --- a/apps/opencs/model/world/idtableproxymodel.cpp +++ b/apps/opencs/model/world/idtableproxymodel.cpp @@ -21,6 +21,18 @@ void CSMWorld::IdTableProxyModel::updateColumnMap() } } +bool CSMWorld::IdTableProxyModel::filterAcceptsColumn (int sourceColumn, const QModelIndex& sourceParent) + const +{ + int flags = + sourceModel()->headerData (sourceColumn, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt(); + + if (flags & CSMWorld::ColumnBase::Flag_Table) + return true; + else + return false; +} + bool CSMWorld::IdTableProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const { diff --git a/apps/opencs/model/world/idtableproxymodel.hpp b/apps/opencs/model/world/idtableproxymodel.hpp index 8683c2b9e..89480f288 100644 --- a/apps/opencs/model/world/idtableproxymodel.hpp +++ b/apps/opencs/model/world/idtableproxymodel.hpp @@ -24,8 +24,6 @@ namespace CSMWorld void updateColumnMap(); - bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const; - public: IdTableProxyModel (QObject *parent = 0); @@ -39,6 +37,10 @@ namespace CSMWorld protected: bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + + virtual bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const; + + virtual bool filterAcceptsColumn (int sourceColumn, const QModelIndex& sourceParent) const; }; }