1 /*
2     SPDX-License-Identifier: GPL-2.0-or-later
3     SPDX-FileCopyrightText: 2002-2021 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
4 */
5 
6 #ifndef ENTITYATTRIBUTE_H
7 #define ENTITYATTRIBUTE_H
8 
9 #include "attribute.h"
10 #include "basictypes.h"
11 
12 /**
13  * This class is used to set up information for an entityattribute.  This is a database field
14  * It has a type, name, index type and default value.
15  *
16  * @short Sets up entityattribute information.
17  * @author Jonathan Riddell <jr@jriddell.org>
18  * Bugs and comments to umbrello-devel@kde.org or https://bugs.kde.org
19  */
20 class UMLEntityAttribute : public UMLAttribute
21 {
22     Q_OBJECT
23     Q_ENUMS(DBIndex_Type)
24 public:
25     enum DBIndex_Type
26     {
27         None  =  1100,
28         Primary,
29         Index,
30         Unique
31     };
32 
33     UMLEntityAttribute(UMLObject* parent, const QString& name,
34                        Uml::ID::Type id = Uml::ID::None,
35                        Uml::Visibility::Enum s = Uml::Visibility::Private,
36                        UMLObject *type = 0, const QString& iv = QString());
37     explicit UMLEntityAttribute(UMLObject* parent);
38     virtual ~UMLEntityAttribute();
39 
40     bool operator==(const UMLEntityAttribute& rhs) const;
41 
42     virtual void copyInto(UMLObject *lhs) const;
43 
44     virtual UMLObject* clone() const;
45 
46     void setAttributes(const QString& attributes);
47     QString getAttributes() const;
48 
49     void setIndexType(const DBIndex_Type indexType);
50     DBIndex_Type indexType() const;
51 
52     void setValues(const QString& values);
53     QString getValues() const;
54 
55     void setAutoIncrement(const bool autoIncrement);
56     bool getAutoIncrement() const;
57 
58     void setNull(const bool null);
59     bool getNull() const;
60 
61     QString toString(Uml::SignatureType::Enum sig = Uml::SignatureType::NoSig,
62                      bool withStereotype=false) const;
63 
64     virtual void saveToXMI1(QXmlStreamWriter& writer);
65 
66     virtual bool showPropertiesDialog(QWidget* parent = 0);
67 
68 protected:
69     void init();
70 
71     bool load1(QDomElement& element);
72 
73 private:
74     DBIndex_Type   m_indexType;
75     QString        m_values;
76     QString        m_attributes;
77     bool           m_autoIncrement;
78     bool           m_null;
79 };
80 
81 #endif
82