forked from mirror/openmw-tes3mp
moved responsibility for getNestedData to the inventory helper
This commit is contained in:
parent
c4598d6200
commit
6573e3f319
2 changed files with 24 additions and 16 deletions
|
@ -10,6 +10,8 @@
|
||||||
#include "refiddata.hpp"
|
#include "refiddata.hpp"
|
||||||
#include "refidadapter.hpp"
|
#include "refidadapter.hpp"
|
||||||
|
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
template <typename ESXRecordT>
|
template <typename ESXRecordT>
|
||||||
|
@ -37,6 +39,27 @@ namespace CSMWorld
|
||||||
return new NestedTableWrapper<std::vector<ESM::ContItem> >(getRecord(data, index).get().mInventory.mList);
|
return new NestedTableWrapper<std::vector<ESM::ContItem> >(getRecord(data, index).get().mInventory.mList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant getNestedData(const CSMWorld::RefIdColumn* column,
|
||||||
|
const CSMWorld::RefIdData& data,
|
||||||
|
int index,
|
||||||
|
int subRowIndex,
|
||||||
|
int subColIndex) const
|
||||||
|
{
|
||||||
|
const ESM::ContItem& content = getRecord(data, index).get().mInventory.mList.at(subRowIndex);
|
||||||
|
|
||||||
|
switch (subColIndex)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return QString::fromUtf8(content.mItem.toString().c_str());
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
return content.mCount;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw std::logic_error("Trying to access non-existing column in the nested table!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const Record<ESXRecordT>& getRecord(const RefIdData& data, int index) const
|
const Record<ESXRecordT>& getRecord(const RefIdData& data, int index) const
|
||||||
|
|
|
@ -329,24 +329,9 @@ QVariant CSMWorld::ContainerRefIdAdapter::getNestedData (const CSMWorld::RefIdCo
|
||||||
int subRowIndex,
|
int subRowIndex,
|
||||||
int subColIndex) const
|
int subColIndex) const
|
||||||
{
|
{
|
||||||
const Record<ESM::Container>& record = static_cast<const Record<ESM::Container>&> (
|
|
||||||
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Container)));
|
|
||||||
|
|
||||||
if (column==mContent)
|
if (column==mContent)
|
||||||
{
|
{
|
||||||
const ESM::ContItem& content = record.get().mInventory.mList.at(subRowIndex);
|
return mHelper.getNestedData(column, data, index, subRowIndex, subColIndex);
|
||||||
|
|
||||||
switch (subColIndex)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return QString::fromUtf8(content.mItem.toString().c_str());
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
return content.mCount;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw std::logic_error("Trying to access non-existing column in the nested table!");
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
throw std::logic_error("This column does not hold multiple values.");
|
throw std::logic_error("This column does not hold multiple values.");
|
||||||
|
|
Loading…
Reference in a new issue