summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-04-29 09:40:38 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-04-29 09:41:13 (GMT)
commitfa612960f423aa413d6d83813807a470aef27d7d (patch)
tree0eda17fc34fd88831cb15168b28eba0e1ca4e5a3 /src/corelib
parentc731d50a8ac908da982c911c73509cdd766c4c0f (diff)
downloadQt-fa612960f423aa413d6d83813807a470aef27d7d.zip
Qt-fa612960f423aa413d6d83813807a470aef27d7d.tar.gz
Qt-fa612960f423aa413d6d83813807a470aef27d7d.tar.bz2
replace QState::Type with QState::childMode property
Result of API review.
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/statemachine/qstate.cpp58
-rw-r--r--src/corelib/statemachine/qstate.h16
-rw-r--r--src/corelib/statemachine/qstate_p.h2
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp4
4 files changed, 61 insertions, 19 deletions
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index dd3af51..5b49f1f 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -81,20 +81,37 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \enum QState::Type
+ \property QState::initialState
- This enum specifies the type of a state.
+ \brief the initial state of this state
+*/
+
+/*!
+ \property QState::errorState
+
+ \brief the error state of this state
+*/
+
+/*!
+ \property QState::childMode
+
+ \brief the child mode of this state
+*/
+
+/*!
+ \enum QState::ChildMode
+
+ This enum specifies how a state's child states are treated.
- \value Normal A normal state. If the state has no child states, it is an
- atomic state; otherwise, the child states are mutually exclusive and an
+ \value ExclusiveStates The child states are mutually exclusive and an
initial state must be set by calling QState::setInitialState().
- \value ParallelGroup The state is a parallel group state. When a parallel
- group state is entered, all its child states are entered in parallel.
+ \value ParallelStates The child states are parallel. When the parent state
+ is entered, all its child states are entered in parallel.
*/
QStatePrivate::QStatePrivate()
- : errorState(0), isParallelGroup(false), initialState(0)
+ : errorState(0), initialState(0), childMode(QState::ExclusiveStates)
{
}
@@ -131,13 +148,14 @@ QState::QState(QState *parent)
}
/*!
- Constructs a new state of the given \a type with the given \a parent state.
+ Constructs a new state with the given \a childMode and the given \a parent
+ state.
*/
-QState::QState(Type type, QState *parent)
+QState::QState(ChildMode childMode, QState *parent)
: QAbstractState(*new QStatePrivate, parent)
{
Q_D(QState);
- d->isParallelGroup = (type == ParallelGroup);
+ d->childMode = childMode;
}
/*!
@@ -393,7 +411,7 @@ QAbstractState *QState::initialState() const
void QState::setInitialState(QAbstractState *state)
{
Q_D(QState);
- if (d->isParallelGroup) {
+ if (d->childMode == QState::ParallelStates) {
qWarning("QState::setInitialState: ignoring attempt to set initial state "
"of parallel state group %p", this);
return;
@@ -407,6 +425,24 @@ void QState::setInitialState(QAbstractState *state)
}
/*!
+ Returns the child mode of this state.
+*/
+QState::ChildMode QState::childMode() const
+{
+ Q_D(const QState);
+ return d->childMode;
+}
+
+/*!
+ Sets the child \a mode of this state.
+*/
+void QState::setChildMode(ChildMode mode)
+{
+ Q_D(QState);
+ d->childMode = mode;
+}
+
+/*!
\reimp
*/
bool QState::event(QEvent *e)
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index 33f0709..926d41f 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -55,21 +55,24 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Core)
class QAbstractTransition;
-class QHistoryState;
class QSignalTransition;
class QStatePrivate;
class Q_CORE_EXPORT QState : public QAbstractState
{
Q_OBJECT
+ Q_PROPERTY(QAbstractState* initialState READ initialState WRITE setInitialState)
+ Q_PROPERTY(QAbstractState* errorState READ errorState WRITE setErrorState)
+ Q_PROPERTY(ChildMode childMode READ childMode WRITE setChildMode)
+ Q_ENUMS(ChildMode)
public:
- enum Type {
- Normal,
- ParallelGroup
+ enum ChildMode {
+ ExclusiveStates,
+ ParallelStates
};
QState(QState *parent = 0);
- QState(Type type, QState *parent = 0);
+ QState(ChildMode childMode, QState *parent = 0);
~QState();
QAbstractState *errorState() const;
@@ -84,6 +87,9 @@ public:
QAbstractState *initialState() const;
void setInitialState(QAbstractState *state);
+ ChildMode childMode() const;
+ void setChildMode(ChildMode mode);
+
void assignProperty(QObject *object, const char *name,
const QVariant &value);
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 603bc18..0c8c858 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -94,8 +94,8 @@ public:
void emitFinished();
QAbstractState *errorState;
- bool isParallelGroup;
QAbstractState *initialState;
+ QState::ChildMode childMode;
QList<QPropertyAssignment> propertyAssignments;
};
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 020700e..0ddeac9 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -751,7 +751,7 @@ bool QStateMachinePrivate::isFinal(const QAbstractState *s)
bool QStateMachinePrivate::isParallel(const QAbstractState *s)
{
const QState *ss = qobject_cast<const QState*>(s);
- return ss && QStatePrivate::get(ss)->isParallelGroup;
+ return ss && (QStatePrivate::get(ss)->childMode == QState::ParallelStates);
}
bool QStateMachinePrivate::isCompound(const QAbstractState *s)
@@ -766,7 +766,7 @@ bool QStateMachinePrivate::isCompound(const QAbstractState *s)
bool QStateMachinePrivate::isAtomic(const QAbstractState *s)
{
const QState *ss = qobject_cast<const QState*>(s);
- return (ss && !QStatePrivate::get(ss)->isParallelGroup
+ return (ss && (QStatePrivate::get(ss)->childMode != QState::ParallelStates)
&& QStatePrivate::get(ss)->childStates().isEmpty())
|| isFinal(s);
}