X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=src%2Fattributeitem.h;fp=src%2Fattributeitem.h;h=69c5f629c8d590d433e62b00ce64782ecc4e8194;hb=d483bd8e6523c23c6f1d8908a2e0611c2bc9ff4f;hp=0000000000000000000000000000000000000000;hpb=7dfa3fe589d1722d49681f42cdb0bf1e6efb5223;p=sven%2Fvym.git diff --git a/src/attributeitem.h b/src/attributeitem.h new file mode 100644 index 0000000..69c5f62 --- /dev/null +++ b/src/attributeitem.h @@ -0,0 +1,51 @@ +#ifndef ATTRIBUTEITEM_H +#define ATTRIBUTEITEM_H + +#include +#include + +#include "branchitem.h" + +/*! \brief A key and a value + The data itself is stored in Attribute Definitions (AttributeDef). + A list of these tables AttributeTable is maintained for every MapEditor. +*/ +class AttributeItem : public BranchItem { + public: + enum Type { + Undefined, //!< Undefined type + Integer, //!< Integer + DateTime, //!< DateTime + String //!< String + }; + + AttributeItem(TreeItem *parent = nullptr); + AttributeItem(const QString &k, const QString &v, TreeItem *parent = nullptr); + virtual ~AttributeItem(); + void copy(AttributeItem *other); + void set(const QString &k, const QString &v); + void get(QString &k, QString &v, Type &t); + void setKey(const QString &k); + QString getKey(); + void setValue(const QString &v); + void setValue(const qlonglong &n); + void setValue(const QDateTime &dt); + QVariant getValue(); + QDateTime getValueDateTime(); + using BranchItem::setType; + virtual void setAttributeType(const Type &t); + AttributeItem::Type getAttributeType(); + QString getAttributeTypeString(); + void setInternal(bool b); + bool isInternal(); + QString getDataXML(); + + protected: + void createHeading(); + bool internal; //!< Internal attributes cannot be edited by user + QString key; + QVariant value; + Type attrType; +}; + +#endif