mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-20 22:53:54 +00:00
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 "refidadapter.hpp"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
template <typename ESXRecordT>
|
||||
|
@ -37,6 +39,27 @@ namespace CSMWorld
|
|||
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:
|
||||
|
||||
const Record<ESXRecordT>& getRecord(const RefIdData& data, int index) const
|
||||
|
|
|
@ -329,24 +329,9 @@ QVariant CSMWorld::ContainerRefIdAdapter::getNestedData (const CSMWorld::RefIdCo
|
|||
int subRowIndex,
|
||||
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)
|
||||
{
|
||||
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 std::logic_error("Trying to access non-existing column in the nested table!");
|
||||
}
|
||||
return mHelper.getNestedData(column, data, index, subRowIndex, subColIndex);
|
||||
} else
|
||||
{
|
||||
throw std::logic_error("This column does not hold multiple values.");
|
||||
|
|
Loading…
Reference in a new issue