From 55b115935aff153c9e6d9ceaf5e86262011308f8 Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sun, 30 Jun 2013 07:43:58 -0500 Subject: [PATCH] Implemented RefRecordTypeDelegate Added accessor functions to CSMWorld::UniversalId for static const sIdArg[] --- apps/opencs/model/world/refidcollection.cpp | 2 +- apps/opencs/model/world/universalid.cpp | 25 ++++++++++++++++++- apps/opencs/model/world/universalid.hpp | 3 +++ .../view/world/refrecordtypedelegate.cpp | 12 +++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 2bb8d07b37..b2cb48ecbc 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -42,7 +42,7 @@ CSMWorld::RefIdCollection::RefIdCollection() mColumns.push_back (RefIdColumn ("*", ColumnBase::Display_RecordState, ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false)); baseColumns.mModified = &mColumns.back(); - mColumns.push_back (RefIdColumn ("Type", ColumnBase::Display_Integer, + mColumns.push_back (RefIdColumn ("Type", ColumnBase::Display_RefRecordType, ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false)); baseColumns.mType = &mColumns.back(); diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index bd1632e3e7..dd44322418 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -5,6 +5,7 @@ #include #include +#include namespace { struct TypeData @@ -83,6 +84,8 @@ namespace { CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker }; + + static const unsigned int IDARG_SIZE = sizeof (sIdArg) / sizeof (TypeData); } CSMWorld::UniversalId::UniversalId (const std::string& universalId) @@ -261,6 +264,26 @@ std::string CSMWorld::UniversalId::toString() const return stream.str(); } + +std::pair CSMWorld::UniversalId::getIdArgPair (unsigned int index) +{ + std::pair retPair; + + if ( index < IDARG_SIZE ) + { + retPair.first = sIdArg[index].mType; + retPair.second = sIdArg[index].mName; + } + + return retPair; +} + +unsigned int CSMWorld::UniversalId::getIdArgSize() +{ + return IDARG_SIZE; +} + + bool CSMWorld::operator== (const CSMWorld::UniversalId& left, const CSMWorld::UniversalId& right) { return left.isEqual (right); @@ -279,4 +302,4 @@ bool CSMWorld::operator< (const UniversalId& left, const UniversalId& right) std::ostream& CSMWorld::operator< (std::ostream& stream, const CSMWorld::UniversalId& universalId) { return stream << universalId.toString(); -} \ No newline at end of file +} diff --git a/apps/opencs/model/world/universalid.hpp b/apps/opencs/model/world/universalid.hpp index 2c4b14eaf5..fb1fdff290 100644 --- a/apps/opencs/model/world/universalid.hpp +++ b/apps/opencs/model/world/universalid.hpp @@ -123,6 +123,9 @@ namespace CSMWorld std::string getTypeName() const; std::string toString() const; + + static std::pair getIdArgPair (unsigned int index); + static unsigned int getIdArgSize (); }; bool operator== (const UniversalId& left, const UniversalId& right); diff --git a/apps/opencs/view/world/refrecordtypedelegate.cpp b/apps/opencs/view/world/refrecordtypedelegate.cpp index 259b1c9b56..52277aa61c 100644 --- a/apps/opencs/view/world/refrecordtypedelegate.cpp +++ b/apps/opencs/view/world/refrecordtypedelegate.cpp @@ -1,4 +1,7 @@ #include "refrecordtypedelegate.hpp" +#include "../../model/world/universalid.hpp" + +#include CSVWorld::RefRecordTypeDelegate::RefRecordTypeDelegate (const std::vector > &values, QUndoStack& undoStack, QObject *parent) @@ -7,7 +10,16 @@ CSVWorld::RefRecordTypeDelegate::RefRecordTypeDelegate CSVWorld::RefRecordTypeDelegateFactory::RefRecordTypeDelegateFactory() { + unsigned int argSize = CSMWorld::UniversalId::getIdArgSize(); + for (unsigned int i = 0; i < argSize; i++) + { + std::pair idPair = CSMWorld::UniversalId::getIdArgPair(i); + + mValues.push_back (std::pair(idPair.first, QString::fromUtf8(idPair.second))); + + qDebug() << "index: " << mValues.at(i).first << "; value: " << mValues.at(i).second; + } } CSVWorld::CommandDelegate *CSVWorld::RefRecordTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,