diff options
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qmlanimation.cpp | 3 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation_p.h | 14 | ||||
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 68 |
3 files changed, 71 insertions, 14 deletions
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 08a7a28..dd4e1eb 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -791,6 +791,7 @@ void QmlColorAnimation::prepare(QmlMetaProperty &p) d->fromSourced = false; d->value.QmlTimeLineValue::setValue(0.); d->ca->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); + d->ca->setFromSourcedValue(&d->fromSourced); } QAbstractAnimation *QmlColorAnimation::qtAnimation() @@ -1595,6 +1596,7 @@ void QmlNumericAnimation::prepare(QmlMetaProperty &p) d->fromSourced = false; d->value.QmlTimeLineValue::setValue(0.); d->na->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); + d->na->setFromSourcedValue(&d->fromSourced); } QAbstractAnimation *QmlNumericAnimation::qtAnimation() @@ -2152,6 +2154,7 @@ void QmlVariantAnimation::prepare(QmlMetaProperty &p) d->fromSourced = false; d->value.QmlTimeLineValue::setValue(0.); d->va->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); + d->va->setFromSourcedValue(&d->fromSourced); } void QmlVariantAnimation::transition(QmlStateActions &actions, diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 06b7c08..00937a6 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -116,8 +116,7 @@ private: class QmlTimeLineValueAnimator : public QVariantAnimation { public: - QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), policy(KeepWhenStopped) {} - QmlTimeLineValueAnimator(QmlTimeLineValue *value, QObject *parent = 0) : QVariantAnimation(parent), animValue(value), policy(KeepWhenStopped) {} + QmlTimeLineValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {} void setAnimValue(QmlTimeLineValue *value, DeletionPolicy p) { if (state() == Running) @@ -125,6 +124,10 @@ public: animValue = value; policy = p; } + void setFromSourcedValue(bool *value) + { + fromSourced = value; + } protected: virtual void updateCurrentValue(const QVariant &value) { @@ -134,7 +137,11 @@ protected: virtual void updateState(State oldState, State newState) { QVariantAnimation::updateState(oldState, newState); - if (newState == Stopped && policy == DeleteWhenStopped) { + if (newState == Running) { + //check for new from every loop + if (fromSourced) + *fromSourced = false; + } else if (newState == Stopped && policy == DeleteWhenStopped) { delete animValue; animValue = 0; } @@ -142,6 +149,7 @@ protected: private: QmlTimeLineValue *animValue; + bool *fromSourced; DeletionPolicy policy; }; diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 1cd2f69..8184bda 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -93,8 +93,7 @@ Q_DECLARE_METATYPE(QListModelInterface *); } \endcode - Elements beginning with a capital are items. Elements beginning - with lower-case are the data roles. The above example defines a + Item roles (properties) must begin with a lower-case letter. The above example defines a ListModel containing three items, with the roles "name" and "cost". The defined model can be used in views such as ListView: @@ -102,15 +101,9 @@ Q_DECLARE_METATYPE(QListModelInterface *); Component { id: FruitDelegate Item { - width: 200 - height: 50 - Text { - text: name - } - Text { - text: '$'+cost - anchors.right: parent.right - } + width: 200; height: 50 + Text { text: name } + Text { text: '$'+cost; anchors.right: parent.right } } } @@ -120,6 +113,59 @@ Q_DECLARE_METATYPE(QListModelInterface *); anchors.fill: parent } \endcode + + It is possible for roles to contain list data. In the example below we create a list of fruit attributes: + + \code + ListModel { + id: FruitModel + ListElement { + name: "Apple" + cost: 2.45 + attributes: [ + ListElement { description: "Core" }, + ListElement { description: "Deciduous" } + ] + } + ListElement { + name: "Orange" + cost: 3.25 + attributes: [ + ListElement { description: "Citrus" } + ] + } + ListElement { + name: "Banana" + cost: 1.95 + attributes: [ + ListElement { description: "Tropical" } + ListElement { description: "Seedless" } + ] + } + } + \endcode + + The delegate below will list all the fruit attributes: + \code + Component { + id: FruitDelegate + Item { + width: 200; height: 50 + Text { id: Name; text: name } + Text { text: '$'+cost; anchors.right: parent.right } + HorizontalLayout { + anchors.top: Name.bottom + spacing: 5 + Text { text: "Attributes:" } + Repeater { + dataSource: attributes + Component { Text { text: description } } + } + } + } + } + \endcode + */ struct ModelNode; |