KDStateMachineEditor API Documentation 2.1
Loading...
Searching...
No Matches
transition.cpp
Go to the documentation of this file.
1/*
2 This file is part of the KDAB State Machine Editor Library.
3
4 SPDX-FileCopyrightText: 2014 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: Kevin Funk <kevin.funk@kdab.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor
8
9 Licensees holding valid commercial KDAB State Machine Editor Library
10 licenses may use this file in accordance with the KDAB State Machine Editor
11 Library License Agreement provided with the Software.
12
13 Contact info@kdab.com if any conditions of this licensing are not clear to you.
14*/
15
16#include "transition.h"
17
18#include "elementutil.h"
19#include "state.h"
20
21#include <QDebug>
22#include <QPainterPath>
23#include <QQmlEngine>
24
25using namespace KDSME;
26
27struct Transition::Private
28{
29 Private()
30 : m_targetState(nullptr)
31 {
32 }
33
34 State *m_targetState;
35 QString m_guard;
36 QPainterPath m_shape;
37 QRectF m_labelBoundingRect;
38};
39
41 : Element(sourceState)
42 , d(new Private)
43{
44}
45
49
51{
53 QQmlEngine::setObjectOwnership(m, QQmlEngine::CppOwnership);
54 return m;
55}
56
58{
59 return qobject_cast<State *>(parent());
60}
61
63{
64 if (parent() == sourceState) {
65 return;
66 }
67
70}
71
73{
74 return d->m_targetState;
75}
76
78{
79 if (d->m_targetState == targetState)
80 return;
81
82 d->m_targetState = targetState;
84}
85
90
91QString Transition::guard() const
92{
93 return d->m_guard;
94}
95
96void Transition::setGuard(const QString &guard)
97{
98 if (d->m_guard == guard)
99 return;
100
101 d->m_guard = guard;
102 Q_EMIT guardChanged(d->m_guard);
103}
104
105QPainterPath Transition::shape() const
106{
107 return d->m_shape;
108}
109
110void Transition::setShape(const QPainterPath &shape)
111{
112 if (d->m_shape == shape)
113 return;
114
115 d->m_shape = shape;
116 Q_EMIT shapeChanged(shape);
117}
118
120{
121 return d->m_labelBoundingRect;
122}
123
124void Transition::setLabelBoundingRect(const QRectF &rect)
125{
126 if (d->m_labelBoundingRect == rect)
127 return;
128
129 d->m_labelBoundingRect = rect;
130 Q_EMIT labelBoundingRectChanged(rect);
131}
132
133struct SignalTransition::Private
134{
135 QString m_signal;
136};
137
139 : Transition(sourceState)
140 , d(new Private)
141{
142}
143
147
152
154{
155 return d->m_signal;
156}
157
158void SignalTransition::setSignal(const QString &signal)
159{
160 if (d->m_signal == signal)
161 return;
162
163 d->m_signal = signal;
164 Q_EMIT signalChanged(d->m_signal);
165}
166
167struct TimeoutTransition::Private
168{
169 Private()
170 : m_timeout(0)
171 {
172 }
173
174 int m_timeout;
175};
176
178 : Transition(sourceState)
179 , d(new Private)
180{
181}
182
186
191
193{
194 return d->m_timeout;
195}
196
198{
199 if (d->m_timeout == timeout)
200 return;
201
202 d->m_timeout = timeout;
203 Q_EMIT timeoutChanged(d->m_timeout);
204}
205
206QDebug KDSME::operator<<(QDebug dbg, const Transition *transition)
207{
208 if (!transition) {
209 return dbg << static_cast<QObject *>(nullptr);
210 }
211 dbg.nospace() << "Transition["
212 << "this=" << ( const void * )transition
213 << ", source=" << transition->sourceState()
214 << ", target=" << transition->targetState()
215 << "]";
216 return dbg.space();
217}
218
219#include "moc_transition.cpp"
void setParent(QObject *object)
Definition element.cpp:240
@ TimeoutTransitionType
Definition element.h:58
@ SignalTransitionType
Definition element.h:57
KDSME::Element * parent
Definition element.h:37
SignalTransition(State *sourceState)
void setSignal(const QString &signal)
Type type() const override
void signalChanged(const QString &signal)
void setTimeout(int timeout)
TimeoutTransition(State *sourceState)
void timeoutChanged(int timeout)
Type type() const override
void shapeChanged(const QPainterPath &path)
KDSME::State * sourceState
Definition transition.h:26
Q_INVOKABLE KDSME::StateMachine * machine() const
Type type() const override
void setTargetState(State *targetState)
KDSME::State * targetState
Definition transition.h:27
void setSourceState(State *sourceState)
void setShape(const QPainterPath &shape)
void setLabelBoundingRect(const QRectF &rect)
void labelBoundingRectChanged(const QRectF &rect)
QRectF labelBoundingRect
Definition transition.h:31
Transition(State *sourceState=nullptr)
QPainterPath shape
The exact shape of this transition.
Definition transition.h:30
void setGuard(const QString &guard)
void guardChanged(const QString &guard)
void sourceStateChanged(KDSME::State *sourceState)
void targetStateChanged(KDSME::State *targetState)
KDSME_CORE_EXPORT StateMachine * findStateMachine(const Element *element)
KDSME_CORE_EXPORT QDebug operator<<(QDebug dbg, const State *state)
Definition state.cpp:408

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDStateMachineEditor
Create Qt State Machine metacode using a graphical user interface
https://github.com/KDAB/KDStateMachineEditor
Generated on Tue Jul 15 2025 15:21:47 for KDStateMachineEditor API Documentation by doxygen 1.9.8