Implemented RefRecordTypeDelegate

Added accessor functions to CSMWorld::UniversalId for static const
sIdArg[]
pull/16/head
graffy76 12 years ago
parent 9d95a38934
commit 55b115935a

@ -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();

@ -5,6 +5,7 @@
#include <stdexcept>
#include <sstream>
#include <QDebug>
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<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)
{
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();
}
}

@ -123,6 +123,9 @@ namespace CSMWorld
std::string getTypeName() 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);

@ -1,4 +1,7 @@
#include "refrecordtypedelegate.hpp"
#include "../../model/world/universalid.hpp"
#include <QDebug>
CSVWorld::RefRecordTypeDelegate::RefRecordTypeDelegate
(const std::vector<std::pair<int, QString> > &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<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,

Loading…
Cancel
Save