| 1 | // Copyright (C) 2016 Ford Motor Company |
|---|---|
| 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 STATEMACHINE_H |
| 5 | #define STATEMACHINE_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qstatemachineqmlglobals_p.h" |
| 19 | #include "childrenprivate_p.h" |
| 20 | |
| 21 | #include <QtCore/private/qproperty_p.h> |
| 22 | #include <QtStateMachine/QStateMachine> |
| 23 | #include <QtQml/QQmlParserStatus> |
| 24 | #include <QtQml/QQmlListProperty> |
| 25 | #include <QtQml/qqml.h> |
| 26 | |
| 27 | QT_BEGIN_NAMESPACE |
| 28 | |
| 29 | class Q_STATEMACHINEQML_EXPORT StateMachine : public QStateMachine, public QQmlParserStatus |
| 30 | { |
| 31 | Q_OBJECT |
| 32 | Q_INTERFACES(QQmlParserStatus) |
| 33 | Q_PROPERTY(QQmlListProperty<QObject> children READ children |
| 34 | NOTIFY childrenChanged BINDABLE bindableChildren) |
| 35 | |
| 36 | // Override to delay execution after componentComplete() |
| 37 | Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY qmlRunningChanged) |
| 38 | |
| 39 | Q_CLASSINFO("DefaultProperty", "children") |
| 40 | QML_ELEMENT |
| 41 | QML_ADDED_IN_VERSION(1, 0) |
| 42 | |
| 43 | public: |
| 44 | explicit StateMachine(QObject *parent = 0); |
| 45 | |
| 46 | void classBegin() override {} |
| 47 | void componentComplete() override; |
| 48 | QQmlListProperty<QObject> children(); |
| 49 | QBindable<QQmlListProperty<QObject>> bindableChildren() const; |
| 50 | |
| 51 | bool isRunning() const; |
| 52 | void setRunning(bool running); |
| 53 | |
| 54 | private Q_SLOTS: |
| 55 | void checkChildMode(); |
| 56 | |
| 57 | Q_SIGNALS: |
| 58 | void childrenChanged(); |
| 59 | /*! |
| 60 | * \internal |
| 61 | */ |
| 62 | void qmlRunningChanged(); |
| 63 | |
| 64 | private: |
| 65 | // See the childrenActualCalculation for the mutable explanation |
| 66 | mutable ChildrenPrivate<StateMachine, ChildrenMode::StateOrTransition> m_children; |
| 67 | friend ChildrenPrivate<StateMachine, ChildrenMode::StateOrTransition>; |
| 68 | void childrenContentChanged(); |
| 69 | QQmlListProperty<QObject> childrenActualCalculation() const; |
| 70 | Q_OBJECT_COMPUTED_PROPERTY(StateMachine, QQmlListProperty<QObject>, m_childrenComputedProperty, |
| 71 | &StateMachine::childrenActualCalculation); |
| 72 | bool m_completed; |
| 73 | bool m_running; |
| 74 | }; |
| 75 | |
| 76 | QT_END_NAMESPACE |
| 77 | |
| 78 | #endif |
| 79 |
