2013-05-11 17:01:16 +02:00
|
|
|
#ifndef CSM_WOLRD_REFIDADAPTER_H
|
2013-05-06 14:11:55 +02:00
|
|
|
#define CSM_WOLRD_REFIDADAPTER_H
|
|
|
|
|
2022-10-06 19:39:46 +02:00
|
|
|
#include <components/esm/refid.hpp>
|
2022-10-18 09:26:55 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2014-07-22 10:27:45 +02:00
|
|
|
|
2014-07-23 20:33:52 +02:00
|
|
|
/*! \brief
|
2015-03-30 11:53:33 +11:00
|
|
|
* Adapters acts as indirection layer, abstracting details of the record types (in the wrappers) from the higher levels
|
2014-07-23 20:33:52 +02:00
|
|
|
* of model. Please notice that nested adaptor uses helper classes for actually performing any actions. Different record
|
|
|
|
* types require different helpers (needs to be created in the subclass and then fetched via member function).
|
2015-04-09 19:33:42 +10:00
|
|
|
*
|
2016-12-14 22:11:22 +01:00
|
|
|
* Important point: don't forget to make sure that getData on the nestedColumn returns true (otherwise code will not
|
|
|
|
* treat the index pointing to the column as having children!
|
2014-07-23 20:33:52 +02:00
|
|
|
*/
|
|
|
|
|
2013-05-06 14:11:55 +02:00
|
|
|
class QVariant;
|
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class RefIdColumn;
|
|
|
|
class RefIdData;
|
2015-03-14 12:42:46 +11:00
|
|
|
struct RecordBase;
|
2015-04-09 20:53:41 +10:00
|
|
|
struct NestedTableWrapperBase;
|
2013-05-06 14:11:55 +02:00
|
|
|
|
|
|
|
class RefIdAdapter
|
|
|
|
{
|
|
|
|
// not implemented
|
|
|
|
RefIdAdapter(const RefIdAdapter&);
|
|
|
|
RefIdAdapter& operator=(const RefIdAdapter&);
|
|
|
|
|
|
|
|
public:
|
|
|
|
RefIdAdapter();
|
|
|
|
|
|
|
|
virtual ~RefIdAdapter();
|
|
|
|
|
|
|
|
virtual QVariant getData(const RefIdColumn* column, const RefIdData& data, int idnex) const = 0;
|
2014-07-23 20:33:52 +02:00
|
|
|
///< If called on the nest column, should return QVariant(true).
|
2013-05-06 14:11:55 +02:00
|
|
|
|
2013-05-07 14:19:02 +02:00
|
|
|
virtual void setData(const RefIdColumn* column, RefIdData& data, int index, const QVariant& value) const = 0;
|
2014-07-23 20:33:52 +02:00
|
|
|
///< If the data type does not match an exception is thrown.
|
2013-05-07 14:19:02 +02:00
|
|
|
|
2022-10-06 19:39:46 +02:00
|
|
|
virtual ESM::RefId getId(const RecordBase& record) const = 0;
|
2013-05-06 14:11:55 +02:00
|
|
|
|
2015-04-12 18:29:42 +10:00
|
|
|
virtual void setId(RecordBase& record, const std::string& id) = 0; // used by RefIdCollection::cloneRecord()
|
2013-05-06 14:11:55 +02:00
|
|
|
};
|
2014-06-09 10:35:39 +02:00
|
|
|
|
2014-07-22 10:27:45 +02:00
|
|
|
class NestedRefIdAdapterBase
|
2014-06-09 10:35:39 +02:00
|
|
|
{
|
|
|
|
public:
|
2014-07-22 10:27:45 +02:00
|
|
|
NestedRefIdAdapterBase();
|
2014-06-09 10:35:39 +02:00
|
|
|
|
2014-07-22 10:27:45 +02:00
|
|
|
virtual ~NestedRefIdAdapterBase();
|
2014-07-18 18:26:22 +02:00
|
|
|
|
2015-04-12 18:29:42 +10:00
|
|
|
virtual void setNestedData(const RefIdColumn* column, RefIdData& data, int row, const QVariant& value,
|
|
|
|
int subRowIndex, int subColIndex) const = 0;
|
2014-06-09 10:35:39 +02:00
|
|
|
|
2015-04-12 18:29:42 +10:00
|
|
|
virtual QVariant getNestedData(
|
|
|
|
const RefIdColumn* column, const RefIdData& data, int index, int subRowIndex, int subColIndex) const = 0;
|
2014-06-09 10:35:39 +02:00
|
|
|
|
2014-06-17 11:49:35 +02:00
|
|
|
virtual int getNestedColumnsCount(const RefIdColumn* column, const RefIdData& data) const = 0;
|
2014-05-27 14:01:15 +02:00
|
|
|
|
2014-06-17 11:49:35 +02:00
|
|
|
virtual int getNestedRowsCount(const RefIdColumn* column, const RefIdData& data, int index) const = 0;
|
2014-06-24 10:22:42 +02:00
|
|
|
|
2015-04-12 18:29:42 +10:00
|
|
|
virtual void removeNestedRow(const RefIdColumn* column, RefIdData& data, int index, int rowToRemove) const = 0;
|
2014-07-18 18:26:22 +02:00
|
|
|
|
2015-04-12 18:29:42 +10:00
|
|
|
virtual void addNestedRow(const RefIdColumn* column, RefIdData& data, int index, int position) const = 0;
|
2014-07-18 18:26:22 +02:00
|
|
|
|
2015-04-12 18:29:42 +10:00
|
|
|
virtual void setNestedTable(
|
|
|
|
const RefIdColumn* column, RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) const = 0;
|
2014-07-18 18:26:22 +02:00
|
|
|
|
2015-04-12 18:29:42 +10:00
|
|
|
virtual NestedTableWrapperBase* nestedTable(
|
|
|
|
const RefIdColumn* column, const RefIdData& data, int index) const = 0;
|
2014-06-09 10:35:39 +02:00
|
|
|
};
|
2013-05-06 14:11:55 +02:00
|
|
|
}
|
|
|
|
|
2014-06-09 10:35:39 +02:00
|
|
|
#endif
|