KDStateMachineEditor  1.0.0
A framework for creating Qt State Machine metacode using a graphical user interface
transition.h
1 /*
2  This file is part of the KDAB State Machine Editor Library.
3 
4  Copyright (C) 2014-2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com.
5  All rights reserved.
6  Author: Kevin Funk <kevin.funk@kdab.com>
7 
8  Licensees holding valid commercial KDAB State Machine Editor Library
9  licenses may use this file in accordance with the KDAB State Machine Editor
10  Library License Agreement provided with the Software.
11 
12  This file may be distributed and/or modified under the terms of the
13  GNU Lesser General Public License version 2.1 as published by the
14  Free Software Foundation and appearing in the file LICENSE.LGPL.txt included.
15 
16  This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
17  WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 
19  Contact info@kdab.com if any conditions of this licensing are not
20  clear to you.
21 */
22 
23 #ifndef KDSME_MODEL_TRANSITION_H
24 #define KDSME_MODEL_TRANSITION_H
25 
26 #include "element.h"
27 
28 namespace KDSME {
29 
30 class KDSME_CORE_EXPORT Transition : public Element
31 {
32  Q_OBJECT
33  Q_PROPERTY(KDSME::State* sourceState READ sourceState WRITE setSourceState NOTIFY sourceStateChanged FINAL)
34  Q_PROPERTY(KDSME::State* targetState READ targetState WRITE setTargetState NOTIFY targetStateChanged FINAL)
35  Q_PROPERTY(QString guard READ guard WRITE setGuard NOTIFY guardChanged FINAL)
37  Q_PROPERTY(QPainterPath shape READ shape WRITE setShape NOTIFY shapeChanged FINAL)
38  Q_PROPERTY(QRectF labelBoundingRect READ labelBoundingRect WRITE setLabelBoundingRect NOTIFY labelBoundingRectChanged FINAL)
39 
40 public:
41  explicit Transition(State* sourceState = nullptr);
42  virtual ~Transition();
43 
44  Q_INVOKABLE KDSME::StateMachine* machine() const;
45 
46  State* sourceState() const;
47  void setSourceState(State* sourceState);
48 
49  State* targetState() const;
50  void setTargetState(State* targetState);
51 
52  virtual Type type() const override;
53 
59  QString guard() const;
60  void setGuard(const QString& guard);
61 
62  QPainterPath shape() const;
63  void setShape(const QPainterPath& path);
64 
65  QRectF labelBoundingRect() const;
66  void setLabelBoundingRect(const QRectF& rect);
67 
68 Q_SIGNALS:
69  void sourceStateChanged(State* sourceState);
70  void targetStateChanged(State* targetState);
71  void guardChanged(const QString& guard);
72  void shapeChanged(const QPainterPath& path);
73  void labelBoundingRectChanged(const QRectF& rect);
74 
75 private:
76  struct Private;
77  QScopedPointer<Private> d;
78 };
79 
80 KDSME_CORE_EXPORT QDebug operator<<(QDebug dbg, const Transition* transition);
81 
82 class KDSME_CORE_EXPORT SignalTransition : public Transition
83 {
84  Q_OBJECT
85  Q_PROPERTY(QString signal READ signal WRITE setSignal NOTIFY signalChanged)
86 
87 public:
88  explicit SignalTransition(State* sourceState);
89  virtual ~SignalTransition();
90 
91  virtual Type type() const override;
92 
93  QString signal() const;
94  void setSignal(const QString& signal);
95 
96 Q_SIGNALS:
97  void signalChanged(const QString& signal);
98 
99 private:
100  struct Private;
101  QScopedPointer<Private> d;
102 };
103 
104 class KDSME_CORE_EXPORT TimeoutTransition : public Transition
105 {
106  Q_OBJECT
107  Q_PROPERTY(int timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged)
108 
109 public:
110  explicit TimeoutTransition(State* sourceState);
111  virtual ~TimeoutTransition();
112 
113  virtual Type type() const override;
114 
115  int timeout() const;
116  void setTimeout(int timeout);
117 
118 Q_SIGNALS:
119  void timeoutChanged(int timeout);
120 
121 private:
122  struct Private;
123  QScopedPointer<Private> d;
124 };
125 
126 }
127 
128 #endif
Definition: state.h:160
Definition: transition.h:82
Definition: state.h:35
Definition: transition.h:30
Definition: transition.h:104
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