statemachine: Small refactoring of animation selection code
QStateMachinePrivate::applyProperties() is an epically long function. Move the code for selecting animations to a separate function, in preparation of a larger refactoring. Change-Id: Ic5846db97dd0cb0d6ad01740f413b233d2a66975 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
This commit is contained in:
parent
2f18e72762
commit
aa7180ca92
@ -757,20 +757,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the animations to use for the state change.
|
// Find the animations to use for the state change.
|
||||||
QList<QAbstractAnimation*> selectedAnimations;
|
QList<QAbstractAnimation *> selectedAnimations = selectAnimations(transitionList);
|
||||||
if (animated) {
|
|
||||||
for (int i = 0; i < transitionList.size(); ++i) {
|
|
||||||
QAbstractTransition *transition = transitionList.at(i);
|
|
||||||
|
|
||||||
selectedAnimations << transition->animations();
|
|
||||||
selectedAnimations << defaultAnimationsForSource.values(transition->sourceState());
|
|
||||||
|
|
||||||
QList<QAbstractState *> targetStates = transition->targetStates();
|
|
||||||
for (int j=0; j<targetStates.size(); ++j)
|
|
||||||
selectedAnimations << defaultAnimationsForTarget.values(targetStates.at(j));
|
|
||||||
}
|
|
||||||
selectedAnimations << defaultAnimations;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize animations from property assignments.
|
// Initialize animations from property assignments.
|
||||||
for (int i = 0; i < selectedAnimations.size(); ++i) {
|
for (int i = 0; i < selectedAnimations.size(); ++i) {
|
||||||
@ -1153,6 +1140,25 @@ void QStateMachinePrivate::_q_animationFinished()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QAbstractAnimation *> QStateMachinePrivate::selectAnimations(const QList<QAbstractTransition *> &transitionList) const
|
||||||
|
{
|
||||||
|
QList<QAbstractAnimation *> selectedAnimations;
|
||||||
|
if (animated) {
|
||||||
|
for (int i = 0; i < transitionList.size(); ++i) {
|
||||||
|
QAbstractTransition *transition = transitionList.at(i);
|
||||||
|
|
||||||
|
selectedAnimations << transition->animations();
|
||||||
|
selectedAnimations << defaultAnimationsForSource.values(transition->sourceState());
|
||||||
|
|
||||||
|
QList<QAbstractState *> targetStates = transition->targetStates();
|
||||||
|
for (int j=0; j<targetStates.size(); ++j)
|
||||||
|
selectedAnimations << defaultAnimationsForTarget.values(targetStates.at(j));
|
||||||
|
}
|
||||||
|
selectedAnimations << defaultAnimations;
|
||||||
|
}
|
||||||
|
return selectedAnimations;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !QT_NO_ANIMATION
|
#endif // !QT_NO_ANIMATION
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -228,6 +228,7 @@ public:
|
|||||||
QMultiHash<QAbstractState *, QAbstractAnimation *> defaultAnimationsForSource;
|
QMultiHash<QAbstractState *, QAbstractAnimation *> defaultAnimationsForSource;
|
||||||
QMultiHash<QAbstractState *, QAbstractAnimation *> defaultAnimationsForTarget;
|
QMultiHash<QAbstractState *, QAbstractAnimation *> defaultAnimationsForTarget;
|
||||||
|
|
||||||
|
QList<QAbstractAnimation *> selectAnimations(const QList<QAbstractTransition *> &transitionList) const;
|
||||||
#endif // QT_NO_ANIMATION
|
#endif // QT_NO_ANIMATION
|
||||||
|
|
||||||
QSignalEventGenerator *signalEventGenerator;
|
QSignalEventGenerator *signalEventGenerator;
|
||||||
|
Loading…
Reference in New Issue
Block a user