|
|
|
@ -52,6 +52,133 @@ void CSMWorld::PotionRefIdAdapter::setData (const RefIdColumn *column, RefIdData
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSMWorld::IngredientColumns::IngredientColumns (const InventoryColumns& columns)
|
|
|
|
|
: InventoryColumns (columns) {}
|
|
|
|
|
|
|
|
|
|
CSMWorld::IngredientRefIdAdapter::IngredientRefIdAdapter (const IngredientColumns& columns)
|
|
|
|
|
: InventoryRefIdAdapter<ESM::Ingredient> (UniversalId::Type_Ingredient, columns),
|
|
|
|
|
mColumns(columns)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
QVariant CSMWorld::IngredientRefIdAdapter::getData (const RefIdColumn *column, const RefIdData& data,
|
|
|
|
|
int index) const
|
|
|
|
|
{
|
|
|
|
|
const Record<ESM::Ingredient>& record = static_cast<const Record<ESM::Ingredient>&> (
|
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, UniversalId::Type_Ingredient)));
|
|
|
|
|
|
|
|
|
|
if (column==mColumns.mEffects)
|
|
|
|
|
return true; // to show nested tables in dialogue subview, see IdTree::hasChildren()
|
|
|
|
|
|
|
|
|
|
return InventoryRefIdAdapter<ESM::Ingredient>::getData (column, data, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMWorld::IngredientRefIdAdapter::setData (const RefIdColumn *column, RefIdData& data, int index,
|
|
|
|
|
const QVariant& value) const
|
|
|
|
|
{
|
|
|
|
|
InventoryRefIdAdapter<ESM::Ingredient>::setData (column, data, index, value);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSMWorld::IngredEffectRefIdAdapter::IngredEffectRefIdAdapter()
|
|
|
|
|
: mType(UniversalId::Type_Ingredient)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
CSMWorld::IngredEffectRefIdAdapter::~IngredEffectRefIdAdapter()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void CSMWorld::IngredEffectRefIdAdapter::addNestedRow (const RefIdColumn *column,
|
|
|
|
|
RefIdData& data, int index, int position) const
|
|
|
|
|
{
|
|
|
|
|
// Do nothing, this table cannot be changed by the user
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMWorld::IngredEffectRefIdAdapter::removeNestedRow (const RefIdColumn *column,
|
|
|
|
|
RefIdData& data, int index, int rowToRemove) const
|
|
|
|
|
{
|
|
|
|
|
// Do nothing, this table cannot be changed by the user
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMWorld::IngredEffectRefIdAdapter::setNestedTable (const RefIdColumn* column,
|
|
|
|
|
RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const
|
|
|
|
|
{
|
|
|
|
|
Record<ESM::Ingredient>& record =
|
|
|
|
|
static_cast<Record<ESM::Ingredient>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
|
ESM::Ingredient ingredient = record.get();
|
|
|
|
|
|
|
|
|
|
ingredient.mData =
|
|
|
|
|
static_cast<const NestedTableWrapper<std::vector<typename ESM::Ingredient::IRDTstruct> >&>(nestedTable).mNestedTable.at(0);
|
|
|
|
|
|
|
|
|
|
record.setModified (ingredient);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSMWorld::NestedTableWrapperBase* CSMWorld::IngredEffectRefIdAdapter::nestedTable (const RefIdColumn* column,
|
|
|
|
|
const RefIdData& data, int index) const
|
|
|
|
|
{
|
|
|
|
|
const Record<ESM::Ingredient>& record =
|
|
|
|
|
static_cast<const Record<ESM::Ingredient>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
|
|
|
|
|
|
// return the whole struct
|
|
|
|
|
std::vector<typename ESM::Ingredient::IRDTstruct> wrap;
|
|
|
|
|
wrap.push_back(record.get().mData);
|
|
|
|
|
|
|
|
|
|
// deleted by dtor of NestedTableStoring
|
|
|
|
|
return new NestedTableWrapper<std::vector<typename ESM::Ingredient::IRDTstruct> >(wrap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant CSMWorld::IngredEffectRefIdAdapter::getNestedData (const RefIdColumn *column,
|
|
|
|
|
const RefIdData& data, int index, int subRowIndex, int subColIndex) const
|
|
|
|
|
{
|
|
|
|
|
const Record<ESM::Ingredient>& record =
|
|
|
|
|
static_cast<const Record<ESM::Ingredient>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
|
|
|
|
|
|
if (subRowIndex < 0 || subRowIndex >= 4)
|
|
|
|
|
throw std::runtime_error ("index out of range");
|
|
|
|
|
|
|
|
|
|
switch (subColIndex)
|
|
|
|
|
{
|
|
|
|
|
case 0: return record.get().mData.mEffectID[subRowIndex];
|
|
|
|
|
case 1: return record.get().mData.mSkills[subRowIndex];
|
|
|
|
|
case 2: return record.get().mData.mAttributes[subRowIndex];
|
|
|
|
|
default:
|
|
|
|
|
throw std::runtime_error("Trying to access non-existing column in the nested table!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMWorld::IngredEffectRefIdAdapter::setNestedData (const RefIdColumn *column,
|
|
|
|
|
RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const
|
|
|
|
|
{
|
|
|
|
|
Record<ESM::Ingredient>& record =
|
|
|
|
|
static_cast<Record<ESM::Ingredient>&> (data.getRecord (RefIdData::LocalIndex (row, mType)));
|
|
|
|
|
ESM::Ingredient ingredient = record.get();
|
|
|
|
|
|
|
|
|
|
if (subRowIndex < 0 || subRowIndex >= 4)
|
|
|
|
|
throw std::runtime_error ("index out of range");
|
|
|
|
|
|
|
|
|
|
switch(subColIndex)
|
|
|
|
|
{
|
|
|
|
|
case 0: ingredient.mData.mEffectID[subRowIndex] = value.toInt(); break;
|
|
|
|
|
case 1: ingredient.mData.mSkills[subRowIndex] = value.toInt(); break;
|
|
|
|
|
case 2: ingredient.mData.mAttributes[subRowIndex] = value.toInt(); break;
|
|
|
|
|
default:
|
|
|
|
|
throw std::runtime_error("Trying to access non-existing column in the nested table!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
record.setModified (ingredient);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int CSMWorld::IngredEffectRefIdAdapter::getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const
|
|
|
|
|
{
|
|
|
|
|
return 3; // effect, skill, attribute
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int CSMWorld::IngredEffectRefIdAdapter::getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const
|
|
|
|
|
{
|
|
|
|
|
return 4; // up to 4 effects
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSMWorld::ApparatusRefIdAdapter::ApparatusRefIdAdapter (const InventoryColumns& columns,
|
|
|
|
|
const RefIdColumn *type, const RefIdColumn *quality)
|
|
|
|
|
: InventoryRefIdAdapter<ESM::Apparatus> (UniversalId::Type_Apparatus, columns),
|
|
|
|
|