2012-12-16 11:52:23 +00:00
|
|
|
#ifndef CSM_WOLRD_COLUMNBASE_H
|
|
|
|
#define CSM_WOLRD_COLUMNBASE_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <Qt>
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
#include "record.hpp"
|
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
struct ColumnBase
|
|
|
|
{
|
|
|
|
enum Roles
|
|
|
|
{
|
2013-01-03 10:20:25 +00:00
|
|
|
Role_Flags = Qt::UserRole,
|
|
|
|
Role_Display = Qt::UserRole+1
|
2012-12-16 11:52:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum Flags
|
|
|
|
{
|
|
|
|
Flag_Table = 1, // column should be displayed in table view
|
|
|
|
Flag_Dialogue = 2 // column should be displayed in dialogue view
|
|
|
|
};
|
|
|
|
|
2013-01-03 10:20:25 +00:00
|
|
|
enum Display
|
|
|
|
{
|
|
|
|
Display_String,
|
|
|
|
Display_Integer,
|
2013-02-08 13:48:38 +00:00
|
|
|
Display_Float,
|
2013-02-17 16:27:25 +00:00
|
|
|
Display_Var,
|
2013-03-05 10:37:13 +00:00
|
|
|
Display_GmstVarType,
|
2013-03-23 12:13:53 +00:00
|
|
|
Display_GlobalVarType,
|
2013-03-24 14:50:29 +00:00
|
|
|
Display_Specialisation,
|
2013-03-26 08:51:39 +00:00
|
|
|
Display_Attribute,
|
2013-04-09 09:53:47 +00:00
|
|
|
Display_Boolean,
|
|
|
|
Display_SpellType
|
2013-01-03 10:20:25 +00:00
|
|
|
};
|
|
|
|
|
2012-12-16 11:52:23 +00:00
|
|
|
std::string mTitle;
|
|
|
|
int mFlags;
|
2013-01-03 10:20:25 +00:00
|
|
|
Display mDisplayType;
|
2012-12-16 11:52:23 +00:00
|
|
|
|
2013-01-03 10:20:25 +00:00
|
|
|
ColumnBase (const std::string& title, Display displayType, int flag);
|
2012-12-16 11:52:23 +00:00
|
|
|
|
|
|
|
virtual ~ColumnBase();
|
|
|
|
|
|
|
|
virtual bool isEditable() const = 0;
|
|
|
|
|
|
|
|
virtual bool isUserEditable() const;
|
|
|
|
///< Can this column be edited directly by the user?
|
2013-01-03 10:20:25 +00:00
|
|
|
|
2012-12-16 11:52:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename ESXRecordT>
|
|
|
|
struct Column : public ColumnBase
|
|
|
|
{
|
|
|
|
std::string mTitle;
|
|
|
|
int mFlags;
|
|
|
|
|
2013-01-03 10:20:25 +00:00
|
|
|
Column (const std::string& title, Display displayType, int flags = Flag_Table | Flag_Dialogue)
|
|
|
|
: ColumnBase (title, displayType, flags) {}
|
2012-12-16 11:52:23 +00:00
|
|
|
|
|
|
|
virtual QVariant get (const Record<ESXRecordT>& record) const = 0;
|
|
|
|
|
|
|
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
|
|
|
{
|
|
|
|
throw std::logic_error ("Column " + mTitle + " is not editable");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|