2012-11-26 12:29:22 +01:00
|
|
|
#ifndef CSM_WOLRD_COLUMNS_H
|
|
|
|
#define CSM_WOLRD_COLUMNS_H
|
|
|
|
|
2012-12-30 14:01:52 +01:00
|
|
|
#include "columnbase.hpp"
|
2012-11-26 12:29:22 +01:00
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
|
|
|
template<typename ESXRecordT>
|
|
|
|
struct FloatValueColumn : public Column<ESXRecordT>
|
|
|
|
{
|
2013-01-03 11:20:25 +01:00
|
|
|
FloatValueColumn() : Column<ESXRecordT> ("Value", ColumnBase::Display_Float) {}
|
2012-11-26 12:29:22 +01:00
|
|
|
|
|
|
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
|
|
|
{
|
|
|
|
return record.get().mValue;
|
|
|
|
}
|
2012-11-29 14:45:34 +01:00
|
|
|
|
|
|
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
|
|
|
{
|
2013-02-09 15:25:50 +01:00
|
|
|
ESXRecordT record2 = record.get();
|
|
|
|
record2.mValue = data.toFloat();
|
|
|
|
record.setModified (record2);
|
2012-11-29 14:45:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isEditable() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-26 12:29:22 +01:00
|
|
|
};
|
|
|
|
|
2012-11-29 18:56:28 +01:00
|
|
|
template<typename ESXRecordT>
|
|
|
|
struct StringIdColumn : public Column<ESXRecordT>
|
|
|
|
{
|
2013-01-03 11:20:25 +01:00
|
|
|
StringIdColumn() : Column<ESXRecordT> ("ID", ColumnBase::Display_String) {}
|
2012-11-29 18:56:28 +01:00
|
|
|
|
|
|
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
|
|
|
{
|
|
|
|
return record.get().mId.c_str();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isEditable() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-12-01 13:42:12 +01:00
|
|
|
template<typename ESXRecordT>
|
|
|
|
struct RecordStateColumn : public Column<ESXRecordT>
|
|
|
|
{
|
2013-01-03 11:20:25 +01:00
|
|
|
RecordStateColumn() : Column<ESXRecordT> ("*", ColumnBase::Display_Integer) {}
|
2012-12-01 13:42:12 +01:00
|
|
|
|
|
|
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
|
|
|
{
|
2012-12-03 13:56:02 +01:00
|
|
|
if (record.mState==Record<ESXRecordT>::State_Erased)
|
|
|
|
return static_cast<int> (Record<ESXRecordT>::State_Deleted);
|
|
|
|
|
2012-12-01 13:42:12 +01:00
|
|
|
return static_cast<int> (record.mState);
|
|
|
|
}
|
|
|
|
|
2012-12-06 14:56:04 +01:00
|
|
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
|
|
|
{
|
|
|
|
record.mState = static_cast<RecordBase::State> (data.toInt());
|
|
|
|
}
|
|
|
|
|
2012-12-01 13:42:12 +01:00
|
|
|
virtual bool isEditable() const
|
|
|
|
{
|
2012-12-06 14:56:04 +01:00
|
|
|
return true;
|
2012-12-01 13:42:12 +01:00
|
|
|
}
|
2012-12-13 13:52:26 +01:00
|
|
|
|
|
|
|
virtual bool isUserEditable() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-12-01 13:42:12 +01:00
|
|
|
};
|
2012-12-13 13:35:08 +01:00
|
|
|
|
|
|
|
template<typename ESXRecordT>
|
|
|
|
struct FixedRecordTypeColumn : public Column<ESXRecordT>
|
|
|
|
{
|
|
|
|
int mType;
|
|
|
|
|
2013-01-03 11:20:25 +01:00
|
|
|
FixedRecordTypeColumn (int type)
|
|
|
|
: Column<ESXRecordT> ("Type", ColumnBase::Display_Integer, 0), mType (type) {}
|
2012-12-13 13:35:08 +01:00
|
|
|
|
|
|
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
|
|
|
{
|
|
|
|
return mType;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isEditable() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2013-02-08 12:20:03 +01:00
|
|
|
|
|
|
|
template<typename ESXRecordT>
|
|
|
|
struct VarTypeColumn : public Column<ESXRecordT>
|
|
|
|
{
|
2013-02-08 14:48:38 +01:00
|
|
|
VarTypeColumn() : Column<ESXRecordT> ("Type", ColumnBase::Display_Integer) {}
|
2013-02-08 12:20:03 +01:00
|
|
|
|
|
|
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
|
|
|
{
|
|
|
|
return static_cast<int> (record.get().mType);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
|
|
|
{
|
2013-02-09 15:25:50 +01:00
|
|
|
ESXRecordT record2 = record.get();
|
|
|
|
record2.mType = static_cast<ESM::VarType> (data.toInt());
|
|
|
|
record.setModified (record2);
|
2013-02-08 12:20:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isEditable() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
2013-02-08 14:48:38 +01:00
|
|
|
|
|
|
|
template<typename ESXRecordT>
|
|
|
|
struct VarValueColumn : public Column<ESXRecordT>
|
|
|
|
{
|
|
|
|
VarValueColumn() : Column<ESXRecordT> ("Value", ColumnBase::Display_Var) {}
|
|
|
|
|
|
|
|
virtual QVariant get (const Record<ESXRecordT>& record) const
|
|
|
|
{
|
|
|
|
switch (record.get().mType)
|
|
|
|
{
|
|
|
|
case ESM::VT_String: return record.get().mStr.c_str(); break;
|
|
|
|
case ESM::VT_Int: return record.get().mI; break;
|
|
|
|
case ESM::VT_Float: return record.get().mF; break;
|
|
|
|
|
|
|
|
default: return QVariant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void set (Record<ESXRecordT>& record, const QVariant& data)
|
|
|
|
{
|
2013-02-09 15:25:50 +01:00
|
|
|
ESXRecordT record2 = record.get();
|
2013-02-08 14:48:38 +01:00
|
|
|
|
2013-02-09 15:25:50 +01:00
|
|
|
switch (record2.mType)
|
2013-02-08 14:48:38 +01:00
|
|
|
{
|
2013-02-09 15:25:50 +01:00
|
|
|
case ESM::VT_String: record2.mStr = data.toString().toUtf8().constData(); break;
|
|
|
|
case ESM::VT_Int: record2.mI = data.toInt(); break;
|
|
|
|
case ESM::VT_Float: record2.mF = data.toFloat(); break;
|
2013-02-08 14:48:38 +01:00
|
|
|
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
2013-02-09 15:25:50 +01:00
|
|
|
record.setModified (record2);
|
2013-02-08 14:48:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool isEditable() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
2012-11-26 12:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|