aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/demos/rssnews/rssnews.qml2
-rw-r--r--src/quick/items/qquicklistview.cpp54
-rw-r--r--src/quick/items/qquicklistview_p.h12
-rw-r--r--tests/auto/quick/qquicklistview/data/displaylist.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/flickBeyondBoundsBug.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-initCurrent.qml1
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-noCurrent.qml1
-rw-r--r--tests/auto/quick/qquicklistview/data/listviewtest-package.qml2
-rw-r--r--tests/auto/quick/qquicklistview/data/listviewtest.qml2
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp3
10 files changed, 74 insertions, 7 deletions
diff --git a/examples/demos/rssnews/rssnews.qml b/examples/demos/rssnews/rssnews.qml
index 706eac2703..d26b94b6d3 100644
--- a/examples/demos/rssnews/rssnews.qml
+++ b/examples/demos/rssnews/rssnews.qml
@@ -75,7 +75,7 @@ Rectangle {
footer: quitButtonDelegate
delegate: CategoryDelegate {}
highlight: Rectangle { color: "steelblue" }
- highlightMoveDuration: 50
+ highlightMoveSpeed: 9999999
}
ScrollBar {
scrollArea: categories; height: categories.height; width: 8
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index d42d1cbc48..018cb862c9 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -143,6 +143,8 @@ public:
QSmoothedAnimation *highlightPosAnimator;
QSmoothedAnimation *highlightSizeAnimator;
+ qreal highlightMoveSpeed;
+ qreal highlightResizeSpeed;
int highlightResizeDuration;
QQuickViewSection *sectionCriteria;
@@ -166,7 +168,7 @@ public:
, averageSize(100.0), spacing(0.0)
, snapMode(QQuickListView::NoSnap)
, highlightPosAnimator(0), highlightSizeAnimator(0)
- , highlightResizeDuration(250)
+ , highlightMoveSpeed(400), highlightResizeSpeed(400), highlightResizeDuration(-1)
, sectionCriteria(0), currentSectionItem(0), nextSectionItem(0)
, overshootDist(0.0), correctFlick(false), inFlickCorrection(false)
{}
@@ -873,10 +875,12 @@ void QQuickListViewPrivate::createHighlight()
const QLatin1String posProp(orient == QQuickListView::Vertical ? "y" : "x");
highlightPosAnimator = new QSmoothedAnimation;
highlightPosAnimator->target = QQmlProperty(item, posProp);
+ highlightPosAnimator->velocity = highlightMoveSpeed;
highlightPosAnimator->userDuration = highlightMoveDuration;
const QLatin1String sizeProp(orient == QQuickListView::Vertical ? "height" : "width");
highlightSizeAnimator = new QSmoothedAnimation;
+ highlightSizeAnimator->velocity = highlightResizeSpeed;
highlightSizeAnimator->userDuration = highlightResizeDuration;
highlightSizeAnimator->target = QQmlProperty(item, sizeProp);
@@ -1901,7 +1905,7 @@ QQuickListView::~QQuickListView()
is scrolled. This is because the view moves to maintain the
highlight within the preferred highlight range (or visible viewport).
- \sa highlight
+ \sa highlight, highlightMoveSpeed
*/
//###Possibly rename these properties, since they are very useful even without a highlight?
/*!
@@ -2190,20 +2194,41 @@ QString QQuickListView::currentSection() const
}
/*!
+ \qmlproperty real QtQuick2::ListView::highlightMoveSpeed
\qmlproperty int QtQuick2::ListView::highlightMoveDuration
+ \qmlproperty real QtQuick2::ListView::highlightResizeSpeed
\qmlproperty int QtQuick2::ListView::highlightResizeDuration
- These properties hold the move and resize animation duration of
- the highlight delegate.
+ These properties hold the move and resize animation speed of the highlight delegate.
\l highlightFollowsCurrentItem must be true for these properties
to have effect.
- The default value for highlightMoveDuration is 150ms and the
- default value for highlightResizeDuration is 250ms.
+ The default value for the speed properties is 400 pixels/second.
+ The default value for the duration properties is -1, i.e. the
+ highlight will take as much time as necessary to move at the set speed.
+
+ These properties have the same characteristics as a SmoothedAnimation.
\sa highlightFollowsCurrentItem
*/
+qreal QQuickListView::highlightMoveSpeed() const
+{
+ Q_D(const QQuickListView);
+ return d->highlightMoveSpeed;
+}
+
+void QQuickListView::setHighlightMoveSpeed(qreal speed)
+{
+ Q_D(QQuickListView);
+ if (d->highlightMoveSpeed != speed) {
+ d->highlightMoveSpeed = speed;
+ if (d->highlightPosAnimator)
+ d->highlightPosAnimator->velocity = d->highlightMoveSpeed;
+ emit highlightMoveSpeedChanged();
+ }
+}
+
void QQuickListView::setHighlightMoveDuration(int duration)
{
Q_D(QQuickListView);
@@ -2214,6 +2239,23 @@ void QQuickListView::setHighlightMoveDuration(int duration)
}
}
+qreal QQuickListView::highlightResizeSpeed() const
+{
+ Q_D(const QQuickListView);
+ return d->highlightResizeSpeed;
+}
+
+void QQuickListView::setHighlightResizeSpeed(qreal speed)
+{
+ Q_D(QQuickListView);
+ if (d->highlightResizeSpeed != speed) {
+ d->highlightResizeSpeed = speed;
+ if (d->highlightSizeAnimator)
+ d->highlightSizeAnimator->velocity = d->highlightResizeSpeed;
+ emit highlightResizeSpeedChanged();
+ }
+}
+
int QQuickListView::highlightResizeDuration() const
{
Q_D(const QQuickListView);
diff --git a/src/quick/items/qquicklistview_p.h b/src/quick/items/qquicklistview_p.h
index 6bdd4cb674..acedbdcb1a 100644
--- a/src/quick/items/qquicklistview_p.h
+++ b/src/quick/items/qquicklistview_p.h
@@ -102,6 +102,10 @@ class Q_AUTOTEST_EXPORT QQuickListView : public QQuickItemView
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickListView)
+ // XXX deprecate these two properties (only duration should be necessary)
+ Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged)
+ Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged)
+
Q_PROPERTY(int highlightResizeDuration READ highlightResizeDuration WRITE setHighlightResizeDuration NOTIFY highlightResizeDurationChanged)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged)
@@ -132,6 +136,12 @@ public:
virtual void setHighlightFollowsCurrentItem(bool);
+ qreal highlightMoveSpeed() const;
+ void setHighlightMoveSpeed(qreal);
+
+ qreal highlightResizeSpeed() const;
+ void setHighlightResizeSpeed(qreal);
+
int highlightResizeDuration() const;
void setHighlightResizeDuration(int);
@@ -151,6 +161,8 @@ Q_SIGNALS:
void spacingChanged();
void orientationChanged();
void currentSectionChanged();
+ void highlightMoveSpeedChanged();
+ void highlightResizeSpeedChanged();
void highlightResizeDurationChanged();
void snapModeChanged();
diff --git a/tests/auto/quick/qquicklistview/data/displaylist.qml b/tests/auto/quick/qquicklistview/data/displaylist.qml
index 6ac56f8630..4e8fd32f6a 100644
--- a/tests/auto/quick/qquicklistview/data/displaylist.qml
+++ b/tests/auto/quick/qquicklistview/data/displaylist.qml
@@ -44,5 +44,7 @@ Rectangle {
model: testModel
delegate: myDelegate
highlight: myHighlight
+ highlightMoveSpeed: 1000
+ highlightResizeSpeed: 1000
}
}
diff --git a/tests/auto/quick/qquicklistview/data/flickBeyondBoundsBug.qml b/tests/auto/quick/qquicklistview/data/flickBeyondBoundsBug.qml
index 17f787c595..0a1b1a1b64 100644
--- a/tests/auto/quick/qquicklistview/data/flickBeyondBoundsBug.qml
+++ b/tests/auto/quick/qquicklistview/data/flickBeyondBoundsBug.qml
@@ -35,6 +35,8 @@ Rectangle {
height: 320
model: 2
delegate: myDelegate
+ highlightMoveSpeed: 1000
+ highlightResizeSpeed: 1000
cacheBuffer: 400
}
Text { anchors.bottom: parent.bottom; text: list.contentY }
diff --git a/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
index 1f6cccddca..c4f1860eda 100644
--- a/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
@@ -56,6 +56,7 @@ Rectangle {
height: 320
keyNavigationWraps: testWrap
delegate: myDelegate
+ highlightMoveSpeed: 1000
model: testModel
header: root.showHeader ? headerFooter : null
footer: root.showFooter ? headerFooter : null
diff --git a/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
index 9aac5064fa..cb9030090e 100644
--- a/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-noCurrent.qml
@@ -45,6 +45,7 @@ Rectangle {
height: 320
cacheBuffer: 0
delegate: myDelegate
+ highlightMoveSpeed: 1000
model: testModel
}
}
diff --git a/tests/auto/quick/qquicklistview/data/listviewtest-package.qml b/tests/auto/quick/qquicklistview/data/listviewtest-package.qml
index 87179d51e1..54d4dabc86 100644
--- a/tests/auto/quick/qquicklistview/data/listviewtest-package.qml
+++ b/tests/auto/quick/qquicklistview/data/listviewtest-package.qml
@@ -136,6 +136,8 @@ Rectangle {
height: 320
model: visualModel.parts.package
highlight: testObject.invalidHighlight ? invalidHl : myHighlight
+ highlightMoveSpeed: 1000
+ highlightResizeSpeed: 1000
cacheBuffer: testObject.cacheBuffer
header: root.showHeader ? headerFooter : null
footer: root.showFooter ? headerFooter : null
diff --git a/tests/auto/quick/qquicklistview/data/listviewtest.qml b/tests/auto/quick/qquicklistview/data/listviewtest.qml
index 29f9b92cb2..47b341c1fc 100644
--- a/tests/auto/quick/qquicklistview/data/listviewtest.qml
+++ b/tests/auto/quick/qquicklistview/data/listviewtest.qml
@@ -124,6 +124,8 @@ Rectangle {
model: testModel
delegate: testObject.animate ? animatedDelegate : myDelegate
highlight: testObject.invalidHighlight ? invalidHl : myHighlight
+ highlightMoveSpeed: 1000
+ highlightResizeSpeed: 1000
cacheBuffer: testObject.cacheBuffer
header: root.showHeader ? headerFooter : null
footer: root.showFooter ? headerFooter : null
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 5233b3de9b..f177263b01 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -407,6 +407,9 @@ void tst_QQuickListView::items(const QUrl &source, bool forceLayout)
int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count();
QTRY_VERIFY(itemCount == 0);
+ QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0);
+ QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0);
+
delete canvas;
delete testObject;
}