KDStateMachineEditor  1.1.0
A framework for creating Qt State Machine metacode using a graphical user interface
element.h
1 /*
2  element.h
3 
4  This file is part of the KDAB State Machine Editor Library.
5 
6  Copyright (C) 2014-2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com.
7  All rights reserved.
8  Author: Kevin Funk <kevin.funk@kdab.com>
9  Author: Volker Krause <volker.krause@kdab.com>
10 
11  Licensees holding valid commercial KDAB State Machine Editor Library
12  licenses may use this file in accordance with the KDAB State Machine Editor
13  Library License Agreement provided with the Software.
14 
15  This file may be distributed and/or modified under the terms of the
16  GNU Lesser General Public License version 2.1 as published by the
17  Free Software Foundation and appearing in the file LICENSE.LGPL.txt included.
18 
19  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 
22  Contact info@kdab.com if any conditions of this licensing are not
23  clear to you.
24 */
25 
26 #ifndef KDSME_MODEL_ELEMENT_H
27 #define KDSME_MODEL_ELEMENT_H
28 
29 #include "kdsme_core_export.h"
30 
31 #include <QObject>
32 #include <QMetaType>
33 
34 QT_BEGIN_NAMESPACE
35 class QPainterPath;
36 QT_END_NAMESPACE
37 
38 namespace KDSME {
39 
40 class State;
41 class StateMachine;
42 
43 class KDSME_CORE_EXPORT Element : public QObject
44 {
45  Q_OBJECT
46  Q_ENUMS(Flags)
47  Q_PROPERTY(KDSME::Element* parent READ parentElement WRITE setParentElement NOTIFY parentChanged FINAL)
48  Q_PROPERTY(Type type READ type CONSTANT FINAL)
49  Q_PROPERTY(Flags flags READ flags WRITE setFlags NOTIFY flagsChanged FINAL)
50  Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged FINAL)
52  Q_PROPERTY(QPointF pos READ pos WRITE setPos NOTIFY posChanged FINAL)
53  Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL)
54  Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL)
56  Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
58  Q_PROPERTY(bool selected READ isSelected WRITE setSelected NOTIFY selectedChanged FINAL)
59 
60 public:
61  enum Type {
62  ElementType,
63 
64  // Transition types
65  TransitionType,
66  SignalTransitionType,
67  TimeoutTransitionType,
68 
69  // State types
70  StateType,
71  StateMachineType,
72  HistoryStateType,
73  FinalStateType,
74  PseudoStateType
75  };
76  Q_ENUMS(Type)
77 
78  enum Flag {
79  NoFlags = 0x0,
80  ElementIsDragEnabled = 0x1,
81  ElementIsSelectable = 0x2,
82  ElementIsEditable = 0x4,
83  };
84  Q_DECLARE_FLAGS(Flags, Flag)
85 
86  explicit Element(QObject* parent = nullptr);
87  ~Element();
88 
89  virtual Type type() const;
90 
91  Flags flags() const;
92  void setFlags(Flags flags);
93 
97  QString label() const;
98  void setLabel(const QString& label);
99 
105  quintptr internalId() const;
106  void setInternalId(quintptr id);
107 
108  void setInternalPointer(void* ptr);
109  void* internalPointer() const;
110 
111  QPointF pos() const;
112  void setPos(const QPointF& pos);
113 
114  qreal height() const;
115  void setHeight(qreal height);
116 
117  qreal width() const;
118  void setWidth(qreal width);
119 
120  QPointF absolutePos() const;
121 
122  bool isVisible() const;
123  void setVisible(bool visible);
124 
125  bool isSelected() const;
126  void setSelected(bool selected);
127 
128  QSizeF preferredSize() const;
129  virtual QRectF boundingRect() const;
130 
131  Element* parentElement() const;
132  void setParentElement(Element* parent);
133  void setParent(QObject* object); // hide parent function
134  QList<Element*> childElements() const;
135 
136  virtual QString toDisplayString() const;
137 
138  Q_INVOKABLE static const char* typeToString(Type type);
139  Q_INVOKABLE static Type stringToType(const char* type);
140 
141 Q_SIGNALS:
142  void parentChanged(Element* parent);
143  void flagsChanged(Flags flags);
144  void labelChanged(const QString& label);
145  void posChanged(const QPointF& pos);
146  void heightChanged(qreal height);
147  void widthChanged(qreal width);
148  void visibleChanged(bool visible);
149  void selectedChanged(bool selected);
150 
151 private:
152  struct Private;
153  QScopedPointer<Private> d;
154 };
155 
156 }
157 
158 Q_DECLARE_METATYPE(KDSME::Element::Type)
159 Q_DECLARE_METATYPE(KDSME::Element*)
160 
161 #endif // TREESTRUCTURE_H
Definition: element.h:43
Definition: abstractexporter.h:33

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
https://github.com/KDAB/KDStateMachineEditor