From f95e72166c20cd6e64cebc5bb46b937e6ca62ccc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 13 Dec 2012 15:03:35 +0100 Subject: [PATCH] hide type column in non-mixed type tables --- apps/opencs/model/world/columns.hpp | 2 +- apps/opencs/view/world/table.cpp | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 00c688484..f58d77c90 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -78,7 +78,7 @@ namespace CSMWorld { int mType; - FixedRecordTypeColumn (int type) : Column ("Type"), mType (type) {} + FixedRecordTypeColumn (int type) : Column ("Type", 0), mType (type) {} virtual QVariant get (const Record& record) const { diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 6892c7f61..0721ead2c 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -84,15 +84,6 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, Q { mModel = &dynamic_cast (*data.getTableModel (id)); - int columns = mModel->columnCount(); - - for (int i=0; isetSourceModel (mModel); @@ -103,6 +94,22 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, Q setSelectionBehavior (QAbstractItemView::SelectRows); setSelectionMode (QAbstractItemView::ExtendedSelection); + int columns = mModel->columnCount(); + + for (int i=0; iheaderData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt(); + + if (flags & CSMWorld::ColumnBase::Flag_Table) + { + CommandDelegate *delegate = new CommandDelegate (undoStack, this); + mDelegates.push_back (delegate); + setItemDelegateForColumn (i, delegate); + } + else + hideColumn (i); + } + /// \todo make initial layout fill the whole width of the table if (createAndDelete)