aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklistview/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquicklistview/data')
-rw-r--r--tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml46
-rw-r--r--tests/auto/quick/qquicklistview/data/listview-initCurrent.qml3
-rw-r--r--tests/auto/quick/qquicklistview/data/objectmodel.qml24
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug48044.qml144
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug48870.qml24
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug50097.qml47
-rw-r--r--tests/auto/quick/qquicklistview/data/qtbug50105.qml130
-rw-r--r--tests/auto/quick/qquicklistview/data/snapOneItemCurrentIndexRemoveAnimation.qml39
-rw-r--r--tests/auto/quick/qquicklistview/data/snapOneItemResize.qml16
9 files changed, 473 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml b/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml
new file mode 100644
index 0000000000..06011519b2
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/contentHeightWithDelayRemove.qml
@@ -0,0 +1,46 @@
+import QtQuick 2.1
+
+Item {
+ width: 400
+ height: 600
+ function takeOne()
+ {
+ listView.model.remove(2)
+ }
+ function takeThree()
+ {
+ listView.model.remove(4)
+ listView.model.remove(2)
+ listView.model.remove(0)
+ }
+ function takeAll()
+ {
+ listView.model.clear()
+ }
+
+ ListView {
+ id: listView
+
+ property bool useDelayRemove
+
+ height: parent.height
+ width: 400
+ model: ListModel {
+ ListElement { name: "A" }
+ ListElement { name: "B" }
+ ListElement { name: "C" }
+ ListElement { name: "D" }
+ ListElement { name: "E" }
+ }
+ delegate: Text {
+ id: wrapper
+ height: 100
+ text: index + listView.count
+ ListView.delayRemove: listView.useDelayRemove
+ ListView.onRemove: SequentialAnimation {
+ PauseAnimation { duration: wrapper.ListView.delayRemove ? 100 : 0 }
+ PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
index a02b66b8af..8aff649a67 100644
--- a/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
+++ b/tests/auto/quick/qquicklistview/data/listview-initCurrent.qml
@@ -6,6 +6,7 @@ Rectangle {
property int current: list.currentIndex
property bool showHeader: false
property bool showFooter: false
+ property int currentItemChangedCount: 0
width: 240
height: 320
@@ -60,5 +61,7 @@ Rectangle {
model: testModel
header: root.showHeader ? headerFooter : null
footer: root.showFooter ? headerFooter : null
+
+ onCurrentItemChanged: { root.currentItemChangedCount++ }
}
}
diff --git a/tests/auto/quick/qquicklistview/data/objectmodel.qml b/tests/auto/quick/qquicklistview/data/objectmodel.qml
new file mode 100644
index 0000000000..5c23d64cd3
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/objectmodel.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.0
+import QtQml.Models 2.1
+
+ListView {
+ width: 360
+ height: 360
+ model: ObjectModel {
+ Rectangle {
+ width: 20
+ height: 20
+ color: "red"
+ }
+ Rectangle {
+ width: 20
+ height: 20
+ color: "green"
+ }
+ Rectangle {
+ width: 20
+ height: 20
+ color: "blue"
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/qtbug48044.qml b/tests/auto/quick/qquicklistview/data/qtbug48044.qml
new file mode 100644
index 0000000000..d318643c1c
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/qtbug48044.qml
@@ -0,0 +1,144 @@
+import QtQuick 2.0
+
+Item {
+ width: 200
+ height: 442
+
+ ListModel {
+ id: listModel
+ ListElement {
+ name: "h1"
+ txt: "Header 1"
+ header: true
+ collapsed: true
+ }
+ ListElement {
+ name: "h2"
+ txt: "Header 2"
+ header: true
+ collapsed: true
+ }
+ ListElement {
+ name: "h3"
+ txt: "Header 3"
+ header: true
+ collapsed: true
+ }
+
+ function indexFromName(name) {
+ for (var i = 0; i < count; i++)
+ if (get(i).name === name)
+ return i
+
+ console.warn("Did not find index for name " + name)
+ return -1
+ }
+ }
+
+ function populateModel(prefix, index, n) {
+ for (var k = 1; k <= n; k++) {
+ var name = prefix + k
+ var data = {
+ "collapsed": false,
+ "name": name,
+ "txt": name,
+ "header": false
+ }
+ listModel.insert(index + k, data)
+ }
+ }
+
+ function h2(open) {
+ var i = listModel.indexFromName("h2")
+ if (listModel.get(i).collapsed === !open)
+ return
+
+ listModel.setProperty(i, "collapsed", !open)
+
+ var n = 15
+ if (open) {
+ h3(false)
+ populateModel("c2_", listModel.indexFromName("h2"), n)
+ } else {
+ listModel.remove(i + 1, n)
+ }
+
+ }
+
+ function h3(open) {
+ var i = listModel.indexFromName("h3")
+ if (listModel.get(i).collapsed === !open)
+ return
+
+ listModel.setProperty(i, "collapsed", !open)
+
+ var n = 6
+ if (open) {
+ h2(false)
+ populateModel("c3_", listModel.indexFromName("h3"), n)
+ } else {
+ listModel.remove(i + 1, n)
+ }
+ }
+
+ ListView {
+ id: listView
+ width: parent.width
+ height: parent.height
+ cacheBuffer: 0
+ model: listModel
+
+ property bool transitionsDone: false
+ property int runningTransitions: 0
+ onRunningTransitionsChanged: {
+ if (runningTransitions === 0)
+ transitionsDone = true
+ }
+
+ displaced: Transition {
+ id: dispTrans
+ SequentialAnimation {
+ ScriptAction {
+ script: listView.runningTransitions++
+ }
+ NumberAnimation {
+ property: "y";
+ duration: 250
+ }
+ ScriptAction {
+ script: listView.runningTransitions--
+ }
+ }
+ }
+
+ delegate: Rectangle {
+ id: rect
+ color: header ? "yellow" : "cyan"
+ border.color: "black"
+ height: 50
+ width: parent.width
+
+ Text {
+ anchors.centerIn: parent
+ font.pixelSize: 20
+ text: txt
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ listView.currentIndex = index
+ var i = listModel.indexFromName("h3")
+ if (i === -1)
+ return;
+ var isCollapsed = listModel.get(i).collapsed
+ if (name === "h2")
+ h2(isCollapsed)
+ else if (name === "h3")
+ h3(isCollapsed)
+ }
+ }
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qquicklistview/data/qtbug48870.qml b/tests/auto/quick/qquicklistview/data/qtbug48870.qml
new file mode 100644
index 0000000000..217f58af48
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/qtbug48870.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.6
+
+Rectangle {
+ width: 500
+ height: 500
+ color: "blue"
+
+ ListView {
+ objectName: "list"
+ anchors.fill: parent
+ model: testModel
+
+ delegate: Rectangle {
+ height: 50
+ width: ListView.view ? ListView.view.width : height
+ color: "green"
+
+ Text {
+ anchors.centerIn: parent
+ text: "Item " + index
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/qtbug50097.qml b/tests/auto/quick/qquicklistview/data/qtbug50097.qml
new file mode 100644
index 0000000000..24d506b804
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/qtbug50097.qml
@@ -0,0 +1,47 @@
+import QtQuick 2.6
+
+ListView {
+ id: lv
+
+ // How many rows per page
+ property int pageSize: 5
+
+ // The current page number
+ property int currentPage: 1
+
+ // How large a single item is
+ property int itemSize: 100
+
+ // Arbitrary
+ property int totalPages: 5
+
+ height: itemSize * pageSize // display one full page at a time
+ width: 500 // arbitrary.
+ model: pageSize * totalPages
+ delegate: Text {
+ height: itemSize
+ text: "Item " + (index + 1) + " of " + lv.count
+ }
+
+ // contentY should be < 0 to account for header visibility
+ onContentYChanged: console.log(contentY)
+
+ headerPositioning: ListView.OverlayHeader
+ header: Rectangle {
+ height: itemSize
+ width: 500
+ z: 1000
+ visible: false
+ color: "black"
+
+ Text {
+ anchors.centerIn: parent
+ color: "red"
+ text: "List header"
+ }
+ }
+
+ onCurrentPageChanged: {
+ lv.positionViewAtIndex((currentPage - 1) * pageSize, ListView.Beginning);
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/qtbug50105.qml b/tests/auto/quick/qquicklistview/data/qtbug50105.qml
new file mode 100644
index 0000000000..a48a881a21
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/qtbug50105.qml
@@ -0,0 +1,130 @@
+import QtQuick 2.4
+import QtQuick.Window 2.2
+
+Window {
+ id : mainWindow
+ visible: true
+ width: 800
+ height: 480
+
+ property real gridListWidth : (width * 0.60)
+ property real gridListHeight : (height * 0.50)
+
+ property real gridCellSpacing : (height * 0.004)
+ property real gridCellHeight : (height * 0.039)
+ property real gridCellWidth : (width * 0.20)
+
+ Rectangle {
+ id : rectBackground
+ anchors.fill: parent
+ color : "white"
+
+ ListView {
+ id : ls
+ width: mainWindow.gridListWidth
+ height: mainWindow.gridListHeight
+ clip : true
+ headerPositioning: ListView.OverlayHeader
+ spacing : mainWindow.gridCellSpacing
+
+ model: ListModel {
+ ListElement {
+ name: "Bill Smith"
+ number: "555 3264"
+ hairColor: "red"
+ }
+ ListElement {
+ name: "John Brown"
+ number: "484 7789"
+ hairColor: "blue"
+ }
+ ListElement {
+ name: "Sam Wise"
+ number: "284 1547"
+ hairColor: "yellow"
+ }
+ }
+
+ header : Row {
+ spacing : mainWindow.gridCellSpacing
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "blue"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: "Name"
+ }
+ }
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "blue"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: "Number"
+ }
+
+ }
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "blue"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: "Hair Color"
+ }
+ }
+ }
+
+ delegate: Row {
+ spacing : mainWindow.gridCellSpacing
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "red"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: name
+ }
+ }
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "red"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: number
+ }
+ }
+
+ Rectangle {
+ width : mainWindow.gridCellWidth
+ height : mainWindow.gridCellHeight
+ color : "red"
+
+ Text {
+ anchors.centerIn: parent
+ color : "white"
+ text: hairColor
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemCurrentIndexRemoveAnimation.qml b/tests/auto/quick/qquicklistview/data/snapOneItemCurrentIndexRemoveAnimation.qml
new file mode 100644
index 0000000000..215467f0cc
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/snapOneItemCurrentIndexRemoveAnimation.qml
@@ -0,0 +1,39 @@
+import QtQuick 2.4
+
+ListView {
+ id: root
+ height: 400
+ width: height
+ model: ListModel {
+ id: lmodel
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ ListElement { dummy: 0 }
+ }
+
+ function removeItemZero()
+ {
+ lmodel.remove(0);
+ }
+
+ orientation: ListView.Horizontal
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+
+ property int transitionsRun: 0
+
+ removeDisplaced: Transition {
+ id: transition
+ PropertyAnimation { property: "x"; duration: 500 }
+ onRunningChanged: if (!running) transitionsRun++;
+ }
+
+ delegate: Text {
+ text: index + " of " + lmodel.count
+ width: root.width
+ height: root.height
+ }
+} \ No newline at end of file
diff --git a/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml
new file mode 100644
index 0000000000..7ecc833a64
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/snapOneItemResize.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+
+ListView {
+ id: list
+ currentIndex: 5
+ snapMode: ListView.SnapOneItem
+ orientation: ListView.Horizontal
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ highlightFollowsCurrentItem: true
+ model: 10
+ spacing: 10
+ delegate: Item {
+ width: ListView.view.width
+ height: ListView.view.height
+ }
+}