summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-12-07 03:08:22 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-12-07 03:08:22 (GMT)
commit560d32ddd80d5c6b21cd39ae93ea3f580da613da (patch)
treedf27accf531654c0c7b0f6606fcbbd386a8a2344 /src/declarative/util
parentf3cbbdc8055c97704d1369c2f435b236c85e1821 (diff)
downloadQt-560d32ddd80d5c6b21cd39ae93ea3f580da613da.zip
Qt-560d32ddd80d5c6b21cd39ae93ea3f580da613da.tar.gz
Qt-560d32ddd80d5c6b21cd39ae93ea3f580da613da.tar.bz2
Minor cleanup/optimization.
Diffstat (limited to 'src/declarative/util')
-rw-r--r--src/declarative/util/qmlanimation.cpp14
-rw-r--r--src/declarative/util/qmlanimation_p_p.h9
-rw-r--r--src/declarative/util/qmltransition.cpp17
3 files changed, 23 insertions, 17 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 00e3056..0143791 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -1608,9 +1608,6 @@ void QmlPropertyAnimationPrivate::init()
Q_Q(QmlPropertyAnimation);
va = new QmlTimeLineValueAnimator;
QmlGraphics_setParent_noEvent(va, q);
-
- va->setStartValue(QVariant(0.0f));
- va->setEndValue(QVariant(1.0f));
}
/*!
@@ -2022,6 +2019,12 @@ void QmlPropertyAnimation::prepare(QmlMetaProperty &p)
else
d->property = d->userProperty;
+ if (!d->rangeIsSet) {
+ d->va->setStartValue(QVariant(0.0f));
+ d->va->setEndValue(QVariant(1.0f));
+ d->rangeIsSet = true;
+ }
+
int propType = d->property.propertyType();
d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : propType);
if (d->fromIsDefined)
@@ -2179,6 +2182,11 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
}
if (data->actions.count()) {
+ if (!d->rangeIsSet) {
+ d->va->setStartValue(QVariant(0.0f));
+ d->va->setEndValue(QVariant(1.0f));
+ d->rangeIsSet = true;
+ }
d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
} else {
delete data;
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
index 71b6caa..71fa9a3 100644
--- a/src/declarative/util/qmlanimation_p_p.h
+++ b/src/declarative/util/qmlanimation_p_p.h
@@ -343,7 +343,7 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate
public:
QmlPropertyAnimationPrivate()
: QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
+ rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
void init();
@@ -358,9 +358,10 @@ public:
QList<QObject *> exclude;
bool fromSourced;
- bool fromIsDefined;
- bool toIsDefined;
- bool defaultToInterpolatorType;
+ bool fromIsDefined:1;
+ bool toIsDefined:1;
+ bool rangeIsSet:1;
+ bool defaultToInterpolatorType:1;
int interpolatorType;
QVariantAnimation::Interpolator interpolator;
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index dad6c37..b96ff61 100644
--- a/src/declarative/util/qmltransition.cpp
+++ b/src/declarative/util/qmltransition.cpp
@@ -83,7 +83,7 @@ class QmlTransitionPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QmlTransition)
public:
QmlTransitionPrivate() : fromState(QLatin1String("*")), toState(QLatin1String("*"))
- , reversed(false), reversible(false), group(0), endState(0)
+ , reversed(false), reversible(false), endState(0)
{
animations.parent = this;
}
@@ -92,13 +92,12 @@ public:
QString toState;
bool reversed;
bool reversible;
- ParallelAnimationWrapper *group;
+ ParallelAnimationWrapper group;
QmlTransitionManager *endState;
void init()
{
- group = new ParallelAnimationWrapper;
- group->trans = this;
+ group.trans = this;
}
void complete()
@@ -121,7 +120,7 @@ public:
void QmlTransitionPrivate::AnimationList::append(QmlAbstractAnimation *a)
{
QmlConcreteList<QmlAbstractAnimation *>::append(a);
- parent->group->addAnimation(a->qtAnimation());
+ parent->group.addAnimation(a->qtAnimation());
}
void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
@@ -146,14 +145,12 @@ QmlTransition::QmlTransition(QObject *parent)
QmlTransition::~QmlTransition()
{
- Q_D(QmlTransition);
- delete d->group;
}
void QmlTransition::stop()
{
Q_D(QmlTransition);
- d->group->stop();
+ d->group.stop();
}
void QmlTransition::setReversed(bool r)
@@ -179,8 +176,8 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions,
}
d->endState = endState;
- d->group->setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
- d->group->start();
+ d->group.setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
+ d->group.start();
}
/*!