diff options
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qmlfollow.cpp | 30 | ||||
-rw-r--r-- | src/declarative/util/qmlfollow.h | 3 | ||||
-rw-r--r-- | src/declarative/util/qmllistmodel.cpp | 4 |
3 files changed, 32 insertions, 5 deletions
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index b8e6685..1e6fea2 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -56,7 +56,7 @@ class QmlFollowPrivate : public QObjectPrivate public: QmlFollowPrivate() : sourceValue(0), maxVelocity(0), lastTime(0) - , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.005), modulus(0.0), enabled(true), mode(Track), clock(this) {} + , mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01), modulus(0.0), enabled(true), mode(Track), clock(this) {} QmlMetaProperty property; qreal currentValue; @@ -164,8 +164,10 @@ void QmlFollowPrivate::tick(int time) } lastTime = time; } - emit q->valueChanged(currentValue); property.write(currentValue); + emit q->valueChanged(currentValue); + if (clock.state() != QAbstractAnimation::Running) + emit q->syncChanged(); } void QmlFollowPrivate::updateMode() @@ -183,12 +185,15 @@ void QmlFollowPrivate::start() if (!enabled) return; + Q_Q(QmlFollow); if (mode == QmlFollowPrivate::Track) { currentValue = sourceValue; property.write(currentValue); } else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) { lastTime = 0; + currentValue = property.read().toDouble(); clock.start(); // infinity?? + emit q->syncChanged(); } } @@ -261,8 +266,10 @@ qreal QmlFollow::sourceValue() const void QmlFollow::setSourceValue(qreal value) { Q_D(QmlFollow); - d->sourceValue = value; - d->start(); + if (d->sourceValue != value) { + d->sourceValue = value; + d->start(); + } } /*! @@ -338,7 +345,7 @@ void QmlFollow::setDamping(qreal damping) to 0 to be considered equal to zero. This will depend on the usage of the value. For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice. - The default is 0.005. Small performance improvements can result in tuning this + The default is 0.01. Small performance improvements can result in tuning this value. */ qreal QmlFollow::epsilon() const @@ -397,6 +404,19 @@ void QmlFollow::setEnabled(bool enabled) d->stop(); } +/*! + \qmlproperty bool Follow::inSync + This property is true when target is equal to the source; otherwise + false. If inSync is true the target is not being animated. + + If \l enabled is false then inSync will also be false. +*/ +bool QmlFollow::inSync() const +{ + Q_D(const QmlFollow); + return d->enabled && d->clock.state() != QAbstractAnimation::Running; +} + qreal QmlFollow::value() const { Q_D(const QmlFollow); diff --git a/src/declarative/util/qmlfollow.h b/src/declarative/util/qmlfollow.h index 07e15e9..e0a588b 100644 --- a/src/declarative/util/qmlfollow.h +++ b/src/declarative/util/qmlfollow.h @@ -68,6 +68,7 @@ class Q_DECLARATIVE_EXPORT QmlFollow : public QmlPropertyValueSource, Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) Q_PROPERTY(qreal followValue READ value NOTIFY valueChanged) Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged) + Q_PROPERTY(bool inSync READ inSync NOTIFY syncChanged) public: QmlFollow(QObject *parent=0); @@ -89,11 +90,13 @@ public: void setModulus(qreal modulus); bool enabled() const; void setEnabled(bool enabled); + bool inSync() const; qreal value() const; Q_SIGNALS: void valueChanged(qreal); + void syncChanged(); }; QT_END_NAMESPACE diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index a969100..0c167c0 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -330,6 +330,10 @@ QHash<int,QVariant> QmlListModel::data(int index, const QList<int> &roles) const return rv; } +/*! + \qmlproperty int ListModel::count + The number of data entries in the model. +*/ int QmlListModel::count() const { if (!_root) return 0; |