summaryrefslogtreecommitdiffstats
path: root/src/corelib/statemachine
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/statemachine')
-rw-r--r--src/corelib/statemachine/qstate.cpp31
-rw-r--r--src/corelib/statemachine/qstate.h4
-rw-r--r--src/corelib/statemachine/qstate_p.h2
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp30
-rw-r--r--src/corelib/statemachine/qstatemachine.h8
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h2
6 files changed, 41 insertions, 36 deletions
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index 5dc310b..cf718a5 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -140,10 +140,10 @@ void QStatePrivate::emitFinished()
emit q->finished();
}
-void QStatePrivate::emitPolished()
+void QStatePrivate::emitPropertiesAssigned()
{
Q_Q(QState);
- emit q->polished();
+ emit q->propertiesAssigned();
}
/*!
@@ -229,7 +229,7 @@ QList<QAbstractTransition*> QStatePrivate::transitions() const
Instructs this state to set the property with the given \a name of the given
\a object to the given \a value when the state is entered.
- \sa polished()
+ \sa propertiesAssigned()
*/
void QState::assignProperty(QObject *object, const char *name,
const QVariant &value)
@@ -287,15 +287,14 @@ void QState::setErrorState(QAbstractState *state)
/*!
Adds the given \a transition. The transition has this state as the source.
- This state takes ownership of the transition. If the transition is successfully
- added, the function will return the \a transition pointer. Otherwise it will return null.
+ This state takes ownership of the transition.
*/
-QAbstractTransition *QState::addTransition(QAbstractTransition *transition)
+void QState::addTransition(QAbstractTransition *transition)
{
Q_D(QState);
if (!transition) {
qWarning("QState::addTransition: cannot add null transition");
- return 0;
+ return ;
}
transition->setParent(this);
@@ -304,18 +303,17 @@ QAbstractTransition *QState::addTransition(QAbstractTransition *transition)
QAbstractState *t = targets.at(i).data();
if (!t) {
qWarning("QState::addTransition: cannot add transition to null state");
- return 0;
+ return ;
}
if ((QAbstractStatePrivate::get(t)->machine() != d->machine())
&& QAbstractStatePrivate::get(t)->machine() && d->machine()) {
qWarning("QState::addTransition: cannot add transition "
"to a state in a different state machine");
- return 0;
+ return ;
}
}
if (machine() != 0 && machine()->configuration().contains(this))
QStateMachinePrivate::get(machine())->registerTransitions(this);
- return transition;
}
/*!
@@ -380,7 +378,8 @@ QAbstractTransition *QState::addTransition(QAbstractState *target)
return 0;
}
UnconditionalTransition *trans = new UnconditionalTransition(target);
- return addTransition(trans);
+ addTransition(trans);
+ return trans;
}
/*!
@@ -493,9 +492,15 @@ bool QState::event(QEvent *e)
*/
/*!
- \fn QState::polished()
+ \fn QState::propertiesAssigned()
+
+ This signal is emitted when all properties have been assigned their final value. If the state
+ assigns a value to one or more properties for which an animation exists (either set on the
+ transition or as a default animation on the state machine), then the signal will not be emitted
+ until all such animations have finished playing.
- This signal is emitted when all properties have been assigned their final value.
+ If there are no relevant animations, or no property assignments defined for the state, then
+ the signal will be emitted immediately before the state is entered.
\sa QState::assignProperty(), QAbstractTransition::addAnimation()
*/
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index 7a47447..423f940 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -76,7 +76,7 @@ public:
QAbstractState *errorState() const;
void setErrorState(QAbstractState *state);
- QAbstractTransition *addTransition(QAbstractTransition *transition);
+ void addTransition(QAbstractTransition *transition);
QSignalTransition *addTransition(QObject *sender, const char *signal, QAbstractState *target);
QAbstractTransition *addTransition(QAbstractState *target);
void removeTransition(QAbstractTransition *transition);
@@ -94,7 +94,7 @@ public:
Q_SIGNALS:
void finished();
- void polished();
+ void propertiesAssigned();
protected:
void onEntry(QEvent *event);
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 34c8838..7fe6279 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -94,7 +94,7 @@ public:
QList<QAbstractTransition*> transitions() const;
void emitFinished();
- void emitPolished();
+ void emitPropertiesAssigned();
QAbstractState *errorState;
QAbstractState *initialState;
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index ea5587e..cf951c9 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -159,12 +159,12 @@ QT_BEGIN_NAMESPACE
\brief the restore policy for states of this state machine.
The default value of this property is
- QStateMachine::DoNotRestoreProperties.
+ QStateMachine::DontRestoreProperties.
*/
#ifndef QT_NO_ANIMATION
/*!
- \property QStateMachine::animationsEnabled
+ \property QStateMachine::animated
\brief whether animations are enabled
@@ -187,10 +187,10 @@ QStateMachinePrivate::QStateMachinePrivate()
stop = false;
stopProcessingReason = EventQueueEmpty;
error = QStateMachine::NoError;
- globalRestorePolicy = QStateMachine::DoNotRestoreProperties;
+ globalRestorePolicy = QStateMachine::DontRestoreProperties;
signalEventGenerator = 0;
#ifndef QT_NO_ANIMATION
- animationsEnabled = true;
+ animated = true;
#endif
}
@@ -744,7 +744,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
// Find the animations to use for the state change.
QList<QAbstractAnimation*> selectedAnimations;
- if (animationsEnabled) {
+ if (animated) {
for (int i = 0; i < transitionList.size(); ++i) {
QAbstractTransition *transition = transitionList.at(i);
@@ -809,7 +809,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
if (anim->state() == QAbstractAnimation::Running) {
// The animation is still running. This can happen if the
// animation is a group, and one of its children just finished,
- // and that caused a state to emit its polished() signal, and
+ // and that caused a state to emit its propertiesAssigned() signal, and
// that triggered a transition in the machine.
// Just stop the animation so it is correctly restarted again.
anim->stop();
@@ -831,7 +831,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
}
}
- // Emit polished signal for entered states that have no animated properties.
+ // Emit propertiesAssigned signal for entered states that have no animated properties.
for (int i = 0; i < enteredStates.size(); ++i) {
QState *s = toStandardState(enteredStates.at(i));
if (s
@@ -839,7 +839,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
&& !animationsForState.contains(s)
#endif
)
- QStatePrivate::get(s)->emitPolished();
+ QStatePrivate::get(s)->emitPropertiesAssigned();
}
}
@@ -1130,7 +1130,7 @@ void QStateMachinePrivate::_q_animationFinished()
animations.removeOne(anim);
if (animations.isEmpty()) {
animationsForState.erase(it);
- QStatePrivate::get(toStandardState(state))->emitPolished();
+ QStatePrivate::get(toStandardState(state))->emitPropertiesAssigned();
}
}
@@ -1726,7 +1726,7 @@ QStateMachine::~QStateMachine()
already been saved by the state machine, it will not be overwritten until the property has been
successfully restored.
- \value DoNotRestoreProperties The state machine should not save the initial values of properties
+ \value DontRestoreProperties The state machine should not save the initial values of properties
and restore them later.
\value RestoreProperties The state machine should save the initial values of properties
and restore them later.
@@ -1776,7 +1776,7 @@ QStateMachine::RestorePolicy QStateMachine::globalRestorePolicy() const
/*!
Sets the restore policy of the state machine to \a restorePolicy. The default
- restore policy is QAbstractState::DoNotRestoreProperties.
+ restore policy is QAbstractState::DontRestoreProperties.
\sa globalRestorePolicy()
*/
@@ -2146,19 +2146,19 @@ void QStateMachine::onExit(QEvent *event)
/*!
Returns whether animations are enabled for this state machine.
*/
-bool QStateMachine::animationsEnabled() const
+bool QStateMachine::isAnimated() const
{
Q_D(const QStateMachine);
- return d->animationsEnabled;
+ return d->animated;
}
/*!
Sets whether animations are \a enabled for this state machine.
*/
-void QStateMachine::setAnimationsEnabled(bool enabled)
+void QStateMachine::setAnimated(bool enabled)
{
Q_D(QStateMachine);
- d->animationsEnabled = enabled;
+ d->animated = enabled;
}
/*!
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index 13b6fe2..ff2b667 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -67,7 +67,7 @@ class Q_CORE_EXPORT QStateMachine : public QState
Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy)
Q_ENUMS(RestorePolicy)
#ifndef QT_NO_ANIMATION
- Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled)
+ Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
#endif
public:
class SignalEvent : public QEvent
@@ -109,7 +109,7 @@ public:
};
enum RestorePolicy {
- DoNotRestoreProperties,
+ DontRestoreProperties,
RestoreProperties
};
@@ -133,8 +133,8 @@ public:
bool isRunning() const;
#ifndef QT_NO_ANIMATION
- bool animationsEnabled() const;
- void setAnimationsEnabled(bool enabled);
+ bool isAnimated() const;
+ void setAnimated(bool enabled);
void addDefaultAnimation(QAbstractAnimation *animation);
QList<QAbstractAnimation *> defaultAnimations() const;
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index 01c9361..aad5c67 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -207,7 +207,7 @@ public:
QSet<QAbstractState *> pendingErrorStatesForDefaultEntry;
#ifndef QT_NO_ANIMATION
- bool animationsEnabled;
+ bool animated;
QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> >
initializeAnimation(QAbstractAnimation *abstractAnimation,