1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 06:53:53 +00:00

Implemented RefRecordTypeDelegate

Added accessor functions to CSMWorld::UniversalId for static const
sIdArg[]
This commit is contained in:
graffy76 2013-06-30 07:43:58 -05:00
parent 9d95a38934
commit 55b115935a
4 changed files with 40 additions and 2 deletions

View file

@ -42,7 +42,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
mColumns.push_back (RefIdColumn ("*", ColumnBase::Display_RecordState, mColumns.push_back (RefIdColumn ("*", ColumnBase::Display_RecordState,
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false)); ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false));
baseColumns.mModified = &mColumns.back(); 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)); ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false));
baseColumns.mType = &mColumns.back(); baseColumns.mType = &mColumns.back();

View file

@ -5,6 +5,7 @@
#include <stdexcept> #include <stdexcept>
#include <sstream> #include <sstream>
#include <QDebug>
namespace namespace
{ {
struct TypeData struct TypeData
@ -83,6 +84,8 @@ namespace
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker { 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) CSMWorld::UniversalId::UniversalId (const std::string& universalId)
@ -261,6 +264,26 @@ std::string CSMWorld::UniversalId::toString() const
return stream.str(); return stream.str();
} }
std::pair<int, const char *> CSMWorld::UniversalId::getIdArgPair (unsigned int index)
{
std::pair<int, const char *> 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) bool CSMWorld::operator== (const CSMWorld::UniversalId& left, const CSMWorld::UniversalId& right)
{ {
return left.isEqual (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) std::ostream& CSMWorld::operator< (std::ostream& stream, const CSMWorld::UniversalId& universalId)
{ {
return stream << universalId.toString(); return stream << universalId.toString();
} }

View file

@ -123,6 +123,9 @@ namespace CSMWorld
std::string getTypeName() const; std::string getTypeName() const;
std::string toString() const; std::string toString() const;
static std::pair<int, const char *> getIdArgPair (unsigned int index);
static unsigned int getIdArgSize ();
}; };
bool operator== (const UniversalId& left, const UniversalId& right); bool operator== (const UniversalId& left, const UniversalId& right);

View file

@ -1,4 +1,7 @@
#include "refrecordtypedelegate.hpp" #include "refrecordtypedelegate.hpp"
#include "../../model/world/universalid.hpp"
#include <QDebug>
CSVWorld::RefRecordTypeDelegate::RefRecordTypeDelegate CSVWorld::RefRecordTypeDelegate::RefRecordTypeDelegate
(const std::vector<std::pair<int, QString> > &values, QUndoStack& undoStack, QObject *parent) (const std::vector<std::pair<int, QString> > &values, QUndoStack& undoStack, QObject *parent)
@ -7,7 +10,16 @@ CSVWorld::RefRecordTypeDelegate::RefRecordTypeDelegate
CSVWorld::RefRecordTypeDelegateFactory::RefRecordTypeDelegateFactory() CSVWorld::RefRecordTypeDelegateFactory::RefRecordTypeDelegateFactory()
{ {
unsigned int argSize = CSMWorld::UniversalId::getIdArgSize();
for (unsigned int i = 0; i < argSize; i++)
{
std::pair<int, const char *> idPair = CSMWorld::UniversalId::getIdArgPair(i);
mValues.push_back (std::pair<int, QString>(idPair.first, QString::fromUtf8(idPair.second)));
qDebug() << "index: " << mValues.at(i).first << "; value: " << mValues.at(i).second;
}
} }
CSVWorld::CommandDelegate *CSVWorld::RefRecordTypeDelegateFactory::makeDelegate (QUndoStack& undoStack, CSVWorld::CommandDelegate *CSVWorld::RefRecordTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,