2013-05-11 15:01:16 +00:00
|
|
|
#ifndef CSM_WOLRD_REFIDADAPTER_H
|
2013-05-06 12:11:55 +00:00
|
|
|
#define CSM_WOLRD_REFIDADAPTER_H
|
|
|
|
|
|
|
|
#include <string>
|
2014-07-22 08:27:45 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "nestedadaptors.hpp"
|
2013-05-06 12:11:55 +00:00
|
|
|
|
|
|
|
class QVariant;
|
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
class RefIdColumn;
|
|
|
|
class RefIdData;
|
|
|
|
class RecordBase;
|
2014-07-18 16:26:22 +00:00
|
|
|
class NestedTableWrapperBase;
|
2014-07-22 08:27:45 +00:00
|
|
|
class HelperBase;
|
2013-05-06 12:11:55 +00:00
|
|
|
|
|
|
|
class RefIdAdapter
|
|
|
|
{
|
|
|
|
// not implemented
|
|
|
|
RefIdAdapter (const RefIdAdapter&);
|
|
|
|
RefIdAdapter& operator= (const RefIdAdapter&);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
RefIdAdapter();
|
|
|
|
|
|
|
|
virtual ~RefIdAdapter();
|
|
|
|
|
2013-05-07 12:19:02 +00:00
|
|
|
virtual QVariant getData (const RefIdColumn *column, const RefIdData& data, int idnex)
|
2013-05-06 12:11:55 +00:00
|
|
|
const = 0;
|
2013-05-07 12:19:02 +00:00
|
|
|
|
|
|
|
virtual void setData (const RefIdColumn *column, RefIdData& data, int index,
|
|
|
|
const QVariant& value) const = 0;
|
2013-05-06 12:11:55 +00:00
|
|
|
///< If the data type does not match an exception is thrown.
|
|
|
|
|
|
|
|
virtual std::string getId (const RecordBase& record) const = 0;
|
2014-06-09 08:35:39 +00:00
|
|
|
|
2014-01-20 13:29:47 +00:00
|
|
|
virtual void setId(RecordBase& record, const std::string& id) = 0;
|
2013-05-06 12:11:55 +00:00
|
|
|
};
|
2014-06-09 08:35:39 +00:00
|
|
|
|
2014-07-22 08:27:45 +00:00
|
|
|
class NestedRefIdAdapterBase
|
2014-06-09 08:35:39 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-07-22 08:27:45 +00:00
|
|
|
NestedRefIdAdapterBase();
|
2014-06-09 08:35:39 +00:00
|
|
|
|
2014-07-22 08:27:45 +00:00
|
|
|
virtual ~NestedRefIdAdapterBase();
|
2014-07-18 16:26:22 +00:00
|
|
|
|
2014-06-09 08:35:39 +00:00
|
|
|
virtual void setNestedData (const RefIdColumn *column, RefIdData& data, int row,
|
2014-06-17 09:49:35 +00:00
|
|
|
const QVariant& value, int subRowIndex, int subColIndex) const = 0;
|
2014-06-09 08:35:39 +00:00
|
|
|
|
2014-06-02 18:41:37 +00:00
|
|
|
virtual QVariant getNestedData (const RefIdColumn *column, const RefIdData& data,
|
2014-06-17 12:21:50 +00:00
|
|
|
int index, int subRowIndex, int subColIndex) const = 0;
|
2014-06-09 08:35:39 +00:00
|
|
|
|
2014-06-17 09:49:35 +00:00
|
|
|
virtual int getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const = 0;
|
2014-05-27 12:01:15 +00:00
|
|
|
|
2014-06-17 09:49:35 +00:00
|
|
|
virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const = 0;
|
2014-06-24 08:22:42 +00:00
|
|
|
|
2014-06-24 10:21:40 +00:00
|
|
|
virtual void removeNestedRow (const RefIdColumn *column, RefIdData& data, int index, int rowToRemove) const = 0;
|
2014-07-18 16:26:22 +00:00
|
|
|
|
2014-06-24 17:03:29 +00:00
|
|
|
virtual void addNestedRow (const RefIdColumn *column, RefIdData& data, int index, int position) const = 0;
|
2014-07-18 16:26:22 +00:00
|
|
|
|
|
|
|
virtual void setNestedTable (const RefIdColumn* column, RefIdData& data, int index, const NestedTableWrapperBase& nestedTable) = 0;
|
|
|
|
|
2014-07-20 16:52:35 +00:00
|
|
|
virtual NestedTableWrapperBase* nestedTable (const RefIdColumn* column, const RefIdData& data, int index) const = 0;
|
2014-06-09 08:35:39 +00:00
|
|
|
};
|
2014-07-22 08:27:45 +00:00
|
|
|
|
|
|
|
class NestedRefIdAdapter : public NestedRefIdAdapterBase
|
|
|
|
{
|
|
|
|
std::vector<std::pair <const RefIdColumn*, HelperBase*> > mAssociatedColumns; //basicly, i wanted map, but with pointer key
|
|
|
|
|
|
|
|
public:
|
|
|
|
NestedRefIdAdapter();
|
|
|
|
|
|
|
|
virtual ~NestedRefIdAdapter();
|
|
|
|
|
|
|
|
virtual void setNestedData (const RefIdColumn *column, RefIdData& data, int row,
|
|
|
|
const QVariant& value, int subRowIndex, int subColIndex) const;
|
|
|
|
|
|
|
|
virtual QVariant getNestedData (const RefIdColumn *column, const RefIdData& data,
|
|
|
|
int index, int subRowIndex, int subColIndex) const;
|
|
|
|
|
|
|
|
virtual int getNestedColumnsCount(const RefIdColumn *column, const RefIdData& data) const;
|
|
|
|
|
|
|
|
virtual int getNestedRowsCount(const RefIdColumn *column, const RefIdData& data, int index) const;
|
|
|
|
|
|
|
|
virtual void removeNestedRow (const RefIdColumn *column, RefIdData& data, int index, int rowToRemove) const;
|
|
|
|
|
|
|
|
virtual void addNestedRow (const RefIdColumn *column, RefIdData& data, int index, int position) const;
|
|
|
|
|
|
|
|
virtual void setNestedTable (const RefIdColumn* column, RefIdData& data, int index, const NestedTableWrapperBase& nestedTable);
|
|
|
|
|
|
|
|
virtual NestedTableWrapperBase* nestedTable (const RefIdColumn* column, const RefIdData& data, int index) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void setAssocColumns(const std::vector<std::pair <const RefIdColumn*, HelperBase*> >& assocColumns);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
HelperBase* getHelper(const RefIdColumn *column) const;
|
|
|
|
};
|
2013-05-06 12:11:55 +00:00
|
|
|
}
|
|
|
|
|
2014-06-09 08:35:39 +00:00
|
|
|
#endif
|