summaryrefslogtreecommitdiffstats
path: root/src/declarative/util/qdeclarativeanimation.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-03-05 03:43:08 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-03-05 03:43:08 (GMT)
commit09e39c9c86e8ed346aff348b28c512710862e70e (patch)
treebdf2df715d410cd8efe56a55a7c11bb3fcb5ad74 /src/declarative/util/qdeclarativeanimation.cpp
parent356963b1bc81dcad1826449da14b6130eea9cc3f (diff)
downloadQt-09e39c9c86e8ed346aff348b28c512710862e70e.zip
Qt-09e39c9c86e8ed346aff348b28c512710862e70e.tar.gz
Qt-09e39c9c86e8ed346aff348b28c512710862e70e.tar.bz2
Add basic support for explicit newParent in ParentAnimation.
Diffstat (limited to 'src/declarative/util/qdeclarativeanimation.cpp')
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp62
1 files changed, 56 insertions, 6 deletions
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 49177d1..8c8dd95 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -2461,6 +2461,9 @@ QDeclarativeParentAnimation::~QDeclarativeParentAnimation()
/*!
\qmlproperty item ParentAnimation::target
The item to reparent.
+
+ When used in a transition, if no target is specified all
+ ParentChanges will be animated by the ParentAnimation.
*/
QDeclarativeItem *QDeclarativeParentAnimation::target() const
{
@@ -2474,6 +2477,12 @@ void QDeclarativeParentAnimation::setTarget(QDeclarativeItem *target)
d->target = target;
}
+/*!
+ \qmlproperty item ParentAnimation::newParent
+ The new parent to animate to.
+
+ If not set, then the parent defined in the end state of the transition.
+*/
QDeclarativeItem *QDeclarativeParentAnimation::newParent() const
{
Q_D(const QDeclarativeParentAnimation);
@@ -2545,12 +2554,13 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
struct QDeclarativeParentActionData : public QAbstractAnimationAction
{
- QDeclarativeParentActionData(): pc(0) {}
- ~QDeclarativeParentActionData() { delete pc; }
+ QDeclarativeParentActionData() {}
+ ~QDeclarativeParentActionData() { qDeleteAll(pc); }
QDeclarativeStateActions actions;
+ //### reverse should probably apply on a per-action basis
bool reverse;
- QDeclarativeParentChange *pc;
+ QList<QDeclarativeParentChange *> pc;
virtual void doAction()
{
for (int ii = 0; ii < actions.count(); ++ii) {
@@ -2565,6 +2575,33 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
QDeclarativeParentActionData *data = new QDeclarativeParentActionData;
QDeclarativeParentActionData *viaData = new QDeclarativeParentActionData;
+
+ bool hasExplicit = false;
+ if (d->target && d->newParent) {
+ data->reverse = false;
+ QDeclarativeAction myAction;
+ QDeclarativeParentChange *pc = new QDeclarativeParentChange;
+ pc->setObject(d->target);
+ pc->setParent(d->newParent);
+ myAction.event = pc;
+ data->pc << pc;
+ data->actions << myAction;
+ hasExplicit = true;
+ if (d->via) {
+ viaData->reverse = false;
+ QDeclarativeAction myVAction;
+ QDeclarativeParentChange *vpc = new QDeclarativeParentChange;
+ vpc->setObject(d->target);
+ vpc->setParent(d->via);
+ myVAction.event = vpc;
+ viaData->pc << vpc;
+ viaData->actions << myVAction;
+ }
+ //### once actions have concept of modified,
+ // loop to match appropriate ParentChanges and mark as modified
+ }
+
+ if (!hasExplicit)
for (int i = 0; i < actions.size(); ++i) {
QDeclarativeAction &action = actions[i];
if (action.event && action.event->typeName() == QLatin1String("ParentChange")
@@ -2573,8 +2610,21 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
QDeclarativeParentChange *pc = static_cast<QDeclarativeParentChange*>(action.event);
QDeclarativeAction myAction = action;
data->reverse = action.reverseEvent;
- action.actionDone = true;
- data->actions << myAction;
+
+ //### this logic differs from PropertyAnimation
+ // (probably a result of modified vs. done)
+ if (d->newParent) {
+ QDeclarativeParentChange *epc = new QDeclarativeParentChange;
+ epc->setObject(static_cast<QDeclarativeParentChange*>(action.event)->object());
+ epc->setParent(d->newParent);
+ myAction.event = epc;
+ data->pc << epc;
+ data->actions << myAction;
+ pc = epc;
+ } else {
+ action.actionDone = true;
+ data->actions << myAction;
+ }
if (d->via) {
viaData->reverse = false;
@@ -2583,7 +2633,7 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions,
vpc->setObject(pc->object());
vpc->setParent(d->via);
myAction.event = vpc;
- viaData->pc = vpc;
+ viaData->pc << vpc;
viaData->actions << myAction;
QDeclarativeAction dummyAction;
QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction;