diff --git a/apps/opencs/model/world/columnbase.cpp b/apps/opencs/model/world/columnbase.cpp index 7adc7e6c3a..134c582c40 100644 --- a/apps/opencs/model/world/columnbase.cpp +++ b/apps/opencs/model/world/columnbase.cpp @@ -1,8 +1,8 @@ #include "columnbase.hpp" -CSMWorld::ColumnBase::ColumnBase (const std::string& title, int flags) -: mTitle (title), mFlags (flags) +CSMWorld::ColumnBase::ColumnBase (const std::string& title, Display displayType, int flags) +: mTitle (title), mDisplayType (displayType), mFlags (flags) {} CSMWorld::ColumnBase::~ColumnBase() {} diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index dc077eff60..38b73ee3f5 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -14,7 +14,8 @@ namespace CSMWorld { enum Roles { - Role_Flags = Qt::UserRole + Role_Flags = Qt::UserRole, + Role_Display = Qt::UserRole+1 }; enum Flags @@ -23,10 +24,18 @@ namespace CSMWorld Flag_Dialogue = 2 // column should be displayed in dialogue view }; + enum Display + { + Display_String, + Display_Integer, + Display_Float + }; + std::string mTitle; int mFlags; + Display mDisplayType; - ColumnBase (const std::string& title, int flag); + ColumnBase (const std::string& title, Display displayType, int flag); virtual ~ColumnBase(); @@ -34,6 +43,7 @@ namespace CSMWorld virtual bool isUserEditable() const; ///< Can this column be edited directly by the user? + }; template @@ -42,8 +52,8 @@ namespace CSMWorld std::string mTitle; int mFlags; - Column (const std::string& title, int flags = Flag_Table | Flag_Dialogue) - : ColumnBase (title, flags) {} + Column (const std::string& title, Display displayType, int flags = Flag_Table | Flag_Dialogue) + : ColumnBase (title, displayType, flags) {} virtual QVariant get (const Record& record) const = 0; diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 5abf4ea8bc..1e2de92658 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -8,7 +8,7 @@ namespace CSMWorld template struct FloatValueColumn : public Column { - FloatValueColumn() : Column ("Value") {} + FloatValueColumn() : Column ("Value", ColumnBase::Display_Float) {} virtual QVariant get (const Record& record) const { @@ -31,7 +31,7 @@ namespace CSMWorld template struct StringIdColumn : public Column { - StringIdColumn() : Column ("ID") {} + StringIdColumn() : Column ("ID", ColumnBase::Display_String) {} virtual QVariant get (const Record& record) const { @@ -47,7 +47,7 @@ namespace CSMWorld template struct RecordStateColumn : public Column { - RecordStateColumn() : Column ("*") {} + RecordStateColumn() : Column ("*", ColumnBase::Display_Integer) {} virtual QVariant get (const Record& record) const { @@ -78,7 +78,8 @@ namespace CSMWorld { int mType; - FixedRecordTypeColumn (int type) : Column ("Type", 0), mType (type) {} + FixedRecordTypeColumn (int type) + : Column ("Type", ColumnBase::Display_Integer, 0), mType (type) {} virtual QVariant get (const Record& record) const { diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index 2815e318c8..afed6b6eda 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -51,6 +51,9 @@ QVariant CSMWorld::IdTable::headerData (int section, Qt::Orientation orientation if (role==ColumnBase::Role_Flags) return mIdCollection->getColumn (section).mFlags; + if (role==ColumnBase::Role_Display) + return mIdCollection->getColumn (section).mDisplayType; + return QVariant(); }