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

does not compile

This commit is contained in:
Marek Kochanowicz 2014-05-27 14:01:15 +02:00
parent befc7a4078
commit 41db48720d
4 changed files with 90 additions and 1 deletions

View file

@ -1,6 +1,20 @@
#include "refidadapter.hpp"
#include "cassert"
#include <QVariant>
CSMWorld::RefIdAdapter::RefIdAdapter() {}
CSMWorld::RefIdAdapter::~RefIdAdapter() {}
QVariant CSMWorld::RefIdAdapter::getData (const CSMWorld::RefIdColumn* column, const CSMWorld::RefIdData& data, int idnex, int subRowIndex, int subColIndex) const
{
assert(false);
return QVariant();
}
void CSMWorld::RefIdAdapter::setData (const CSMWorld::RefIdColumn* column, CSMWorld::RefIdData& data, const QVariant& value, int index, int subRowIndex, int subColIndex) const
{
assert(false);
}

View file

@ -30,6 +30,13 @@ namespace CSMWorld
const QVariant& value) const = 0;
///< If the data type does not match an exception is thrown.
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data,
int idnex, int subRowIndex, int subColIndex) const;
virtual void setData (const RefIdColumn *column, RefIdData& data,
const QVariant& value, int index,
int subRowIndex, int subColIndex) const;
virtual std::string getId (const RecordBase& record) const = 0;
virtual void setId(RecordBase& record, const std::string& id) = 0;
};

View file

@ -222,6 +222,66 @@ void CSMWorld::ContainerRefIdAdapter::setData (const RefIdColumn *column, RefIdD
NameRefIdAdapter<ESM::Container>::setData (column, data, index, value);
}
void CSMWorld::ContainerRefIdAdapter::setData(const RefIdColumn *column, RefIdData& data,
int index,
const QVariant& value,
int subRowIndex,
int subColIndex)
{
using RefIdAdapter::setData;
Record<ESM::Container>& record = static_cast<Record<ESM::Container>&> (
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Container)));
if (column==mContent)
{
switch (subColIndex)
{
case 0:
record.get().mInventory.mList.at(subRowIndex).mItem.assign(std::string(value.toString().toUtf8().constData()));
break;
case 1:
record.get().mInventory.mList.at(subRowIndex).mCount = value.toInt();
break;
}
} else
{
throw "This column does not hold multiple values.";
}
}
QVariant CSMWorld::ContainerRefIdAdapter::getData (const CSMWorld::RefIdColumn* column,
const CSMWorld::RefIdData& data,
int index,
int subRowIndex,
int subColIndex) const
{
using RefIdAdapter::getData;
const Record<ESM::Container>& record = static_cast<const Record<ESM::Container>&> (
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Container)));
if (column==mContent)
{
const ESM::ContItem& content = record.get().mInventory.mList.at(subRowIndex);
switch (subColIndex)
{
case 0:
return QString::fromUtf8(content.mItem.toString().c_str());
case 1:
return content.mCount;
default:
throw "Trying to access non-existing column in the nested table!";
}
} else
{
throw "This column does not hold multiple values.";
}
}
CSMWorld::CreatureColumns::CreatureColumns (const ActorColumns& actorColumns)
: ActorColumns (actorColumns)
{}

View file

@ -617,9 +617,17 @@ namespace CSMWorld
ContainerRefIdAdapter (const NameColumns& columns, const RefIdColumn *weight,
const RefIdColumn *organic, const RefIdColumn *respawn, const RefIdColumn *content);
using RefIdAdapter::getData;
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index,
int subRowIndex, int subColIndex) const;
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
const;
using RefIdAdapter::setData;
virtual void setData (const RefIdColumn *column, RefIdData& data, int index,
const QVariant& value, int subRowIndex, int subColIndex) const;
virtual void setData (const RefIdColumn *column, RefIdData& data, int index,
const QVariant& value) const;
///< If the data type does not match an exception is thrown.