diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2016-04-06 12:18:42 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2016-04-19 07:03:31 +0000 |
commit | f648d720d0c2a5dcef02c10cfe6cfaea717a6cdc (patch) | |
tree | b2ba0cd1b6073b75b2159a05b4744dbb7779c133 /src | |
parent | 7c4111286b3c1f072a731ae9aa938c9e73b035e7 (diff) |
Allow history states for <scxml>'s "initial" attribute
The standard doesn't seem to prohibit this and QStateMachine can
handle it.
Change-Id: Ia22f564c9657582199c3c67318fafd21ec4a8770
Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/scxml/qscxmlparser.cpp | 2 | ||||
-rw-r--r-- | src/scxml/qscxmlqstates.cpp | 24 | ||||
-rw-r--r-- | src/scxml/qscxmlqstates.h | 15 |
3 files changed, 40 insertions, 1 deletions
diff --git a/src/scxml/qscxmlparser.cpp b/src/scxml/qscxmlparser.cpp index 6abe74e..eb7f016 100644 --- a/src/scxml/qscxmlparser.cpp +++ b/src/scxml/qscxmlparser.cpp @@ -1270,7 +1270,7 @@ private: bool visit(DocumentModel::HistoryState *state) Q_DECL_OVERRIDE { - QHistoryState *newState = new QHistoryState(currentParent()); + QHistoryState *newState = new QScxmlHistoryState(currentParent()); switch (state->type) { case DocumentModel::HistoryState::Shallow: newState->setHistoryType(QHistoryState::ShallowHistory); diff --git a/src/scxml/qscxmlqstates.cpp b/src/scxml/qscxmlqstates.cpp index 6fd1e53..d40ef20 100644 --- a/src/scxml/qscxmlqstates.cpp +++ b/src/scxml/qscxmlqstates.cpp @@ -196,6 +196,30 @@ QScxmlStateMachine *QScxmlFinalState::stateMachine() const { return qobject_cast<QScxmlInternal::WrappedQStateMachine *>(machine())->stateMachine(); } +QScxmlHistoryState::QScxmlHistoryState(QState *parent) + : QHistoryState(parent) +{ +} + +QScxmlHistoryState::~QScxmlHistoryState() +{ +} + +void QScxmlHistoryState::setAsInitialStateFor(QScxmlState *state) +{ + state->setInitialState(this); +} + +void QScxmlHistoryState::setAsInitialStateFor(QScxmlStateMachine *stateMachine) +{ + QScxmlStateMachinePrivate::get(stateMachine)->m_qStateMachine->setInitialState(this); +} + +QScxmlStateMachine *QScxmlHistoryState::stateMachine() const +{ + return qobject_cast<QScxmlInternal::WrappedQStateMachine *>(machine())->stateMachine(); +} + QScxmlExecutableContent::ContainerId QScxmlFinalState::doneData() const { Q_D(const QScxmlFinalState); diff --git a/src/scxml/qscxmlqstates.h b/src/scxml/qscxmlqstates.h index 63abe3b..7280a0f 100644 --- a/src/scxml/qscxmlqstates.h +++ b/src/scxml/qscxmlqstates.h @@ -45,6 +45,7 @@ #include <QAbstractTransition> #include <QFinalState> +#include <QHistoryState> #include <QState> QT_BEGIN_NAMESPACE @@ -133,6 +134,20 @@ private: Q_DECLARE_PRIVATE(QScxmlFinalState) }; +class Q_SCXML_EXPORT QScxmlHistoryState: public QHistoryState +{ + Q_OBJECT + +public: + QScxmlHistoryState(QState *parent = Q_NULLPTR); + ~QScxmlHistoryState(); + + void setAsInitialStateFor(QScxmlState *state); + void setAsInitialStateFor(QScxmlStateMachine *stateMachine); + + QScxmlStateMachine *stateMachine() const; +}; + class QScxmlBaseTransitionPrivate; class Q_SCXML_EXPORT QScxmlBaseTransition: public QAbstractTransition { |