1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-27 03:35:27 +00:00

moved setNestedData to the helper as well

This commit is contained in:
Marek Kochanowicz 2014-07-21 14:34:48 +02:00
parent 6573e3f319
commit cb004936e0
2 changed files with 25 additions and 17 deletions

View File

@ -2,6 +2,7 @@
#define CSM_WORLD_NESTEDADAPTORS_H
#include <vector>
#include <stdexcept>
#include "universalid.hpp"
#include "nestedtablewrapper.hpp"
@ -59,6 +60,28 @@ namespace CSMWorld
throw std::logic_error("Trying to access non-existing column in the nested table!");
}
}
void setNestedData (const RefIdColumn *column,
RefIdData& data,
int index,
const QVariant& value,
int subRowIndex,
int subColIndex) const
{
switch(subColIndex)
{
case 0:
getRecord(data, index).get().mInventory.mList.at(subRowIndex).mItem.assign(std::string(value.toString().toUtf8().constData()));
break;
case 1:
getRecord(data, index).get().mInventory.mList.at(subRowIndex).mCount = value.toInt();
break;
default:
throw std::logic_error("Trying to access non-existing column in the nested table!");
}
}
private:

View File

@ -285,23 +285,8 @@ void CSMWorld::ContainerRefIdAdapter::setNestedData(const RefIdColumn *column,
{
if (column==mContent)
{
Record<ESM::Container>& record = static_cast<Record<ESM::Container>&> (
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Container)));
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;
default:
throw std::logic_error("Trying to access non-existing column in the nested table!");
}
{
mHelper.setNestedData(column, data, index, value, subRowIndex, subColIndex);
} else
{
assert(false);