aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-01-18 22:53:16 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2022-02-08 08:50:18 +0100
commitedb18d6101e8bb9dd265330dbe019722181d7577 (patch)
treed5539b2921aa93a2c76da12778d314cec7bfa30b
parent51e3aee67a1bb31ee1ab54fd5dadb2de30764be9 (diff)
SwipeView: don't cull every child item that gets added
This reverts commit a055629f43cf8589ff6d69e46b2610429aaa4167. A SwipeView is a ListView, which means as long as the side-by-side delegates are the right size, only one of them should occupy the area of the SwipeView itself. The other delegates (isCurrentItem == false) are to the sides, and might be outside the window, hidden under other items, or clipped. So hopefully there are not users who rely on this culling to hide them. Fixes: QTBUG-99547 Task-number: QTBUG-51078 Task-number: QTBUG-51669 Change-Id: Ic90dc1c44b9a36dc717238b47003b4d88e91f789 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit e10de033f4c44855de7287a97e2aa651f648742e) Reviewed-by: Seokha Ko <seokha.ko@qt.io>
-rw-r--r--src/quicktemplates2/qquickswipeview.cpp1
-rw-r--r--tests/auto/controls/data/tst_swipeview.qml63
2 files changed, 63 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp
index 9c7b0c86..28c5e201 100644
--- a/src/quicktemplates2/qquickswipeview.cpp
+++ b/src/quicktemplates2/qquickswipeview.cpp
@@ -310,7 +310,6 @@ void QQuickSwipeView::geometryChanged(const QRectF &newGeometry, const QRectF &o
void QQuickSwipeView::itemAdded(int index, QQuickItem *item)
{
Q_D(QQuickSwipeView);
- QQuickItemPrivate::get(item)->setCulled(true); // QTBUG-51078, QTBUG-51669
if (isComponentComplete())
item->setSize(QSizeF(d->contentItem->width(), d->contentItem->height()));
QQuickSwipeViewAttached *attached = qobject_cast<QQuickSwipeViewAttached *>(qmlAttachedPropertiesObject<QQuickSwipeView>(item));
diff --git a/tests/auto/controls/data/tst_swipeview.qml b/tests/auto/controls/data/tst_swipeview.qml
index 5775491c..07d0cc0c 100644
--- a/tests/auto/controls/data/tst_swipeview.qml
+++ b/tests/auto/controls/data/tst_swipeview.qml
@@ -623,4 +623,67 @@ TestCase {
compare(control.rectanglePressCount, 1)
compare(control.rectangleReleaseCount, 1)
}
+
+ // We have a particular customer who came up with this hack to make SwipeView wrap around at the end.
+ // It's not advisible, and perhaps the test can be removed when we add a bool wrap property.
+ Component {
+ id: pathViewWorkaroundComponent
+
+ SwipeView {
+ id: swipeView
+ anchors.left: parent.left
+ width: 100
+ height: 100
+ clip: true
+ Repeater {
+ id: repeater
+ objectName: "peter"
+ delegate: Rectangle {
+ id: rect
+ color: "#ffff00"
+ border.color: "black"
+ width: 100
+ height: 100
+ Text {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.horizontalCenter: parent.horizontalCenter
+ font.pixelSize: 24
+ text: model.index
+ }
+ }
+ }
+ contentItem: PathView {
+ id: pathview
+
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ model: swipeView.contentModel
+
+ path: Path {
+ id: path
+ startX: (swipeView.width / 2 * -1) * (swipeView.count - 1)
+ startY: swipeView.height / 2
+ PathLine {
+ relativeX: swipeView.width * swipeView.count
+ relativeY: 0
+ }
+ }
+ }
+ }
+ }
+
+ function test_child_pathview() {
+ const control = createTemporaryObject(pathViewWorkaroundComponent, testCase)
+ verify(control)
+ const repeater = control.children[0].children[0]
+ const spy = signalSpy.createObject(repeater, {target: repeater, signalName: "itemAdded"})
+ repeater.model = 1
+ tryCompare(spy, "count", 1)
+ const rect = repeater.itemAt(0)
+ tryCompare(rect, "visible", true)
+ if (Qt.platform.pluginName === "offscreen")
+ skip("grabImage() is not functional on the offscreen platform (QTBUG-63185)")
+ var image = grabImage(control)
+ compare(image.pixel(3, 3), "#ffff00")
+ }
}