diff options
Diffstat (limited to 'src/declarative/util/qmlanimation.cpp')
-rw-r--r-- | src/declarative/util/qmlanimation.cpp | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 82bd33e..c044f97 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -176,7 +176,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj The \c running property can be set to declaratively control whether or not an animation is running. The following example will animate a rectangle - whenever the \l MouseRegion is pressed. + whenever the \l MouseArea is pressed. \code Rectangle { @@ -185,7 +185,7 @@ QmlAbstractAnimation::QmlAbstractAnimation(QmlAbstractAnimationPrivate &dd, QObj running: myMouse.pressed from: 0; to: 100 } - MouseRegion { id: myMouse } + MouseArea { id: myMouse } } \endcode @@ -937,10 +937,10 @@ void QmlPropertyAction::setProperties(const QString &p) emit propertiesChanged(p); } -QList<QObject *> *QmlPropertyAction::targets() +QmlListProperty<QObject> QmlPropertyAction::targets() { Q_D(QmlPropertyAction); - return &d->targets; + return QmlListProperty<QObject>(this, d->targets); } /*! @@ -948,10 +948,10 @@ QList<QObject *> *QmlPropertyAction::targets() This property holds the objects not to be affected by this animation. \sa targets */ -QList<QObject *> *QmlPropertyAction::exclude() +QmlListProperty<QObject> QmlPropertyAction::exclude() { Q_D(QmlPropertyAction); - return &d->exclude; + return QmlListProperty<QObject>(this, d->exclude); } /*! @@ -1577,14 +1577,36 @@ QmlAnimationGroup::QmlAnimationGroup(QObject *parent) { } +void QmlAnimationGroupPrivate::append_animation(QmlListProperty<QmlAbstractAnimation> *list, QmlAbstractAnimation *a) +{ + QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object); + if (q) { + q->d_func()->animations.append(a); + a->setGroup(q); + } +} + +void QmlAnimationGroupPrivate::clear_animation(QmlListProperty<QmlAbstractAnimation> *list) +{ + QmlAnimationGroup *q = qobject_cast<QmlAnimationGroup *>(list->object); + if (q) { + for (int i = 0; i < q->d_func()->animations.count(); ++i) + q->d_func()->animations.at(i)->setGroup(0); + q->d_func()->animations.clear(); + } +} + QmlAnimationGroup::~QmlAnimationGroup() { } -QmlList<QmlAbstractAnimation *> *QmlAnimationGroup::animations() +QmlListProperty<QmlAbstractAnimation> QmlAnimationGroup::animations() { Q_D(QmlAnimationGroup); - return &d->animations; + QmlListProperty<QmlAbstractAnimation> list(this, d->animations); + list.append = &QmlAnimationGroupPrivate::append_animation; + list.clear = &QmlAnimationGroupPrivate::clear_animation; + return list; } /*! @@ -1794,7 +1816,7 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) Fade out \c theObject when clicked: \qml - MouseRegion { + MouseArea { anchors.fill: theObject onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 } } @@ -2214,7 +2236,7 @@ void QmlPropertyAnimation::setProperties(const QString &prop) color: Qt.rgba(0,0,1) //need to explicitly specify target and property NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 } - MouseRegion { + MouseArea { anchors.fill: parent onClicked: theAnim.start() } @@ -2226,10 +2248,10 @@ void QmlPropertyAnimation::setProperties(const QString &prop) \sa exclude */ -QList<QObject *> *QmlPropertyAnimation::targets() +QmlListProperty<QObject> QmlPropertyAnimation::targets() { Q_D(QmlPropertyAnimation); - return &d->targets; + return QmlListProperty<QObject>(this, d->targets); } /*! @@ -2237,10 +2259,10 @@ QList<QObject *> *QmlPropertyAnimation::targets() This property holds the items not to be affected by this animation. \sa targets */ -QList<QObject *> *QmlPropertyAnimation::exclude() +QmlListProperty<QObject> QmlPropertyAnimation::exclude() { Q_D(QmlPropertyAnimation); - return &d->exclude; + return QmlListProperty<QObject>(this, d->exclude); } QAbstractAnimation *QmlPropertyAnimation::qtAnimation() |