summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-09-10 03:21:36 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-09-10 03:21:36 (GMT)
commit2c0255521f00a1fd95988161a03c39631350eaba (patch)
tree20947c82c768b3aa785628e92ae0ee7a0ac3bfbd
parentc494da05e1d3cb597990098e9713a0af5364c828 (diff)
downloadQt-2c0255521f00a1fd95988161a03c39631350eaba.zip
Qt-2c0255521f00a1fd95988161a03c39631350eaba.tar.gz
Qt-2c0255521f00a1fd95988161a03c39631350eaba.tar.bz2
Follow renamed to SpringFollow.
-rw-r--r--demos/declarative/samegame/content/BoomBlock.qml4
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml1
-rw-r--r--examples/declarative/aspectratio/face_fit_animated.qml2
-rw-r--r--examples/declarative/clock/Clock.qml6
-rw-r--r--examples/declarative/dial/DialLibrary/Dial.qml4
-rw-r--r--examples/declarative/follow/follow.qml10
-rw-r--r--examples/declarative/follow/pong.qml6
-rw-r--r--examples/declarative/listview/highlight.qml2
-rw-r--r--examples/declarative/snow/snow.qml6
-rw-r--r--examples/declarative/velocity/Day.qml2
-rw-r--r--src/declarative/QmlChanges.txt1
-rw-r--r--src/declarative/fx/qfxgridview.cpp16
-rw-r--r--src/declarative/fx/qfxlistview.cpp52
-rw-r--r--src/declarative/fx/qfxlistview.h1
-rw-r--r--src/declarative/util/qmleasefollow.cpp28
-rw-r--r--src/declarative/util/qmleasefollow.h4
-rw-r--r--src/declarative/util/qmlspringfollow.cpp (renamed from src/declarative/util/qmlfollow.cpp)134
-rw-r--r--src/declarative/util/qmlspringfollow.h (renamed from src/declarative/util/qmlfollow.h)12
-rw-r--r--src/declarative/util/util.pri4
19 files changed, 180 insertions, 115 deletions
diff --git a/demos/declarative/samegame/content/BoomBlock.qml b/demos/declarative/samegame/content/BoomBlock.qml
index 7860cf4..a495cd0 100644
--- a/demos/declarative/samegame/content/BoomBlock.qml
+++ b/demos/declarative/samegame/content/BoomBlock.qml
@@ -7,8 +7,8 @@ Item { id:block
property int targetX: 0
property int targetY: 0
- x: Follow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 }
- y: Follow { source: targetY; spring: 2; damping: 0.2 }
+ x: SpringFollow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 }
+ y: SpringFollow { source: targetY; spring: 2; damping: 0.2 }
Image { id: img
source: {
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 9a8af29..ae3d048 100644
--- a/demos/declarative/webbrowser/webbrowser.qml
+++ b/demos/declarative/webbrowser/webbrowser.qml
@@ -167,6 +167,7 @@ Item {
anchors.bottom: Footer.top
anchors.left: parent.left
anchors.right: parent.right
+ pressDelay: 200
WebView {
id: MyWebView
diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml
index 2768150..7db1c80 100644
--- a/examples/declarative/aspectratio/face_fit_animated.qml
+++ b/examples/declarative/aspectratio/face_fit_animated.qml
@@ -16,7 +16,7 @@ Rectangle {
source: "pics/face.png"
x: (parent.width-width*scale)/2
y: (parent.height-height*scale)/2
- scale: Follow {
+ scale: SpringFollow {
source: Math.max(Math.min(Image.parent.width/Image.width*1.333,Image.parent.height/Image.height),
Math.min(Image.parent.width/Image.width,Image.parent.height/Image.height*1.333))
spring: 1
diff --git a/examples/declarative/clock/Clock.qml b/examples/declarative/clock/Clock.qml
index e152be3..6064dd4 100644
--- a/examples/declarative/clock/Clock.qml
+++ b/examples/declarative/clock/Clock.qml
@@ -28,7 +28,7 @@ Item {
id: HourRotation
origin.x: 4; origin.y: 45
angle: 0
- angle: Follow {
+ angle: SpringFollow {
spring: 2
damping: .2
source: Clock.hours * 50 * 3 + Clock.minutes / 2
@@ -44,7 +44,7 @@ Item {
id: MinuteRotation
origin.x: 4; origin.y: 70
angle: 0
- angle: Follow {
+ angle: SpringFollow {
spring: 2
damping: .2
source: Clock.minutes * 6
@@ -60,7 +60,7 @@ Item {
id: SecondRotation
origin.x: 2; origin.y: 60
angle: 0
- angle: Follow {
+ angle: SpringFollow {
spring: 5
damping: .25
modulus: 360
diff --git a/examples/declarative/dial/DialLibrary/Dial.qml b/examples/declarative/dial/DialLibrary/Dial.qml
index f53b25e..1a163a8 100644
--- a/examples/declarative/dial/DialLibrary/Dial.qml
+++ b/examples/declarative/dial/DialLibrary/Dial.qml
@@ -26,8 +26,8 @@ Item {
id: NeedleRotation
origin.x: 7; origin.y: 65
angle: -130
- angle: Follow {
-id: MyFollow
+ angle: SpringFollow {
+ id: MyFollow
spring: 1.4
damping: .15
source: Math.min(Math.max(-130, Root.value*2.2 - 130), 133)
diff --git a/examples/declarative/follow/follow.qml b/examples/declarative/follow/follow.qml
index 37dc2e8..1f585e2 100644
--- a/examples/declarative/follow/follow.qml
+++ b/examples/declarative/follow/follow.qml
@@ -26,7 +26,7 @@ Rectangle {
color: "#ff0000"
x: Rect.width; width: Rect.width; height: 20
y: 200
- y: Follow { source: Rect.y; velocity: 200 }
+ y: SpringFollow { source: Rect.y; velocity: 200 }
}
Text { x: Rect.width; y: 220; text: "Velocity" }
@@ -35,13 +35,13 @@ Rectangle {
color: "#ff0000"
x: Rect.width * 2; width: Rect.width/2; height: 20
y: 200
- y: Follow { source: Rect.y; spring: 1.0; damping: 0.2 }
+ y: SpringFollow { source: Rect.y; spring: 1.0; damping: 0.2 }
}
Rectangle {
color: "#880000"
x: Rect.width * 2.5; width: Rect.width/2; height: 20
y: 200
- y: Follow { source: Rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
+ y: SpringFollow { source: Rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
}
Text { x: Rect.width * 2; y: 220; text: "Spring" }
@@ -54,8 +54,8 @@ Rectangle {
width: 20; height: 20
radius: 10
color: "#0000ff"
- x: Follow { id: "F1"; source: Mouse.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
- y: Follow { id: "F2"; source: Mouse.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ x: SpringFollow { id: "F1"; source: Mouse.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ y: SpringFollow { id: "F2"; source: Mouse.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
states: [
State {
name: "following"
diff --git a/examples/declarative/follow/pong.qml b/examples/declarative/follow/pong.qml
index 0314bb8..b51c0d0 100644
--- a/examples/declarative/follow/pong.qml
+++ b/examples/declarative/follow/pong.qml
@@ -25,7 +25,7 @@ Rectangle {
}
// Make y follow the target y coordinate, with a velocity of 200
- y: Follow { source: Ball.targetY; velocity: 200 }
+ y: SpringFollow { source: Ball.targetY; velocity: 200 }
// Detect the ball hitting the top or bottom of the view and bounce it
onYChanged: {
@@ -42,7 +42,7 @@ Rectangle {
id: LeftBat
color: "#00ee00"
x: 2; width: 20; height: 90
- y: Follow {
+ y: SpringFollow {
source: Ball.y-45; velocity: 300
enabled: Ball.direction == 'left'
}
@@ -51,7 +51,7 @@ Rectangle {
id: RightBat
color: "#00ee00"
x: Page.width-22; width: 20; height: 90
- y: Follow {
+ y: SpringFollow {
source: Ball.y-45; velocity: 300
enabled: Ball.direction == 'right'
}
diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml
index 2bf3a9f..e707ac0 100644
--- a/examples/declarative/listview/highlight.qml
+++ b/examples/declarative/listview/highlight.qml
@@ -44,7 +44,7 @@ Rectangle {
id: PetHighlight
Rectangle {
width: 200; height: 50; color: "#FFFF88"
- y: Follow { source: List1.current.y; spring: 3; damping: 0.1 }
+ y: SpringFollow { source: List1.current.y; spring: 3; damping: 0.1 }
}
}
ListView {
diff --git a/examples/declarative/snow/snow.qml b/examples/declarative/snow/snow.qml
index b6781c3..2241c3f 100644
--- a/examples/declarative/snow/snow.qml
+++ b/examples/declarative/snow/snow.qml
@@ -30,15 +30,15 @@ Rectangle {
property bool slowDeform: true
property real deform: 0
- deform: Follow {
+ deform: SpringFollow {
id: "DeformFollow"; source: MyLayout.targetDeform; velocity: MyLayout.slowDeform?0.1:2
onSyncChanged: if(inSync) { MyLayout.slowDeform = true; MyLayout.targetDeform = 0; }
}
ImageBatch { offset: 0; ref: ImagePanel }
- x: Follow { source: MyLayout.targetX; velocity: 1000 }
- y: Follow { source: -(selectedY + imageHeight / 2); velocity: 500 }
+ x: SpringFollow { source: MyLayout.targetX; velocity: 1000 }
+ y: SpringFollow { source: -(selectedY + imageHeight / 2); velocity: 500 }
}
transform: Rotation {
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index 06d0bd4..4001a3e 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -31,7 +31,7 @@ Rectangle {
x: Math.random() * 200 + 100
y: Math.random() * 300 + 50
id: StickyPage
- rotation: Follow {
+ rotation: SpringFollow {
source: -Flick.horizontalVelocity / 100
spring: 2.0
damping: 0.1
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 87873f2..9043421 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -29,6 +29,7 @@ SetPropertyAction -> PropertyAction
RunScriptAction -> ScriptAction
ParentChangeAction -> ParentAction
VisualModel -> VisualDataModel
+Follow -> SpringFollow
Renamed properties:
Item: contents -> childrenRect
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index cccd7a6..dfb04ad 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -41,7 +41,7 @@
#include "qfxvisualitemmodel.h"
#include "qlistmodelinterface.h"
-#include "qmlfollow.h"
+#include "qmleasefollow.h"
#include "private/qfxflickable_p.h"
#include "qfxgridview.h"
@@ -313,8 +313,8 @@ public:
enum MovementReason { Other, Key, Mouse };
MovementReason moveReason;
int buffer;
- QmlFollow *highlightXAnimator;
- QmlFollow *highlightYAnimator;
+ QmlEaseFollow *highlightXAnimator;
+ QmlEaseFollow *highlightYAnimator;
int ownModel : 1;
int wrap : 1;
@@ -591,15 +591,13 @@ void QFxGridViewPrivate::createHighlight()
if (item) {
item->setParent(q->viewport());
highlight = new FxGridItem(item, q);
- highlightXAnimator = new QmlFollow(q);
+ highlightXAnimator = new QmlEaseFollow(q);
highlightXAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("x")));
- highlightXAnimator->setSpring(3);
- highlightXAnimator->setDamping(0.3);
+ highlightXAnimator->setVelocity(400);
highlightXAnimator->setEnabled(autoHighlight);
- highlightYAnimator = new QmlFollow(q);
+ highlightYAnimator = new QmlEaseFollow(q);
highlightYAnimator->setTarget(QmlMetaProperty(highlight->item, QLatin1String("y")));
- highlightYAnimator->setSpring(3);
- highlightYAnimator->setDamping(0.3);
+ highlightYAnimator->setVelocity(400);
highlightYAnimator->setEnabled(autoHighlight);
} else {
delete highlightContext;
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 6c0a83e..49de016 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include "private/qfxflickable_p.h"
-#include "qmlfollow.h"
+#include "qmleasefollow.h"
#include "qlistmodelinterface.h"
#include "qfxvisualitemmodel.h"
#include "qfxlistview.h"
@@ -381,8 +381,8 @@ public:
enum MovementReason { Other, Key, Mouse };
MovementReason moveReason;
int buffer;
- QmlFollow *highlightPosAnimator;
- QmlFollow *highlightSizeAnimator;
+ QmlEaseFollow *highlightPosAnimator;
+ QmlEaseFollow *highlightSizeAnimator;
QString sectionExpression;
QString currentSection;
int spacing;
@@ -660,15 +660,18 @@ void QFxListViewPrivate::createHighlight()
}
if (item) {
highlight = new FxListItem(item, q);
+ if (orient == Qt::Vertical)
+ highlight->item->setHeight(currentItem->item->height());
+ else
+ highlight->item->setWidth(currentItem->item->width());
const QLatin1String posProp(orient == Qt::Vertical ? "y" : "x");
- highlightPosAnimator = new QmlFollow(q);
+ highlightPosAnimator = new QmlEaseFollow(q);
highlightPosAnimator->setTarget(QmlMetaProperty(highlight->item, posProp));
- highlightPosAnimator->setEpsilon(0.25);
- highlightPosAnimator->setSpring(2.5);
- highlightPosAnimator->setDamping(0.35);
+ highlightPosAnimator->setVelocity(400);
highlightPosAnimator->setEnabled(autoHighlight);
const QLatin1String sizeProp(orient == Qt::Vertical ? "height" : "width");
- highlightSizeAnimator = new QmlFollow(q);
+ highlightSizeAnimator = new QmlEaseFollow(q);
+ highlightSizeAnimator->setVelocity(400);
highlightSizeAnimator->setTarget(QmlMetaProperty(highlight->item, sizeProp));
highlightSizeAnimator->setEnabled(autoHighlight);
}
@@ -909,6 +912,7 @@ void QFxListView::setModel(const QVariant &model)
if (d->model) {
disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
disconnect(d->model, SIGNAL(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*)));
disconnect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*)));
}
@@ -937,6 +941,7 @@ void QFxListView::setModel(const QVariant &model)
d->updateCurrent(d->currentIndex);
connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int)));
connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int)));
+ connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int)));
connect(d->model, SIGNAL(createdItem(int, QFxItem*)), this, SLOT(createdItem(int,QFxItem*)));
connect(d->model, SIGNAL(destroyingItem(QFxItem*)), this, SLOT(destroyingItem(QFxItem*)));
refill();
@@ -1635,6 +1640,37 @@ void QFxListView::destroyRemoved()
d->layout();
}
+void QFxListView::itemsMoved(int from, int to, int count)
+{
+ qWarning() << "ListView does not support moving in models";
+
+ Q_D(QFxListView);
+ int fromCount = count;
+ int toCount = count;
+ bool fromVisible = d->mapRangeFromModel(from, fromCount);
+ bool toVisible = d->mapRangeFromModel(to, toCount);
+
+ if (!fromVisible && !toVisible) {
+ // The items are outside the visible range.
+ if (d->visibleItems.count())
+ d->visibleIndex = -1;
+ for (int i = 0; i < d->visibleItems.count(); ++i) {
+ FxListItem *listItem = d->visibleItems.at(i);
+ if (listItem->index != -1) {
+ listItem->index = d->model->indexOf(listItem->item, this);
+ if (d->visibleIndex < 0)
+ d->visibleIndex = listItem->index;
+ }
+ }
+ if (d->currentItem) {
+ d->currentItem->index = d->model->indexOf(d->currentItem->item, this);
+ d->currentIndex = d->currentItem->index;
+ }
+ return;
+ }
+
+}
+
void QFxListView::createdItem(int index, QFxItem *item)
{
Q_D(QFxListView);
diff --git a/src/declarative/fx/qfxlistview.h b/src/declarative/fx/qfxlistview.h
index dc0b039..829e202 100644
--- a/src/declarative/fx/qfxlistview.h
+++ b/src/declarative/fx/qfxlistview.h
@@ -155,6 +155,7 @@ private Q_SLOTS:
void itemResized();
void itemsInserted(int index, int count);
void itemsRemoved(int index, int count);
+ void itemsMoved(int from, int to, int count);
void destroyRemoved();
void createdItem(int index, QFxItem *item);
void destroyingItem(QFxItem *item);
diff --git a/src/declarative/util/qmleasefollow.cpp b/src/declarative/util/qmleasefollow.cpp
index 83dbde7..b58ad14 100644
--- a/src/declarative/util/qmleasefollow.cpp
+++ b/src/declarative/util/qmleasefollow.cpp
@@ -56,7 +56,7 @@ public:
QmlEaseFollowPrivate()
: source(0), velocity(200), duration(-1),
reversingMode(QmlEaseFollow::Eased), initialVelocity(0),
- initialValue(0), invert(false), trackVelocity(0), clockOffset(0),
+ initialValue(0), invert(false), enabled(true), trackVelocity(0), clockOffset(0),
lastTick(0), clock(this)
{}
@@ -68,6 +68,7 @@ public:
qreal initialVelocity;
qreal initialValue;
bool invert;
+ bool enabled;
qreal trackVelocity;
@@ -267,7 +268,7 @@ qreal QmlEaseFollow::sourceValue() const
/*!
\qmlproperty enumeration EaseFollow::reversingMode
- Sets how the EaseFollow behaves if an animation diration is reversed.
+ Sets how the EaseFollow behaves if an animation direction is reversed.
If reversing mode is \c Eased, the animation will smoothly decelerate, and
then reverse direction. If the reversing mode is \c Immediate, the
@@ -289,6 +290,9 @@ void QmlEaseFollow::setReversingMode(ReversingMode m)
void QmlEaseFollowPrivate::restart()
{
+ if (!enabled)
+ return;
+
initialValue = target.read().toReal();
if (source == initialValue) {
@@ -382,6 +386,26 @@ void QmlEaseFollow::setVelocity(qreal v)
d->restart();
}
+/*!
+ \qmlproperty bool EaseFollow::enabled
+ This property holds whether the target will track the source.
+*/
+bool QmlEaseFollow::enabled() const
+{
+ Q_D(const QmlEaseFollow);
+ return d->enabled;
+}
+
+void QmlEaseFollow::setEnabled(bool enabled)
+{
+ Q_D(QmlEaseFollow);
+ d->enabled = enabled;
+ if (enabled)
+ d->restart();
+ else
+ d->clockStop();
+}
+
void QmlEaseFollow::setTarget(const QmlMetaProperty &t)
{
Q_D(QmlEaseFollow);
diff --git a/src/declarative/util/qmleasefollow.h b/src/declarative/util/qmleasefollow.h
index adcb647..8e8c59d 100644
--- a/src/declarative/util/qmleasefollow.h
+++ b/src/declarative/util/qmleasefollow.h
@@ -66,6 +66,7 @@ class Q_DECLARATIVE_EXPORT QmlEaseFollow : public QObject,
Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
Q_PROPERTY(qreal duration READ duration WRITE setDuration)
Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode)
+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
public:
enum ReversingMode { Eased, Immediate, Sync };
@@ -85,6 +86,9 @@ public:
qreal duration() const;
void setDuration(qreal);
+ bool enabled() const;
+ void setEnabled(bool enabled);
+
virtual void setTarget(const QmlMetaProperty &);
};
diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlspringfollow.cpp
index fe5303f..8c902aa 100644
--- a/src/declarative/util/qmlfollow.cpp
+++ b/src/declarative/util/qmlspringfollow.cpp
@@ -43,18 +43,18 @@
#include <math.h>
#include <QtCore/qdebug.h>
#include "private/qobject_p.h"
-#include "qmlfollow.h"
+#include "qmlspringfollow.h"
#include "private/qmlanimation_p.h"
QT_BEGIN_NAMESPACE
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Follow,QmlFollow)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,SpringFollow,QmlSpringFollow)
-class QmlFollowPrivate : public QObjectPrivate
+class QmlSpringFollowPrivate : public QObjectPrivate
{
- Q_DECLARE_PUBLIC(QmlFollow)
+ Q_DECLARE_PUBLIC(QmlSpringFollow)
public:
- QmlFollowPrivate()
+ QmlSpringFollowPrivate()
: sourceValue(0), maxVelocity(0), lastTime(0)
, mass(1.0), useMass(false), spring(0.), damping(0.), velocity(0), epsilon(0.01)
, modulus(0.0), haveModulus(false), enabled(true), mode(Track), clock(this) {}
@@ -87,12 +87,12 @@ public:
void start();
void stop();
- QTickAnimationProxy<QmlFollowPrivate, &QmlFollowPrivate::tick> clock;
+ QTickAnimationProxy<QmlSpringFollowPrivate, &QmlSpringFollowPrivate::tick> clock;
};
-void QmlFollowPrivate::tick(int time)
+void QmlSpringFollowPrivate::tick(int time)
{
- Q_Q(QmlFollow);
+ Q_Q(QmlSpringFollow);
int elapsed = time - lastTime;
if (!elapsed)
@@ -174,7 +174,7 @@ void QmlFollowPrivate::tick(int time)
emit q->syncChanged();
}
-void QmlFollowPrivate::updateMode()
+void QmlSpringFollowPrivate::updateMode()
{
if (spring == 0. && maxVelocity == 0.)
mode = Track;
@@ -184,13 +184,13 @@ void QmlFollowPrivate::updateMode()
mode = Velocity;
}
-void QmlFollowPrivate::start()
+void QmlSpringFollowPrivate::start()
{
if (!enabled)
return;
- Q_Q(QmlFollow);
- if (mode == QmlFollowPrivate::Track) {
+ Q_Q(QmlSpringFollow);
+ if (mode == QmlSpringFollowPrivate::Track) {
currentValue = sourceValue;
property.write(currentValue);
} else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) {
@@ -201,14 +201,14 @@ void QmlFollowPrivate::start()
}
}
-void QmlFollowPrivate::stop()
+void QmlSpringFollowPrivate::stop()
{
clock.stop();
}
/*!
- \qmlclass Follow QmlFollow
- \brief The Follow element allows a property to track a value.
+ \qmlclass SpringFollow QmlSpringFollow
+ \brief The SpringFollow element allows a property to track a value.
In example below, Rect2 will follow Rect1 moving with a velocity of up to 200:
\code
@@ -233,43 +233,43 @@ void QmlFollowPrivate::stop()
x: Rect1.width
width: 20; height: 20
color: "#ff0000"
- y: Follow { source: Rect1.y; velocity: 200 }
+ y: SpringFollow { source: Rect1.y; velocity: 200 }
}
\endcode
*/
-QmlFollow::QmlFollow(QObject *parent)
-: QObject(*(new QmlFollowPrivate),parent)
+QmlSpringFollow::QmlSpringFollow(QObject *parent)
+: QObject(*(new QmlSpringFollowPrivate),parent)
{
}
-QmlFollow::~QmlFollow()
+QmlSpringFollow::~QmlSpringFollow()
{
}
-void QmlFollow::setTarget(const QmlMetaProperty &property)
+void QmlSpringFollow::setTarget(const QmlMetaProperty &property)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->property = property;
d->currentValue = property.read().toDouble();
}
-qreal QmlFollow::sourceValue() const
+qreal QmlSpringFollow::sourceValue() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->sourceValue;
}
/*!
- \qmlproperty qreal Follow::source
+ \qmlproperty qreal SpringFollow::source
This property holds the source value which will be tracked.
Bind to a property in order to track its changes.
*/
-void QmlFollow::setSourceValue(qreal value)
+void QmlSpringFollow::setSourceValue(qreal value)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
if (d->sourceValue != value) {
d->sourceValue = value;
d->start();
@@ -277,26 +277,26 @@ void QmlFollow::setSourceValue(qreal value)
}
/*!
- \qmlproperty qreal Follow::velocity
+ \qmlproperty qreal SpringFollow::velocity
This property holds the maximum velocity allowed when tracking the source.
*/
-qreal QmlFollow::velocity() const
+qreal QmlSpringFollow::velocity() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->maxVelocity;
}
-void QmlFollow::setVelocity(qreal velocity)
+void QmlSpringFollow::setVelocity(qreal velocity)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->maxVelocity = velocity;
d->velocityms = velocity / 1000.0;
d->updateMode();
}
/*!
- \qmlproperty qreal Follow::spring
+ \qmlproperty qreal SpringFollow::spring
This property holds the spring constant
The spring constant describes how strongly the target is pulled towards the
@@ -305,35 +305,35 @@ void QmlFollow::setVelocity(qreal velocity)
When a spring constant is set and the velocity property is greater than 0,
velocity limits the maximum speed.
*/
-qreal QmlFollow::spring() const
+qreal QmlSpringFollow::spring() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->spring;
}
-void QmlFollow::setSpring(qreal spring)
+void QmlSpringFollow::setSpring(qreal spring)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->spring = spring;
d->updateMode();
}
/*!
- \qmlproperty qreal Follow::damping
+ \qmlproperty qreal SpringFollow::damping
This property holds the spring damping constant
The damping constant describes how quickly a sprung follower comes to rest.
Useful range is 0 - 1.0
*/
-qreal QmlFollow::damping() const
+qreal QmlSpringFollow::damping() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->damping;
}
-void QmlFollow::setDamping(qreal damping)
+void QmlSpringFollow::setDamping(qreal damping)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
if (damping > 1.)
damping = 1.;
@@ -342,7 +342,7 @@ void QmlFollow::setDamping(qreal damping)
/*!
- \qmlproperty qreal Follow::epsilon
+ \qmlproperty qreal SpringFollow::epsilon
This property holds the spring epsilon
The epsilon is the rate and amount of change in the value which is close enough
@@ -351,34 +351,34 @@ void QmlFollow::setDamping(qreal damping)
The default is 0.01. Tuning this value can provide small performance improvements.
*/
-qreal QmlFollow::epsilon() const
+qreal QmlSpringFollow::epsilon() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->epsilon;
}
-void QmlFollow::setEpsilon(qreal epsilon)
+void QmlSpringFollow::setEpsilon(qreal epsilon)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->epsilon = epsilon;
}
/*!
- \qmlproperty qreal Follow::modulus
+ \qmlproperty qreal SpringFollow::modulus
This property holds the modulus value.
Setting a \a modulus forces the target value to "wrap around" at the modulus.
For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10.
*/
-qreal QmlFollow::modulus() const
+qreal QmlSpringFollow::modulus() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->modulus;
}
-void QmlFollow::setModulus(qreal modulus)
+void QmlSpringFollow::setModulus(qreal modulus)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
if (d->modulus != modulus) {
d->haveModulus = modulus != 0.0;
d->modulus = modulus;
@@ -387,21 +387,21 @@ void QmlFollow::setModulus(qreal modulus)
}
/*!
- \qmlproperty qreal Follow::mass
+ \qmlproperty qreal SpringFollow::mass
This property holds the "mass" of the property being moved.
mass is 1.0 by default. Setting a different mass changes the dynamics of
a \l spring follow.
*/
-qreal QmlFollow::mass() const
+qreal QmlSpringFollow::mass() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->mass;
}
-void QmlFollow::setMass(qreal mass)
+void QmlSpringFollow::setMass(qreal mass)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
if (d->mass != mass && mass > 0.0) {
d->useMass = mass != 1.0;
d->mass = mass;
@@ -410,23 +410,23 @@ void QmlFollow::setMass(qreal mass)
}
/*!
- \qmlproperty qreal Follow::value
+ \qmlproperty qreal SpringFollow::value
The current value.
*/
/*!
- \qmlproperty bool Follow::enabled
+ \qmlproperty bool SpringFollow::enabled
This property holds whether the target will track the source.
*/
-bool QmlFollow::enabled() const
+bool QmlSpringFollow::enabled() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->enabled;
}
-void QmlFollow::setEnabled(bool enabled)
+void QmlSpringFollow::setEnabled(bool enabled)
{
- Q_D(QmlFollow);
+ Q_D(QmlSpringFollow);
d->enabled = enabled;
if (enabled)
d->start();
@@ -435,21 +435,21 @@ void QmlFollow::setEnabled(bool enabled)
}
/*!
- \qmlproperty bool Follow::inSync
+ \qmlproperty bool SpringFollow::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
+bool QmlSpringFollow::inSync() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->enabled && d->clock.state() != QAbstractAnimation::Running;
}
-qreal QmlFollow::value() const
+qreal QmlSpringFollow::value() const
{
- Q_D(const QmlFollow);
+ Q_D(const QmlSpringFollow);
return d->currentValue;
}
diff --git a/src/declarative/util/qmlfollow.h b/src/declarative/util/qmlspringfollow.h
index ff34d08..1b77861 100644
--- a/src/declarative/util/qmlfollow.h
+++ b/src/declarative/util/qmlspringfollow.h
@@ -51,12 +51,12 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QmlFollowPrivate;
-class Q_DECLARATIVE_EXPORT QmlFollow : public QObject,
+class QmlSpringFollowPrivate;
+class Q_DECLARATIVE_EXPORT QmlSpringFollow : public QObject,
public QmlPropertyValueSource
{
Q_OBJECT
- Q_DECLARE_PRIVATE(QmlFollow)
+ Q_DECLARE_PRIVATE(QmlSpringFollow)
Q_INTERFACES(QmlPropertyValueSource)
Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue)
@@ -72,8 +72,8 @@ class Q_DECLARATIVE_EXPORT QmlFollow : public QObject,
Q_PROPERTY(bool inSync READ inSync NOTIFY syncChanged)
public:
- QmlFollow(QObject *parent=0);
- ~QmlFollow();
+ QmlSpringFollow(QObject *parent=0);
+ ~QmlSpringFollow();
virtual void setTarget(const QmlMetaProperty &);
@@ -106,7 +106,7 @@ Q_SIGNALS:
QT_END_NAMESPACE
-QML_DECLARE_TYPE(QmlFollow)
+QML_DECLARE_TYPE(QmlSpringFollow)
QT_END_HEADER
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index a57f69f..442380a 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -7,7 +7,7 @@ SOURCES += \
util/qmlscript.cpp \
util/qmlanimation.cpp \
util/qmlsystempalette.cpp \
- util/qmlfollow.cpp \
+ util/qmlspringfollow.cpp \
util/qmleasefollow.cpp \
util/qmlstate.cpp\
util/qmltransitionmanager.cpp \
@@ -33,7 +33,7 @@ HEADERS += \
util/qmlanimation.h \
util/qmlanimation_p.h \
util/qmlsystempalette.h \
- util/qmlfollow.h \
+ util/qmlspringfollow.h \
util/qmleasefollow.h \
util/qmlstate.h\
util/qmlstateoperations.h \