2012-12-16 12:52:23 +01:00
|
|
|
#ifndef CSM_WOLRD_COLUMNBASE_H
|
|
|
|
#define CSM_WOLRD_COLUMNBASE_H
|
|
|
|
|
|
|
|
#include <string>
|
2014-06-19 18:46:09 +02:00
|
|
|
#include <vector>
|
2015-04-02 20:19:15 +11:00
|
|
|
#include <stdexcept>
|
2012-12-16 12:52:23 +01:00
|
|
|
|
|
|
|
#include <Qt>
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
#include "record.hpp"
|
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
struct ColumnBase
|
|
|
|
{
|
|
|
|
enum Roles
|
|
|
|
{
|
2013-01-03 11:20:25 +01:00
|
|
|
Role_Flags = Qt::UserRole,
|
2015-01-16 11:27:17 +01:00
|
|
|
Role_Display = Qt::UserRole+1,
|
2015-04-25 09:39:37 +10:00
|
|
|
Role_ColumnId = Qt::UserRole+2
|
2012-12-16 12:52:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enum Flags
|
|
|
|
{
|
|
|
|
Flag_Table = 1, // column should be displayed in table view
|
2015-04-17 01:27:36 +10:00
|
|
|
Flag_Dialogue = 2, // column should be displayed in dialogue view
|
2015-05-26 13:35:10 +10:00
|
|
|
Flag_Dialogue_List = 4, // column should be diaplyed in dialogue view
|
|
|
|
Flag_Dialogue_Refresh = 8 // refresh dialogue view if this column is modified
|
2012-12-16 12:52:23 +01:00
|
|
|
};
|
|
|
|
|
2013-01-03 11:20:25 +01:00
|
|
|
enum Display
|
|
|
|
{
|
2014-02-20 19:27:51 +01:00
|
|
|
Display_None, //Do not use
|
2013-01-03 11:20:25 +01:00
|
|
|
Display_String,
|
2014-03-10 14:11:49 +01:00
|
|
|
Display_LongString,
|
2014-02-12 09:04:52 +01:00
|
|
|
|
2014-06-20 13:40:54 +02:00
|
|
|
//CONCRETE TYPES STARTS HERE (for drag and drop)
|
2014-02-12 09:04:52 +01:00
|
|
|
Display_Skill,
|
|
|
|
Display_Class,
|
|
|
|
Display_Faction,
|
|
|
|
Display_Race,
|
|
|
|
Display_Sound,
|
|
|
|
Display_Region,
|
|
|
|
Display_Birthsign,
|
|
|
|
Display_Spell,
|
|
|
|
Display_Cell,
|
|
|
|
Display_Referenceable,
|
|
|
|
Display_Activator,
|
|
|
|
Display_Potion,
|
|
|
|
Display_Apparatus,
|
|
|
|
Display_Armor,
|
|
|
|
Display_Book,
|
|
|
|
Display_Clothing,
|
|
|
|
Display_Container,
|
|
|
|
Display_Creature,
|
|
|
|
Display_Door,
|
|
|
|
Display_Ingredient,
|
|
|
|
Display_CreatureLevelledList,
|
|
|
|
Display_ItemLevelledList,
|
|
|
|
Display_Light,
|
|
|
|
Display_Lockpick,
|
|
|
|
Display_Miscellaneous,
|
|
|
|
Display_Npc,
|
|
|
|
Display_Probe,
|
|
|
|
Display_Repair,
|
|
|
|
Display_Static,
|
|
|
|
Display_Weapon,
|
|
|
|
Display_Reference,
|
|
|
|
Display_Filter,
|
|
|
|
Display_Topic,
|
|
|
|
Display_Journal,
|
|
|
|
Display_TopicInfo,
|
|
|
|
Display_JournalInfo,
|
|
|
|
Display_Scene,
|
2014-08-30 10:13:34 +02:00
|
|
|
Display_GlobalVariable,
|
2015-06-03 00:02:53 +03:00
|
|
|
Display_BodyPart,
|
|
|
|
Display_Enchantment,
|
2014-02-12 09:04:52 +01:00
|
|
|
//CONCRETE TYPES ENDS HERE
|
|
|
|
|
2013-01-03 11:20:25 +01:00
|
|
|
Display_Integer,
|
2013-02-08 14:48:38 +01:00
|
|
|
Display_Float,
|
2013-02-17 17:27:25 +01:00
|
|
|
Display_Var,
|
2013-03-05 11:37:13 +01:00
|
|
|
Display_GmstVarType,
|
2013-03-23 13:13:53 +01:00
|
|
|
Display_GlobalVarType,
|
2013-03-24 15:50:29 +01:00
|
|
|
Display_Specialisation,
|
2013-03-26 09:51:39 +01:00
|
|
|
Display_Attribute,
|
2013-04-09 11:53:47 +02:00
|
|
|
Display_Boolean,
|
2013-04-10 20:14:10 +02:00
|
|
|
Display_SpellType,
|
2013-05-13 12:51:27 +02:00
|
|
|
Display_Script,
|
2013-05-14 14:21:30 +02:00
|
|
|
Display_ApparatusType,
|
2013-05-15 11:37:46 +02:00
|
|
|
Display_ArmorType,
|
2013-05-16 16:27:33 +02:00
|
|
|
Display_ClothingType,
|
2013-05-19 14:44:41 +02:00
|
|
|
Display_CreatureType,
|
2013-05-29 06:38:35 -05:00
|
|
|
Display_WeaponType,
|
2013-06-29 08:11:09 -05:00
|
|
|
Display_RecordState,
|
2013-10-20 17:26:09 +02:00
|
|
|
Display_RefRecordType,
|
2013-10-31 12:54:55 +01:00
|
|
|
Display_DialogueType,
|
2013-11-05 11:41:48 +01:00
|
|
|
Display_QuestStatusType,
|
2014-07-01 09:42:56 +02:00
|
|
|
Display_EnchantmentType,
|
2014-07-01 14:28:12 +02:00
|
|
|
Display_BodyPartType,
|
|
|
|
Display_MeshType,
|
2014-07-08 09:08:01 +02:00
|
|
|
Display_Gender,
|
2014-07-08 09:51:17 +02:00
|
|
|
Display_Mesh,
|
|
|
|
Display_Icon,
|
|
|
|
Display_Music,
|
|
|
|
Display_SoundRes,
|
|
|
|
Display_Texture,
|
|
|
|
Display_Video,
|
2014-08-24 13:15:18 +02:00
|
|
|
Display_Colour,
|
2015-04-04 19:55:53 +02:00
|
|
|
Display_ScriptFile,
|
2014-09-25 11:40:45 +02:00
|
|
|
Display_ScriptLines, // console context
|
2014-09-30 12:33:48 +02:00
|
|
|
Display_SoundGeneratorType,
|
2015-03-28 14:48:06 +01:00
|
|
|
Display_School,
|
2015-04-17 13:45:45 +10:00
|
|
|
Display_Id,
|
2015-04-18 07:15:40 +10:00
|
|
|
Display_SkillImpact,
|
2015-04-18 08:09:14 +10:00
|
|
|
Display_EffectRange,
|
|
|
|
Display_EffectId,
|
2015-04-18 08:31:08 +10:00
|
|
|
Display_PartRefType,
|
2015-04-18 09:37:19 +10:00
|
|
|
Display_AiPackageType,
|
|
|
|
Display_YesNo,
|
2015-05-09 21:21:16 +10:00
|
|
|
Display_InfoCondFunc,
|
|
|
|
Display_InfoCondVar,
|
|
|
|
Display_InfoCondComp,
|
2015-05-19 06:56:38 +10:00
|
|
|
Display_RaceSkill,
|
2015-06-26 18:19:00 +02:00
|
|
|
Display_String32,
|
|
|
|
Display_LongString256,
|
2015-04-17 13:45:45 +10:00
|
|
|
|
|
|
|
//top level columns that nest other columns
|
|
|
|
Display_NestedHeader
|
2013-01-03 11:20:25 +01:00
|
|
|
};
|
|
|
|
|
2013-08-07 09:36:05 +02:00
|
|
|
int mColumnId;
|
2012-12-16 12:52:23 +01:00
|
|
|
int mFlags;
|
2013-01-03 11:20:25 +01:00
|
|
|
Display mDisplayType;
|
2012-12-16 12:52:23 +01:00
|
|
|
|
2013-08-07 09:36:05 +02:00
|
|
|
ColumnBase (int columnId, Display displayType, int flag);
|
2012-12-16 12:52:23 +01:00
|
|
|
|
|
|
|
virtual ~ColumnBase();
|
|
|
|
|
|
|
|
virtual bool isEditable() const = 0;
|
|
|
|
|
|
|
|
virtual bool isUserEditable() const;
|
|
|
|
///< Can this column be edited directly by the user?
|
2013-01-03 11:20:25 +01:00
|
|
|
|
2013-08-07 09:36:05 +02:00
|
|
|
virtual std::string getTitle() const;
|
2014-03-08 15:27:43 +01:00
|
|
|
|
|
|
|
virtual int getId() const;
|
2015-03-25 11:56:14 +01:00
|
|
|
|
|
|
|
static bool isId (Display display);
|
|
|
|
|
|
|
|
static bool isText (Display display);
|
|
|
|
|
|
|
|
static bool isScript (Display display);
|
2015-04-09 19:11:19 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
class NestableColumn : public ColumnBase
|
|
|
|
{
|
|
|
|
std::vector<NestableColumn *> mNestedColumns;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
NestableColumn(int columnId, Display displayType, int flag);
|
|
|
|
|
|
|
|
~NestableColumn();
|
|
|
|
|
|
|
|
void addColumn(CSMWorld::NestableColumn *column);
|
|
|
|
|
|
|
|
const ColumnBase& nestedColumn(int subColumn) const;
|
|
|
|
|
|
|
|
bool hasChildren() const;
|
2012-12-16 12:52:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename ESXRecordT>
|
2015-04-09 19:11:19 +10:00
|
|
|
struct Column : public NestableColumn
|
2012-12-16 12:52:23 +01:00
|
|
|
{
|
2013-08-07 09:36:05 +02:00
|
|
|
Column (int columnId, Display displayType, int flags = Flag_Table | Flag_Dialogue)
|
2015-04-09 19:11:19 +10:00
|
|
|
: NestableColumn (columnId, displayType, flags) {}
|
2012-12-16 12:52:23 +01:00
|
|
|
|
|
|
|
virtual QVariant get (const Record<ESXRecordT>& record) const = 0;
|
|
|
|
|
|
|
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
|
|
|
{
|
2013-08-07 09:36:05 +02:00
|
|
|
throw std::logic_error ("Column " + getTitle() + " is not editable");
|
2012-12-16 12:52:23 +01:00
|
|
|
}
|
|
|
|
};
|
2015-04-12 08:52:09 +10:00
|
|
|
|
|
|
|
template<typename ESXRecordT>
|
|
|
|
struct NestedParentColumn : public Column<ESXRecordT>
|
|
|
|
{
|
2015-05-26 13:58:58 +10:00
|
|
|
NestedParentColumn (int id, int flags = ColumnBase::Flag_Dialogue) : Column<ESXRecordT> (id,
|
2015-04-19 13:31:16 +10:00
|
|
|
ColumnBase::Display_NestedHeader, flags)
|
2015-04-12 08:52:09 +10:00
|
|
|
{}
|
|
|
|
|
|
|
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
|
|
|
{
|
|
|
|
return true; // required by IdTree::hasChildren()
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isEditable() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NestedChildColumn : public NestableColumn
|
|
|
|
{
|
2015-05-26 13:35:10 +10:00
|
|
|
NestedChildColumn (int id,
|
2015-05-26 13:58:58 +10:00
|
|
|
Display display, int flags = ColumnBase::Flag_Dialogue, bool isEditable = true);
|
2015-04-12 08:52:09 +10:00
|
|
|
|
|
|
|
virtual bool isEditable() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool mIsEditable;
|
|
|
|
};
|
2012-12-16 12:52:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|