From 1c4b70805b3ae77c38ec71ad090b372c8da5a1f2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sat, 6 Jul 2013 17:41:06 +0200 Subject: [PATCH] added missing reference table columns --- apps/opencs/model/world/columns.hpp | 373 ++++++++++++++++++++++++++++ apps/opencs/model/world/data.cpp | 15 ++ 2 files changed, 388 insertions(+) diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index f1d8d4ae62..ba60aaf904 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -773,6 +773,379 @@ namespace CSMWorld return true; } }; + + template + struct CellColumn : public Column + { + CellColumn() : Column ("Cell", ColumnBase::Display_String) {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mCellId.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mCellId = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + + virtual bool isUserEditable() const + { + return false; + } + }; + + template + struct IdColumn : public Column + { + IdColumn() : Column ("ID", ColumnBase::Display_String) {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mRefID.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mRefID = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct ScaleColumn : public Column + { + ScaleColumn() : Column ("Scale", ColumnBase::Display_Float) {} + + virtual QVariant get (const Record& record) const + { + return record.get().mScale; + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + record2.mScale = data.toFloat(); + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct OwnerColumn : public Column + { + OwnerColumn() : Column ("Owner", ColumnBase::Display_String) {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mOwner.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mOwner = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct SoulColumn : public Column + { + SoulColumn() : Column ("Soul", ColumnBase::Display_String) {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mSoul.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mSoul = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct FactionColumn : public Column + { + FactionColumn() : Column ("Faction", ColumnBase::Display_String) {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mFaction.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mFaction = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct FactionIndexColumn : public Column + { + FactionIndexColumn() : Column ("Faction Index", ColumnBase::Display_Integer) {} + + virtual QVariant get (const Record& record) const + { + return record.get().mFactIndex; + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + record2.mFactIndex = data.toInt(); + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct ChargesColumn : public Column + { + ChargesColumn() : Column ("Charges", ColumnBase::Display_Integer) {} + + virtual QVariant get (const Record& record) const + { + return record.get().mCharge; + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + record2.mCharge = data.toInt(); + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct EnchantmentChargesColumn : public Column + { + EnchantmentChargesColumn() : Column ("Entchantment", ColumnBase::Display_Float) {} + + virtual QVariant get (const Record& record) const + { + return record.get().mEnchantmentCharge; + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + record2.mEnchantmentCharge = data.toFloat(); + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct GoldValueColumn : public Column + { + GoldValueColumn() : Column ("Value", ColumnBase::Display_Integer) {} + + virtual QVariant get (const Record& record) const + { + return record.get().mGoldValue; + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + record2.mGoldValue = data.toInt(); + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct TeleportColumn : public Column + { + TeleportColumn() : Column ("Teleport", ColumnBase::Display_Boolean) {} + + virtual QVariant get (const Record& record) const + { + return record.get().mTeleport; + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mTeleport = data.toInt(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct TeleportCellColumn : public Column + { + TeleportCellColumn() : Column ("Teleport Cell", ColumnBase::Display_String) {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mDestCell.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mDestCell = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + + virtual bool isUserEditable() const + { + return false; + } + }; + + template + struct LockLevelColumn : public Column + { + LockLevelColumn() : Column ("Lock Level", ColumnBase::Display_Integer) {} + + virtual QVariant get (const Record& record) const + { + return record.get().mLockLevel; + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + record2.mLockLevel = data.toInt(); + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct KeyColumn : public Column + { + KeyColumn() : Column ("Key", ColumnBase::Display_String) {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mKey.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mKey = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; + + template + struct TrapColumn : public Column + { + TrapColumn() : Column ("Trap", ColumnBase::Display_String) {} + + virtual QVariant get (const Record& record) const + { + return QString::fromUtf8 (record.get().mTrap.c_str()); + } + + virtual void set (Record& record, const QVariant& data) + { + ESXRecordT record2 = record.get(); + + record2.mTrap = data.toString().toUtf8().constData(); + + record.setModified (record2); + } + + virtual bool isEditable() const + { + return true; + } + }; } #endif \ No newline at end of file diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index a9686928ae..ed11d4af01 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -129,6 +129,21 @@ CSMWorld::Data::Data() : mRefs (mCells) mCells.addColumn (new RegionColumn); mRefs.addColumn (new RecordStateColumn); + mRefs.addColumn (new CellColumn); + mRefs.addColumn (new IdColumn); + mRefs.addColumn (new ScaleColumn); + mRefs.addColumn (new OwnerColumn); + mRefs.addColumn (new SoulColumn); + mRefs.addColumn (new FactionColumn); + mRefs.addColumn (new FactionIndexColumn); + mRefs.addColumn (new ChargesColumn); + mRefs.addColumn (new EnchantmentChargesColumn); + mRefs.addColumn (new GoldValueColumn); + mRefs.addColumn (new TeleportColumn); + mRefs.addColumn (new TeleportCellColumn); + mRefs.addColumn (new LockLevelColumn); + mRefs.addColumn (new KeyColumn); + mRefs.addColumn (new TrapColumn); addModel (new IdTable (&mGlobals), UniversalId::Type_Globals, UniversalId::Type_Global); addModel (new IdTable (&mGmsts), UniversalId::Type_Gmsts, UniversalId::Type_Gmst);