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 QABSTRACTSTATE_H |
5 | #define QABSTRACTSTATE_H |
6 | |
7 | #include <QtCore/qobject.h> |
8 | #include <QtStateMachine/qstatemachineglobal.h> |
9 | |
10 | QT_REQUIRE_CONFIG(statemachine); |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QState; |
15 | class QStateMachine; |
16 | |
17 | class QAbstractStatePrivate; |
18 | class Q_STATEMACHINE_EXPORT QAbstractState : public QObject |
19 | { |
20 | Q_OBJECT |
21 | Q_PROPERTY(bool active READ active NOTIFY activeChanged BINDABLE bindableActive) |
22 | public: |
23 | ~QAbstractState(); |
24 | |
25 | QState *parentState() const; |
26 | QStateMachine *machine() const; |
27 | |
28 | bool active() const; |
29 | QBindable<bool> bindableActive(); |
30 | |
31 | Q_SIGNALS: |
32 | void entered(QPrivateSignal); |
33 | void exited(QPrivateSignal); |
34 | void activeChanged(bool active); |
35 | |
36 | protected: |
37 | QAbstractState(QState *parent = nullptr); |
38 | |
39 | virtual void onEntry(QEvent *event) = 0; |
40 | virtual void onExit(QEvent *event) = 0; |
41 | |
42 | bool event(QEvent *e) override; |
43 | |
44 | protected: |
45 | QAbstractState(QAbstractStatePrivate &dd, QState *parent); |
46 | |
47 | private: |
48 | Q_DISABLE_COPY(QAbstractState) |
49 | Q_DECLARE_PRIVATE(QAbstractState) |
50 | }; |
51 | |
52 | QT_END_NAMESPACE |
53 | |
54 | #endif |
55 |