summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r--src/corelib/statemachine/qabstracttransition.cpp27
-rw-r--r--src/corelib/statemachine/qstate.cpp24
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp258
-rw-r--r--src/corelib/statemachine/qstatemachine.h22
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h17
5 files changed, 114 insertions, 234 deletions
diff --git a/src/corelib/statemachine/qabstracttransition.cpp b/src/corelib/statemachine/qabstracttransition.cpp
index c040c58..0004d3e 100644
--- a/src/corelib/statemachine/qabstracttransition.cpp
+++ b/src/corelib/statemachine/qabstracttransition.cpp
@@ -115,13 +115,10 @@ QAbstractTransitionPrivate *QAbstractTransitionPrivate::get(QAbstractTransition
QStateMachine *QAbstractTransitionPrivate::machine() const
{
- QObject *par = parent;
- while (par != 0) {
- if (QStateMachine *mach = qobject_cast<QStateMachine*>(par))
- return mach;
- par = par->parent();
- }
- return 0;
+ QState *source = sourceState();
+ if (!source)
+ return 0;
+ return source->machine();
}
bool QAbstractTransitionPrivate::callEventTest(QEvent *e)
@@ -256,10 +253,6 @@ void QAbstractTransition::setTargetStates(const QList<QAbstractState*> &targets)
qWarning("QAbstractTransition::setTargetStates: target state(s) cannot be null");
return;
}
- if (target->machine() != 0 && target->machine()->rootState() == target) {
- qWarning("QAbstractTransition::setTargetStates: root state cannot be target of transition");
- return;
- }
}
d->targetStates.clear();
@@ -330,18 +323,6 @@ QList<QAbstractAnimation*> QAbstractTransition::animations() const
This function is called to determine whether the given \a event should cause
this transition to trigger. Reimplement this function and return true if the
event should trigger the transition, otherwise return false.
-
-
- Note that \a event is a QWrappedEvent, which contains a clone of
- the event generated by Qt. For instance, if you want to check a
- key press event, do the following:
-
- \snippet doc/src/snippets/statemachine/eventtest.cpp 0
-
- You need to check if \a event is a QWrappedEvent because Qt also
- uses other events for internal reasons; you don't need to concern
- yourself with these in any case.
-
*/
/*!
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index 83dd869..f74edc3 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE
The assignProperty() function is used for defining property assignments that
should be performed when a state is entered.
- Top-level states must be passed QStateMachine::rootState() as their parent
+ Top-level states must be passed a QStateMachine object as their parent
state, or added to a state machine using QStateMachine::addState().
\section1 States with Child States
@@ -242,7 +242,7 @@ void QState::assignProperty(QObject *object, const char *name,
/*!
Returns this state's error state.
- \sa QStateMachine::errorState(), QStateMachine::setErrorState()
+ \sa QStateMachine::error()
*/
QAbstractState *QState::errorState() const
{
@@ -256,19 +256,17 @@ QAbstractState *QState::errorState() const
state recursively. If no error state is set for the state itself or any of
its ancestors, an error will cause the machine to stop executing and an error
will be printed to the console.
-
- \sa QStateMachine::setErrorState(), QStateMachine::errorState()
*/
void QState::setErrorState(QAbstractState *state)
{
Q_D(QState);
- if (state != 0 && state->machine() != machine()) {
- qWarning("QState::setErrorState: error state cannot belong "
- "to a different state machine");
+ if (state != 0 && qobject_cast<QStateMachine*>(state)) {
+ qWarning("QStateMachine::setErrorState: root state cannot be error state");
return;
}
- if (state != 0 && state->machine() != 0 && state->machine()->rootState() == state) {
- qWarning("QStateMachine::setErrorState: root state cannot be error state");
+ if (state != 0 && (!state->machine() || ((state->machine() != machine()) && !qobject_cast<QStateMachine*>(this)))) {
+ qWarning("QState::setErrorState: error state cannot belong "
+ "to a different state machine");
return;
}
@@ -288,12 +286,7 @@ QAbstractTransition *QState::addTransition(QAbstractTransition *transition)
return 0;
}
- // machine() will always be non-null for root state
- if (machine() != 0 && machine()->rootState() == this) {
- qWarning("QState::addTransition: cannot add transition from root state");
- return 0;
- }
-
+ transition->setParent(this);
const QList<QPointer<QAbstractState> > &targets = QAbstractTransitionPrivate::get(transition)->targetStates;
for (int i = 0; i < targets.size(); ++i) {
QAbstractState *t = targets.at(i);
@@ -308,7 +301,6 @@ QAbstractTransition *QState::addTransition(QAbstractTransition *transition)
return 0;
}
}
- transition->setParent(this);
if (machine() != 0 && machine()->configuration().contains(this))
QStateMachinePrivate::get(machine())->registerTransitions(this);
return transition;
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index bf3ee31..5402b04 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -102,14 +102,9 @@ QT_BEGIN_NAMESPACE
Framework}{overview} gives several state graphs and the code to
build them.
- The rootState() is the parent of all top-level states in the
- machine; it is used, for instance, when the state graph is
- deleted. It is created by the machine.
-
- Use the addState() function to add a state to the state machine.
- All top-level states are added to the root state. States are
- removed with the removeState() function. Removing states while the
- machine is running is discouraged.
+ Use the addState() function to add a top-level state to the state machine.
+ States are removed with the removeState() function. Removing states while
+ the machine is running is discouraged.
Before the machine can be started, the \l{initialState}{initial
state} must be set. The initial state is the state that the
@@ -179,26 +174,6 @@ This is
*/
/*!
- \property QStateMachine::rootState
-
- \brief the root state of this state machine
-*/
-
-/*!
- \property QStateMachine::initialState
-
- \brief the initial state of this state machine
-
- The initial state must be one of the rootState()'s child states.
-*/
-
-/*!
- \property QStateMachine::errorState
-
- \brief the error state of this state machine
-*/
-
-/*!
\property QStateMachine::errorString
\brief the error string of this state machine
@@ -235,7 +210,6 @@ QStateMachinePrivate::QStateMachinePrivate()
stop = false;
error = QStateMachine::NoError;
globalRestorePolicy = QStateMachine::DoNotRestoreProperties;
- rootState = 0;
signalEventGenerator = 0;
#ifndef QT_NO_ANIMATION
animationsEnabled = true;
@@ -255,6 +229,11 @@ QStateMachinePrivate *QStateMachinePrivate::get(QStateMachine *q)
return 0;
}
+QState *QStateMachinePrivate::rootState() const
+{
+ return const_cast<QStateMachine*>(q_func());
+}
+
static QEvent *cloneEvent(QEvent *e)
{
switch (e->type()) {
@@ -302,7 +281,9 @@ bool QStateMachinePrivate::stateEntryLessThan(QAbstractState *s1, QAbstractState
} else if (isDescendantOf(s2, s1)) {
return true;
} else {
- QState *lca = findLCA(QList<QAbstractState*>() << s1 << s2);
+ Q_ASSERT(s1->machine() != 0);
+ QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine());
+ QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2);
Q_ASSERT(lca != 0);
return (indexOfDescendant(lca, s1) < indexOfDescendant(lca, s2));
}
@@ -318,17 +299,19 @@ bool QStateMachinePrivate::stateExitLessThan(QAbstractState *s1, QAbstractState
} else if (isDescendantOf(s2, s1)) {
return false;
} else {
- QState *lca = findLCA(QList<QAbstractState*>() << s1 << s2);
+ Q_ASSERT(s1->machine() != 0);
+ QStateMachinePrivate *mach = QStateMachinePrivate::get(s1->machine());
+ QState *lca = mach->findLCA(QList<QAbstractState*>() << s1 << s2);
Q_ASSERT(lca != 0);
return (indexOfDescendant(lca, s1) < indexOfDescendant(lca, s2));
}
}
-QState *QStateMachinePrivate::findLCA(const QList<QAbstractState*> &states)
+QState *QStateMachinePrivate::findLCA(const QList<QAbstractState*> &states) const
{
if (states.isEmpty())
return 0;
- QList<QState*> ancestors = properAncestors(states.at(0), 0);
+ QList<QState*> ancestors = properAncestors(states.at(0), rootState()->parentState());
for (int i = 0; i < ancestors.size(); ++i) {
QState *anc = ancestors.at(i);
bool ok = true;
@@ -376,7 +359,7 @@ QSet<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *event
continue;
if (isPreempted(state, enabledTransitions))
continue;
- QList<QState*> lst = properAncestors(state, 0);
+ QList<QState*> lst = properAncestors(state, rootState()->parentState());
if (QState *grp = qobject_cast<QState*>(state))
lst.prepend(grp);
bool found = false;
@@ -557,11 +540,13 @@ QList<QAbstractState*> QStateMachinePrivate::enterStates(QEvent *event, const QL
if (isFinal(s)) {
QState *parent = s->parentState();
if (parent) {
- QState *grandparent = parent->parentState();
+ if (parent != rootState()) {
#ifdef QSTATEMACHINE_DEBUG
- qDebug() << q << ": emitting finished signal for" << parent;
+ qDebug() << q << ": emitting finished signal for" << parent;
#endif
- QStatePrivate::get(parent)->emitFinished();
+ QStatePrivate::get(parent)->emitFinished();
+ }
+ QState *grandparent = parent->parentState();
if (grandparent && isParallel(grandparent)) {
bool allChildStatesFinal = true;
QList<QAbstractState*> childStates = QStatePrivate::get(grandparent)->childStates();
@@ -572,7 +557,7 @@ QList<QAbstractState*> QStateMachinePrivate::enterStates(QEvent *event, const QL
break;
}
}
- if (allChildStatesFinal) {
+ if (allChildStatesFinal && (grandparent != rootState())) {
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": emitting finished signal for" << grandparent;
#endif
@@ -585,7 +570,7 @@ QList<QAbstractState*> QStateMachinePrivate::enterStates(QEvent *event, const QL
{
QSet<QAbstractState*>::const_iterator it;
for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) {
- if (isFinal(*it) && (*it)->parentState() == rootState) {
+ if (isFinal(*it) && (*it)->parentState() == rootState()) {
processing = false;
stopProcessingReason = Finished;
break;
@@ -630,6 +615,11 @@ void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root,
}
}
} else {
+ if (s == rootState()) {
+ // Error has already been set by exitStates().
+ Q_ASSERT(error != QStateMachine::NoError);
+ return;
+ }
statesToEnter.insert(s);
if (isParallel(s)) {
QState *grp = qobject_cast<QState*>(s);
@@ -643,6 +633,7 @@ void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root,
QState *grp = qobject_cast<QState*>(s);
QAbstractState *initial = grp->initialState();
if (initial != 0) {
+ Q_ASSERT(initial->machine() == q_func());
addStatesToEnter(initial, grp, statesToEnter, statesForDefaultEntry);
} else {
setError(QStateMachine::NoInitialStateError, grp);
@@ -873,20 +864,26 @@ bool QStateMachinePrivate::isParallel(const QAbstractState *s)
return ss && (QStatePrivate::get(ss)->childMode == QState::ParallelStates);
}
-bool QStateMachinePrivate::isCompound(const QAbstractState *s)
+bool QStateMachinePrivate::isCompound(const QAbstractState *s) const
{
const QState *group = qobject_cast<const QState*>(s);
if (!group)
return false;
+ bool isMachine = (qobject_cast<const QStateMachine*>(group) != 0);
+ // Don't treat the machine as compound if it's a sub-state of this machine
+ if (isMachine && (group != rootState()))
+ return false;
return (!isParallel(group) && !QStatePrivate::get(group)->childStates().isEmpty())
- || (qobject_cast<QStateMachine*>(group->parent()) != 0);
+ || isMachine;
}
-bool QStateMachinePrivate::isAtomic(const QAbstractState *s)
+bool QStateMachinePrivate::isAtomic(const QAbstractState *s) const
{
const QState *ss = qobject_cast<const QState*>(s);
return (ss && QStatePrivate::get(ss)->childStates().isEmpty())
- || isFinal(s);
+ || isFinal(s)
+ // Treat the machine as atomic if it's a sub-state of this machine
+ || (ss && (qobject_cast<const QStateMachine*>(ss) != 0) && (ss != rootState()));
}
@@ -1034,7 +1031,7 @@ void QStateMachinePrivate::setError(QStateMachine::Error errorCode, QAbstractSta
if (currentContext == currentErrorState)
currentErrorState = 0;
- Q_ASSERT(currentErrorState != rootState);
+ Q_ASSERT(currentErrorState != rootState());
if (currentErrorState != 0) {
QState *lca = findLCA(QList<QAbstractState*>() << currentErrorState << currentContext);
@@ -1141,11 +1138,8 @@ void QStateMachinePrivate::_q_start()
{
Q_Q(QStateMachine);
Q_ASSERT(state == Starting);
- if (!rootState) {
- state = NotRunning;
- return;
- }
- QAbstractState *initial = rootState->initialState();
+ Q_ASSERT(rootState() != 0);
+ QAbstractState *initial = rootState()->initialState();
configuration.clear();
qDeleteAll(internalEventQueue);
internalEventQueue.clear();
@@ -1159,7 +1153,7 @@ void QStateMachinePrivate::_q_start()
processingScheduled = true; // we call _q_process() below
emit q->started();
- StartState *start = new StartState(rootState);
+ StartState *start = new StartState(rootState());
QAbstractTransition *initialTransition = new InitialTransition(initial);
start->addTransition(initialTransition);
QList<QAbstractTransition*> transitions;
@@ -1371,15 +1365,22 @@ void QStateMachinePrivate::unregisterSignalTransition(QSignalTransition *transit
void QStateMachinePrivate::unregisterAllTransitions()
{
+ Q_Q(QStateMachine);
{
- QList<QSignalTransition*> transitions = qFindChildren<QSignalTransition*>(rootState);
- for (int i = 0; i < transitions.size(); ++i)
- unregisterSignalTransition(transitions.at(i));
+ QList<QSignalTransition*> transitions = qFindChildren<QSignalTransition*>(rootState());
+ for (int i = 0; i < transitions.size(); ++i) {
+ QSignalTransition *t = transitions.at(i);
+ if (t->machine() == q)
+ unregisterSignalTransition(t);
+ }
}
{
- QList<QEventTransition*> transitions = qFindChildren<QEventTransition*>(rootState);
- for (int i = 0; i < transitions.size(); ++i)
- unregisterEventTransition(transitions.at(i));
+ QList<QEventTransition*> transitions = qFindChildren<QEventTransition*>(rootState());
+ for (int i = 0; i < transitions.size(); ++i) {
+ QEventTransition *t = transitions.at(i);
+ if (t->machine() == q)
+ unregisterEventTransition(t);
+ }
}
}
@@ -1457,16 +1458,20 @@ void QStateMachinePrivate::handleTransitionSignal(const QObject *sender, int sig
Constructs a new state machine with the given \a parent.
*/
QStateMachine::QStateMachine(QObject *parent)
- : QObject(*new QStateMachinePrivate, parent)
+ : QState(*new QStateMachinePrivate, /*parentState=*/0)
{
+ // Can't pass the parent to the QState constructor, as it expects a QState
+ // But this works as expected regardless of whether parent is a QState or not
+ setParent(parent);
}
/*!
\internal
*/
QStateMachine::QStateMachine(QStateMachinePrivate &dd, QObject *parent)
- : QObject(dd, parent)
+ : QState(dd, /*parentState=*/0)
{
+ setParent(parent);
}
/*!
@@ -1476,69 +1481,6 @@ QStateMachine::~QStateMachine()
{
}
-namespace {
-
-class RootState : public QState
-{
-public:
- RootState(QState *parent)
- : QState(parent)
- {
- }
-
- void onEntry(QEvent *) {}
- void onExit(QEvent *) {}
-};
-
-} // namespace
-
-/*!
- Returns this state machine's root state.
-*/
-QState *QStateMachine::rootState() const
-{
- Q_D(const QStateMachine);
- if (!d->rootState) {
- const_cast<QStateMachinePrivate*>(d)->rootState = new RootState(0);
- d->rootState->setParent(const_cast<QStateMachine*>(this));
- }
- return d->rootState;
-}
-
-/*!
- Returns the error state of the state machine's root state.
-
- \sa QState::errorState()
-*/
-QAbstractState *QStateMachine::errorState() const
-{
- return rootState()->errorState();
-}
-
-/*!
- Sets the error state of this state machine's root state to be \a state. When a running state
- machine encounters an error which puts it in an undefined state, it will enter an error state
- based on the context of the error that occurred. It will enter this state regardless of what
- is currently in the event queue.
-
- If the erroneous state has an error state set, this will be entered by the machine. If no error
- state has been set, the state machine will search the parent hierarchy recursively for an
- error state. The error state of the root state can thus be seen as a global error state that
- applies for all states for which a more specific error state has not been set.
-
- Before entering the error state, the state machine will set the error code returned by error() and
- error message returned by errorString().
-
- If there is no error state available for the erroneous state, the state machine will print a
- warning message on the console and stop executing.
-
- \sa QState::setErrorState(), rootState()
-*/
-void QStateMachine::setErrorState(QAbstractState *state)
-{
- rootState()->setErrorState(state);
-}
-
/*! \enum QStateMachine::Error
This enum type defines errors that can occur in the state machine at run time. When the state
@@ -1640,39 +1582,13 @@ void QStateMachine::setGlobalRestorePolicy(QStateMachine::RestorePolicy restoreP
}
/*!
- Returns this state machine's initial state, or 0 if no initial state has
- been set.
-*/
-QAbstractState *QStateMachine::initialState() const
-{
- Q_D(const QStateMachine);
- if (!d->rootState)
- return 0;
- return d->rootState->initialState();
-}
-
-/*!
- Sets this state machine's initial \a state.
-*/
-void QStateMachine::setInitialState(QAbstractState *state)
-{
- Q_D(QStateMachine);
- if (!d->rootState) {
- if (!state)
- return;
- rootState()->setInitialState(state);
- }
- d->rootState->setInitialState(state);
-}
-
-/*!
Adds the given \a state to this state machine. The state becomes a top-level
- state (i.e. a child of the rootState()).
+ state.
If the state is already in a different machine, it will first be removed
from its old machine, and then added to this machine.
- \sa removeState(), rootState(), setInitialState()
+ \sa removeState(), setInitialState()
*/
void QStateMachine::addState(QAbstractState *state)
{
@@ -1684,7 +1600,7 @@ void QStateMachine::addState(QAbstractState *state)
qWarning("QStateMachine::addState: state has already been added to this machine");
return;
}
- state->setParent(rootState());
+ state->setParent(this);
}
/*!
@@ -1730,7 +1646,7 @@ void QStateMachine::start()
{
Q_D(QStateMachine);
- if (rootState()->initialState() == 0) {
+ if (initialState() == 0) {
qWarning("QStateMachine::start: No initial state set for machine. Refusing to start.");
return;
}
@@ -1821,7 +1737,7 @@ void QStateMachine::postInternalEvent(QEvent *event)
Returns the maximal consistent set of states (including parallel and final
states) that this state machine is currently in. If a state \c s is in the
configuration, it is always the case that the parent of \c s is also in
- c. Note, however, that the rootState() is not an explicit member of the
+ c. Note, however, that the machine itself is not an explicit member of the
configuration.
*/
QSet<QAbstractState*> QStateMachine::configuration() const
@@ -1840,15 +1756,6 @@ QSet<QAbstractState*> QStateMachine::configuration() const
*/
/*!
- \fn QStateMachine::finished()
-
- This signal is emitted when the state machine has reached a top-level final
- state (QFinalState).
-
- \sa QStateMachine::started()
-*/
-
-/*!
\fn QStateMachine::stopped()
This signal is emitted when the state machine has stopped.
@@ -1872,14 +1779,6 @@ bool QStateMachine::event(QEvent *e)
d->scheduleProcess();
return true;
}
- } else if (e->type() == QEvent::ChildAdded) {
- QChildEvent *ce = static_cast<QChildEvent*>(e);
- if (QAbstractState *state = qobject_cast<QAbstractState*>(ce->child())) {
- if (state != rootState()) {
- state->setParent(rootState());
- return true;
- }
- }
}
return QObject::event(e);
}
@@ -1949,6 +1848,24 @@ void QStateMachine::endMicrostep(QEvent *event)
Q_UNUSED(event);
}
+/*!
+ \reimp
+*/
+void QStateMachine::onEntry(QEvent *event)
+{
+ start();
+ QState::onEntry(event);
+}
+
+/*!
+ \reimp
+*/
+void QStateMachine::onExit(QEvent *event)
+{
+ stop();
+ QState::onExit(event);
+}
+
#ifndef QT_NO_ANIMATION
/*!
@@ -2155,6 +2072,8 @@ QSignalEvent::~QSignalEvent()
Constructs a new QWrappedEvent object with the given \a object
and \a event.
+
+ The QWrappedEvent object takes ownership of \a event.
*/
QWrappedEvent::QWrappedEvent(QObject *object, QEvent *event)
: QEvent(QEvent::Wrapped), m_object(object), m_event(event)
@@ -2166,6 +2085,7 @@ QWrappedEvent::QWrappedEvent(QObject *object, QEvent *event)
*/
QWrappedEvent::~QWrappedEvent()
{
+ delete m_event;
}
/*!
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index 30d0e3a..230d852 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -42,7 +42,7 @@
#ifndef QSTATEMACHINE_H
#define QSTATEMACHINE_H
-#include <QtCore/qabstractstate.h>
+#include <QtCore/qstate.h>
#include <QtCore/qlist.h>
#include <QtCore/qobject.h>
@@ -57,18 +57,12 @@ QT_MODULE(Core)
#ifndef QT_NO_STATEMACHINE
class QEvent;
-class QAbstractState;
-class QState;
class QStateMachinePrivate;
class QAbstractAnimation;
-class QAbstractState;
-class Q_CORE_EXPORT QStateMachine : public QObject
+class Q_CORE_EXPORT QStateMachine : public QState
{
Q_OBJECT
- Q_PROPERTY(QState* rootState READ rootState)
- Q_PROPERTY(QAbstractState* initialState READ initialState WRITE setInitialState)
- Q_PROPERTY(QAbstractState* errorState READ errorState WRITE setErrorState)
Q_PROPERTY(QString errorString READ errorString)
Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy)
Q_ENUMS(RestorePolicy)
@@ -94,14 +88,6 @@ public:
void addState(QAbstractState *state);
void removeState(QAbstractState *state);
- QState *rootState() const;
-
- QAbstractState *initialState() const;
- void setInitialState(QAbstractState *state);
-
- QAbstractState *errorState() const;
- void setErrorState(QAbstractState *state);
-
Error error() const;
QString errorString() const;
void clearError();
@@ -135,9 +121,11 @@ public Q_SLOTS:
Q_SIGNALS:
void started();
void stopped();
- void finished();
protected:
+ void onEntry(QEvent *event);
+ void onExit(QEvent *event);
+
void postInternalEvent(QEvent *event);
virtual void beginSelectTransitions(QEvent *event);
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index 1335b93..21e405d 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -53,7 +53,8 @@
// We mean it.
//
-#include <private/qobject_p.h>
+#include "private/qstate_p.h"
+
#include <QtCore/qcoreevent.h>
#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
@@ -61,9 +62,6 @@
#include <QtCore/qset.h>
#include <QtCore/qvector.h>
-#include "qstate.h"
-#include "private/qstate_p.h"
-
QT_BEGIN_NAMESPACE
class QEvent;
@@ -81,7 +79,7 @@ class QAbstractAnimation;
#endif
class QStateMachine;
-class QStateMachinePrivate : public QObjectPrivate
+class QStateMachinePrivate : public QStatePrivate
{
Q_DECLARE_PUBLIC(QStateMachine)
public:
@@ -101,7 +99,7 @@ public:
static QStateMachinePrivate *get(QStateMachine *q);
- static QState *findLCA(const QList<QAbstractState*> &states);
+ QState *findLCA(const QList<QAbstractState*> &states) const;
static bool stateEntryLessThan(QAbstractState *s1, QAbstractState *s2);
static bool stateExitLessThan(QAbstractState *s1, QAbstractState *s2);
@@ -116,6 +114,8 @@ public:
void _q_animationFinished();
#endif
+ QState *rootState() const;
+
void microstep(QEvent *event, const QList<QAbstractTransition*> &transitionList);
bool isPreempted(const QAbstractState *s, const QSet<QAbstractTransition*> &transitions) const;
QSet<QAbstractTransition*> selectTransitions(QEvent *event) const;
@@ -133,8 +133,8 @@ public:
bool isInFinalState(QAbstractState *s) const;
static bool isFinal(const QAbstractState *s);
static bool isParallel(const QAbstractState *s);
- static bool isCompound(const QAbstractState *s);
- static bool isAtomic(const QAbstractState *s);
+ bool isCompound(const QAbstractState *s) const;
+ bool isAtomic(const QAbstractState *s) const;
static bool isDescendantOf(const QAbstractState *s, const QAbstractState *other);
static QList<QState*> properAncestors(const QAbstractState *s, const QState *upperBound);
@@ -164,7 +164,6 @@ public:
bool processingScheduled;
bool stop;
StopProcessingReason stopProcessingReason;
- QState *rootState;
QSet<QAbstractState*> configuration;
QList<QEvent*> internalEventQueue;
QList<QEvent*> externalEventQueue;