aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-04-28 20:40:22 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-04-29 12:45:12 +0000
commit3980354daa4d8dfa8ec07ed2c2265ebb137b6f36 (patch)
tree88d64fe36e91c0242767e1bb5b28f984f8a63882
parent8d340d7f3f28364d6b2b8fad2d4828ae761a2dad (diff)
Revert Tumbler::displacement to position changes
This reverts commits 150d8fcc7f97e4a5d56bdcf608fa22533d807677 and 0905066bcbb967d3344d399383d0ea4b30e1d489 that broke Tumbler. The normalized position calculation did not work in some corner cases (eg. when the total amount of model items is just 2). Therefore, just go back to "displacement"; and if we ever get this working correctly, we can call it position and deprecate displacement. Task-number: QTBUG-53061 Change-Id: Ic721f8a96c250dd5d40f881ff991fae687311996 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r--src/imports/controls/Tumbler.qml2
-rw-r--r--src/imports/controls/doc/images/qtquickcontrols2-tumbler-position.pngbin5150 -> 0 bytes
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-position.qml44
-rw-r--r--src/imports/controls/material/Tumbler.qml2
-rw-r--r--src/imports/controls/universal/Tumbler.qml2
-rw-r--r--src/imports/templates/plugins.qmltypes2
-rw-r--r--src/quicktemplates2/qquicktumbler.cpp90
-rw-r--r--src/quicktemplates2/qquicktumbler_p.h8
-rw-r--r--tests/auto/controls/data/tst_tumbler.qml138
-rw-r--r--tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml4
10 files changed, 120 insertions, 172 deletions
diff --git a/src/imports/controls/Tumbler.qml b/src/imports/controls/Tumbler.qml
index 782933ae..785708c9 100644
--- a/src/imports/controls/Tumbler.qml
+++ b/src/imports/controls/Tumbler.qml
@@ -49,7 +49,7 @@ T.Tumbler {
text: modelData
color: control.enabled ? (control.visualFocus ? "#0066ff" : "#26282a") : "#c2c2c2"
font: control.font
- opacity: 1 - Math.abs(Tumbler.position * 0.8) * (control.enabled ? 1.0 : 0.4)
+ opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
diff --git a/src/imports/controls/doc/images/qtquickcontrols2-tumbler-position.png b/src/imports/controls/doc/images/qtquickcontrols2-tumbler-position.png
deleted file mode 100644
index 437459a8..00000000
--- a/src/imports/controls/doc/images/qtquickcontrols2-tumbler-position.png
+++ /dev/null
Binary files differ
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-position.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-position.qml
deleted file mode 100644
index 65263110..00000000
--- a/src/imports/controls/doc/snippets/qtquickcontrols2-tumbler-position.qml
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-import QtQuick 2.0
-import QtQuick.Controls 2.0
-
-Frame {
- Tumbler {
- model: 6
- visibleItemCount: 5
- delegate: Label {
- text: qsTr("%1 (%2)").arg(index).arg(Tumbler.position.toFixed(1))
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- //! [1]
- opacity: 1 - Math.abs(Tumbler.position * 0.8)
- //! [1]
- }
- }
-}
diff --git a/src/imports/controls/material/Tumbler.qml b/src/imports/controls/material/Tumbler.qml
index f2b934fa..8ac8a7c4 100644
--- a/src/imports/controls/material/Tumbler.qml
+++ b/src/imports/controls/material/Tumbler.qml
@@ -50,7 +50,7 @@ T.Tumbler {
text: modelData
color: control.Material.primaryTextColor
font: control.font
- opacity: 1 - Math.abs(Tumbler.position * 0.8) * (control.enabled ? 1.0 : 0.4)
+ opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
diff --git a/src/imports/controls/universal/Tumbler.qml b/src/imports/controls/universal/Tumbler.qml
index 109ed186..5998a6aa 100644
--- a/src/imports/controls/universal/Tumbler.qml
+++ b/src/imports/controls/universal/Tumbler.qml
@@ -50,7 +50,7 @@ T.Tumbler {
text: modelData
font: control.font
color: control.Universal.foreground
- opacity: 1 - Math.abs(Tumbler.position * 0.8) * (control.enabled ? 1.0 : 0.4)
+ opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * (control.enabled ? 0.6 : 0.2)
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
diff --git a/src/imports/templates/plugins.qmltypes b/src/imports/templates/plugins.qmltypes
index db18f740..f9ef4c61 100644
--- a/src/imports/templates/plugins.qmltypes
+++ b/src/imports/templates/plugins.qmltypes
@@ -1737,6 +1737,6 @@ Module {
name: "QQuickTumblerAttached"
prototype: "QObject"
Property { name: "tumbler"; type: "QQuickTumbler"; isReadonly: true; isPointer: true }
- Property { name: "position"; type: "double"; isReadonly: true }
+ Property { name: "displacement"; type: "double"; isReadonly: true }
}
}
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp
index 2e4d58d0..546e699c 100644
--- a/src/quicktemplates2/qquicktumbler.cpp
+++ b/src/quicktemplates2/qquicktumbler.cpp
@@ -403,7 +403,7 @@ public:
QQuickTumblerAttachedPrivate(QQuickItem *delegateItem) :
tumbler(nullptr),
index(-1),
- position(1)
+ displacement(1)
{
if (!delegateItem->parentItem()) {
qWarning() << "Tumbler: attached properties must be accessed from within a delegate item that has a parent";
@@ -434,29 +434,29 @@ public:
void itemChildAdded(QQuickItem *, QQuickItem *) override;
void itemChildRemoved(QQuickItem *, QQuickItem *) override;
- void _q_calculatePosition();
+ void _q_calculateDisplacement();
- // The Tumbler that contains the delegate. Required to calculated the position.
+ // The Tumbler that contains the delegate. Required to calculated the displacement.
QQuickTumbler *tumbler;
- // The index of the delegate. Used to calculate the position.
+ // The index of the delegate. Used to calculate the displacement.
int index;
- // The position for our delegate.
- qreal position;
+ // The displacement for our delegate.
+ qreal displacement;
};
void QQuickTumblerAttachedPrivate::itemGeometryChanged(QQuickItem *, const QRectF &, const QRectF &)
{
- _q_calculatePosition();
+ _q_calculateDisplacement();
}
void QQuickTumblerAttachedPrivate::itemChildAdded(QQuickItem *, QQuickItem *)
{
- _q_calculatePosition();
+ _q_calculateDisplacement();
}
void QQuickTumblerAttachedPrivate::itemChildRemoved(QQuickItem *item, QQuickItem *child)
{
- _q_calculatePosition();
+ _q_calculateDisplacement();
if (parent == child) {
// The child that was removed from the contentItem was the delegate
@@ -470,10 +470,10 @@ void QQuickTumblerAttachedPrivate::itemChildRemoved(QQuickItem *item, QQuickItem
}
}
-void QQuickTumblerAttachedPrivate::_q_calculatePosition()
+void QQuickTumblerAttachedPrivate::_q_calculateDisplacement()
{
- const int previousPosition = position;
- position = 0;
+ const int previousDisplacement = displacement;
+ displacement = 0;
const int count = tumbler->count();
// This can happen in tests, so it may happen in normal usage too.
@@ -484,30 +484,29 @@ void QQuickTumblerAttachedPrivate::_q_calculatePosition()
if (contentType == UnsupportedContentItemType)
return;
- const int halfVisibleItems = tumbler->visibleItemCount() / 2;
+ qreal offset = 0;
if (contentType == PathViewContentItem) {
- qreal offset = tumbler->contentItem()->property("offset").toReal();
-
- position = count - index - offset;
- if (position > halfVisibleItems + 1)
- position -= count;
- else if (position < -halfVisibleItems - 1)
- position += count;
+ offset = tumbler->contentItem()->property("offset").toReal();
+
+ displacement = count - index - offset;
+ int halfVisibleItems = tumbler->visibleItemCount() / 2 + 1;
+ if (displacement > halfVisibleItems)
+ displacement -= count;
+ else if (displacement < -halfVisibleItems)
+ displacement += count;
} else {
const qreal contentY = tumbler->contentItem()->property("contentY").toReal();
const qreal delegateH = delegateHeight(tumbler);
const qreal preferredHighlightBegin = tumbler->contentItem()->property("preferredHighlightBegin").toReal();
- // Tumbler's position goes from negative at the top to positive towards the bottom, so we must switch this around.
- const qreal reversePosition = (contentY + preferredHighlightBegin) / delegateH;
- position = reversePosition - index;
+ // Tumbler's displacement goes from negative at the top to positive towards the bottom, so we must switch this around.
+ const qreal reverseDisplacement = (contentY + preferredHighlightBegin) / delegateH;
+ displacement = reverseDisplacement - index;
}
- position /= halfVisibleItems;
-
Q_Q(QQuickTumblerAttached);
- if (position != previousPosition)
- emit q->positionChanged();
+ if (displacement != previousDisplacement)
+ emit q->displacementChanged();
}
QQuickTumblerAttached::QQuickTumblerAttached(QQuickItem *delegateItem) :
@@ -522,7 +521,7 @@ QQuickTumblerAttached::QQuickTumblerAttached(QQuickItem *delegateItem) :
const char *contentItemSignal = contentType == PathViewContentItem
? SIGNAL(offsetChanged()) : SIGNAL(contentYChanged());
- connect(d->tumbler->contentItem(), contentItemSignal, this, SLOT(_q_calculatePosition()));
+ connect(d->tumbler->contentItem(), contentItemSignal, this, SLOT(_q_calculateDisplacement()));
}
}
@@ -544,34 +543,27 @@ QQuickTumbler *QQuickTumblerAttached::tumbler() const
}
/*!
- \qmlattachedproperty real QtQuick.Controls::Tumbler::position
+ \qmlattachedproperty real QtQuick.Controls::Tumbler::displacement
\readonly
- This attached property holds a value that describes the logical position
- of a delegate item.
-
- The logical position is a percentage describing how far away an item is from
- being the current item; that is, how far the item is from the vertical center
- of the tumbler. The following image presents a tumbler with five visible items
- that each print their index, and the respective logical position in parentheses:
-
- \image qtquickcontrols2-tumbler-position.png
+ This attached property holds a value from \c {-visibleItemCount / 2} to
+ \c {visibleItemCount / 2}, which represents how far away this item is from
+ being the current item, with \c 0 being completely current.
- The logical position is convenient for applying effects on delegate items.
- For example, adding the line below to a tumbler delegate makes the item 100%
- opaque when it is at the center of the tumbler, and 20% opaque when it is at
- the top or bottom of the tumbler.
+ For example, the item below will be 40% opaque when it is not the current item,
+ and transition to 100% opacity when it becomes the current item:
- \snippet qtquickcontrols2-tumbler-position.qml 1
-
- \note When the tumbler is being interacted with, the logical position can be
- outside the range \c [-1.0..1.0] when an item moves past the position of
- the first or last stationary visible item.
+ \code
+ delegate: Text {
+ text: modelData
+ opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
+ }
+ \endcode
*/
-qreal QQuickTumblerAttached::position() const
+qreal QQuickTumblerAttached::displacement() const
{
Q_D(const QQuickTumblerAttached);
- return d->position;
+ return d->displacement;
}
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquicktumbler_p.h b/src/quicktemplates2/qquicktumbler_p.h
index 19d86bf2..e28102e4 100644
--- a/src/quicktemplates2/qquicktumbler_p.h
+++ b/src/quicktemplates2/qquicktumbler_p.h
@@ -116,23 +116,23 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumblerAttached : public QObject
{
Q_OBJECT
Q_PROPERTY(QQuickTumbler *tumbler READ tumbler CONSTANT)
- Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
+ Q_PROPERTY(qreal displacement READ displacement NOTIFY displacementChanged FINAL)
public:
explicit QQuickTumblerAttached(QQuickItem *delegateItem);
~QQuickTumblerAttached();
QQuickTumbler *tumbler() const;
- qreal position() const;
+ qreal displacement() const;
Q_SIGNALS:
- void positionChanged();
+ void displacementChanged();
private:
Q_DISABLE_COPY(QQuickTumblerAttached)
Q_DECLARE_PRIVATE(QQuickTumblerAttached)
- Q_PRIVATE_SLOT(d_func(), void _q_calculatePosition())
+ Q_PRIVATE_SLOT(d_func(), void _q_calculateDisplacement())
};
QT_END_NAMESPACE
diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml
index 154fd576..ec716f32 100644
--- a/tests/auto/controls/data/tst_tumbler.qml
+++ b/tests/auto/controls/data/tst_tumbler.qml
@@ -234,55 +234,55 @@ TestCase {
tryCompare(tumbler.dayTumbler, "currentIndex", 27);
}
- function test_position_data() {
+ function test_displacement_data() {
var data = [
// At 0 offset, the first item is current.
- { index: 0, offset: 0, expectedPosition: 0 },
- { index: 1, offset: 0, expectedPosition: -1 },
- { index: 5, offset: 0, expectedPosition: 1 },
+ { index: 0, offset: 0, expectedDisplacement: 0 },
+ { index: 1, offset: 0, expectedDisplacement: -1 },
+ { index: 5, offset: 0, expectedDisplacement: 1 },
// When we start to move the first item down, the second item above it starts to become current.
- { index: 0, offset: 0.25, expectedPosition: -0.25 },
- { index: 1, offset: 0.25, expectedPosition: -1.25 },
- { index: 5, offset: 0.25, expectedPosition: 0.75 },
- { index: 0, offset: 0.5, expectedPosition: -0.5 },
- { index: 1, offset: 0.5, expectedPosition: -1.5 },
- { index: 5, offset: 0.5, expectedPosition: 0.5 },
- // By this stage, the delegate at index 1 is destroyed, so we can't test its position.
- { index: 0, offset: 0.75, expectedPosition: -0.75 },
- { index: 5, offset: 0.75, expectedPosition: 0.25 },
- { index: 0, offset: 4.75, expectedPosition: 1.25 },
- { index: 1, offset: 4.75, expectedPosition: 0.25 },
- { index: 0, offset: 4.5, expectedPosition: 1.5 },
- { index: 1, offset: 4.5, expectedPosition: 0.5 },
- { index: 0, offset: 4.25, expectedPosition: 1.75 },
- { index: 1, offset: 4.25, expectedPosition: 0.75 }
+ { index: 0, offset: 0.25, expectedDisplacement: -0.25 },
+ { index: 1, offset: 0.25, expectedDisplacement: -1.25 },
+ { index: 5, offset: 0.25, expectedDisplacement: 0.75 },
+ { index: 0, offset: 0.5, expectedDisplacement: -0.5 },
+ { index: 1, offset: 0.5, expectedDisplacement: -1.5 },
+ { index: 5, offset: 0.5, expectedDisplacement: 0.5 },
+ // By this stage, the delegate at index 1 is destroyed, so we can't test its displacement.
+ { index: 0, offset: 0.75, expectedDisplacement: -0.75 },
+ { index: 5, offset: 0.75, expectedDisplacement: 0.25 },
+ { index: 0, offset: 4.75, expectedDisplacement: 1.25 },
+ { index: 1, offset: 4.75, expectedDisplacement: 0.25 },
+ { index: 0, offset: 4.5, expectedDisplacement: 1.5 },
+ { index: 1, offset: 4.5, expectedDisplacement: 0.5 },
+ { index: 0, offset: 4.25, expectedDisplacement: 1.75 },
+ { index: 1, offset: 4.25, expectedDisplacement: 0.75 }
];
for (var i = 0; i < data.length; ++i) {
var row = data[i];
- row.tag = "delegate" + row.index + " offset=" + row.offset + " expectedPosition=" + row.expectedPosition;
+ row.tag = "delegate" + row.index + " offset=" + row.offset + " expectedDisplacement=" + row.expectedDisplacement;
}
return data;
}
- property Component positionDelegate: Text {
+ property Component displacementDelegate: Text {
objectName: "delegate" + index
text: modelData
- opacity: 0.2 + Math.max(0, 1 - Math.abs(Tumbler.position)) * 0.8
+ opacity: 0.2 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.8
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Text {
- text: parent.position.toFixed(2)
+ text: parent.displacement.toFixed(2)
anchors.right: parent.right
}
- property real position: Tumbler.position
+ property real displacement: Tumbler.displacement
}
- function test_position(data) {
+ function test_displacement(data) {
// TODO: test setting these in the opposite order (delegate after model
// doesn't seem to cause a change in delegates in PathView)
- tumbler.delegate = positionDelegate;
+ tumbler.delegate = displacementDelegate;
tumbler.model = 6;
compare(tumbler.count, 6);
@@ -290,9 +290,9 @@ TestCase {
verify(delegate);
tumbler.contentItem.offset = data.offset;
- compare(delegate.position, data.expectedPosition);
+ compare(delegate.displacement, data.expectedDisplacement);
- // test position after adding and removing items
+ // test displacement after adding and removing items
}
Component {
@@ -316,34 +316,34 @@ TestCase {
//! [contentItem]
}
- function test_positionListView_data() {
+ function test_displacementListView_data() {
var offset = defaultListViewTumblerOffset;
var data = [
// At 0 contentY, the first item is current.
- { contentY: offset, expectedPositions: [
- { index: 0, position: 0 },
- { index: 1, position: -1 },
- { index: 2, position: -2 } ]
+ { contentY: offset, expectedDisplacements: [
+ { index: 0, displacement: 0 },
+ { index: 1, displacement: -1 },
+ { index: 2, displacement: -2 } ]
},
// When we start to move the first item down, the second item above it starts to become current.
- { contentY: offset + defaultImplicitDelegateHeight * 0.25, expectedPositions: [
- { index: 0, position: 0.25 },
- { index: 1, position: -0.75 },
- { index: 2, position: -1.75 } ]
+ { contentY: offset + defaultImplicitDelegateHeight * 0.25, expectedDisplacements: [
+ { index: 0, displacement: 0.25 },
+ { index: 1, displacement: -0.75 },
+ { index: 2, displacement: -1.75 } ]
},
- { contentY: offset + defaultImplicitDelegateHeight * 0.5, expectedPositions: [
- { index: 0, position: 0.5 },
- { index: 1, position: -0.5 },
- { index: 2, position: -1.5 } ]
+ { contentY: offset + defaultImplicitDelegateHeight * 0.5, expectedDisplacements: [
+ { index: 0, displacement: 0.5 },
+ { index: 1, displacement: -0.5 },
+ { index: 2, displacement: -1.5 } ]
},
- { contentY: offset + defaultImplicitDelegateHeight * 0.75, expectedPositions: [
- { index: 0, position: 0.75 },
- { index: 1, position: -0.25 } ]
+ { contentY: offset + defaultImplicitDelegateHeight * 0.75, expectedDisplacements: [
+ { index: 0, displacement: 0.75 },
+ { index: 1, displacement: -0.25 } ]
},
- { contentY: offset + defaultImplicitDelegateHeight * 3.5, expectedPositions: [
- { index: 3, position: 0.5 },
- { index: 4, position: -0.5 } ]
+ { contentY: offset + defaultImplicitDelegateHeight * 3.5, expectedDisplacements: [
+ { index: 3, displacement: 0.5 },
+ { index: 4, displacement: -0.5 } ]
}
];
for (var i = 0; i < data.length; ++i) {
@@ -353,7 +353,7 @@ TestCase {
return data;
}
- function test_positionListView(data) {
+ function test_displacementListView(data) {
tumbler.destroy();
// Sanity check that they're aren't any children at this stage.
tryCompare(testCase.children, "length", 0);
@@ -361,7 +361,7 @@ TestCase {
tumbler = listViewTumblerComponent.createObject(testCase);
verify(tumbler);
- tumbler.delegate = positionDelegate;
+ tumbler.delegate = displacementDelegate;
tumbler.model = 5;
compare(tumbler.count, 5);
// Ensure assumptions about the tumbler used in our data() function are correct.
@@ -384,12 +384,12 @@ TestCase {
//
// Even after the last item above, QQuickFlickable wouldn't consider it a drag.
// It seems that overThreshold is set too late, and because the drag distance is quite small
- // to begin with, nothing changes (the position was always very close to 0 in the end).
+ // to begin with, nothing changes (the displacement was always very close to 0 in the end).
// Ensure that we at least cover the distance required to reach the desired contentY.
var distanceToReachContentY = data.contentY - defaultListViewTumblerOffset;
var distance = Math.abs(distanceToReachContentY) + tumbler.height / 2;
- // If distanceToReachContentY is 0, we're testing 0 position, so we don't need to do anything.
+ // If distanceToReachContentY is 0, we're testing 0 displacement, so we don't need to do anything.
if (distanceToReachContentY != 0) {
mousePress(tumbler, tumblerXCenter(), tumblerYCenter());
@@ -399,15 +399,15 @@ TestCase {
}
}
- for (var i = 0; i < data.expectedPositions.length; ++i) {
- var delegate = findChild(listViewContentItem, "delegate" + data.expectedPositions[i].index);
+ for (var i = 0; i < data.expectedDisplacements.length; ++i) {
+ var delegate = findChild(listViewContentItem, "delegate" + data.expectedDisplacements[i].index);
verify(delegate);
compare(delegate.height, defaultImplicitDelegateHeight);
// Due to the way we must perform this test, we can't expect high precision.
- var expectedPosition = data.expectedPositions[i].position;
- fuzzyCompare(delegate.position, expectedPosition, 0.1,
- "Delegate of ListView-based Tumbler at index " + data.expectedPositions[i].index
- + " has position of " + delegate.position + " when it should be " + expectedPosition);
+ var expectedDisplacement = data.expectedDisplacements[i].displacement;
+ fuzzyCompare(delegate.displacement, expectedDisplacement, 0.1,
+ "Delegate of ListView-based Tumbler at index " + data.expectedDisplacements[i].index
+ + " has displacement of " + delegate.displacement + " when it should be " + expectedDisplacement);
}
if (distanceToReachContentY != 0)
@@ -416,7 +416,7 @@ TestCase {
function test_listViewFlickAboveBounds_data() {
// Tests that flicking above the bounds when already at the top of the
- // tumbler doesn't result in an incorrect position.
+ // tumbler doesn't result in an incorrect displacement.
var data = [];
// Less than two items doesn't make sense. The default visibleItemCount
// is 3, so we test a bit more than double that.
@@ -432,7 +432,7 @@ TestCase {
tumbler = listViewTumblerComponent.createObject(testCase);
verify(tumbler);
- tumbler.delegate = positionDelegate;
+ tumbler.delegate = displacementDelegate;
tumbler.model = data.model;
mousePress(tumbler, tumblerXCenter(), tumblerYCenter());
@@ -455,10 +455,10 @@ TestCase {
var delegate = findChild(listView.contentItem, "delegate" + delegateIndex);
verify(delegate);
- verify(delegate.position <= -delegateIndex, "Delegate at index " + delegateIndex + " has a position of "
- + delegate.position + " when it should be less than or equal to " + -delegateIndex);
- verify(delegate.position > -delegateIndex - 0.1, "Delegate at index 0 has a position of "
- + delegate.position + " when it should be greater than ~ " + -delegateIndex - 0.1);
+ verify(delegate.displacement <= -delegateIndex, "Delegate at index " + delegateIndex + " has a displacement of "
+ + delegate.displacement + " when it should be less than or equal to " + -delegateIndex);
+ verify(delegate.displacement > -delegateIndex - 0.1, "Delegate at index 0 has a displacement of "
+ + delegate.displacement + " when it should be greater than ~ " + -delegateIndex - 0.1);
}
changed = true;
@@ -512,16 +512,16 @@ TestCase {
}
property Component wrongDelegateTypeComponent: QtObject {
- property real position: Tumbler.position
+ property real displacement: Tumbler.displacement
}
property Component noParentDelegateComponent: Item {
- property real position: Tumbler.position
+ property real displacement: Tumbler.displacement
}
property Component gridViewComponent: GridView {}
- property Component simplePositionDelegate: Text {
- property real position: Tumbler.position
+ property Component simpleDisplacementDelegate: Text {
+ property real displacement: Tumbler.displacement
property int index: -1
}
@@ -530,7 +530,7 @@ TestCase {
// tumbler.model = 5;
// tumbler.delegate = wrongDelegateTypeComponent;
// ignoreWarning("Attached properties of Tumbler must be accessed from within a delegate item");
-// // Cause position to be changed. The warning isn't triggered if we don't do this.
+// // Cause displacement to be changed. The warning isn't triggered if we don't do this.
// tumbler.contentItem.offset += 1;
ignoreWarning("Tumbler: attached properties must be accessed from within a delegate item that has a parent");
@@ -542,7 +542,7 @@ TestCase {
// Should not be any warnings from this, as ListView, for example, doesn't produce warnings for the same code.
var gridView = gridViewComponent.createObject(testCase);
- object = simplePositionDelegate.createObject(gridView);
+ object = simpleDisplacementDelegate.createObject(gridView);
object.destroy();
gridView.destroy();
}
diff --git a/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml b/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml
index 1cd526e4..e1139177 100644
--- a/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml
+++ b/tests/manual/gifs/data/qtquickcontrols2-tumbler-wrap.qml
@@ -63,7 +63,7 @@ Window {
Text {
text: modelData.toString().length < 2 ? "0" + modelData : modelData
color: "#666666"
- opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.position)) * 0.6
+ opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pixelSize: fontMetrics.font.pixelSize * 1.25
@@ -79,7 +79,7 @@ Window {
delegate: Text {
text: (modelData.toString().length < 2 ? "0" : "") + (modelData + 1)
color: "#666666"
- opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.position)) * 0.6
+ opacity: 0.4 + Math.max(0, 1 - Math.abs(Tumbler.displacement)) * 0.6
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font.pixelSize: fontMetrics.font.pixelSize * 1.25