summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp66
-rw-r--r--src/corelib/statemachine/qstatemachine.h8
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp165
3 files changed, 85 insertions, 154 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index b0f6cd6..8320b0d 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -1930,72 +1930,6 @@ void QStateMachine::removeDefaultAnimation(QAbstractAnimation *animation)
d->defaultAnimations.removeAll(animation);
}
-
-/*!
- Adds a default \a animation to be considered for any transition with the source state
- \a sourceState.
-*/
-void QStateMachine::addDefaultAnimationForSourceState(QAbstractState *sourceState,
- QAbstractAnimation *animation)
-{
- Q_D(QStateMachine);
- d->defaultAnimationsForSource.insert(sourceState, animation);
-}
-
-
-/*!
- Returns the list of default animations that will be considered for any transition with
- the source state \a sourceState.
-*/
-QList<QAbstractAnimation*> QStateMachine::defaultAnimationsForSourceState(QAbstractState *sourceState) const
-{
- Q_D(const QStateMachine);
- return d->defaultAnimationsForSource.values(sourceState);
-}
-
-/*!
- Removes \a animation from the list of default animations for the source state
- \a sourceState.
-*/
-void QStateMachine::removeDefaultAnimationForSourceState(QAbstractState *sourceState,
- QAbstractAnimation *animation)
-{
- Q_D(QStateMachine);
- d->defaultAnimationsForSource.remove(sourceState, animation);
-}
-
-/*!
- Adds a default \a animation to be considered for any transition with the target state
- \a targetState.
-*/
-void QStateMachine::addDefaultAnimationForTargetState(QAbstractState *targetState,
- QAbstractAnimation *animation)
-{
- Q_D(QStateMachine);
- d->defaultAnimationsForTarget.insert(targetState, animation);
-}
-
-/*!
- Returns the list of default animations that will be considered for any transition with
- the target state \a targetState.
-*/
-QList<QAbstractAnimation *> QStateMachine::defaultAnimationsForTargetState(QAbstractState *targetState) const
-{
- Q_D(const QStateMachine);
- return d->defaultAnimationsForTarget.values(targetState);
-}
-
-/*!
- Removes \a animation from the list of default animations for the target state
- \a targetState.
-*/
-void QStateMachine::removeDefaultAnimationForTargetState(QAbstractState *targetState,
- QAbstractAnimation *animation)
-{
- Q_D(QStateMachine);
- d->defaultAnimationsForTarget.remove(targetState, animation);
-}
-
#endif // QT_NO_ANIMATION
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index 3ad215b..bbe85e2 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -114,14 +114,6 @@ public:
void addDefaultAnimation(QAbstractAnimation *animation);
QList<QAbstractAnimation *> defaultAnimations() const;
void removeDefaultAnimation(QAbstractAnimation *animation);
-
- void addDefaultAnimationForSourceState(QAbstractState *sourceState, QAbstractAnimation *animation);
- QList<QAbstractAnimation *> defaultAnimationsForSourceState(QAbstractState *sourceState) const;
- void removeDefaultAnimationForSourceState(QAbstractState *sourceState, QAbstractAnimation *animation);
-
- void addDefaultAnimationForTargetState(QAbstractState *targetState, QAbstractAnimation *animation);
- QList<QAbstractAnimation *> defaultAnimationsForTargetState(QAbstractState *targetState) const;
- void removeDefaultAnimationForTargetState(QAbstractState *targetState, QAbstractAnimation *animation);
#endif // QT_NO_ANIMATION
QStateMachine::RestorePolicy globalRestorePolicy() const;
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index b380f6d..abe0c2b 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -144,19 +144,21 @@ private slots:
void nestedTargetStateForAnimation();
void animatedGlobalRestoreProperty();
void specificTargetValueOfAnimation();
+
void addDefaultAnimation();
void addDefaultAnimationWithUnusedAnimation();
- void addDefaultAnimationForSource();
- void addDefaultAnimationForTarget();
void removeDefaultAnimation();
- void removeDefaultAnimationForSource();
- void removeDefaultAnimationForTarget();
- void overrideDefaultAnimationWithSource();
- void overrideDefaultAnimationWithTarget();
void overrideDefaultAnimationWithSpecific();
- void overrideDefaultSourceAnimationWithSpecific();
- void overrideDefaultTargetAnimationWithSpecific();
- void overrideDefaultTargetAnimationWithSource();
+
+// void addDefaultAnimationForSource();
+// void addDefaultAnimationForTarget();
+// void removeDefaultAnimationForSource();
+// void removeDefaultAnimationForTarget();
+// void overrideDefaultAnimationWithSource();
+// void overrideDefaultAnimationWithTarget();
+// void overrideDefaultSourceAnimationWithSpecific();
+// void overrideDefaultTargetAnimationWithSpecific();
+// void overrideDefaultTargetAnimationWithSource();
};
tst_QStateMachine::tst_QStateMachine()
@@ -2417,28 +2419,71 @@ void tst_QStateMachine::addDefaultAnimationWithUnusedAnimation()
QCOMPARE(counter.counter, 1);
}
-void tst_QStateMachine::addDefaultAnimationForSource()
+void tst_QStateMachine::removeDefaultAnimation()
+{
+ QStateMachine machine;
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+
+ QPropertyAnimation *anim = new QPropertyAnimation(this, "foo");
+
+ machine.addDefaultAnimation(anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 1);
+ QVERIFY(machine.defaultAnimations().contains(anim));
+
+ machine.removeDefaultAnimation(anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+
+ machine.addDefaultAnimation(anim);
+
+ QPropertyAnimation *anim2 = new QPropertyAnimation(this, "foo");
+ machine.addDefaultAnimation(anim2);
+
+ QCOMPARE(machine.defaultAnimations().size(), 2);
+ QVERIFY(machine.defaultAnimations().contains(anim));
+ QVERIFY(machine.defaultAnimations().contains(anim2));
+
+ machine.removeDefaultAnimation(anim);
+
+ QCOMPARE(machine.defaultAnimations().size(), 1);
+ QVERIFY(machine.defaultAnimations().contains(anim2));
+
+ machine.removeDefaultAnimation(anim2);
+ QCOMPARE(machine.defaultAnimations().size(), 0);
+}
+
+void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
{
QStateMachine machine;
QObject *object = new QObject();
object->setProperty("foo", 1.0);
+ SlotCalledCounter counter;
+
QState *s1 = new QState(machine.rootState());
+ machine.setInitialState(s1);
QState *s2 = new QState(machine.rootState());
s2->assignProperty(object, "foo", 2.0);
QState *s3 = new QState(machine.rootState());
QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
+
+ QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
- s1->addTransition(new EventTransition(QEvent::User, s2));
+ QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
+ connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
- QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
- machine.addDefaultAnimationForSourceState(s1, pa);
- s2->addTransition(pa, SIGNAL(finished()), s3);
+ QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
+ s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
+ connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
+
+ machine.addDefaultAnimation(defaultAnimation);
+ at->addAnimation(moreSpecificAnimation);
- machine.setInitialState(s1);
machine.start();
QCoreApplication::processEvents();
@@ -2446,10 +2491,11 @@ void tst_QStateMachine::addDefaultAnimationForSource()
QCOREAPPLICATION_EXEC(5000);
QVERIFY(machine.configuration().contains(s3));
- QCOMPARE(object->property("foo").toDouble(), 2.0);
+ QCOMPARE(counter.counter, 2); // specific animation started and stopped
}
-void tst_QStateMachine::addDefaultAnimationForTarget()
+/*
+void tst_QStateMachine::addDefaultAnimationForSource()
{
QStateMachine machine;
@@ -2467,7 +2513,7 @@ void tst_QStateMachine::addDefaultAnimationForTarget()
s1->addTransition(new EventTransition(QEvent::User, s2));
QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
- machine.addDefaultAnimationForTargetState(s2, pa);
+ machine.addDefaultAnimationForSourceState(s1, pa);
s2->addTransition(pa, SIGNAL(finished()), s3);
machine.setInitialState(s1);
@@ -2481,39 +2527,36 @@ void tst_QStateMachine::addDefaultAnimationForTarget()
QCOMPARE(object->property("foo").toDouble(), 2.0);
}
-void tst_QStateMachine::removeDefaultAnimation()
+void tst_QStateMachine::addDefaultAnimationForTarget()
{
QStateMachine machine;
- QCOMPARE(machine.defaultAnimations().size(), 0);
-
- QPropertyAnimation *anim = new QPropertyAnimation(this, "foo");
-
- machine.addDefaultAnimation(anim);
-
- QCOMPARE(machine.defaultAnimations().size(), 1);
- QVERIFY(machine.defaultAnimations().contains(anim));
+ QObject *object = new QObject();
+ object->setProperty("foo", 1.0);
- machine.removeDefaultAnimation(anim);
+ QState *s1 = new QState(machine.rootState());
- QCOMPARE(machine.defaultAnimations().size(), 0);
+ QState *s2 = new QState(machine.rootState());
+ s2->assignProperty(object, "foo", 2.0);
- machine.addDefaultAnimation(anim);
+ QState *s3 = new QState(machine.rootState());
+ QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
- QPropertyAnimation *anim2 = new QPropertyAnimation(this, "foo");
- machine.addDefaultAnimation(anim2);
+ s1->addTransition(new EventTransition(QEvent::User, s2));
- QCOMPARE(machine.defaultAnimations().size(), 2);
- QVERIFY(machine.defaultAnimations().contains(anim));
- QVERIFY(machine.defaultAnimations().contains(anim2));
+ QPropertyAnimation *pa = new QPropertyAnimation(object, "foo", &machine);
+ machine.addDefaultAnimationForTargetState(s2, pa);
+ s2->addTransition(pa, SIGNAL(finished()), s3);
- machine.removeDefaultAnimation(anim);
+ machine.setInitialState(s1);
+ machine.start();
+ QCoreApplication::processEvents();
- QCOMPARE(machine.defaultAnimations().size(), 1);
- QVERIFY(machine.defaultAnimations().contains(anim2));
+ machine.postEvent(new QEvent(QEvent::User));
+ QCOREAPPLICATION_EXEC(5000);
- machine.removeDefaultAnimation(anim2);
- QCOMPARE(machine.defaultAnimations().size(), 0);
+ QVERIFY(machine.configuration().contains(s3));
+ QCOMPARE(object->property("foo").toDouble(), 2.0);
}
void tst_QStateMachine::removeDefaultAnimationForSource()
@@ -2685,46 +2728,6 @@ void tst_QStateMachine::overrideDefaultAnimationWithTarget()
}
-void tst_QStateMachine::overrideDefaultAnimationWithSpecific()
-{
- QStateMachine machine;
-
- QObject *object = new QObject();
- object->setProperty("foo", 1.0);
-
- SlotCalledCounter counter;
-
- QState *s1 = new QState(machine.rootState());
- machine.setInitialState(s1);
-
- QState *s2 = new QState(machine.rootState());
- s2->assignProperty(object, "foo", 2.0);
-
- QState *s3 = new QState(machine.rootState());
- QObject::connect(s3, SIGNAL(entered()), QCoreApplication::instance(), SLOT(quit()));
-
- QAbstractTransition *at = s1->addTransition(new EventTransition(QEvent::User, s2));
-
- QPropertyAnimation *defaultAnimation = new QPropertyAnimation(object, "foo");
- connect(defaultAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
-
- QPropertyAnimation *moreSpecificAnimation = new QPropertyAnimation(object, "foo");
- s2->addTransition(moreSpecificAnimation, SIGNAL(finished()), s3);
- connect(moreSpecificAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), &counter, SLOT(slot()));
-
- machine.addDefaultAnimation(defaultAnimation);
- at->addAnimation(moreSpecificAnimation);
-
- machine.start();
- QCoreApplication::processEvents();
-
- machine.postEvent(new QEvent(QEvent::User));
- QCOREAPPLICATION_EXEC(5000);
-
- QVERIFY(machine.configuration().contains(s3));
- QCOMPARE(counter.counter, 2); // specific animation started and stopped
-}
-
void tst_QStateMachine::overrideDefaultSourceAnimationWithSpecific()
{
QStateMachine machine;
@@ -2845,6 +2848,8 @@ void tst_QStateMachine::overrideDefaultTargetAnimationWithSource()
QCOMPARE(counter.counter, 2); // specific animation started and stopped
}
+*/
+
void tst_QStateMachine::parallelStateAssignmentsDone()
{
QStateMachine machine;