summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-04-29 14:57:46 (GMT)
committerLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-04-30 09:31:53 (GMT)
commit5b15e629641281dd87197b22bd4d0dc5dc7c89e1 (patch)
treee0fb174cc8124a836aaf656204dbcf477f5fdf43
parent2e71dc6b97dfa0f8193162019da326aa32291d5e (diff)
downloadQt-5b15e629641281dd87197b22bd4d0dc5dc7c89e1.zip
Qt-5b15e629641281dd87197b22bd4d0dc5dc7c89e1.tar.gz
Qt-5b15e629641281dd87197b22bd4d0dc5dc7c89e1.tar.bz2
Using QVariant for 'to' and 'from' values in QmlVariantAnimationPrivate
The 'to' and 'from' attiributes in QmlVariantAnimationPrivate were QmlNullableValue before, but we can query QVariant::isValid for the same purpose.
-rw-r--r--src/declarative/util/qmlanimation.cpp32
-rw-r--r--src/declarative/util/qmlanimation_p.h6
2 files changed, 18 insertions, 20 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index a099e54..7861e55 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -1997,7 +1997,7 @@ QVariant QmlVariantAnimation::from() const
void QmlVariantAnimation::setFrom(const QVariant &f)
{
Q_D(QmlVariantAnimation);
- if (!d->from.isNull && f == d->from)
+ if (d->from.isValid() && f == d->from)
return;
d->from = f;
emit fromChanged(f);
@@ -2021,7 +2021,7 @@ QVariant QmlVariantAnimation::to() const
void QmlVariantAnimation::setTo(const QVariant &t)
{
Q_D(QmlVariantAnimation);
- if (!d->to.isNull && t == d->to)
+ if (d->to.isValid() && t == d->to)
return;
d->to = t;
emit toChanged(t);
@@ -2113,18 +2113,16 @@ QList<QObject *> *QmlVariantAnimation::exclude()
void QmlVariantAnimationPrivate::valueChanged(qreal r)
{
if (!fromSourced) {
- if (from.isNull) {
- fromValue = property.read();
- } else {
- fromValue = from;
+ if (!from.isValid()) {
+ from = property.read();
}
fromSourced = true;
}
if (r == 1.) {
- property.write(to.value);
+ property.write(to);
} else {
- QVariant val = interpolateVariant(fromValue, to.value, r);
+ QVariant val = interpolateVariant(from, to, r);
property.write(val);
}
}
@@ -2143,9 +2141,9 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p)
else
d->property = d->userProperty;
- d->convertVariant(d->to.value, (QVariant::Type)d->property.propertyType());
- if (!d->from.isNull)
- d->convertVariant(d->from.value, (QVariant::Type)d->property.propertyType());
+ d->convertVariant(d->to, (QVariant::Type)d->property.propertyType());
+ if (d->from.isValid())
+ d->convertVariant(d->from, (QVariant::Type)d->property.propertyType());
d->fromSourced = false;
d->value.QmlTimeLineValue::setValue(0.);
@@ -2205,12 +2203,12 @@ void QmlVariantAnimation::transition(QmlStateActions &actions,
Action myAction = action;
if (d->from.isValid()) {
- myAction.fromValue = QVariant(d->from);
+ myAction.fromValue = d->from;
} else {
myAction.fromValue = QVariant();
}
if (d->to.isValid())
- myAction.toValue = QVariant(d->to);
+ myAction.toValue = d->to;
d->convertVariant(myAction.fromValue, (QVariant::Type)myAction.property.propertyType());
d->convertVariant(myAction.toValue, (QVariant::Type)myAction.property.propertyType());
@@ -2229,12 +2227,12 @@ void QmlVariantAnimation::transition(QmlStateActions &actions,
myAction.property = QmlMetaProperty(obj, props.at(jj));
if (d->from.isValid()) {
- d->convertVariant(d->from.value, (QVariant::Type)myAction.property.propertyType());
- myAction.fromValue = QVariant(d->from);
+ d->convertVariant(d->from, (QVariant::Type)myAction.property.propertyType());
+ myAction.fromValue = d->from;
}
- d->convertVariant(d->to.value, (QVariant::Type)myAction.property.propertyType());
- myAction.toValue = QVariant(d->to);
+ d->convertVariant(d->to, (QVariant::Type)myAction.property.propertyType());
+ myAction.toValue = d->to;
myAction.bv = 0;
myAction.event = 0;
data->actions << myAction;
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 0ef89f4..4fcaa47 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -354,8 +354,8 @@ public:
void init();
- QmlNullableValue<QVariant> from;
- QmlNullableValue<QVariant> to;
+ QVariant from;
+ QVariant to;
QString easing;
@@ -364,7 +364,7 @@ public:
QList<QObject *> exclude;
bool fromSourced;
- QVariant fromValue;
+
QmlTimeLineValueAnimator *va;
virtual void valueChanged(qreal);