KDStateMachineEditor  1.0.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-2015 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 class QPainterPath;
35 
36 namespace KDSME {
37 
38 class State;
39 class StateMachine;
40 
41 class KDSME_CORE_EXPORT Element : public QObject
42 {
43  Q_OBJECT
44  Q_ENUMS(Flags)
45  Q_PROPERTY(KDSME::Element* parent READ parentElement WRITE setParentElement NOTIFY parentChanged FINAL)
46  Q_PROPERTY(Type type READ type CONSTANT FINAL)
47  Q_PROPERTY(Flags flags READ flags WRITE setFlags NOTIFY flagsChanged FINAL)
48  Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged FINAL)
50  Q_PROPERTY(QPointF pos READ pos WRITE setPos NOTIFY posChanged FINAL)
51  Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL)
52  Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL)
54  Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
56  Q_PROPERTY(bool selected READ isSelected WRITE setSelected NOTIFY selectedChanged FINAL)
57 
58 public:
59  enum Type {
60  ElementType,
61 
62  // Transition types
63  TransitionType,
64  SignalTransitionType,
65  TimeoutTransitionType,
66 
67  // State types
68  StateType,
69  StateMachineType,
70  HistoryStateType,
71  FinalStateType,
72  PseudoStateType
73  };
74  Q_ENUMS(Type)
75 
76  enum Flag {
77  NoFlags = 0x0,
78  ElementIsDragEnabled = 0x1,
79  ElementIsSelectable = 0x2,
80  ElementIsEditable = 0x4,
81  };
82  Q_DECLARE_FLAGS(Flags, Flag)
83 
84  explicit Element(QObject* parent = nullptr);
85  virtual ~Element();
86 
87  virtual Type type() const;
88 
89  Flags flags() const;
90  void setFlags(Flags flags);
91 
95  QString label() const;
96  void setLabel(const QString& label);
97 
103  quintptr internalId() const;
104  void setInternalId(quintptr id);
105 
106  void setInternalPointer(void* ptr);
107  void* internalPointer() const;
108 
109  QPointF pos() const;
110  void setPos(const QPointF& pos);
111 
112  qreal height() const;
113  void setHeight(qreal height);
114 
115  qreal width() const;
116  void setWidth(qreal width);
117 
118  QPointF absolutePos() const;
119 
120  bool isVisible() const;
121  void setVisible(bool visible);
122 
123  bool isSelected() const;
124  void setSelected(bool selected);
125 
126  QSizeF preferredSize() const;
127  virtual QRectF boundingRect() const;
128 
129  Element* parentElement() const;
130  void setParentElement(Element* parent);
131  void setParent(QObject* object); // hide parent function
132  QList<Element*> childElements() const;
133 
134  virtual QString toDisplayString() const;
135 
136  Q_INVOKABLE static const char* typeToString(Type type);
137  Q_INVOKABLE static Type stringToType(const char* type);
138 
139 Q_SIGNALS:
140  void parentChanged(Element* parent);
141  void flagsChanged(Flags flags);
142  void labelChanged(const QString& label);
143  void posChanged(const QPointF& pos);
144  void heightChanged(qreal height);
145  void widthChanged(qreal width);
146  void visibleChanged(bool visible);
147  void selectedChanged(bool selected);
148 
149 private:
150  struct Private;
151  QScopedPointer<Private> d;
152 };
153 
154 }
155 
156 Q_DECLARE_METATYPE(KDSME::Element::Type)
157 Q_DECLARE_METATYPE(KDSME::Element*)
158 
159 #endif // TREESTRUCTURE_H
Definition: element.h:41
Definition: abstractexporter.h:33

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