summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-11-03 15:29:58 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2009-11-03 15:29:58 (GMT)
commitbf2ba79d1cdc0d5347d394a892bee287bc84fb81 (patch)
treeb6032f84dbad1fc1c4dea3c66a943aae5e560c84
parenta4e7db378ecd11bc858f76beb33c56ccebef6308 (diff)
parentddd1c40712a6a50b0574341087118fe4db67c3b2 (diff)
downloadQt-bf2ba79d1cdc0d5347d394a892bee287bc84fb81.zip
Qt-bf2ba79d1cdc0d5347d394a892bee287bc84fb81.tar.gz
Qt-bf2ba79d1cdc0d5347d394a892bee287bc84fb81.tar.bz2
Merge branch 'statemachine-api-changes' into 4.6
Conflicts: doc/src/frameworks-technologies/statemachine.qdoc src/corelib/statemachine/qstatemachine.cpp
-rw-r--r--doc/src/examples/stickman.qdoc9
-rw-r--r--doc/src/frameworks-technologies/statemachine.qdoc10
-rw-r--r--doc/src/snippets/statemachine/main5.cpp2
-rw-r--r--examples/animation/stickman/lifecycle.cpp4
-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
-rw-r--r--src/gui/statemachine/qbasickeyeventtransition.cpp24
-rw-r--r--src/gui/statemachine/qbasickeyeventtransition_p.h6
-rw-r--r--src/gui/statemachine/qbasicmouseeventtransition.cpp24
-rw-r--r--src/gui/statemachine/qbasicmouseeventtransition_p.h8
-rw-r--r--src/gui/statemachine/qkeyeventtransition.cpp18
-rw-r--r--src/gui/statemachine/qkeyeventtransition.h6
-rw-r--r--src/gui/statemachine/qmouseeventtransition.cpp30
-rw-r--r--src/gui/statemachine/qmouseeventtransition.h10
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp94
19 files changed, 171 insertions, 151 deletions
diff --git a/doc/src/examples/stickman.qdoc b/doc/src/examples/stickman.qdoc
index e70c39b..c9e98d0 100644
--- a/doc/src/examples/stickman.qdoc
+++ b/doc/src/examples/stickman.qdoc
@@ -55,9 +55,9 @@
Animations are implemented as composite states. Each child state of the animation state
represents a frame in the animation by setting the position of each joint in the stickman's
skeleton to the positions defined for the particular frame. The frames are then bound together
- with animated transitions that trigger on the source state's polished() signal. Thus, the
- machine will enter the state representing the next frame in the animation immediately after it
- has finished animating into the previous frame.
+ with animated transitions that trigger on the source state's propertiesAssigned() signal. Thus,
+ the machine will enter the state representing the next frame in the animation immediately after
+ it has finished animating into the previous frame.
\image stickman-example1.png
@@ -67,7 +67,8 @@
\snippet examples/animation/stickman/lifecycle.cpp 1
- The states are then bound together with signal transitions that listen to the polished() signal.
+ The states are then bound together with signal transitions that listen to the
+ propertiesAssigned() signal.
\snippet examples/animation/stickman/lifecycle.cpp 2
diff --git a/doc/src/frameworks-technologies/statemachine.qdoc b/doc/src/frameworks-technologies/statemachine.qdoc
index 9614dd3..b0b13a7 100644
--- a/doc/src/frameworks-technologies/statemachine.qdoc
+++ b/doc/src/frameworks-technologies/statemachine.qdoc
@@ -495,9 +495,9 @@
message box will pop up before the geometry of the button has actually been set.
To ensure that the message box does not pop up until the geometry actually reaches its final
- value, we can use the state's polished() signal. The polished() signal will be emitted when the
- the property is assigned its final value, whether this is done immediately or after the animation
- has finished playing.
+ value, we can use the state's propertiesAssigned() signal. The propertiesAssigned() signal will be
+ emitted when the property is assigned its final value, whether this is done immediately or
+ after the animation has finished playing.
\snippet doc/src/snippets/statemachine/main5.cpp 6
@@ -512,14 +512,14 @@
has been assigned the defined value.
If the global restore policy is set to QStateMachine::RestoreProperties, the state will not emit
- the polished() signal until these have been executed as well.
+ the propertiesAssigned() signal until these have been executed as well.
\section1 What Happens If A State Is Exited Before The Animation Has Finished
If a state has property assignments, and the transition into the state has animations for the
properties, the state can potentially be exited before the properties have been assigned to the
values defines by the state. This is true in particular when there are transitions out from the
- state that do not depend on the state being polished, as described in the previous section.
+ state that do not depend on the propertiesAssigned signal, as described in the previous section.
The State Machine API guarantees that a property assigned by the state machine either:
\list
diff --git a/doc/src/snippets/statemachine/main5.cpp b/doc/src/snippets/statemachine/main5.cpp
index 346cbce..ff25b7b 100644
--- a/doc/src/snippets/statemachine/main5.cpp
+++ b/doc/src/snippets/statemachine/main5.cpp
@@ -145,7 +145,7 @@ int main(int argv, char **args)
connect(s3, SIGNAL(entered()), messageBox, SLOT(exec()));
s1->addTransition(button, SIGNAL(clicked()), s2);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
//![6]
}
diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp
index 250fb85..1b6f9cd 100644
--- a/examples/animation/stickman/lifecycle.cpp
+++ b/examples/animation/stickman/lifecycle.cpp
@@ -194,14 +194,14 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa
topLevel->setInitialState(frameState);
else
//! [2]
- previousState->addTransition(previousState, SIGNAL(polished()), frameState);
+ previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState);
//! [2]
previousState = frameState;
}
// Loop
- previousState->addTransition(previousState, SIGNAL(polished()), topLevel->initialState());
+ previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), topLevel->initialState());
return topLevel;
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,
diff --git a/src/gui/statemachine/qbasickeyeventtransition.cpp b/src/gui/statemachine/qbasickeyeventtransition.cpp
index 445a253..bf10e3d 100644
--- a/src/gui/statemachine/qbasickeyeventtransition.cpp
+++ b/src/gui/statemachine/qbasickeyeventtransition.cpp
@@ -68,14 +68,14 @@ public:
QEvent::Type eventType;
int key;
- Qt::KeyboardModifiers modifiersMask;
+ Qt::KeyboardModifiers modifierMask;
};
QBasicKeyEventTransitionPrivate::QBasicKeyEventTransitionPrivate()
{
eventType = QEvent::None;
key = 0;
- modifiersMask = Qt::NoModifier;
+ modifierMask = Qt::NoModifier;
}
QBasicKeyEventTransitionPrivate *QBasicKeyEventTransitionPrivate::get(QBasicKeyEventTransition *q)
@@ -106,17 +106,17 @@ QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key,
/*!
Constructs a new event transition for events of the given \a type for the
- given \a key, with the given \a modifiersMask and \a sourceState.
+ given \a key, with the given \a modifierMask and \a sourceState.
*/
QBasicKeyEventTransition::QBasicKeyEventTransition(QEvent::Type type, int key,
- Qt::KeyboardModifiers modifiersMask,
+ Qt::KeyboardModifiers modifierMask,
QState *sourceState)
: QAbstractTransition(*new QBasicKeyEventTransitionPrivate, sourceState)
{
Q_D(QBasicKeyEventTransition);
d->eventType = type;
d->key = key;
- d->modifiersMask = modifiersMask;
+ d->modifierMask = modifierMask;
}
/*!
@@ -163,23 +163,23 @@ void QBasicKeyEventTransition::setKey(int key)
}
/*!
- Returns the keyboard modifiers mask that this key event transition checks
+ Returns the keyboard modifier mask that this key event transition checks
for.
*/
-Qt::KeyboardModifiers QBasicKeyEventTransition::modifiersMask() const
+Qt::KeyboardModifiers QBasicKeyEventTransition::modifierMask() const
{
Q_D(const QBasicKeyEventTransition);
- return d->modifiersMask;
+ return d->modifierMask;
}
/*!
- Sets the keyboard modifiers mask that this key event transition will check
+ Sets the keyboard modifier mask that this key event transition will check
for.
*/
-void QBasicKeyEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+void QBasicKeyEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
{
Q_D(QBasicKeyEventTransition);
- d->modifiersMask = modifiersMask;
+ d->modifierMask = modifierMask;
}
/*!
@@ -191,7 +191,7 @@ bool QBasicKeyEventTransition::eventTest(QEvent *event)
if (event->type() == d->eventType) {
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
return (ke->key() == d->key)
- && ((ke->modifiers() & d->modifiersMask) == d->modifiersMask);
+ && ((ke->modifiers() & d->modifierMask) == d->modifierMask);
}
return false;
}
diff --git a/src/gui/statemachine/qbasickeyeventtransition_p.h b/src/gui/statemachine/qbasickeyeventtransition_p.h
index 3c2ec7d..87d3dc7 100644
--- a/src/gui/statemachine/qbasickeyeventtransition_p.h
+++ b/src/gui/statemachine/qbasickeyeventtransition_p.h
@@ -69,7 +69,7 @@ public:
QBasicKeyEventTransition(QState *sourceState = 0);
QBasicKeyEventTransition(QEvent::Type type, int key, QState *sourceState = 0);
QBasicKeyEventTransition(QEvent::Type type, int key,
- Qt::KeyboardModifiers modifiersMask,
+ Qt::KeyboardModifiers modifierMask,
QState *sourceState = 0);
~QBasicKeyEventTransition();
@@ -79,8 +79,8 @@ public:
int key() const;
void setKey(int key);
- Qt::KeyboardModifiers modifiersMask() const;
- void setModifiersMask(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifierMask() const;
+ void setModifierMask(Qt::KeyboardModifiers modifiers);
protected:
bool eventTest(QEvent *event);
diff --git a/src/gui/statemachine/qbasicmouseeventtransition.cpp b/src/gui/statemachine/qbasicmouseeventtransition.cpp
index 694c319..fe0dea9 100644
--- a/src/gui/statemachine/qbasicmouseeventtransition.cpp
+++ b/src/gui/statemachine/qbasicmouseeventtransition.cpp
@@ -69,7 +69,7 @@ public:
QEvent::Type eventType;
Qt::MouseButton button;
- Qt::KeyboardModifiers modifiersMask;
+ Qt::KeyboardModifiers modifierMask;
QPainterPath path;
};
@@ -149,38 +149,38 @@ void QBasicMouseEventTransition::setButton(Qt::MouseButton button)
}
/*!
- Returns the keyboard modifiers mask that this mouse event transition checks
+ Returns the keyboard modifier mask that this mouse event transition checks
for.
*/
-Qt::KeyboardModifiers QBasicMouseEventTransition::modifiersMask() const
+Qt::KeyboardModifiers QBasicMouseEventTransition::modifierMask() const
{
Q_D(const QBasicMouseEventTransition);
- return d->modifiersMask;
+ return d->modifierMask;
}
/*!
- Sets the keyboard modifiers mask that this mouse event transition will check
+ Sets the keyboard modifier mask that this mouse event transition will check
for.
*/
-void QBasicMouseEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+void QBasicMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
{
Q_D(QBasicMouseEventTransition);
- d->modifiersMask = modifiersMask;
+ d->modifierMask = modifierMask;
}
/*!
- Returns the path for this mouse event transition.
+ Returns the hit test path for this mouse event transition.
*/
-QPainterPath QBasicMouseEventTransition::path() const
+QPainterPath QBasicMouseEventTransition::hitTestPath() const
{
Q_D(const QBasicMouseEventTransition);
return d->path;
}
/*!
- Sets the path for this mouse event transition.
+ Sets the hit test path for this mouse event transition.
*/
-void QBasicMouseEventTransition::setPath(const QPainterPath &path)
+void QBasicMouseEventTransition::setHitTestPath(const QPainterPath &path)
{
Q_D(QBasicMouseEventTransition);
d->path = path;
@@ -195,7 +195,7 @@ bool QBasicMouseEventTransition::eventTest(QEvent *event)
if (event->type() == d->eventType) {
QMouseEvent *me = static_cast<QMouseEvent*>(event);
return (me->button() == d->button)
- && ((me->modifiers() & d->modifiersMask) == d->modifiersMask)
+ && ((me->modifiers() & d->modifierMask) == d->modifierMask)
&& (d->path.isEmpty() || d->path.contains(me->pos()));
}
return false;
diff --git a/src/gui/statemachine/qbasicmouseeventtransition_p.h b/src/gui/statemachine/qbasicmouseeventtransition_p.h
index 512e0f8..6754c55 100644
--- a/src/gui/statemachine/qbasicmouseeventtransition_p.h
+++ b/src/gui/statemachine/qbasicmouseeventtransition_p.h
@@ -79,11 +79,11 @@ public:
Qt::MouseButton button() const;
void setButton(Qt::MouseButton button);
- Qt::KeyboardModifiers modifiersMask() const;
- void setModifiersMask(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifierMask() const;
+ void setModifierMask(Qt::KeyboardModifiers modifiers);
- QPainterPath path() const;
- void setPath(const QPainterPath &path);
+ QPainterPath hitTestPath() const;
+ void setHitTestPath(const QPainterPath &path);
protected:
bool eventTest(QEvent *event);
diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/gui/statemachine/qkeyeventtransition.cpp
index dee3168..a15e671 100644
--- a/src/gui/statemachine/qkeyeventtransition.cpp
+++ b/src/gui/statemachine/qkeyeventtransition.cpp
@@ -69,9 +69,9 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \property QKeyEventTransition::modifiersMask
+ \property QKeyEventTransition::modifierMask
- \brief the keyboard modifiers mask that this key event transition checks for
+ \brief the keyboard modifier mask that this key event transition checks for
*/
class QKeyEventTransitionPrivate : public QEventTransitionPrivate
@@ -133,23 +133,23 @@ void QKeyEventTransition::setKey(int key)
}
/*!
- Returns the keyboard modifiers mask that this key event transition checks
+ Returns the keyboard modifier mask that this key event transition checks
for.
*/
-Qt::KeyboardModifiers QKeyEventTransition::modifiersMask() const
+Qt::KeyboardModifiers QKeyEventTransition::modifierMask() const
{
Q_D(const QKeyEventTransition);
- return d->transition->modifiersMask();
+ return d->transition->modifierMask();
}
/*!
- Sets the keyboard \a modifiers mask that this key event transition will
- check for.
+ Sets the keyboard modifier mask that this key event transition will
+ check for to \a modifierMask.
*/
-void QKeyEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+void QKeyEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
{
Q_D(QKeyEventTransition);
- d->transition->setModifiersMask(modifiersMask);
+ d->transition->setModifierMask(modifierMask);
}
/*!
diff --git a/src/gui/statemachine/qkeyeventtransition.h b/src/gui/statemachine/qkeyeventtransition.h
index 8df8138..ab1c155 100644
--- a/src/gui/statemachine/qkeyeventtransition.h
+++ b/src/gui/statemachine/qkeyeventtransition.h
@@ -57,7 +57,7 @@ class Q_GUI_EXPORT QKeyEventTransition : public QEventTransition
{
Q_OBJECT
Q_PROPERTY(int key READ key WRITE setKey)
- Q_PROPERTY(Qt::KeyboardModifiers modifiersMask READ modifiersMask WRITE setModifiersMask)
+ Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
public:
QKeyEventTransition(QState *sourceState = 0);
QKeyEventTransition(QObject *object, QEvent::Type type, int key,
@@ -67,8 +67,8 @@ public:
int key() const;
void setKey(int key);
- Qt::KeyboardModifiers modifiersMask() const;
- void setModifiersMask(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifierMask() const;
+ void setModifierMask(Qt::KeyboardModifiers modifiers);
protected:
void onTransition(QEvent *event);
diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/gui/statemachine/qmouseeventtransition.cpp
index 86cacf7..f5c0cb1 100644
--- a/src/gui/statemachine/qmouseeventtransition.cpp
+++ b/src/gui/statemachine/qmouseeventtransition.cpp
@@ -70,9 +70,9 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \property QMouseEventTransition::modifiersMask
+ \property QMouseEventTransition::modifierMask
- \brief the keyboard modifiers mask that this mouse event transition checks for
+ \brief the keyboard modifier mask that this mouse event transition checks for
*/
class QMouseEventTransitionPrivate : public QEventTransitionPrivate
@@ -139,45 +139,45 @@ void QMouseEventTransition::setButton(Qt::MouseButton button)
}
/*!
- Returns the keyboard modifiers mask that this mouse event transition checks
+ Returns the keyboard modifier mask that this mouse event transition checks
for.
*/
-Qt::KeyboardModifiers QMouseEventTransition::modifiersMask() const
+Qt::KeyboardModifiers QMouseEventTransition::modifierMask() const
{
Q_D(const QMouseEventTransition);
- return d->transition->modifiersMask();
+ return d->transition->modifierMask();
}
/*!
- Sets the keyboard \a modifiers mask that this mouse event transition will
- check for.
+ Sets the keyboard modifier mask that this mouse event transition will
+ check for to \a modifierMask.
*/
-void QMouseEventTransition::setModifiersMask(Qt::KeyboardModifiers modifiersMask)
+void QMouseEventTransition::setModifierMask(Qt::KeyboardModifiers modifierMask)
{
Q_D(QMouseEventTransition);
- d->transition->setModifiersMask(modifiersMask);
+ d->transition->setModifierMask(modifierMask);
}
/*!
- Returns the path for this mouse event transition.
+ Returns the hit test path for this mouse event transition.
*/
-QPainterPath QMouseEventTransition::path() const
+QPainterPath QMouseEventTransition::hitTestPath() const
{
Q_D(const QMouseEventTransition);
- return d->transition->path();
+ return d->transition->hitTestPath();
}
/*!
- Sets the \a path for this mouse event transition.
+ Sets the hit test path for this mouse event transition to \a path.
If a valid path has been set, the transition will only trigger if the mouse
event position (QMouseEvent::pos()) is inside the path.
\sa QPainterPath::contains()
*/
-void QMouseEventTransition::setPath(const QPainterPath &path)
+void QMouseEventTransition::setHitTestPath(const QPainterPath &path)
{
Q_D(QMouseEventTransition);
- d->transition->setPath(path);
+ d->transition->setHitTestPath(path);
}
/*!
diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/gui/statemachine/qmouseeventtransition.h
index 4e324ec..e7f6a45 100644
--- a/src/gui/statemachine/qmouseeventtransition.h
+++ b/src/gui/statemachine/qmouseeventtransition.h
@@ -58,7 +58,7 @@ class Q_GUI_EXPORT QMouseEventTransition : public QEventTransition
{
Q_OBJECT
Q_PROPERTY(Qt::MouseButton button READ button WRITE setButton)
- Q_PROPERTY(Qt::KeyboardModifiers modifiersMask READ modifiersMask WRITE setModifiersMask)
+ Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
public:
QMouseEventTransition(QState *sourceState = 0);
QMouseEventTransition(QObject *object, QEvent::Type type,
@@ -68,11 +68,11 @@ public:
Qt::MouseButton button() const;
void setButton(Qt::MouseButton button);
- Qt::KeyboardModifiers modifiersMask() const;
- void setModifiersMask(Qt::KeyboardModifiers modifiers);
+ Qt::KeyboardModifiers modifierMask() const;
+ void setModifierMask(Qt::KeyboardModifiers modifiers);
- QPainterPath path() const;
- void setPath(const QPainterPath &path);
+ QPainterPath hitTestPath() const;
+ void setHitTestPath(const QPainterPath &path);
protected:
void onTransition(QEvent *event);
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 975b301..9a2b2ed 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -162,7 +162,7 @@ private slots:
void defaultGlobalRestorePolicy();
void globalRestorePolicySetToRestore();
- void globalRestorePolicySetToDoNotRestore();
+ void globalRestorePolicySetToDontRestore();
void noInitialStateForInitialState();
@@ -184,7 +184,7 @@ private slots:
void twoAnimatedTransitions();
void playAnimationTwice();
void nestedTargetStateForAnimation();
- void polishedSignalTransitionsReuseAnimationGroup();
+ void propertiesAssignedSignalTransitionsReuseAnimationGroup();
void animatedGlobalRestoreProperty();
void specificTargetValueOfAnimation();
@@ -286,8 +286,8 @@ void tst_QStateMachine::transitionToRootState()
machine.addState(initialState);
machine.setInitialState(initialState);
- QAbstractTransition *trans = initialState->addTransition(new EventTransition(QEvent::User, &machine));
- QVERIFY(trans != 0);
+ QAbstractTransition *trans = new EventTransition(QEvent::User, &machine);
+ initialState->addTransition(trans);
QCOMPARE(trans->sourceState(), initialState);
QCOMPARE(trans->targetState(), static_cast<QAbstractState *>(&machine));
@@ -310,7 +310,7 @@ void tst_QStateMachine::transitionFromRootState()
QState *root = &machine;
QState *s1 = new QState(root);
EventTransition *trans = new EventTransition(QEvent::User, s1);
- QCOMPARE(root->addTransition(trans), static_cast<QAbstractTransition *>(trans));
+ root->addTransition(trans);
QCOMPARE(trans->sourceState(), root);
QCOMPARE(trans->targetState(), static_cast<QAbstractState *>(s1));
}
@@ -984,7 +984,7 @@ void tst_QStateMachine::customErrorStateNotInGraph()
void tst_QStateMachine::restoreProperties()
{
QStateMachine machine;
- QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DoNotRestoreProperties);
+ QCOMPARE(machine.globalRestorePolicy(), QStateMachine::DontRestoreProperties);
machine.setGlobalRestorePolicy(QStateMachine::RestoreProperties);
QObject *object = new QObject(&machine);
@@ -1155,7 +1155,7 @@ void tst_QStateMachine::stateEntryAndExit()
QCOMPARE(t->targetState(), (QAbstractState*)s2);
QCOMPARE(t->targetStates().size(), 1);
QCOMPARE(t->targetStates().at(0), (QAbstractState*)s2);
- QCOMPARE(s1->addTransition(t), (QAbstractTransition*)t);
+ s1->addTransition(t);
QCOMPARE(t->sourceState(), (QState*)s1);
QCOMPARE(t->machine(), &machine);
@@ -1173,7 +1173,7 @@ void tst_QStateMachine::stateEntryAndExit()
s2->removeTransition(trans);
QCOMPARE(trans->sourceState(), (QState*)0);
QCOMPARE(trans->targetState(), (QAbstractState*)s3);
- QCOMPARE(s2->addTransition(trans), trans);
+ s2->addTransition(trans);
QCOMPARE(trans->sourceState(), (QState*)s2);
}
@@ -1319,9 +1319,9 @@ void tst_QStateMachine::assignProperty()
QCOMPARE(s1->objectName(), QString::fromLatin1("foo"));
{
- QSignalSpy polishedSpy(s1, SIGNAL(polished()));
+ QSignalSpy propertiesAssignedSpy(s1, SIGNAL(propertiesAssigned()));
machine.start();
- QTRY_COMPARE(polishedSpy.count(), 1);
+ QTRY_COMPARE(propertiesAssignedSpy.count(), 1);
}
// nested states
@@ -1340,11 +1340,11 @@ void tst_QStateMachine::assignPropertyWithAnimation()
// Single animation
{
QStateMachine machine;
- QVERIFY(machine.animationsEnabled());
- machine.setAnimationsEnabled(false);
- QVERIFY(!machine.animationsEnabled());
- machine.setAnimationsEnabled(true);
- QVERIFY(machine.animationsEnabled());
+ QVERIFY(machine.isAnimated());
+ machine.setAnimated(false);
+ QVERIFY(!machine.isAnimated());
+ machine.setAnimated(true);
+ QVERIFY(machine.isAnimated());
QObject obj;
obj.setProperty("foo", 321);
obj.setProperty("bar", 654);
@@ -1371,7 +1371,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
QCOMPARE(trans->animations().size(), 1);
QCOMPARE(trans->animations().at(0), (QAbstractAnimation*)&anim);
QFinalState *s3 = new QFinalState(&machine);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1399,7 +1399,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
anim2.setDuration(150);
trans->addAnimation(&anim2);
QFinalState *s3 = new QFinalState(&machine);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1427,7 +1427,7 @@ void tst_QStateMachine::assignPropertyWithAnimation()
group.addAnimation(new QPropertyAnimation(&obj, "bar"));
trans->addAnimation(&group);
QFinalState *s3 = new QFinalState(&machine);
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1473,10 +1473,10 @@ void tst_QStateMachine::assignPropertyWithAnimation()
anim2.setDuration(250);
trans->addAnimation(&anim2);
- s21->addTransition(s21, SIGNAL(polished()), s22);
+ s21->addTransition(s21, SIGNAL(propertiesAssigned()), s22);
QFinalState *s3 = new QFinalState(&machine);
- s22->addTransition(s2, SIGNAL(polished()), s3);
+ s22->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
QSignalSpy finishedSpy(&machine, SIGNAL(finished()));
@@ -1513,13 +1513,13 @@ void tst_QStateMachine::assignPropertyWithAnimation()
machine.setInitialState(group);
machine.start();
QTRY_COMPARE(machine.configuration().contains(s1), true);
- QSignalSpy polishedSpy(s2, SIGNAL(polished()));
+ QSignalSpy propertiesAssignedSpy(s2, SIGNAL(propertiesAssigned()));
emitter.emitSignalWithNoArg();
QTRY_COMPARE(machine.configuration().contains(s2), true);
- QVERIFY(polishedSpy.isEmpty());
+ QVERIFY(propertiesAssignedSpy.isEmpty());
emitter.emitSignalWithNoArg(); // will cause animations from s1-->s2 to abort
QTRY_COMPARE(machine.configuration().contains(s3), true);
- QVERIFY(polishedSpy.isEmpty());
+ QVERIFY(propertiesAssignedSpy.isEmpty());
QCOMPARE(obj.property("foo").toInt(), 911);
QCOMPARE(obj.property("bar").toInt(), 789);
}
@@ -2736,10 +2736,10 @@ void tst_QStateMachine::restorePolicyNotInherited()
}*/
-void tst_QStateMachine::globalRestorePolicySetToDoNotRestore()
+void tst_QStateMachine::globalRestorePolicySetToDontRestore()
{
QStateMachine machine;
- machine.setGlobalRestorePolicy(QStateMachine::DoNotRestoreProperties);
+ machine.setGlobalRestorePolicy(QStateMachine::DontRestoreProperties);
QObject *propertyHolder = new QObject(&machine);
propertyHolder->setProperty("a", 1);
@@ -3089,7 +3089,7 @@ void tst_QStateMachine::twoAnimations()
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- s2->addTransition(s2, SIGNAL(polished()), s3);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
machine.setInitialState(s1);
machine.start();
@@ -3117,7 +3117,9 @@ void tst_QStateMachine::twoAnimatedTransitions()
QState *s2 = new QState(&machine);
s2->assignProperty(object, "foo", 5.0);
QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
- s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ trans->addAnimation(fooAnimation);
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3126,7 +3128,9 @@ void tst_QStateMachine::twoAnimatedTransitions()
QState *s4 = new QState(&machine);
s4->assignProperty(object, "foo", 2.0);
QPropertyAnimation *fooAnimation2 = new QPropertyAnimation(object, "foo", s4);
- s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation2);
+ trans = new EventTransition(QEvent::User, s4);
+ s3->addTransition(trans);
+ trans->addAnimation(fooAnimation2);
QState *s5 = new QState(&machine);
QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit()));
@@ -3161,7 +3165,9 @@ void tst_QStateMachine::playAnimationTwice()
QState *s2 = new QState(&machine);
s2->assignProperty(object, "foo", 5.0);
QPropertyAnimation *fooAnimation = new QPropertyAnimation(object, "foo", s2);
- s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(fooAnimation);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ trans->addAnimation(fooAnimation);
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3169,7 +3175,9 @@ void tst_QStateMachine::playAnimationTwice()
QState *s4 = new QState(&machine);
s4->assignProperty(object, "foo", 2.0);
- s3->addTransition(new EventTransition(QEvent::User, s4))->addAnimation(fooAnimation);
+ trans = new EventTransition(QEvent::User, s4);
+ s3->addTransition(trans);
+ trans->addAnimation(fooAnimation);
QState *s5 = new QState(&machine);
QObject::connect(s5, SIGNAL(entered()), QApplication::instance(), SLOT(quit()));
@@ -3213,14 +3221,16 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
QState *s2Child2 = new QState(s2);
s2Child2->assignProperty(object, "bar", 11.0);
- QAbstractTransition *at = s2Child->addTransition(new EventTransition(QEvent::User, s2Child2));
+ QAbstractTransition *at = new EventTransition(QEvent::User, s2Child2);
+ s2Child->addTransition(at);
QPropertyAnimation *animation = new QPropertyAnimation(object, "bar", s2);
animation->setDuration(2000);
connect(animation, SIGNAL(finished()), &counter, SLOT(slot()));
at->addAnimation(animation);
- at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ at = new EventTransition(QEvent::User, s2);
+ s1->addTransition(at);
animation = new QPropertyAnimation(object, "foo", s2);
connect(animation, SIGNAL(finished()), &counter, SLOT(slot()));
@@ -3231,7 +3241,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
at->addAnimation(animation);
QState *s3 = new QState(&machine);
- s2->addTransition(s2Child, SIGNAL(polished()), s3);
+ s2->addTransition(s2Child, SIGNAL(propertiesAssigned()), s3);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3248,7 +3258,7 @@ void tst_QStateMachine::nestedTargetStateForAnimation()
QCOMPARE(counter.counter, 2);
}
-void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup()
+void tst_QStateMachine::propertiesAssignedSignalTransitionsReuseAnimationGroup()
{
QStateMachine machine;
QObject *object = new QObject(&machine);
@@ -3265,9 +3275,9 @@ void tst_QStateMachine::polishedSignalTransitionsReuseAnimationGroup()
QParallelAnimationGroup animationGroup;
animationGroup.addAnimation(new QPropertyAnimation(object, "foo"));
QSignalSpy animationFinishedSpy(&animationGroup, SIGNAL(finished()));
- s1->addTransition(s1, SIGNAL(polished()), s2)->addAnimation(&animationGroup);
- s2->addTransition(s2, SIGNAL(polished()), s3)->addAnimation(&animationGroup);
- s3->addTransition(s3, SIGNAL(polished()), s4);
+ s1->addTransition(s1, SIGNAL(propertiesAssigned()), s2)->addAnimation(&animationGroup);
+ s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3)->addAnimation(&animationGroup);
+ s3->addTransition(s3, SIGNAL(propertiesAssigned()), s4);
machine.setInitialState(s1);
QSignalSpy machineFinishedSpy(&machine, SIGNAL(finished()));
@@ -3299,7 +3309,8 @@ void tst_QStateMachine::animatedGlobalRestoreProperty()
QState *s4 = new QState(&machine);
QObject::connect(s4, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ QAbstractTransition *at = new EventTransition(QEvent::User, s2);
+ s1->addTransition(at);
QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", s2);
connect(pa, SIGNAL(finished()), &counter, SLOT(slot()));
at->addAnimation(pa);
@@ -3341,7 +3352,9 @@ void tst_QStateMachine::specificTargetValueOfAnimation()
QPropertyAnimation *anim = new QPropertyAnimation(object, "foo");
anim->setEndValue(10.0);
- s1->addTransition(new EventTransition(QEvent::User, s2))->addAnimation(anim);
+ EventTransition *trans = new EventTransition(QEvent::User, s2);
+ s1->addTransition(trans);
+ trans->addAnimation(anim);
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
@@ -3495,7 +3508,8 @@ void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
QState *s3 = new QState(&machine);
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
+ QAbstractTransition *at = new EventTransition(QEvent::User, s2);
+ s1->addTransition(at);
QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));