]> git.sven.stormbind.net Git - sven/vym.git/blob - src/attributeitem.h
Replace Pierre as the maintainer
[sven/vym.git] / src / attributeitem.h
1 #ifndef ATTRIBUTEITEM_H
2 #define ATTRIBUTEITEM_H
3
4 #include <QStringList>
5 #include <QVariant>
6
7 #include "branchitem.h"
8
9 /*! \brief A key and a value
10     The data itself is stored in Attribute Definitions (AttributeDef).
11     A list of these tables AttributeTable is maintained for every MapEditor.
12 */
13 class AttributeItem : public BranchItem {
14   public:
15     enum Type {
16         Undefined,   //!< Undefined type
17         Integer,     //!< Integer
18         DateTime,    //!< DateTime
19         String       //!< String
20     };
21
22     AttributeItem(TreeItem *parent = nullptr);
23     AttributeItem(const QString &k, const QString &v, TreeItem *parent = nullptr);
24     virtual ~AttributeItem();
25     void copy(AttributeItem *other);
26     void set(const QString &k, const QString &v);
27     void get(QString &k, QString &v, Type &t);
28     void setKey(const QString &k);
29     QString getKey();
30     void setValue(const QString &v);
31     void setValue(const qlonglong &n);
32     void setValue(const QDateTime &dt);
33     QVariant getValue();
34     QDateTime getValueDateTime();
35     using BranchItem::setType;
36     virtual void setAttributeType(const Type &t);
37     AttributeItem::Type getAttributeType();
38     QString getAttributeTypeString();
39     void setInternal(bool b);
40     bool isInternal();
41     QString getDataXML();
42
43   protected:
44     void createHeading();
45     bool internal; //!< Internal attributes cannot be edited by user
46     QString key;
47     QVariant value;
48     Type attrType;
49 };
50
51 #endif