mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-23 01:53:53 +00:00
57 lines
1.2 KiB
C++
57 lines
1.2 KiB
C++
#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
|
|
{
|
|
Role_Flags = Qt::UserRole
|
|
};
|
|
|
|
enum Flags
|
|
{
|
|
Flag_Table = 1, // column should be displayed in table view
|
|
Flag_Dialogue = 2 // column should be displayed in dialogue view
|
|
};
|
|
|
|
std::string mTitle;
|
|
int mFlags;
|
|
|
|
ColumnBase (const std::string& title, int flag);
|
|
|
|
virtual ~ColumnBase();
|
|
|
|
virtual bool isEditable() const = 0;
|
|
|
|
virtual bool isUserEditable() const;
|
|
///< Can this column be edited directly by the user?
|
|
};
|
|
|
|
template<typename ESXRecordT>
|
|
struct Column : public ColumnBase
|
|
{
|
|
std::string mTitle;
|
|
int mFlags;
|
|
|
|
Column (const std::string& title, int flags = Flag_Table | Flag_Dialogue)
|
|
: ColumnBase (title, flags) {}
|
|
|
|
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
|