summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-12-07 03:22:25 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-12-07 03:22:25 (GMT)
commit55a3fda3baf545cc7fbfa6b2c00705be40a7319b (patch)
tree04f82179b29b46b3fd540cab4dfea54f7ea377e8 /src
parent560d32ddd80d5c6b21cd39ae93ea3f580da613da (diff)
downloadQt-55a3fda3baf545cc7fbfa6b2c00705be40a7319b.zip
Qt-55a3fda3baf545cc7fbfa6b2c00705be40a7319b.tar.gz
Qt-55a3fda3baf545cc7fbfa6b2c00705be40a7319b.tar.bz2
Move target/property functions to their appropriate classes.
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qmlanimation.cpp138
-rw-r--r--src/declarative/util/qmlanimation_p.h21
-rw-r--r--src/declarative/util/qmlanimation_p_p.h12
3 files changed, 112 insertions, 59 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 0143791..8afe667 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -422,50 +422,6 @@ void QmlAbstractAnimation::setGroup(QmlAnimationGroup *g)
setParent(g);
}
-QObject *QmlAbstractAnimation::target() const
-{
- Q_D(const QmlAbstractAnimation);
- return d->target;
-}
-
-void QmlAbstractAnimation::setTarget(QObject *o)
-{
- Q_D(QmlAbstractAnimation);
- if (d->target == o)
- return;
-
- d->target = o;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
- emit targetChanged(d->target, d->propertyName);
-}
-
-QString QmlAbstractAnimation::property() const
-{
- Q_D(const QmlAbstractAnimation);
- return d->propertyName;
-}
-
-void QmlAbstractAnimation::setProperty(const QString &n)
-{
- Q_D(QmlAbstractAnimation);
- if (d->propertyName == n)
- return;
-
- d->propertyName = n;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
- emit targetChanged(d->target, d->propertyName);
-}
-
/*!
\qmlmethod Animation::start()
\brief Starts the animation.
@@ -886,6 +842,28 @@ void QmlPropertyActionPrivate::init()
is being used. Refer to the \l animation documentation for details.
*/
+QObject *QmlPropertyAction::target() const
+{
+ Q_D(const QmlPropertyAction);
+ return d->target;
+}
+
+void QmlPropertyAction::setTarget(QObject *o)
+{
+ Q_D(QmlPropertyAction);
+ if (d->target == o)
+ return;
+
+ d->target = o;
+ if (d->target && !d->propertyName.isEmpty()) {
+ d->userProperty = d->createProperty(d->target, d->propertyName, this);
+ } else {
+ d->userProperty.invalidate();
+ }
+
+ emit targetChanged(d->target, d->propertyName);
+}
+
/*!
\qmlproperty string PropertyAction::property
This property holds an explicit property to animated.
@@ -894,6 +872,28 @@ void QmlPropertyActionPrivate::init()
is being used. Refer to the \l animation documentation for details.
*/
+QString QmlPropertyAction::property() const
+{
+ Q_D(const QmlPropertyAction);
+ return d->propertyName;
+}
+
+void QmlPropertyAction::setProperty(const QString &n)
+{
+ Q_D(QmlPropertyAction);
+ if (d->propertyName == n)
+ return;
+
+ d->propertyName = n;
+ if (d->target && !d->propertyName.isEmpty()) {
+ d->userProperty = d->createProperty(d->target, d->propertyName, this);
+ } else {
+ d->userProperty.invalidate();
+ }
+
+ emit targetChanged(d->target, d->propertyName);
+}
+
/*!
\qmlproperty string PropertyAction::matchProperties
This property holds a comma-separated list of property names this action
@@ -1445,10 +1445,10 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions,
}
//needed for Behavior
- if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) {
+ if (d->userProperty.isValid()) {
for (int i = 0; i < d->animations.count(); ++i)
d->animations.at(i)->setTarget(d->userProperty);
- }
+ }
for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
d->animations.at(ii)->transition(actions, modified, direction);
@@ -1517,7 +1517,7 @@ void QmlParallelAnimation::transition(QmlStateActions &actions,
Q_D(QmlAnimationGroup);
//needed for Behavior
- if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) {
+ if (d->userProperty.isValid()) {
for (int i = 0; i < d->animations.count(); ++i)
d->animations.at(i)->setTarget(d->userProperty);
}
@@ -1881,6 +1881,28 @@ void QmlPropertyAnimation::setEasing(const QString &e)
\sa property matchTargets
*/
+QObject *QmlPropertyAnimation::target() const
+{
+ Q_D(const QmlPropertyAnimation);
+ return d->target;
+}
+
+void QmlPropertyAnimation::setTarget(QObject *o)
+{
+ Q_D(QmlPropertyAnimation);
+ if (d->target == o)
+ return;
+
+ d->target = o;
+ if (d->target && !d->propertyName.isEmpty()) {
+ d->userProperty = d->createProperty(d->target, d->propertyName, this);
+ } else {
+ d->userProperty.invalidate();
+ }
+
+ emit targetChanged(d->target, d->propertyName);
+}
+
/*!
\qmlproperty string PropertyAnimation::property
This property holds an explicit property name to animate.
@@ -1891,6 +1913,28 @@ void QmlPropertyAnimation::setEasing(const QString &e)
\sa target matchProperties
*/
+QString QmlPropertyAnimation::property() const
+{
+ Q_D(const QmlPropertyAnimation);
+ return d->propertyName;
+}
+
+void QmlPropertyAnimation::setProperty(const QString &n)
+{
+ Q_D(QmlPropertyAnimation);
+ if (d->propertyName == n)
+ return;
+
+ d->propertyName = n;
+ if (d->target && !d->propertyName.isEmpty()) {
+ d->userProperty = d->createProperty(d->target, d->propertyName, this);
+ } else {
+ d->userProperty.invalidate();
+ }
+
+ emit targetChanged(d->target, d->propertyName);
+}
+
/*!
\qmlproperty string PropertyAnimation::matchProperties
This property holds a comma-separated list of property names this animation
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 707ed33..322f048 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -94,12 +94,6 @@ public:
QmlAnimationGroup *group() const;
void setGroup(QmlAnimationGroup *);
- //### these belong at a lower level in the hierarchy
- QObject *target() const;
- void setTarget(QObject *);
- QString property() const;
- void setProperty(const QString &);
-
virtual void setTarget(const QmlMetaProperty &);
void classBegin();
@@ -111,7 +105,6 @@ Q_SIGNALS:
void runningChanged(bool);
void pausedChanged(bool);
void repeatChanged(bool);
- void targetChanged(QObject *, const QString &);
void alwaysRunToEndChanged(bool);
public Q_SLOTS:
@@ -202,6 +195,12 @@ public:
QmlPropertyAction(QObject *parent=0);
virtual ~QmlPropertyAction();
+ QObject *target() const;
+ void setTarget(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
QString properties() const;
void setProperties(const QString &);
@@ -214,6 +213,7 @@ public:
Q_SIGNALS:
void valueChanged(const QVariant &);
void propertiesChanged(const QString &);
+ void targetChanged(QObject *, const QString &);
protected:
virtual void transition(QmlStateActions &actions,
@@ -286,6 +286,12 @@ public:
QString easing() const;
void setEasing(const QString &);
+ QObject *target() const;
+ void setTarget(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
QString properties() const;
void setProperties(const QString &);
@@ -305,6 +311,7 @@ Q_SIGNALS:
void toChanged(QVariant);
void easingChanged(const QString &);
void propertiesChanged(const QString &);
+ void targetChanged(QObject *, const QString &);
};
class Q_AUTOTEST_EXPORT QmlColorAnimation : public QmlPropertyAnimation
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
index 71fa9a3..fbd7114 100644
--- a/src/declarative/util/qmlanimation_p_p.h
+++ b/src/declarative/util/qmlanimation_p_p.h
@@ -203,7 +203,7 @@ public:
QmlAbstractAnimationPrivate()
: running(false), paused(false), alwaysRunToEnd(false), repeat(false),
connectedTimeLine(false), componentComplete(true), startOnCompletion(false),
- target(0), group(0) {}
+ group(0) {}
bool running:1;
bool paused:1;
@@ -217,8 +217,6 @@ public:
void commence();
QmlNullableValue<QmlMetaProperty> userProperty;
- QObject *target;
- QString propertyName;
QmlMetaProperty property;
QmlAnimationGroup *group;
@@ -264,10 +262,12 @@ class QmlPropertyActionPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlPropertyAction)
public:
QmlPropertyActionPrivate()
- : QmlAbstractAnimationPrivate(), proxy(this), spa(0) {}
+ : QmlAbstractAnimationPrivate(), target(0), proxy(this), spa(0) {}
void init();
+ QObject *target;
+ QString propertyName;
QString properties;
QList<QObject *> targets;
QList<QObject *> exclude;
@@ -342,7 +342,7 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlPropertyAnimation)
public:
QmlPropertyAnimationPrivate()
- : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false),
+ : QmlAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
@@ -353,6 +353,8 @@ public:
QString easing;
+ QObject *target;
+ QString propertyName;
QString properties;
QList<QObject *> targets;
QList<QObject *> exclude;