diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/scxmlstatemachine/invokedservices.cpp (renamed from src/imports/scxmlstatemachine/substatemachines.cpp) | 35 | ||||
-rw-r--r-- | src/imports/scxmlstatemachine/invokedservices.h (renamed from src/imports/scxmlstatemachine/substatemachines.h) | 10 | ||||
-rw-r--r-- | src/imports/scxmlstatemachine/plugin.cpp | 4 | ||||
-rw-r--r-- | src/imports/scxmlstatemachine/scxmlstatemachine.pro | 4 | ||||
-rw-r--r-- | src/scxml/qscxmlinvokableservice.h | 10 | ||||
-rw-r--r-- | src/scxml/qscxmlstatemachine.cpp | 31 | ||||
-rw-r--r-- | src/scxml/qscxmlstatemachine.h | 7 | ||||
-rw-r--r-- | src/scxml/qscxmlstatemachine_p.h | 2 |
8 files changed, 50 insertions, 53 deletions
diff --git a/src/imports/scxmlstatemachine/substatemachines.cpp b/src/imports/scxmlstatemachine/invokedservices.cpp index 7feac92..8b4fd44 100644 --- a/src/imports/scxmlstatemachine/substatemachines.cpp +++ b/src/imports/scxmlstatemachine/invokedservices.cpp @@ -37,61 +37,62 @@ ** ****************************************************************************/ -#include "substatemachines.h" +#include "invokedservices.h" +#include <QtScxml/qscxmlinvokableservice.h> QT_BEGIN_NAMESPACE -QScxmlSubStateMachines::QScxmlSubStateMachines(QObject *parent) : QObject(parent) +QScxmlInvokedServices::QScxmlInvokedServices(QObject *parent) : QObject(parent) { } -QVariantMap QScxmlSubStateMachines::children() +QVariantMap QScxmlInvokedServices::children() { QVariantMap ret; if (m_stateMachine) { - const QVector<QScxmlStateMachine *> children = m_stateMachine->runningSubStateMachines(); - for (QScxmlStateMachine *stateMachine : children) - ret.insertMulti(stateMachine->name(), QVariant::fromValue(stateMachine)); + const QVector<QScxmlInvokableService *> children = m_stateMachine->invokedServices(); + for (QScxmlInvokableService *service : children) + ret.insertMulti(service->name(), QVariant::fromValue(service)); } return ret; } -void QScxmlSubStateMachines::classBegin() +void QScxmlInvokedServices::classBegin() { } -QScxmlStateMachine *QScxmlSubStateMachines::stateMachine() const +QScxmlStateMachine *QScxmlInvokedServices::stateMachine() const { return m_stateMachine; } -void QScxmlSubStateMachines::setStateMachine(QScxmlStateMachine *stateMachine) +void QScxmlInvokedServices::setStateMachine(QScxmlStateMachine *stateMachine) { if (stateMachine != m_stateMachine) { if (m_stateMachine) { - disconnect(m_stateMachine, &QScxmlStateMachine::runningSubStateMachinesChanged, - this, &QScxmlSubStateMachines::childrenChanged); + disconnect(m_stateMachine, &QScxmlStateMachine::invokedServicesChanged, + this, &QScxmlInvokedServices::childrenChanged); } m_stateMachine = stateMachine; - connect(m_stateMachine, &QScxmlStateMachine::runningSubStateMachinesChanged, - this, &QScxmlSubStateMachines::childrenChanged); + connect(m_stateMachine, &QScxmlStateMachine::invokedServicesChanged, + this, &QScxmlInvokedServices::childrenChanged); emit stateMachineChanged(); emit childrenChanged(); } } -QQmlListProperty<QObject> QScxmlSubStateMachines::qmlChildren() +QQmlListProperty<QObject> QScxmlInvokedServices::qmlChildren() { return QQmlListProperty<QObject>(this, m_qmlChildren); } -void QScxmlSubStateMachines::componentComplete() +void QScxmlInvokedServices::componentComplete() { if (!m_stateMachine) { if ((m_stateMachine = qobject_cast<QScxmlStateMachine *>(parent()))) { - connect(m_stateMachine, &QScxmlStateMachine::runningSubStateMachinesChanged, - this, &QScxmlSubStateMachines::childrenChanged); + connect(m_stateMachine, &QScxmlStateMachine::invokedServicesChanged, + this, &QScxmlInvokedServices::childrenChanged); } } } diff --git a/src/imports/scxmlstatemachine/substatemachines.h b/src/imports/scxmlstatemachine/invokedservices.h index 064f37a..58d93ad 100644 --- a/src/imports/scxmlstatemachine/substatemachines.h +++ b/src/imports/scxmlstatemachine/invokedservices.h @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#ifndef SUBSTATEMACHINES_H -#define SUBSTATEMACHINES_H +#ifndef INVOKEDSERVICES_H +#define INVOKEDSERVICES_H #include <QtQml/qqmlparserstatus.h> #include <QtQml/qqmllist.h> @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE -class QScxmlSubStateMachines : public QObject, public QQmlParserStatus +class QScxmlInvokedServices : public QObject, public QQmlParserStatus { Q_OBJECT Q_PROPERTY(QScxmlStateMachine *stateMachine READ stateMachine WRITE setStateMachine @@ -56,7 +56,7 @@ class QScxmlSubStateMachines : public QObject, public QQmlParserStatus Q_INTERFACES(QQmlParserStatus) Q_CLASSINFO("DefaultProperty", "qmlChildren") public: - QScxmlSubStateMachines(QObject *parent = 0); + QScxmlInvokedServices(QObject *parent = 0); QVariantMap children(); QScxmlStateMachine *stateMachine() const; @@ -78,4 +78,4 @@ private: QT_END_NAMESPACE -#endif // SUBSTATEMACHINES_H +#endif // INVOKEDSERVICES_H diff --git a/src/imports/scxmlstatemachine/plugin.cpp b/src/imports/scxmlstatemachine/plugin.cpp index 9357764..cd13f33 100644 --- a/src/imports/scxmlstatemachine/plugin.cpp +++ b/src/imports/scxmlstatemachine/plugin.cpp @@ -41,7 +41,7 @@ #include "eventconnection.h" #include "qscxmlevent.h" #include "statemachineextended.h" -#include "substatemachines.h" +#include "invokedservices.h" #include <QQmlExtensionPlugin> #include <qqml.h> @@ -70,7 +70,7 @@ public: Q_UNUSED(qScxmlEventMetaTypeId) qmlRegisterType<QScxmlStateMachineLoader>(uri, major, minor, "StateMachineLoader"); qmlRegisterType<QScxmlEventConnection>(uri, major, minor, "EventConnection"); - qmlRegisterType<QScxmlSubStateMachines>(uri, major, minor, "SubStateMachines"); + qmlRegisterType<QScxmlInvokedServices>(uri, major, minor, "InvokedServices"); qmlRegisterExtendedUncreatableType<QScxmlStateMachine, QScxmlStateMachineExtended>( uri, major, minor, "QScxmlStateMachine", "Only created through derived types"); qmlProtectModule(uri, 1); diff --git a/src/imports/scxmlstatemachine/scxmlstatemachine.pro b/src/imports/scxmlstatemachine/scxmlstatemachine.pro index 7c94091..da8dc18 100644 --- a/src/imports/scxmlstatemachine/scxmlstatemachine.pro +++ b/src/imports/scxmlstatemachine/scxmlstatemachine.pro @@ -8,13 +8,13 @@ SOURCES = \ $$PWD/statemachineloader.cpp \ $$PWD/eventconnection.cpp \ $$PWD/statemachineextended.cpp \ - $$PWD/substatemachines.cpp + $$PWD/invokedservices.cpp HEADERS = \ $$PWD/statemachineloader.h \ $$PWD/eventconnection.h \ $$PWD/statemachineextended.h \ - $$PWD/substatemachines.h + $$PWD/invokedservices.h load(qml_plugin) diff --git a/src/scxml/qscxmlinvokableservice.h b/src/scxml/qscxmlinvokableservice.h index 8323fe2..a17fdde 100644 --- a/src/scxml/qscxmlinvokableservice.h +++ b/src/scxml/qscxmlinvokableservice.h @@ -51,8 +51,14 @@ class QScxmlEvent; class QScxmlStateMachine; class QScxmlInvokableServiceFactory; -class Q_SCXML_EXPORT QScxmlInvokableService +class Q_SCXML_EXPORT QScxmlInvokableService : public QObject { + Q_OBJECT + Q_PROPERTY(QScxmlStateMachine *parentStateMachine READ parentStateMachine CONSTANT) + Q_PROPERTY(bool autoforward READ autoforward CONSTANT) + Q_PROPERTY(QString id READ id CONSTANT) + Q_PROPERTY(QString name READ name CONSTANT) + public: QScxmlInvokableService(QScxmlInvokableServiceFactory *service, QScxmlStateMachine *parentStateMachine); virtual ~QScxmlInvokableService(); @@ -105,6 +111,8 @@ private: class Q_SCXML_EXPORT QScxmlInvokableScxml: public QScxmlInvokableService { + Q_OBJECT + Q_PROPERTY(QScxmlStateMachine *stateMachine READ stateMachine CONSTANT) public: QScxmlInvokableScxml(QScxmlInvokableServiceFactory *service, QScxmlStateMachine *stateMachine, diff --git a/src/scxml/qscxmlstatemachine.cpp b/src/scxml/qscxmlstatemachine.cpp index 7dae1e3..ab03ad4 100644 --- a/src/scxml/qscxmlstatemachine.cpp +++ b/src/scxml/qscxmlstatemachine.cpp @@ -332,7 +332,7 @@ void QScxmlStateMachinePrivate::addService(int invokingState) m_invokedServices[size_t(id)] = { invokingState, service, serviceName }; service->start(); } - emitRunningSubStateMachinesChanged(); + emitInvokedServicesChanged(); } void QScxmlStateMachinePrivate::removeService(int invokingState) @@ -349,7 +349,7 @@ void QScxmlStateMachinePrivate::removeService(int invokingState) delete service; } } - emitRunningSubStateMachinesChanged(); + emitInvokedServicesChanged(); } QScxmlInvokableServiceFactory *QScxmlStateMachinePrivate::serviceFactory(int id) @@ -576,10 +576,10 @@ void QScxmlStateMachinePrivate::emitStateActive(int stateIndex, bool active) QMetaObject::activate(q, m_metaObject, stateIndex, args); } -void QScxmlStateMachinePrivate::emitRunningSubStateMachinesChanged() +void QScxmlStateMachinePrivate::emitInvokedServicesChanged() { Q_Q(QScxmlStateMachine); - emit q->runningSubStateMachinesChanged(q->runningSubStateMachines()); + emit q->invokedServicesChanged(q->invokedServices()); } QStringList QScxmlStateMachinePrivate::stateNames(const std::vector<int> &stateIndexes) const @@ -1819,20 +1819,19 @@ bool QScxmlStateMachine::isDispatchableTarget(const QString &target) const } /*! - \property QScxmlStateMachine::runningSubStateMachines - \brief A list of running sub state machines that were invoked from the main + \property QScxmlStateMachine::invokedServices + \brief A list of SCXML services that were invoked from the main state machine (possibly recursively). */ -QVector<QScxmlStateMachine *> QScxmlStateMachine::runningSubStateMachines() const +QVector<QScxmlInvokableService *> QScxmlStateMachine::invokedServices() const { Q_D(const QScxmlStateMachine); - QVector<QScxmlStateMachine *> result; + QVector<QScxmlInvokableService *> result; for (int i = 0, ei = int(d->m_invokedServices.size()); i != ei; ++i) { - auto sub = runningSubStateMachine(i); - if (sub) - result.append(sub); + if (auto service = d->m_invokedServices[size_t(i)].service) + result.append(service); } return result; } @@ -1911,14 +1910,4 @@ bool QScxmlStateMachine::isActive(int stateIndex) const return d->m_configuration.contains(stateIndex); } -QScxmlStateMachine *QScxmlStateMachine::runningSubStateMachine(int index) const -{ - Q_D(const QScxmlStateMachine); - auto invokedService = d->m_invokedServices[size_t(index)].service; - if (auto scxmlService = dynamic_cast<QScxmlInvokableScxml *>(invokedService)) - return scxmlService->stateMachine(); - else - return nullptr; -} - QT_END_NAMESPACE diff --git a/src/scxml/qscxmlstatemachine.h b/src/scxml/qscxmlstatemachine.h index c436b0d..b80fcae 100644 --- a/src/scxml/qscxmlstatemachine.h +++ b/src/scxml/qscxmlstatemachine.h @@ -70,7 +70,7 @@ class Q_SCXML_EXPORT QScxmlStateMachine: public QObject Q_PROPERTY(bool initialized READ isInitialized NOTIFY initializedChanged) Q_PROPERTY(QScxmlDataModel *dataModel READ dataModel WRITE setDataModel NOTIFY dataModelChanged) Q_PROPERTY(QVariantMap initialValues READ initialValues WRITE setInitialValues NOTIFY initialValuesChanged) - Q_PROPERTY(QVector<QScxmlStateMachine *> runningSubStateMachines READ runningSubStateMachines NOTIFY runningSubStateMachinesChanged) + Q_PROPERTY(QVector<QScxmlInvokableService *> invokedServices READ invokedServices NOTIFY invokedServicesChanged) Q_PROPERTY(QString sessionId READ sessionId CONSTANT) Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(bool invoked READ isInvoked CONSTANT) @@ -235,11 +235,11 @@ public: Q_INVOKABLE bool isDispatchableTarget(const QString &target) const; - QVector<QScxmlStateMachine *> runningSubStateMachines() const; + QVector<QScxmlInvokableService *> invokedServices() const; Q_SIGNALS: void runningChanged(bool running); - void runningSubStateMachinesChanged(const QVector<QScxmlStateMachine *> &runningMachines); + void invokedServicesChanged(const QVector<QScxmlInvokableService *> &invokedServices); void log(const QString &label, const QString &msg); void reachedStableState(); void finished(); @@ -262,7 +262,6 @@ protected: // methods for friends: #ifndef Q_QDOC // The methods below are used by the compiled state machines. bool isActive(int stateIndex) const; - QScxmlStateMachine *runningSubStateMachine(int index) const; QScxmlTableData *tableData() const; void setTableData(QScxmlTableData *tableData); #endif // Q_QDOC diff --git a/src/scxml/qscxmlstatemachine_p.h b/src/scxml/qscxmlstatemachine_p.h index a2a52b9..3ca0688 100644 --- a/src/scxml/qscxmlstatemachine_p.h +++ b/src/scxml/qscxmlstatemachine_p.h @@ -261,7 +261,7 @@ public: void resetEvent(); void emitStateActive(int stateIndex, bool active); - void emitRunningSubStateMachinesChanged(); + void emitInvokedServicesChanged(); void emitSignalForEvent(int signalIndex, const QVariant &data); private: |