| 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 STATEMACHINELOADER_P_H |
| 5 | #define STATEMACHINELOADER_P_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 "qscxmlqmlglobals_p.h" |
| 19 | |
| 20 | #include <QtCore/qurl.h> |
| 21 | #include <QtScxml/qscxmlstatemachine.h> |
| 22 | |
| 23 | #include <QtCore/private/qproperty_p.h> |
| 24 | #include <QtQml/qqml.h> |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class Q_SCXMLQML_EXPORT QScxmlStateMachineLoader: public QObject |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | Q_PROPERTY(QUrl source READ source WRITE setSource |
| 32 | NOTIFY sourceChanged BINDABLE bindableSource) |
| 33 | Q_PROPERTY(QScxmlStateMachine *stateMachine READ stateMachine DESIGNABLE false |
| 34 | NOTIFY stateMachineChanged BINDABLE bindableStateMachine) |
| 35 | Q_PROPERTY(QVariantMap initialValues READ initialValues WRITE setInitialValues |
| 36 | NOTIFY initialValuesChanged BINDABLE bindableInitialValues) |
| 37 | Q_PROPERTY(QScxmlDataModel *dataModel READ dataModel |
| 38 | WRITE setDataModel NOTIFY dataModelChanged BINDABLE bindableDataModel) |
| 39 | QML_NAMED_ELEMENT(StateMachineLoader) |
| 40 | QML_ADDED_IN_VERSION(5,8) |
| 41 | |
| 42 | public: |
| 43 | explicit QScxmlStateMachineLoader(QObject *parent = nullptr); |
| 44 | |
| 45 | QScxmlStateMachine *stateMachine() const; |
| 46 | QBindable<QScxmlStateMachine*> bindableStateMachine(); |
| 47 | |
| 48 | QUrl source(); |
| 49 | void setSource(const QUrl &source); |
| 50 | QBindable<QUrl> bindableSource(); |
| 51 | |
| 52 | QVariantMap initialValues() const; |
| 53 | void setInitialValues(const QVariantMap &initialValues); |
| 54 | QBindable<QVariantMap> bindableInitialValues(); |
| 55 | |
| 56 | QScxmlDataModel *dataModel() const; |
| 57 | void setDataModel(QScxmlDataModel *dataModel); |
| 58 | QBindable<QScxmlDataModel*> bindableDataModel(); |
| 59 | |
| 60 | Q_SIGNALS: |
| 61 | void sourceChanged(); |
| 62 | void initialValuesChanged(); |
| 63 | void stateMachineChanged(); |
| 64 | void dataModelChanged(); |
| 65 | |
| 66 | private: |
| 67 | bool parse(const QUrl &source); |
| 68 | void setStateMachine(QScxmlStateMachine* stateMachine); |
| 69 | |
| 70 | private: |
| 71 | Q_OBJECT_COMPAT_PROPERTY(QScxmlStateMachineLoader, QUrl, |
| 72 | m_source, &QScxmlStateMachineLoader::setSource, |
| 73 | &QScxmlStateMachineLoader::sourceChanged); |
| 74 | Q_OBJECT_COMPAT_PROPERTY(QScxmlStateMachineLoader, QVariantMap, |
| 75 | m_initialValues, &QScxmlStateMachineLoader::setInitialValues, |
| 76 | &QScxmlStateMachineLoader::initialValuesChanged); |
| 77 | Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QScxmlStateMachineLoader, QScxmlDataModel*, |
| 78 | m_dataModel, &QScxmlStateMachineLoader::setDataModel, |
| 79 | &QScxmlStateMachineLoader::dataModelChanged, nullptr); |
| 80 | Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QScxmlStateMachineLoader, QScxmlStateMachine*, |
| 81 | m_stateMachine, nullptr, &QScxmlStateMachineLoader::stateMachineChanged); |
| 82 | QScxmlDataModel *m_implicitDataModel; |
| 83 | }; |
| 84 | |
| 85 | QT_END_NAMESPACE |
| 86 | |
| 87 | #endif // STATEMACHINELOADER_P_H |
| 88 | |