2013-05-11 15:01:16 +00:00
|
|
|
#ifndef CSM_WOLRD_REFIDADAPTERIMP_H
|
|
|
|
#define CSM_WOLRD_REFIDADAPTERIMP_H
|
|
|
|
|
2013-05-14 11:20:59 +00:00
|
|
|
#include <map>
|
|
|
|
|
2013-05-11 15:34:18 +00:00
|
|
|
#include <QVariant>
|
|
|
|
|
2013-05-12 13:50:29 +00:00
|
|
|
#include <components/esm/loadalch.hpp>
|
2015-04-12 08:29:42 +00:00
|
|
|
#include <components/esm/loadench.hpp>
|
2013-05-13 10:51:27 +00:00
|
|
|
#include <components/esm/loadappa.hpp>
|
2013-05-12 13:50:29 +00:00
|
|
|
|
2013-05-11 15:34:18 +00:00
|
|
|
#include "record.hpp"
|
|
|
|
#include "refiddata.hpp"
|
|
|
|
#include "universalid.hpp"
|
2013-05-11 15:01:16 +00:00
|
|
|
#include "refidadapter.hpp"
|
2015-03-30 00:53:33 +00:00
|
|
|
#include "nestedadapters.hpp"
|
2013-05-11 15:01:16 +00:00
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
2015-04-09 10:53:41 +00:00
|
|
|
struct NestedTableWrapperBase;
|
2014-07-18 16:26:22 +00:00
|
|
|
|
2013-05-11 15:34:18 +00:00
|
|
|
struct BaseColumns
|
2013-05-11 15:01:16 +00:00
|
|
|
{
|
2013-05-11 15:34:18 +00:00
|
|
|
const RefIdColumn *mId;
|
|
|
|
const RefIdColumn *mModified;
|
2013-05-11 15:49:38 +00:00
|
|
|
const RefIdColumn *mType;
|
2013-05-11 15:34:18 +00:00
|
|
|
};
|
|
|
|
|
2013-05-11 16:35:48 +00:00
|
|
|
/// \brief Base adapter for all refereceable record types
|
2014-06-09 08:35:39 +00:00
|
|
|
/// Adapters that can handle nested tables, needs to return valid qvariant for parent columns
|
2013-05-11 15:34:18 +00:00
|
|
|
template<typename RecordT>
|
|
|
|
class BaseRefIdAdapter : public RefIdAdapter
|
|
|
|
{
|
|
|
|
UniversalId::Type mType;
|
|
|
|
BaseColumns mBase;
|
2013-05-11 15:01:16 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2013-05-11 15:34:18 +00:00
|
|
|
BaseRefIdAdapter (UniversalId::Type type, const BaseColumns& base);
|
|
|
|
|
|
|
|
virtual std::string getId (const RecordBase& record) const;
|
2014-05-25 13:46:23 +00:00
|
|
|
|
2014-01-20 13:29:47 +00:00
|
|
|
virtual void setId (RecordBase& record, const std::string& id);
|
2013-05-11 15:01:16 +00:00
|
|
|
|
2013-05-11 15:34:18 +00:00
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
2013-05-11 15:01:16 +00:00
|
|
|
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.
|
2013-05-11 16:35:48 +00:00
|
|
|
|
|
|
|
UniversalId::Type getType() const;
|
2013-05-11 15:01:16 +00:00
|
|
|
};
|
2013-05-11 15:34:18 +00:00
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
BaseRefIdAdapter<RecordT>::BaseRefIdAdapter (UniversalId::Type type, const BaseColumns& base)
|
|
|
|
: mType (type), mBase (base)
|
|
|
|
{}
|
|
|
|
|
2014-01-20 13:29:47 +00:00
|
|
|
template<typename RecordT>
|
|
|
|
void BaseRefIdAdapter<RecordT>::setId (RecordBase& record, const std::string& id)
|
|
|
|
{
|
|
|
|
(dynamic_cast<Record<RecordT>&> (record).get().mId) = id;
|
|
|
|
}
|
2014-05-25 13:46:23 +00:00
|
|
|
|
2013-05-11 15:34:18 +00:00
|
|
|
template<typename RecordT>
|
|
|
|
std::string BaseRefIdAdapter<RecordT>::getId (const RecordBase& record) const
|
|
|
|
{
|
|
|
|
return dynamic_cast<const Record<RecordT>&> (record).get().mId;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
QVariant BaseRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data,
|
|
|
|
int index) const
|
|
|
|
{
|
|
|
|
const Record<RecordT>& record = static_cast<const Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
|
|
|
|
if (column==mBase.mId)
|
|
|
|
return QString::fromUtf8 (record.get().mId.c_str());
|
|
|
|
|
|
|
|
if (column==mBase.mModified)
|
|
|
|
{
|
|
|
|
if (record.mState==Record<RecordT>::State_Erased)
|
|
|
|
return static_cast<int> (Record<RecordT>::State_Deleted);
|
|
|
|
|
|
|
|
return static_cast<int> (record.mState);
|
|
|
|
}
|
|
|
|
|
2013-05-11 15:49:38 +00:00
|
|
|
if (column==mBase.mType)
|
|
|
|
return static_cast<int> (mType);
|
|
|
|
|
2013-05-11 15:34:18 +00:00
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
void BaseRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index,
|
|
|
|
const QVariant& value) const
|
|
|
|
{
|
|
|
|
Record<RecordT>& record = static_cast<Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
|
|
|
|
if (column==mBase.mModified)
|
|
|
|
record.mState = static_cast<RecordBase::State> (value.toInt());
|
|
|
|
}
|
2013-05-11 16:35:48 +00:00
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
UniversalId::Type BaseRefIdAdapter<RecordT>::getType() const
|
|
|
|
{
|
|
|
|
return mType;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct ModelColumns : public BaseColumns
|
|
|
|
{
|
|
|
|
const RefIdColumn *mModel;
|
|
|
|
|
|
|
|
ModelColumns (const BaseColumns& base) : BaseColumns (base) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Adapter for IDs with models (all but levelled lists)
|
|
|
|
template<typename RecordT>
|
|
|
|
class ModelRefIdAdapter : public BaseRefIdAdapter<RecordT>
|
|
|
|
{
|
|
|
|
ModelColumns mModel;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ModelRefIdAdapter (UniversalId::Type type, const ModelColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
ModelRefIdAdapter<RecordT>::ModelRefIdAdapter (UniversalId::Type type, const ModelColumns& columns)
|
|
|
|
: BaseRefIdAdapter<RecordT> (type, columns), mModel (columns)
|
|
|
|
{}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
QVariant ModelRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data,
|
|
|
|
int index) const
|
|
|
|
{
|
|
|
|
const Record<RecordT>& record = static_cast<const Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
|
|
|
if (column==mModel.mModel)
|
|
|
|
return QString::fromUtf8 (record.get().mModel.c_str());
|
|
|
|
|
|
|
|
return BaseRefIdAdapter<RecordT>::getData (column, data, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
void ModelRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index,
|
|
|
|
const QVariant& value) const
|
|
|
|
{
|
|
|
|
Record<RecordT>& record = static_cast<Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
2015-03-09 19:51:54 +00:00
|
|
|
RecordT record2 = record.get();
|
2013-05-11 16:35:48 +00:00
|
|
|
if (column==mModel.mModel)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mModel = value.toString().toUtf8().constData();
|
2013-05-11 16:35:48 +00:00
|
|
|
else
|
2015-03-09 19:51:54 +00:00
|
|
|
{
|
2013-05-11 16:35:48 +00:00
|
|
|
BaseRefIdAdapter<RecordT>::setData (column, data, index, value);
|
2015-03-09 19:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
record.setModified(record2);
|
2013-05-11 16:35:48 +00:00
|
|
|
}
|
2013-05-11 16:43:01 +00:00
|
|
|
|
|
|
|
struct NameColumns : public ModelColumns
|
|
|
|
{
|
|
|
|
const RefIdColumn *mName;
|
2013-05-11 16:57:23 +00:00
|
|
|
const RefIdColumn *mScript;
|
2013-05-11 16:43:01 +00:00
|
|
|
|
|
|
|
NameColumns (const ModelColumns& base) : ModelColumns (base) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Adapter for IDs with names (all but levelled lists and statics)
|
|
|
|
template<typename RecordT>
|
|
|
|
class NameRefIdAdapter : public ModelRefIdAdapter<RecordT>
|
|
|
|
{
|
|
|
|
NameColumns mName;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
NameRefIdAdapter (UniversalId::Type type, const NameColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
NameRefIdAdapter<RecordT>::NameRefIdAdapter (UniversalId::Type type, const NameColumns& columns)
|
|
|
|
: ModelRefIdAdapter<RecordT> (type, columns), mName (columns)
|
|
|
|
{}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
QVariant NameRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data,
|
|
|
|
int index) const
|
|
|
|
{
|
|
|
|
const Record<RecordT>& record = static_cast<const Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
|
|
|
if (column==mName.mName)
|
|
|
|
return QString::fromUtf8 (record.get().mName.c_str());
|
|
|
|
|
2013-05-11 16:57:23 +00:00
|
|
|
if (column==mName.mScript)
|
|
|
|
return QString::fromUtf8 (record.get().mScript.c_str());
|
|
|
|
|
2013-05-11 16:43:01 +00:00
|
|
|
return ModelRefIdAdapter<RecordT>::getData (column, data, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
void NameRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index,
|
|
|
|
const QVariant& value) const
|
|
|
|
{
|
|
|
|
Record<RecordT>& record = static_cast<Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
2015-03-09 19:51:54 +00:00
|
|
|
RecordT record2 = record.get();
|
2013-05-11 16:43:01 +00:00
|
|
|
if (column==mName.mName)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mName = value.toString().toUtf8().constData();
|
2013-05-11 16:57:23 +00:00
|
|
|
else if (column==mName.mScript)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mScript = value.toString().toUtf8().constData();
|
2013-05-11 16:43:01 +00:00
|
|
|
else
|
2015-03-09 19:51:54 +00:00
|
|
|
{
|
2013-05-11 16:43:01 +00:00
|
|
|
ModelRefIdAdapter<RecordT>::setData (column, data, index, value);
|
2015-03-09 19:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
record.setModified(record2);
|
2013-05-11 16:43:01 +00:00
|
|
|
}
|
2013-05-11 17:21:16 +00:00
|
|
|
|
|
|
|
struct InventoryColumns : public NameColumns
|
|
|
|
{
|
|
|
|
const RefIdColumn *mIcon;
|
|
|
|
const RefIdColumn *mWeight;
|
|
|
|
const RefIdColumn *mValue;
|
|
|
|
|
|
|
|
InventoryColumns (const NameColumns& base) : NameColumns (base) {}
|
|
|
|
};
|
|
|
|
|
2013-05-13 11:11:43 +00:00
|
|
|
/// \brief Adapter for IDs that can go into an inventory
|
2013-05-11 17:21:16 +00:00
|
|
|
template<typename RecordT>
|
|
|
|
class InventoryRefIdAdapter : public NameRefIdAdapter<RecordT>
|
|
|
|
{
|
2013-05-13 11:11:43 +00:00
|
|
|
InventoryColumns mInventory;
|
2013-05-11 17:21:16 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
InventoryRefIdAdapter (UniversalId::Type type, const InventoryColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
InventoryRefIdAdapter<RecordT>::InventoryRefIdAdapter (UniversalId::Type type,
|
|
|
|
const InventoryColumns& columns)
|
2013-05-13 11:11:43 +00:00
|
|
|
: NameRefIdAdapter<RecordT> (type, columns), mInventory (columns)
|
2013-05-11 17:21:16 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
QVariant InventoryRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data,
|
|
|
|
int index) const
|
|
|
|
{
|
|
|
|
const Record<RecordT>& record = static_cast<const Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
2013-05-13 11:11:43 +00:00
|
|
|
if (column==mInventory.mIcon)
|
2013-05-11 17:21:16 +00:00
|
|
|
return QString::fromUtf8 (record.get().mIcon.c_str());
|
|
|
|
|
2013-05-13 11:11:43 +00:00
|
|
|
if (column==mInventory.mWeight)
|
2013-05-11 17:21:16 +00:00
|
|
|
return record.get().mData.mWeight;
|
|
|
|
|
2013-05-13 11:11:43 +00:00
|
|
|
if (column==mInventory.mValue)
|
2013-05-11 17:21:16 +00:00
|
|
|
return record.get().mData.mValue;
|
|
|
|
|
|
|
|
return NameRefIdAdapter<RecordT>::getData (column, data, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
void InventoryRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index,
|
|
|
|
const QVariant& value) const
|
|
|
|
{
|
|
|
|
Record<RecordT>& record = static_cast<Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
2015-03-09 19:51:54 +00:00
|
|
|
RecordT record2 = record.get();
|
2013-05-13 11:11:43 +00:00
|
|
|
if (column==mInventory.mIcon)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mIcon = value.toString().toUtf8().constData();
|
2013-05-13 11:11:43 +00:00
|
|
|
else if (column==mInventory.mWeight)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mData.mWeight = value.toFloat();
|
2013-05-13 11:11:43 +00:00
|
|
|
else if (column==mInventory.mValue)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mData.mValue = value.toInt();
|
2013-05-11 17:21:16 +00:00
|
|
|
else
|
2015-03-09 19:51:54 +00:00
|
|
|
{
|
2013-05-11 17:21:16 +00:00
|
|
|
NameRefIdAdapter<RecordT>::setData (column, data, index, value);
|
2015-03-09 19:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
record.setModified(record2);
|
2013-05-11 17:21:16 +00:00
|
|
|
}
|
2013-05-12 13:50:29 +00:00
|
|
|
|
2015-04-12 08:29:42 +00:00
|
|
|
struct PotionColumns : public InventoryColumns
|
|
|
|
{
|
|
|
|
const RefIdColumn *mEffects;
|
|
|
|
|
|
|
|
PotionColumns (const InventoryColumns& columns);
|
|
|
|
};
|
|
|
|
|
2013-05-12 13:50:29 +00:00
|
|
|
class PotionRefIdAdapter : public InventoryRefIdAdapter<ESM::Potion>
|
|
|
|
{
|
2015-04-12 08:29:42 +00:00
|
|
|
PotionColumns mColumns;
|
2013-05-12 13:50:29 +00:00
|
|
|
const RefIdColumn *mAutoCalc;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2015-04-12 08:29:42 +00:00
|
|
|
PotionRefIdAdapter (const PotionColumns& columns, const RefIdColumn *autoCalc);
|
2013-05-12 13:50:29 +00:00
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2013-05-13 10:51:27 +00:00
|
|
|
|
2013-05-13 11:11:43 +00:00
|
|
|
struct EnchantableColumns : public InventoryColumns
|
|
|
|
{
|
|
|
|
const RefIdColumn *mEnchantment;
|
|
|
|
const RefIdColumn *mEnchantmentPoints;
|
|
|
|
|
|
|
|
EnchantableColumns (const InventoryColumns& base) : InventoryColumns (base) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Adapter for enchantable IDs
|
|
|
|
template<typename RecordT>
|
|
|
|
class EnchantableRefIdAdapter : public InventoryRefIdAdapter<RecordT>
|
|
|
|
{
|
|
|
|
EnchantableColumns mEnchantable;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
EnchantableRefIdAdapter (UniversalId::Type type, const EnchantableColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
EnchantableRefIdAdapter<RecordT>::EnchantableRefIdAdapter (UniversalId::Type type,
|
|
|
|
const EnchantableColumns& columns)
|
|
|
|
: InventoryRefIdAdapter<RecordT> (type, columns), mEnchantable (columns)
|
|
|
|
{}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
QVariant EnchantableRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data,
|
|
|
|
int index) const
|
|
|
|
{
|
|
|
|
const Record<RecordT>& record = static_cast<const Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
|
|
|
if (column==mEnchantable.mEnchantment)
|
|
|
|
return QString::fromUtf8 (record.get().mEnchant.c_str());
|
|
|
|
|
|
|
|
if (column==mEnchantable.mEnchantmentPoints)
|
|
|
|
return static_cast<int> (record.get().mData.mEnchant);
|
|
|
|
|
|
|
|
return InventoryRefIdAdapter<RecordT>::getData (column, data, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
void EnchantableRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data,
|
|
|
|
int index, const QVariant& value) const
|
|
|
|
{
|
|
|
|
Record<RecordT>& record = static_cast<Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
2015-03-09 19:51:54 +00:00
|
|
|
RecordT record2 = record.get();
|
2013-05-13 11:11:43 +00:00
|
|
|
if (column==mEnchantable.mEnchantment)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mEnchant = value.toString().toUtf8().constData();
|
2013-05-13 11:11:43 +00:00
|
|
|
else if (column==mEnchantable.mEnchantmentPoints)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mData.mEnchant = value.toInt();
|
2013-05-13 11:11:43 +00:00
|
|
|
else
|
2015-03-09 19:51:54 +00:00
|
|
|
{
|
2013-05-13 11:11:43 +00:00
|
|
|
InventoryRefIdAdapter<RecordT>::setData (column, data, index, value);
|
2015-03-09 19:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
record.setModified(record2);
|
2013-05-13 11:11:43 +00:00
|
|
|
}
|
|
|
|
|
2013-05-13 11:36:24 +00:00
|
|
|
struct ToolColumns : public InventoryColumns
|
|
|
|
{
|
|
|
|
const RefIdColumn *mQuality;
|
|
|
|
const RefIdColumn *mUses;
|
|
|
|
|
|
|
|
ToolColumns (const InventoryColumns& base) : InventoryColumns (base) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Adapter for tools with limited uses IDs (lockpick, repair, probes)
|
|
|
|
template<typename RecordT>
|
|
|
|
class ToolRefIdAdapter : public InventoryRefIdAdapter<RecordT>
|
|
|
|
{
|
|
|
|
ToolColumns mTools;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ToolRefIdAdapter (UniversalId::Type type, const ToolColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
ToolRefIdAdapter<RecordT>::ToolRefIdAdapter (UniversalId::Type type, const ToolColumns& columns)
|
|
|
|
: InventoryRefIdAdapter<RecordT> (type, columns), mTools (columns)
|
|
|
|
{}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
QVariant ToolRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data,
|
|
|
|
int index) const
|
|
|
|
{
|
|
|
|
const Record<RecordT>& record = static_cast<const Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
|
|
|
if (column==mTools.mQuality)
|
|
|
|
return record.get().mData.mQuality;
|
|
|
|
|
|
|
|
if (column==mTools.mUses)
|
|
|
|
return record.get().mData.mUses;
|
|
|
|
|
|
|
|
return InventoryRefIdAdapter<RecordT>::getData (column, data, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
void ToolRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data,
|
|
|
|
int index, const QVariant& value) const
|
|
|
|
{
|
|
|
|
Record<RecordT>& record = static_cast<Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
2015-03-09 19:51:54 +00:00
|
|
|
RecordT record2 = record.get();
|
2013-05-13 11:36:24 +00:00
|
|
|
if (column==mTools.mQuality)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mData.mQuality = value.toFloat();
|
2013-05-13 11:36:24 +00:00
|
|
|
else if (column==mTools.mUses)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mData.mUses = value.toInt();
|
2013-05-13 11:36:24 +00:00
|
|
|
else
|
2015-03-09 19:51:54 +00:00
|
|
|
{
|
2013-05-13 11:36:24 +00:00
|
|
|
InventoryRefIdAdapter<RecordT>::setData (column, data, index, value);
|
2015-03-09 19:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
record.setModified(record2);
|
2013-05-13 11:36:24 +00:00
|
|
|
}
|
|
|
|
|
2013-05-14 11:20:59 +00:00
|
|
|
struct ActorColumns : public NameColumns
|
|
|
|
{
|
|
|
|
const RefIdColumn *mHasAi;
|
|
|
|
const RefIdColumn *mHello;
|
|
|
|
const RefIdColumn *mFlee;
|
|
|
|
const RefIdColumn *mFight;
|
|
|
|
const RefIdColumn *mAlarm;
|
2014-07-22 11:08:32 +00:00
|
|
|
const RefIdColumn *mInventory;
|
2014-07-25 09:25:36 +00:00
|
|
|
const RefIdColumn *mSpells;
|
2013-05-14 11:20:59 +00:00
|
|
|
std::map<const RefIdColumn *, unsigned int> mServices;
|
|
|
|
|
|
|
|
ActorColumns (const NameColumns& base) : NameColumns (base) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// \brief Adapter for actor IDs (handles common AI functionality)
|
|
|
|
template<typename RecordT>
|
2014-07-22 11:08:32 +00:00
|
|
|
class ActorRefIdAdapter : public NameRefIdAdapter<RecordT>, public NestedRefIdAdapter
|
2013-05-14 11:20:59 +00:00
|
|
|
{
|
|
|
|
ActorColumns mActors;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ActorRefIdAdapter (UniversalId::Type type, const ActorColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
ActorRefIdAdapter<RecordT>::ActorRefIdAdapter (UniversalId::Type type,
|
|
|
|
const ActorColumns& columns)
|
|
|
|
: NameRefIdAdapter<RecordT> (type, columns), mActors (columns)
|
2014-07-22 11:08:32 +00:00
|
|
|
{
|
|
|
|
std::vector<std::pair <const RefIdColumn*, HelperBase*> > assoCol;
|
|
|
|
|
|
|
|
assoCol.push_back(std::make_pair(mActors.mInventory, new InventoryHelper<RecordT>(type)));
|
2014-07-25 10:09:25 +00:00
|
|
|
assoCol.push_back(std::make_pair(mActors.mSpells, new SpellsHelper<RecordT>(type)));
|
2015-03-30 00:53:33 +00:00
|
|
|
|
2014-07-22 11:08:32 +00:00
|
|
|
setAssocColumns(assoCol);
|
|
|
|
}
|
2013-05-14 11:20:59 +00:00
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
QVariant ActorRefIdAdapter<RecordT>::getData (const RefIdColumn *column, const RefIdData& data,
|
|
|
|
int index) const
|
|
|
|
{
|
|
|
|
const Record<RecordT>& record = static_cast<const Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
|
|
|
if (column==mActors.mHasAi)
|
|
|
|
return record.get().mHasAI!=0;
|
|
|
|
|
|
|
|
if (column==mActors.mHello)
|
|
|
|
return record.get().mAiData.mHello;
|
|
|
|
|
|
|
|
if (column==mActors.mFlee)
|
|
|
|
return record.get().mAiData.mFlee;
|
|
|
|
|
|
|
|
if (column==mActors.mFight)
|
|
|
|
return record.get().mAiData.mFight;
|
|
|
|
|
|
|
|
if (column==mActors.mAlarm)
|
|
|
|
return record.get().mAiData.mAlarm;
|
|
|
|
|
2014-07-22 11:08:32 +00:00
|
|
|
if (column==mActors.mInventory)
|
2015-04-09 09:33:42 +00:00
|
|
|
return true; // required by IdTree::hasChildren()
|
2014-07-22 11:08:32 +00:00
|
|
|
|
2014-07-25 10:09:25 +00:00
|
|
|
if (column==mActors.mSpells)
|
2015-04-09 09:33:42 +00:00
|
|
|
return true; // required by IdTree::hasChildren()
|
2015-03-30 00:53:33 +00:00
|
|
|
|
2013-05-14 11:20:59 +00:00
|
|
|
std::map<const RefIdColumn *, unsigned int>::const_iterator iter =
|
|
|
|
mActors.mServices.find (column);
|
|
|
|
|
|
|
|
if (iter!=mActors.mServices.end())
|
|
|
|
return (record.get().mAiData.mServices & iter->second)!=0;
|
|
|
|
|
|
|
|
return NameRefIdAdapter<RecordT>::getData (column, data, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename RecordT>
|
|
|
|
void ActorRefIdAdapter<RecordT>::setData (const RefIdColumn *column, RefIdData& data, int index,
|
|
|
|
const QVariant& value) const
|
|
|
|
{
|
|
|
|
Record<RecordT>& record = static_cast<Record<RecordT>&> (
|
|
|
|
data.getRecord (RefIdData::LocalIndex (index, BaseRefIdAdapter<RecordT>::getType())));
|
|
|
|
|
2015-03-09 19:51:54 +00:00
|
|
|
RecordT record2 = record.get();
|
2013-05-14 11:20:59 +00:00
|
|
|
if (column==mActors.mHasAi)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mHasAI = value.toInt();
|
2013-05-14 11:20:59 +00:00
|
|
|
else if (column==mActors.mHello)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mAiData.mHello = value.toInt();
|
2013-05-14 11:20:59 +00:00
|
|
|
else if (column==mActors.mFlee)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mAiData.mFlee = value.toInt();
|
2013-05-14 11:20:59 +00:00
|
|
|
else if (column==mActors.mFight)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mAiData.mFight = value.toInt();
|
2013-05-14 11:20:59 +00:00
|
|
|
else if (column==mActors.mAlarm)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mAiData.mAlarm = value.toInt();
|
2013-05-14 11:20:59 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
typename std::map<const RefIdColumn *, unsigned int>::const_iterator iter =
|
|
|
|
mActors.mServices.find (column);
|
|
|
|
if (iter!=mActors.mServices.end())
|
|
|
|
{
|
|
|
|
if (value.toInt()!=0)
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mAiData.mServices |= iter->second;
|
2013-05-14 11:20:59 +00:00
|
|
|
else
|
2015-03-09 19:51:54 +00:00
|
|
|
record2.mAiData.mServices &= ~iter->second;
|
2013-05-14 11:20:59 +00:00
|
|
|
}
|
|
|
|
else
|
2015-03-09 19:51:54 +00:00
|
|
|
{
|
2013-05-14 11:20:59 +00:00
|
|
|
NameRefIdAdapter<RecordT>::setData (column, data, index, value);
|
2015-03-09 19:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-14 11:20:59 +00:00
|
|
|
}
|
2015-03-09 19:51:54 +00:00
|
|
|
|
|
|
|
record.setModified(record2);
|
2013-05-14 11:20:59 +00:00
|
|
|
}
|
|
|
|
|
2013-05-13 10:51:27 +00:00
|
|
|
class ApparatusRefIdAdapter : public InventoryRefIdAdapter<ESM::Apparatus>
|
|
|
|
{
|
|
|
|
const RefIdColumn *mType;
|
|
|
|
const RefIdColumn *mQuality;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ApparatusRefIdAdapter (const InventoryColumns& columns, const RefIdColumn *type,
|
|
|
|
const RefIdColumn *quality);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2013-05-14 12:21:30 +00:00
|
|
|
|
|
|
|
class ArmorRefIdAdapter : public EnchantableRefIdAdapter<ESM::Armor>
|
|
|
|
{
|
|
|
|
const RefIdColumn *mType;
|
|
|
|
const RefIdColumn *mHealth;
|
|
|
|
const RefIdColumn *mArmor;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ArmorRefIdAdapter (const EnchantableColumns& columns, const RefIdColumn *type,
|
|
|
|
const RefIdColumn *health, const RefIdColumn *armor);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2013-05-14 12:40:06 +00:00
|
|
|
|
|
|
|
class BookRefIdAdapter : public EnchantableRefIdAdapter<ESM::Book>
|
|
|
|
{
|
|
|
|
const RefIdColumn *mScroll;
|
|
|
|
const RefIdColumn *mSkill;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
BookRefIdAdapter (const EnchantableColumns& columns, const RefIdColumn *scroll,
|
|
|
|
const RefIdColumn *skill);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2013-05-15 09:37:46 +00:00
|
|
|
|
|
|
|
class ClothingRefIdAdapter : public EnchantableRefIdAdapter<ESM::Clothing>
|
|
|
|
{
|
|
|
|
const RefIdColumn *mType;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ClothingRefIdAdapter (const EnchantableColumns& columns, const RefIdColumn *type);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2013-05-15 15:02:34 +00:00
|
|
|
|
2014-06-09 08:35:39 +00:00
|
|
|
class ContainerRefIdAdapter : public NameRefIdAdapter<ESM::Container>, public NestedRefIdAdapter
|
2013-05-15 15:02:34 +00:00
|
|
|
{
|
|
|
|
const RefIdColumn *mWeight;
|
|
|
|
const RefIdColumn *mOrganic;
|
|
|
|
const RefIdColumn *mRespawn;
|
2014-05-25 13:46:23 +00:00
|
|
|
const RefIdColumn *mContent;
|
2015-03-30 00:53:33 +00:00
|
|
|
|
2013-05-15 15:02:34 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
ContainerRefIdAdapter (const NameColumns& columns, const RefIdColumn *weight,
|
2014-06-17 09:49:35 +00:00
|
|
|
const RefIdColumn *organic, const RefIdColumn *respawn, const RefIdColumn *content);
|
2013-05-15 15:02:34 +00:00
|
|
|
|
2014-06-17 09:49:35 +00:00
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index) const;
|
2013-05-15 15:02:34 +00:00
|
|
|
|
|
|
|
virtual void setData (const RefIdColumn *column, RefIdData& data, int index,
|
2014-06-17 09:49:35 +00:00
|
|
|
const QVariant& value) const;
|
2013-05-15 15:02:34 +00:00
|
|
|
///< If the data type does not match an exception is thrown.
|
2013-05-16 14:27:33 +00:00
|
|
|
};
|
2013-05-15 15:02:34 +00:00
|
|
|
|
2013-05-16 14:27:33 +00:00
|
|
|
struct CreatureColumns : public ActorColumns
|
|
|
|
{
|
|
|
|
std::map<const RefIdColumn *, unsigned int> mFlags;
|
|
|
|
const RefIdColumn *mType;
|
|
|
|
const RefIdColumn *mSoul;
|
|
|
|
const RefIdColumn *mScale;
|
|
|
|
const RefIdColumn *mOriginal;
|
2014-06-30 17:51:59 +00:00
|
|
|
const RefIdColumn *mCombat;
|
|
|
|
const RefIdColumn *mMagic;
|
|
|
|
const RefIdColumn *mStealth;
|
2013-05-16 14:27:33 +00:00
|
|
|
|
|
|
|
CreatureColumns (const ActorColumns& actorColumns);
|
|
|
|
};
|
|
|
|
|
|
|
|
class CreatureRefIdAdapter : public ActorRefIdAdapter<ESM::Creature>
|
|
|
|
{
|
|
|
|
CreatureColumns mColumns;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
CreatureRefIdAdapter (const CreatureColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
2013-05-15 15:02:34 +00:00
|
|
|
};
|
2013-05-17 13:10:41 +00:00
|
|
|
|
|
|
|
class DoorRefIdAdapter : public NameRefIdAdapter<ESM::Door>
|
|
|
|
{
|
|
|
|
const RefIdColumn *mOpenSound;
|
|
|
|
const RefIdColumn *mCloseSound;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
DoorRefIdAdapter (const NameColumns& columns, const RefIdColumn *openSound,
|
|
|
|
const RefIdColumn *closeSound);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2013-05-18 16:46:41 +00:00
|
|
|
|
|
|
|
struct LightColumns : public InventoryColumns
|
|
|
|
{
|
|
|
|
const RefIdColumn *mTime;
|
|
|
|
const RefIdColumn *mRadius;
|
|
|
|
const RefIdColumn *mColor;
|
|
|
|
const RefIdColumn *mSound;
|
|
|
|
std::map<const RefIdColumn *, unsigned int> mFlags;
|
|
|
|
|
|
|
|
LightColumns (const InventoryColumns& columns);
|
|
|
|
};
|
|
|
|
|
|
|
|
class LightRefIdAdapter : public InventoryRefIdAdapter<ESM::Light>
|
|
|
|
{
|
|
|
|
LightColumns mColumns;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
LightRefIdAdapter (const LightColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2013-05-18 16:55:23 +00:00
|
|
|
|
|
|
|
class MiscRefIdAdapter : public InventoryRefIdAdapter<ESM::Miscellaneous>
|
|
|
|
{
|
|
|
|
const RefIdColumn *mKey;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
MiscRefIdAdapter (const InventoryColumns& columns, const RefIdColumn *key);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2013-05-19 11:53:47 +00:00
|
|
|
|
|
|
|
struct NpcColumns : public ActorColumns
|
|
|
|
{
|
|
|
|
std::map<const RefIdColumn *, unsigned int> mFlags;
|
|
|
|
const RefIdColumn *mRace;
|
|
|
|
const RefIdColumn *mClass;
|
|
|
|
const RefIdColumn *mFaction;
|
|
|
|
const RefIdColumn *mHair;
|
|
|
|
const RefIdColumn *mHead;
|
2014-07-25 15:11:18 +00:00
|
|
|
const RefIdColumn *mDestinations;
|
2013-05-19 11:53:47 +00:00
|
|
|
|
|
|
|
NpcColumns (const ActorColumns& actorColumns);
|
|
|
|
};
|
|
|
|
|
|
|
|
class NpcRefIdAdapter : public ActorRefIdAdapter<ESM::NPC>
|
|
|
|
{
|
|
|
|
NpcColumns mColumns;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
NpcRefIdAdapter (const NpcColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2013-05-19 12:44:41 +00:00
|
|
|
|
|
|
|
struct WeaponColumns : public EnchantableColumns
|
|
|
|
{
|
|
|
|
const RefIdColumn *mType;
|
|
|
|
const RefIdColumn *mHealth;
|
|
|
|
const RefIdColumn *mSpeed;
|
|
|
|
const RefIdColumn *mReach;
|
|
|
|
const RefIdColumn *mChop[2];
|
|
|
|
const RefIdColumn *mSlash[2];
|
|
|
|
const RefIdColumn *mThrust[2];
|
|
|
|
std::map<const RefIdColumn *, unsigned int> mFlags;
|
|
|
|
|
|
|
|
WeaponColumns (const EnchantableColumns& columns);
|
|
|
|
};
|
|
|
|
|
|
|
|
class WeaponRefIdAdapter : public EnchantableRefIdAdapter<ESM::Weapon>
|
|
|
|
{
|
|
|
|
WeaponColumns mColumns;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
WeaponRefIdAdapter (const WeaponColumns& columns);
|
|
|
|
|
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int index)
|
|
|
|
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.
|
|
|
|
};
|
2015-04-12 08:29:42 +00:00
|
|
|
|
|
|
|
class NestedRefIdAdapterBase;
|
|
|
|
|
|
|
|
template<typename ESXRecordT>
|
|
|
|
class EffectsListAdapter;
|
|
|
|
|
|
|
|
template<typename ESXRecordT>
|
|
|
|
class EffectsRefIdAdapter : public EffectsListAdapter<ESXRecordT>, public NestedRefIdAdapterBase
|
|
|
|
{
|
|
|
|
UniversalId::Type mType;
|
|
|
|
|
|
|
|
// not implemented
|
|
|
|
EffectsRefIdAdapter (const EffectsRefIdAdapter&);
|
|
|
|
EffectsRefIdAdapter& operator= (const EffectsRefIdAdapter&);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
EffectsRefIdAdapter(UniversalId::Type type) :mType(type) {}
|
|
|
|
|
|
|
|
virtual ~EffectsRefIdAdapter() {}
|
|
|
|
|
|
|
|
virtual void addNestedRow (const RefIdColumn *column,
|
|
|
|
RefIdData& data, int index, int position) const
|
|
|
|
{
|
|
|
|
Record<ESXRecordT>& record =
|
|
|
|
static_cast<Record<ESXRecordT>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
EffectsListAdapter<ESXRecordT>::addNestedRow(record, position);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void removeNestedRow (const RefIdColumn *column,
|
|
|
|
RefIdData& data, int index, int rowToRemove) const
|
|
|
|
{
|
|
|
|
Record<ESXRecordT>& record =
|
|
|
|
static_cast<Record<ESXRecordT>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
EffectsListAdapter<ESXRecordT>::removeNestedRow(record, rowToRemove);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setNestedTable (const RefIdColumn* column,
|
|
|
|
RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const
|
|
|
|
{
|
|
|
|
Record<ESXRecordT>& record =
|
|
|
|
static_cast<Record<ESXRecordT>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
EffectsListAdapter<ESXRecordT>::setNestedTable(record, nestedTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual NestedTableWrapperBase* nestedTable (const RefIdColumn* column,
|
|
|
|
const RefIdData& data, int index) const
|
|
|
|
{
|
|
|
|
const Record<ESXRecordT>& record =
|
|
|
|
static_cast<const Record<ESXRecordT>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
return EffectsListAdapter<ESXRecordT>::nestedTable(record);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual QVariant getNestedData (const RefIdColumn *column,
|
|
|
|
const RefIdData& data, int index, int subRowIndex, int subColIndex) const
|
|
|
|
{
|
|
|
|
const Record<ESXRecordT>& record =
|
|
|
|
static_cast<const Record<ESXRecordT>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
return EffectsListAdapter<ESXRecordT>::getNestedData(record, subRowIndex, subColIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setNestedData (const RefIdColumn *column,
|
|
|
|
RefIdData& data, int row, const QVariant& value, int subRowIndex, int subColIndex) const
|
|
|
|
{
|
|
|
|
Record<ESXRecordT>& record =
|
|
|
|
static_cast<Record<ESXRecordT>&> (data.getRecord (RefIdData::LocalIndex (row, mType)));
|
|
|
|
EffectsListAdapter<ESXRecordT>::setNestedData(record, value, subRowIndex, subColIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const
|
|
|
|
{
|
|
|
|
const Record<ESXRecordT> record;
|
|
|
|
return EffectsListAdapter<ESXRecordT>::getNestedColumnsCount(record);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const
|
|
|
|
{
|
|
|
|
const Record<ESXRecordT>& record =
|
|
|
|
static_cast<const Record<ESXRecordT>&> (data.getRecord (RefIdData::LocalIndex (index, mType)));
|
|
|
|
return EffectsListAdapter<ESXRecordT>::getNestedRowsCount(record);
|
|
|
|
}
|
|
|
|
};
|
2013-05-11 15:01:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|