1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSIGNALTRANSITION_H
5#define QSIGNALTRANSITION_H
6
7#include <QtCore/qmetaobject.h>
8#include <QtStateMachine/qabstracttransition.h>
9
10QT_REQUIRE_CONFIG(statemachine);
11
12QT_BEGIN_NAMESPACE
13
14class QSignalTransitionPrivate;
15class Q_STATEMACHINE_EXPORT QSignalTransition : public QAbstractTransition
16{
17 Q_OBJECT
18 Q_PROPERTY(const QObject* senderObject READ senderObject WRITE setSenderObject
19 NOTIFY senderObjectChanged BINDABLE bindableSenderObject)
20 Q_PROPERTY(QByteArray signal READ signal WRITE setSignal
21 NOTIFY signalChanged BINDABLE bindableSignal)
22
23public:
24 QSignalTransition(QState *sourceState = nullptr);
25 QSignalTransition(const QObject *sender, const char *signal,
26 QState *sourceState = nullptr);
27#ifdef Q_QDOC
28 template<typename PointerToMemberFunction>
29 QSignalTransition(const QObject *object, PointerToMemberFunction signal,
30 QState *sourceState = nullptr);
31#elif defined(Q_COMPILER_DELEGATING_CONSTRUCTORS)
32 template <typename Func>
33 QSignalTransition(const typename QtPrivate::FunctionPointer<Func>::Object *obj,
34 Func sig, QState *srcState = nullptr)
35 : QSignalTransition(obj, QMetaMethod::fromSignal(sig).methodSignature().constData(), srcState)
36 {
37 }
38#endif
39
40 ~QSignalTransition();
41
42 const QObject *senderObject() const;
43 void setSenderObject(const QObject *sender);
44 QBindable<const QObject*> bindableSenderObject();
45
46 QByteArray signal() const;
47 void setSignal(const QByteArray &signal);
48 QBindable<QByteArray> bindableSignal();
49
50protected:
51 bool eventTest(QEvent *event) override;
52 void onTransition(QEvent *event) override;
53
54 bool event(QEvent *e) override;
55
56Q_SIGNALS:
57 void senderObjectChanged(QPrivateSignal);
58 void signalChanged(QPrivateSignal);
59
60private:
61 Q_DISABLE_COPY(QSignalTransition)
62 Q_DECLARE_PRIVATE(QSignalTransition)
63};
64
65QT_END_NAMESPACE
66
67#endif
68

source code of qtscxml/src/statemachine/qsignaltransition.h