From 893ad11be109ab1a4e249c1d091092ff5cdfb9fe Mon Sep 17 00:00:00 2001 From: cc9cii Date: Mon, 8 Jun 2015 08:04:18 +1000 Subject: [PATCH] Fix missing columns in tables. Should resolve Bug #2624. - Using Flag_Table in filterAcceptsColumn() does not work. - Workaround by not allowing nested columns in sorting and filtering. --- apps/opencs/model/world/idtableproxymodel.cpp | 18 +++++++----------- apps/opencs/model/world/idtableproxymodel.hpp | 2 -- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/apps/opencs/model/world/idtableproxymodel.cpp b/apps/opencs/model/world/idtableproxymodel.cpp index 3697b055f..d8932d205 100644 --- a/apps/opencs/model/world/idtableproxymodel.cpp +++ b/apps/opencs/model/world/idtableproxymodel.cpp @@ -21,21 +21,17 @@ void CSMWorld::IdTableProxyModel::updateColumnMap() } } -bool CSMWorld::IdTableProxyModel::filterAcceptsColumn (int sourceColumn, const QModelIndex& sourceParent) +bool CSMWorld::IdTableProxyModel::filterAcceptsRow (int sourceRow, 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 + // It is not possible to use filterAcceptsColumn() and check for + // sourceModel()->headerData (sourceColumn, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags) + // because the sourceColumn parameter excludes the hidden columns, i.e. wrong columns can + // be rejected. Workaround by disallowing tree branches (nested columns), which are not meant + // to be visible, from the filter. + if (sourceParent.isValid()) return false; -} -bool CSMWorld::IdTableProxyModel::filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) - const -{ if (!mFilter) return true; diff --git a/apps/opencs/model/world/idtableproxymodel.hpp b/apps/opencs/model/world/idtableproxymodel.hpp index 89480f288..d2a240529 100644 --- a/apps/opencs/model/world/idtableproxymodel.hpp +++ b/apps/opencs/model/world/idtableproxymodel.hpp @@ -39,8 +39,6 @@ namespace CSMWorld 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; }; }