diff options
Diffstat (limited to 'tests/auto/quick/qquicklistview2/data')
24 files changed, 417 insertions, 11 deletions
diff --git a/tests/auto/quick/qquicklistview2/data/areaZeroView.qml b/tests/auto/quick/qquicklistview2/data/areaZeroView.qml new file mode 100644 index 0000000000..e0329f4e83 --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/areaZeroView.qml @@ -0,0 +1,22 @@ +import QtQuick + +Window { + width: 600 + height: 600 + visible: true + property int delegateCreationCounter: 0 + + ListView { + id: lv + anchors.fill: parent + model: 6000 + + delegate: Rectangle { + width: ListView.view.width + height: ListView.view.width / 6 + color: "white" + border.width: 1 + Component.onCompleted: ++delegateCreationCounter + } + } +} diff --git a/tests/auto/quick/qquicklistview2/data/bindOnHeaderAndFooterXPosition.qml b/tests/auto/quick/qquicklistview2/data/bindOnHeaderAndFooterXPosition.qml new file mode 100644 index 0000000000..69431fb525 --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/bindOnHeaderAndFooterXPosition.qml @@ -0,0 +1,29 @@ +import QtQuick + +ListView { + width: 200 + height: 300 + spacing: 20 + orientation: ListView.Vertical + + header: Rectangle { + x: (ListView.view.width - width) / 2 + color: 'tomato' + width: 50 + height: 50 + } + + footer: Rectangle { + x: (ListView.view.width - width) / 2 + color: 'lime' + width: 50 + height: 50 + } + + model: 3 + delegate: Text { + text: 'Foobar' + horizontalAlignment: Text.AlignHCenter + width: ListView.view.width + } +} diff --git a/tests/auto/quick/qquicklistview2/data/bindOnHeaderAndFooterYPosition.qml b/tests/auto/quick/qquicklistview2/data/bindOnHeaderAndFooterYPosition.qml new file mode 100644 index 0000000000..a484a154a7 --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/bindOnHeaderAndFooterYPosition.qml @@ -0,0 +1,29 @@ +import QtQuick + +ListView { + width: 300 + height: 200 + spacing: 20 + orientation: ListView.Horizontal + + header: Rectangle { + y: (ListView.view.height - height) / 2 + color: 'tomato' + width: 50 + height: 50 + } + + footer: Rectangle { + y: (ListView.view.height - height) / 2 + color: 'lime' + width: 50 + height: 50 + } + + model: 3 + delegate: Text { + text: 'Foobar' + verticalAlignment: Text.AlignVCenter + height: ListView.view.height + } +} diff --git a/tests/auto/quick/qquicklistview2/data/boundDelegateComponent.qml b/tests/auto/quick/qquicklistview2/data/boundDelegateComponent.qml index 6fb84279b0..5e4de1a08d 100644 --- a/tests/auto/quick/qquicklistview2/data/boundDelegateComponent.qml +++ b/tests/auto/quick/qquicklistview2/data/boundDelegateComponent.qml @@ -6,6 +6,8 @@ Item { objectName: "outer" ListView { id: listView + width: 100 + height: 100 model: 1 property string foo: "foo" delegate: Text { @@ -16,6 +18,8 @@ Item { ListView { id: listView2 + width: 100 + height: 100 model: 1 delegate: Text { required property int index @@ -49,6 +53,8 @@ Item { } ListView { + width: 100 + height: 100 id: innerListView model: listModel delegate: innerComponent diff --git a/tests/auto/quick/qquicklistview2/data/changingOrientationWithListModel.qml b/tests/auto/quick/qquicklistview2/data/changingOrientationWithListModel.qml new file mode 100644 index 0000000000..366b20b029 --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/changingOrientationWithListModel.qml @@ -0,0 +1,47 @@ +import QtQuick + +ListView { + id: root + + function allDelegates(valueSelector) { + let sum = 0; + for (let i = 0; i < root.count; i++) + sum += valueSelector(root.itemAtIndex(i)); + return sum; + } + + readonly property bool isXReset: allDelegates(function(item) { return item?.x ?? 0; }) === 0 + readonly property bool isYReset: allDelegates(function(item) { return item?.y ?? 0; }) === 0 + + width: 500 + height: 500 + delegate: Rectangle { + width: root.width + height: root.height + color: c + } + model: ListModel { + ListElement { + c: "red" + } + ListElement { + c: "green" + } + ListElement { + c: "blue" + } + ListElement { + c: "cyan" + } + ListElement { + c: "magenta" + } + ListElement { + c: "teal" + } + } + clip: true + orientation: ListView.Vertical + snapMode: ListView.SnapOneItem + highlightRangeMode: ListView.StrictlyEnforceRange +}
\ No newline at end of file diff --git a/tests/auto/quick/qquicklistview2/data/changingOrientationWithObjectModel.qml b/tests/auto/quick/qquicklistview2/data/changingOrientationWithObjectModel.qml new file mode 100644 index 0000000000..1d165a496e --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/changingOrientationWithObjectModel.qml @@ -0,0 +1,54 @@ +import QtQuick + +ListView { + id: root + + readonly property bool isXReset: red.x === 0 && green.x === 0 && blue.x === 0 && cyan.x === 0 && magenta.x === 0 && teal.x === 0 + + readonly property bool isYReset: red.y === 0 && green.y === 0 && blue.y === 0 && cyan.y === 0 && magenta.y === 0 && teal.y === 0 + + width: 500 + height: 500 + model: ObjectModel { + Rectangle { + id: red + width: root.width + height: root.height + color: "red" + } + Rectangle { + id: green + width: root.width + height: root.height + color: "green" + } + Rectangle { + id: blue + width: root.width + height: root.height + color: "blue" + } + Rectangle { + id: cyan + width: root.width + height: root.height + color: "cyan" + } + Rectangle { + id: magenta + width: root.width + height: root.height + color: "magenta" + } + Rectangle { + id: teal + width: root.width + height: root.height + color: "teal" + } + } + clip: true + orientation: ListView.Vertical + snapMode: ListView.SnapOneItem + highlightRangeMode: ListView.StrictlyEnforceRange +}
\ No newline at end of file diff --git a/tests/auto/quick/qquicklistview2/data/delegateChooserEnumRole.qml b/tests/auto/quick/qquicklistview2/data/delegateChooserEnumRole.qml index 655900d9de..66e92c5616 100644 --- a/tests/auto/quick/qquicklistview2/data/delegateChooserEnumRole.qml +++ b/tests/auto/quick/qquicklistview2/data/delegateChooserEnumRole.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import Qt.labs.qmlmodels diff --git a/tests/auto/quick/qquicklistview2/data/delegateContextHandling.qml b/tests/auto/quick/qquicklistview2/data/delegateContextHandling.qml new file mode 100644 index 0000000000..4c513df905 --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/delegateContextHandling.qml @@ -0,0 +1,75 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import QtQuick.Window + +Item { + id: win + height: 640 + width: 480 + + property string currentModel: 'foo' + + function toggle() : Item { + var ret = listView.itemAtIndex(0); + win.currentModel = win.currentModel === 'foo' ? 'bar' : 'foo' + + switch (win.currentModel) { + case 'foo': + if (listView.model) { + listView.model.destroy() + } + listView.model = fooModelComponent.createObject(win) + break + + case 'bar': + if (listView.model) { + listView.model.destroy() + } + listView.model = barModelComponent.createObject(win) + break + } + + return ret; + } + + Component { + id: fooModelComponent + ListModel { + ListElement { textValue: "foo1" } + } + } + + Component { + id: barModelComponent + ListModel { + ListElement { textValue: "bar1" } + } + } + + ListView { + states: [ + State { + when: win.currentModel === 'bar' + PropertyChanges { + listView.section.property: 'sectionProp' + } + } + ] + + id: listView + model: fooModelComponent.createObject(win) + anchors.fill: parent + + section.delegate: Text { + required property string section + text: section + } + + delegate: Text { + id: delg + text: delg.textValue + required property string textValue + } + } +} diff --git a/tests/auto/quick/qquicklistview2/data/delegateModelRefresh.qml b/tests/auto/quick/qquicklistview2/data/delegateModelRefresh.qml index 7a2a017515..7a22f1a0f4 100644 --- a/tests/auto/quick/qquicklistview2/data/delegateModelRefresh.qml +++ b/tests/auto/quick/qquicklistview2/data/delegateModelRefresh.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import QtQuick.Controls diff --git a/tests/auto/quick/qquicklistview2/data/delegateWithMouseArea.qml b/tests/auto/quick/qquicklistview2/data/delegateWithMouseArea.qml index c94001eb43..f447f913e6 100644 --- a/tests/auto/quick/qquicklistview2/data/delegateWithMouseArea.qml +++ b/tests/auto/quick/qquicklistview2/data/delegateWithMouseArea.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/quick/qquicklistview2/data/fetchMore.qml b/tests/auto/quick/qquicklistview2/data/fetchMore.qml new file mode 100644 index 0000000000..4ce53e4d28 --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/fetchMore.qml @@ -0,0 +1,21 @@ +import QtQuick +import org.qtproject.Test + +ListView { + id: listView + width: 300 + height: 150 + flickDeceleration: 10000 + + model: FetchMoreModel + delegate: Text { + height: 50 + text: model.display + } + + Text { + anchors.right: parent.right + text: "count " + listView.count + color: listView.moving ? "red" : "blue" + } +} diff --git a/tests/auto/quick/qquicklistview2/data/footerUpdate.qml b/tests/auto/quick/qquicklistview2/data/footerUpdate.qml index 058b7a6276..c5729ad633 100644 --- a/tests/auto/quick/qquicklistview2/data/footerUpdate.qml +++ b/tests/auto/quick/qquicklistview2/data/footerUpdate.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/quick/qquicklistview2/data/innerRequired.qml b/tests/auto/quick/qquicklistview2/data/innerRequired.qml index b45181c0d2..c0862cec0d 100644 --- a/tests/auto/quick/qquicklistview2/data/innerRequired.qml +++ b/tests/auto/quick/qquicklistview2/data/innerRequired.qml @@ -25,6 +25,8 @@ Item { ListView { id: listView model: myModel + width: 100 + height: 100 delegate: AnotherDelegate { age: model.age text: model.noise diff --git a/tests/auto/quick/qquicklistview2/data/maxXExtent.qml b/tests/auto/quick/qquicklistview2/data/maxXExtent.qml index b9e88cfc9e..d72f825654 100644 --- a/tests/auto/quick/qquicklistview2/data/maxXExtent.qml +++ b/tests/auto/quick/qquicklistview2/data/maxXExtent.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/quick/qquicklistview2/data/maxYExtent.qml b/tests/auto/quick/qquicklistview2/data/maxYExtent.qml index 3be8948691..b8a1f0e12b 100644 --- a/tests/auto/quick/qquicklistview2/data/maxYExtent.qml +++ b/tests/auto/quick/qquicklistview2/data/maxYExtent.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/quick/qquicklistview2/data/metaSequenceAsModel.qml b/tests/auto/quick/qquicklistview2/data/metaSequenceAsModel.qml index 2b4651feaa..461450239f 100644 --- a/tests/auto/quick/qquicklistview2/data/metaSequenceAsModel.qml +++ b/tests/auto/quick/qquicklistview2/data/metaSequenceAsModel.qml @@ -2,6 +2,8 @@ import QtQuick ListView { id: view + width: 100 + height: 100 property list<rect> rects: [ Qt.rect(1, 2, 3, 4), Qt.rect(5, 6, 7, 8) ] property list<string> texts diff --git a/tests/auto/quick/qquicklistview2/data/qtbug86744.qml b/tests/auto/quick/qquicklistview2/data/qtbug86744.qml index c69a4f7ec6..d8b89a147d 100644 --- a/tests/auto/quick/qquicklistview2/data/qtbug86744.qml +++ b/tests/auto/quick/qquicklistview2/data/qtbug86744.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import QtQml.Models diff --git a/tests/auto/quick/qquicklistview2/data/qtbug98315.qml b/tests/auto/quick/qquicklistview2/data/qtbug98315.qml index bf2ed857b1..4035915c6d 100644 --- a/tests/auto/quick/qquicklistview2/data/qtbug98315.qml +++ b/tests/auto/quick/qquicklistview2/data/qtbug98315.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import QtQml.Models diff --git a/tests/auto/quick/qquicklistview2/data/qtbug_92809.qml b/tests/auto/quick/qquicklistview2/data/qtbug_92809.qml index a003b51335..7507e83f73 100644 --- a/tests/auto/quick/qquicklistview2/data/qtbug_92809.qml +++ b/tests/auto/quick/qquicklistview2/data/qtbug_92809.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/quick/qquicklistview2/data/sectionBoundComponent.qml b/tests/auto/quick/qquicklistview2/data/sectionBoundComponent.qml new file mode 100644 index 0000000000..74ab6b59fa --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/sectionBoundComponent.qml @@ -0,0 +1,14 @@ +pragma ComponentBehavior: Bound +import QtQuick +ListView { + id: view + width: 100 + height: 100 + model: ListModel { + ListElement { name: "foo"; age: 42 } + ListElement { name: "bar"; age: 13 } + } + delegate: Text { required property string name; text: name} + section.property: "age" + section.delegate: Rectangle { color: "gray"; width: view.width; height: 20; required property string section; Text {text: parent.section} } +} diff --git a/tests/auto/quick/qquicklistview2/data/sectionGeometryChange.qml b/tests/auto/quick/qquicklistview2/data/sectionGeometryChange.qml new file mode 100644 index 0000000000..6981af51ec --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/sectionGeometryChange.qml @@ -0,0 +1,58 @@ +import QtQuick +import QtQuick.Controls + +Rectangle { + width: 640 + height: 480 + color: "#FFFFFF" + ListView { + objectName: "list" + anchors.fill: parent + + delegate: Rectangle { + objectName: value + implicitHeight: text.implicitHeight + color: "#ff3" + + Text { + id: text + width: parent.width + padding: 5 + font.pixelSize: 20 + text: value + } + } + + section { + property: "section" + + delegate: Rectangle { + objectName: section + width: parent.width + implicitHeight: text.implicitHeight + color: "#3ff" + + Text { + id: text + width: parent.width + padding: 5 + font.pixelSize: 20 + text: section + wrapMode: Text.Wrap + } + } + } + + model: ListModel { + ListElement { value: "Element1"; section: "Section1" } + ListElement { value: "Element2"; section: "Section1" } + ListElement { value: "Element3"; section: "Section1" } + ListElement { value: "Element4"; section: "Section2" } + ListElement { value: "Element5"; section: "Section2" } + ListElement { value: "Element6"; section: "Section2" } + ListElement { value: "Element7"; section: "Section2" } + ListElement { value: "Element8"; section: "Section3" } + ListElement { value: "Element9"; section: "Section3" } + } + } +} diff --git a/tests/auto/quick/qquicklistview2/data/sectionsNoOverlap.qml b/tests/auto/quick/qquicklistview2/data/sectionsNoOverlap.qml index d931bbb77c..3a22626032 100644 --- a/tests/auto/quick/qquicklistview2/data/sectionsNoOverlap.qml +++ b/tests/auto/quick/qquicklistview2/data/sectionsNoOverlap.qml @@ -1,5 +1,5 @@ // Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick import QtQuick.Controls diff --git a/tests/auto/quick/qquicklistview2/data/urlListModel.qml b/tests/auto/quick/qquicklistview2/data/urlListModel.qml index 94d5c37a56..38237234e0 100644 --- a/tests/auto/quick/qquicklistview2/data/urlListModel.qml +++ b/tests/auto/quick/qquicklistview2/data/urlListModel.qml @@ -1,5 +1,5 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only import QtQuick diff --git a/tests/auto/quick/qquicklistview2/data/viewportAvoidUndesiredMovementOnSetCurrentIndex.qml b/tests/auto/quick/qquicklistview2/data/viewportAvoidUndesiredMovementOnSetCurrentIndex.qml new file mode 100644 index 0000000000..cd3865d55b --- /dev/null +++ b/tests/auto/quick/qquicklistview2/data/viewportAvoidUndesiredMovementOnSetCurrentIndex.qml @@ -0,0 +1,47 @@ +import QtQuick + +Item { + id: root + width: 400 + height: 600 + + ListView { + id: rawList + objectName: "list" + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + height: 300 + + // full disabling of automatic viewport positioning + highlightFollowsCurrentItem: false + snapMode: ListView.NoSnap + highlightRangeMode: ListView.NoHighlightRange + + delegate: Rectangle { + color: model.index === rawList.currentIndex ? "red" : "white" + border.color: rawList.currentItem === this ? "red" : "black" + height: 100 + width: 400 + + Text { + anchors.centerIn: parent + text: model.index + font.pixelSize: 50 + } + + MouseArea { + // only for using this file to do manual testing + // autotest calls setCurrentIndex + anchors.fill: parent + + onClicked: { + rawList.currentIndex = model.index; + } + } + } + + model: 30 + } + +} |