mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +00:00
added new Role for table headers (Role_Display)
This commit is contained in:
parent
5c007cd527
commit
b7b51f24d6
4 changed files with 24 additions and 10 deletions
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
#include "columnbase.hpp"
|
#include "columnbase.hpp"
|
||||||
|
|
||||||
CSMWorld::ColumnBase::ColumnBase (const std::string& title, int flags)
|
CSMWorld::ColumnBase::ColumnBase (const std::string& title, Display displayType, int flags)
|
||||||
: mTitle (title), mFlags (flags)
|
: mTitle (title), mDisplayType (displayType), mFlags (flags)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSMWorld::ColumnBase::~ColumnBase() {}
|
CSMWorld::ColumnBase::~ColumnBase() {}
|
||||||
|
|
|
@ -14,7 +14,8 @@ namespace CSMWorld
|
||||||
{
|
{
|
||||||
enum Roles
|
enum Roles
|
||||||
{
|
{
|
||||||
Role_Flags = Qt::UserRole
|
Role_Flags = Qt::UserRole,
|
||||||
|
Role_Display = Qt::UserRole+1
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Flags
|
enum Flags
|
||||||
|
@ -23,10 +24,18 @@ namespace CSMWorld
|
||||||
Flag_Dialogue = 2 // column should be displayed in dialogue view
|
Flag_Dialogue = 2 // column should be displayed in dialogue view
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Display
|
||||||
|
{
|
||||||
|
Display_String,
|
||||||
|
Display_Integer,
|
||||||
|
Display_Float
|
||||||
|
};
|
||||||
|
|
||||||
std::string mTitle;
|
std::string mTitle;
|
||||||
int mFlags;
|
int mFlags;
|
||||||
|
Display mDisplayType;
|
||||||
|
|
||||||
ColumnBase (const std::string& title, int flag);
|
ColumnBase (const std::string& title, Display displayType, int flag);
|
||||||
|
|
||||||
virtual ~ColumnBase();
|
virtual ~ColumnBase();
|
||||||
|
|
||||||
|
@ -34,6 +43,7 @@ namespace CSMWorld
|
||||||
|
|
||||||
virtual bool isUserEditable() const;
|
virtual bool isUserEditable() const;
|
||||||
///< Can this column be edited directly by the user?
|
///< Can this column be edited directly by the user?
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ESXRecordT>
|
template<typename ESXRecordT>
|
||||||
|
@ -42,8 +52,8 @@ namespace CSMWorld
|
||||||
std::string mTitle;
|
std::string mTitle;
|
||||||
int mFlags;
|
int mFlags;
|
||||||
|
|
||||||
Column (const std::string& title, int flags = Flag_Table | Flag_Dialogue)
|
Column (const std::string& title, Display displayType, int flags = Flag_Table | Flag_Dialogue)
|
||||||
: ColumnBase (title, flags) {}
|
: ColumnBase (title, displayType, flags) {}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const = 0;
|
virtual QVariant get (const Record<ESXRecordT>& record) const = 0;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace CSMWorld
|
||||||
template<typename ESXRecordT>
|
template<typename ESXRecordT>
|
||||||
struct FloatValueColumn : public Column<ESXRecordT>
|
struct FloatValueColumn : public Column<ESXRecordT>
|
||||||
{
|
{
|
||||||
FloatValueColumn() : Column<ESXRecordT> ("Value") {}
|
FloatValueColumn() : Column<ESXRecordT> ("Value", ColumnBase::Display_Float) {}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ namespace CSMWorld
|
||||||
template<typename ESXRecordT>
|
template<typename ESXRecordT>
|
||||||
struct StringIdColumn : public Column<ESXRecordT>
|
struct StringIdColumn : public Column<ESXRecordT>
|
||||||
{
|
{
|
||||||
StringIdColumn() : Column<ESXRecordT> ("ID") {}
|
StringIdColumn() : Column<ESXRecordT> ("ID", ColumnBase::Display_String) {}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ namespace CSMWorld
|
||||||
template<typename ESXRecordT>
|
template<typename ESXRecordT>
|
||||||
struct RecordStateColumn : public Column<ESXRecordT>
|
struct RecordStateColumn : public Column<ESXRecordT>
|
||||||
{
|
{
|
||||||
RecordStateColumn() : Column<ESXRecordT> ("*") {}
|
RecordStateColumn() : Column<ESXRecordT> ("*", ColumnBase::Display_Integer) {}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,8 @@ namespace CSMWorld
|
||||||
{
|
{
|
||||||
int mType;
|
int mType;
|
||||||
|
|
||||||
FixedRecordTypeColumn (int type) : Column<ESXRecordT> ("Type", 0), mType (type) {}
|
FixedRecordTypeColumn (int type)
|
||||||
|
: Column<ESXRecordT> ("Type", ColumnBase::Display_Integer, 0), mType (type) {}
|
||||||
|
|
||||||
virtual QVariant get (const Record<ESXRecordT>& record) const
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,9 @@ QVariant CSMWorld::IdTable::headerData (int section, Qt::Orientation orientation
|
||||||
if (role==ColumnBase::Role_Flags)
|
if (role==ColumnBase::Role_Flags)
|
||||||
return mIdCollection->getColumn (section).mFlags;
|
return mIdCollection->getColumn (section).mFlags;
|
||||||
|
|
||||||
|
if (role==ColumnBase::Role_Display)
|
||||||
|
return mIdCollection->getColumn (section).mDisplayType;
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue