From 9d95a38934c52041d5457da9e7cb6c4711eb3dd2 Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 29 Jun 2013 08:11:09 -0500 Subject: [PATCH] Implementing delegate for referenceables table Type column Added delegate skeleton class Added delegate creation code in ViewManager Added Display_RefRecordType enum to columnbase.hpp Changed Type column'sDisplay type to Display_RefRecordType in refidcollection.cpp modified OpenCS CMakeLists.txt to incorporate RefRecordTypeDelegate class --- apps/opencs/CMakeLists.txt | 4 +- apps/opencs/model/world/columnbase.hpp | 3 +- apps/opencs/view/doc/viewmanager.cpp | 4 ++ .../view/world/refrecordtypedelegate.cpp | 17 ++++++ .../view/world/refrecordtypedelegate.hpp | 58 +++++++++++++++++++ 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 apps/opencs/view/world/refrecordtypedelegate.cpp create mode 100644 apps/opencs/view/world/refrecordtypedelegate.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 866c0f1f2e..37d9256625 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -61,7 +61,9 @@ opencs_units (view/world ) opencs_units_noqt (view/world - dialoguesubview subviews enumdelegate vartypedelegate scripthighlighter recordstatusdelegate + dialoguesubview subviews + enumdelegate vartypedelegate recordstatusdelegate refrecordtypedelegate + scripthighlighter ) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index e71e633a44..280341216a 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -42,7 +42,8 @@ namespace CSMWorld Display_ClothingType, Display_CreatureType, Display_WeaponType, - Display_RecordState + Display_RecordState, + Display_RefRecordType }; std::string mTitle; diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index bf9da68a06..5530b426b9 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -13,6 +13,7 @@ #include "../world/enumdelegate.hpp" #include "../world/vartypedelegate.hpp" #include "../world/recordstatusdelegate.hpp" +#include "../world/refrecordtypedelegate.hpp" #include "../settings/usersettingsdialog.hpp" #include "view.hpp" @@ -122,6 +123,9 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) mDelegateFactories->add (CSMWorld::ColumnBase::Display_RecordState, new CSVWorld::RecordStatusDelegateFactory() ); + mDelegateFactories->add (CSMWorld::ColumnBase::Display_RefRecordType, + new CSVWorld::RefRecordTypeDelegateFactory() ); + connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)), this, SLOT (slotUpdateEditorSetting (const QString &, const QString &))); } diff --git a/apps/opencs/view/world/refrecordtypedelegate.cpp b/apps/opencs/view/world/refrecordtypedelegate.cpp new file mode 100644 index 0000000000..259b1c9b56 --- /dev/null +++ b/apps/opencs/view/world/refrecordtypedelegate.cpp @@ -0,0 +1,17 @@ +#include "refrecordtypedelegate.hpp" + +CSVWorld::RefRecordTypeDelegate::RefRecordTypeDelegate + (const std::vector > &values, QUndoStack& undoStack, QObject *parent) + : EnumDelegate (values, undoStack, parent) +{} + +CSVWorld::RefRecordTypeDelegateFactory::RefRecordTypeDelegateFactory() +{ + +} + +CSVWorld::CommandDelegate *CSVWorld::RefRecordTypeDelegateFactory::makeDelegate (QUndoStack& undoStack, + QObject *parent) const +{ + return new RefRecordTypeDelegate (mValues, undoStack, parent); +} diff --git a/apps/opencs/view/world/refrecordtypedelegate.hpp b/apps/opencs/view/world/refrecordtypedelegate.hpp new file mode 100644 index 0000000000..baec2cc2e9 --- /dev/null +++ b/apps/opencs/view/world/refrecordtypedelegate.hpp @@ -0,0 +1,58 @@ +#ifndef REFRECORDTYPEDELEGATE_HPP +#define REFRECORDTYPEDELEGATE_HPP + +#include "enumdelegate.hpp" +#include "util.hpp" + +namespace CSVWorld +{ + class RefRecordTypeDelegate : public EnumDelegate + { + public: + RefRecordTypeDelegate (const std::vector > &mValues, QUndoStack& undoStack, QObject *parent); + }; + + class RefRecordTypeDelegateFactory : public CommandDelegateFactory + { + + std::vector > mValues; + + public: + RefRecordTypeDelegateFactory(); + + virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const; + ///< The ownership of the returned CommandDelegate is transferred to the caller. + }; +} +/* + class VarTypeDelegate : public EnumDelegate + { + private: + + virtual void addCommands (QAbstractItemModel *model, + const QModelIndex& index, int type) const; + + public: + + VarTypeDelegate (const std::vector >& values, + QUndoStack& undoStack, QObject *parent); + }; + + class VarTypeDelegateFactory : public CommandDelegateFactory + { + std::vector > mValues; + + public: + + VarTypeDelegateFactory (ESM::VarType type0 = ESM::VT_Unknown, + ESM::VarType type1 = ESM::VT_Unknown, ESM::VarType type2 = ESM::VT_Unknown, + ESM::VarType type3 = ESM::VT_Unknown); + + virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const; + ///< The ownership of the returned CommandDelegate is transferred to the caller. + + void add (ESM::VarType type); + }; +*/ + +#endif // REFRECORDTYPEDELEGATE_HPP