summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin Funk <kevin.funk@kdab.com>2016-11-17 22:53:14 +0100
committerJan Arne Petersen <jan.petersen@kdab.com>2016-11-22 15:21:17 +0000
commit1806b1b4dd93ab10e0dbe0435596b32aa8b8e1b3 (patch)
tree8e98749a51376ac114901ae05a36a003422d21ba /src
parent198c94527b48eb402a4043ed5f6c24b04de43f76 (diff)
Add QScxmlStateMachineInfo::stateParent() + tests
Change-Id: I3d97e1d4019c68859c9551e4a60d39348cf7ebe1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/scxml/qscxmlstatemachineinfo.cpp11
-rw-r--r--src/scxml/qscxmlstatemachineinfo_p.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/scxml/qscxmlstatemachineinfo.cpp b/src/scxml/qscxmlstatemachineinfo.cpp
index 32074cd..7b52f8a 100644
--- a/src/scxml/qscxmlstatemachineinfo.cpp
+++ b/src/scxml/qscxmlstatemachineinfo.cpp
@@ -107,6 +107,17 @@ QString QScxmlStateMachineInfo::stateName(int stateId) const
return QString();
}
+QScxmlStateMachineInfo::StateId QScxmlStateMachineInfo::stateParent(StateId stateId) const
+{
+ Q_D(const QScxmlStateMachineInfo);
+
+ if (stateId < 0 || stateId >= d->stateTable()->stateCount)
+ return InvalidStateId;
+
+ auto state = d->stateTable()->state(stateId);
+ return state.parent;
+}
+
QScxmlStateMachineInfo::StateType QScxmlStateMachineInfo::stateType(StateId stateId) const
{
Q_D(const QScxmlStateMachineInfo);
diff --git a/src/scxml/qscxmlstatemachineinfo_p.h b/src/scxml/qscxmlstatemachineinfo_p.h
index 10d4c02..04d1967 100644
--- a/src/scxml/qscxmlstatemachineinfo_p.h
+++ b/src/scxml/qscxmlstatemachineinfo_p.h
@@ -94,6 +94,7 @@ public: // methods
QVector<StateId> allStates() const;
QVector<TransitionId> allTransitions() const;
QString stateName(int stateId) const;
+ StateId stateParent(StateId stateId) const;
StateType stateType(int stateId) const;
QVector<StateId> stateChildren(StateId stateId) const;
TransitionType transitionType(TransitionId transitionId) const;