From 03c0cbc65a3eefe6c5f0280dead9078d13abfcc5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 30 Aug 2014 10:13:34 +0200 Subject: [PATCH] added owner global column to references table (Fixes #1695) --- apps/opencs/model/world/columnbase.hpp | 1 + apps/opencs/model/world/columnimp.hpp | 27 +++++++++++++++++++++++ apps/opencs/model/world/columns.cpp | 1 + apps/opencs/model/world/columns.hpp | 1 + apps/opencs/model/world/data.cpp | 1 + apps/opencs/model/world/tablemimedata.cpp | 1 + apps/opencs/view/world/util.cpp | 1 + 7 files changed, 33 insertions(+) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 1444f70f1..6a0ee68d6 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -68,6 +68,7 @@ namespace CSMWorld Display_TopicInfo, Display_JournalInfo, Display_Scene, + Display_GlobalVariable, //CONCRETE TYPES ENDS HERE Display_Integer, diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 3fad05f65..a8ee52fdc 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -1870,6 +1870,33 @@ namespace CSMWorld return true; } }; + + template + struct OwnerGlobalColumn : public Column + { + OwnerGlobalColumn() + : Column (Columns::ColumnId_OwnerGlobal, ColumnBase::Display_GlobalVariable) + {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mGlobalVariable.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mGlobalVariable = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; } #endif diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index 05df0b735..d809f69b9 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -181,6 +181,7 @@ namespace CSMWorld { ColumnId_Vampire, "Vampire" }, { ColumnId_BodyPartType, "Bodypart Type" }, { ColumnId_MeshType, "Mesh Type" }, + { ColumnId_OwnerGlobal, "Owner Global" }, { ColumnId_UseValue1, "Use value 1" }, { ColumnId_UseValue2, "Use value 2" }, diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index 326a02596..08ed66377 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -174,6 +174,7 @@ namespace CSMWorld ColumnId_Vampire = 161, ColumnId_BodyPartType = 162, ColumnId_MeshType = 163, + ColumnId_OwnerGlobal = 164, // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index f9cf32a4c..d3562c0f7 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -250,6 +250,7 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mRefs.addColumn (new LockLevelColumn); mRefs.addColumn (new KeyColumn); mRefs.addColumn (new TrapColumn); + mRefs.addColumn (new OwnerGlobalColumn); mFilters.addColumn (new StringIdColumn); mFilters.addColumn (new RecordStateColumn); diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 9b80650ab..f3b0e3761 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -264,6 +264,7 @@ namespace { CSMWorld::UniversalId::Type_SoundRes, CSMWorld::ColumnBase::Display_SoundRes }, { CSMWorld::UniversalId::Type_Texture, CSMWorld::ColumnBase::Display_Texture }, { CSMWorld::UniversalId::Type_Video, CSMWorld::ColumnBase::Display_Video }, + { CSMWorld::UniversalId::Type_Global, CSMWorld::ColumnBase::Display_GlobalVariable }, { CSMWorld::UniversalId::Type_None, CSMWorld::ColumnBase::Display_None } // end marker }; diff --git a/apps/opencs/view/world/util.cpp b/apps/opencs/view/world/util.cpp index ca66087fa..8987c90a0 100644 --- a/apps/opencs/view/world/util.cpp +++ b/apps/opencs/view/world/util.cpp @@ -183,6 +183,7 @@ QWidget *CSVWorld::CommandDelegate::createEditor (QWidget *parent, const QStyleO case CSMWorld::ColumnBase::Display_SoundRes: case CSMWorld::ColumnBase::Display_Texture: case CSMWorld::ColumnBase::Display_Video: + case CSMWorld::ColumnBase::Display_GlobalVariable: return new DropLineEdit(parent);