summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2019-03-22 11:41:15 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2019-05-23 09:46:07 +0200
commit4ce9717c6de3f69556b90d97c40fcfc5bb54b6d4 (patch)
tree9e147e5eb2032216e0a61d0ea602b3725d727064 /tests
parentb6adafe256c87f611b8e6790dbf37c80aa98e353 (diff)
Manual test, TableView: improve test with syncView functionality
Add some more TableViews and buttons that can be used to test the new syncView functionality. Change-Id: I0ad649598ef2ff08487c9a0b450861c27535c62c Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/manual/tableview/abstracttablemodel/Button.qml2
-rw-r--r--tests/manual/tableview/abstracttablemodel/main.qml156
2 files changed, 132 insertions, 26 deletions
diff --git a/tests/manual/tableview/abstracttablemodel/Button.qml b/tests/manual/tableview/abstracttablemodel/Button.qml
index 2d4dcde80d..7057e33633 100644
--- a/tests/manual/tableview/abstracttablemodel/Button.qml
+++ b/tests/manual/tableview/abstracttablemodel/Button.qml
@@ -40,7 +40,7 @@
import QtQuick 2.12
Rectangle {
- width: 100
+ width: 110
height: 40
border.width: 1
color: "lightgreen"
diff --git a/tests/manual/tableview/abstracttablemodel/main.qml b/tests/manual/tableview/abstracttablemodel/main.qml
index 52967a1a0d..4b9158f03c 100644
--- a/tests/manual/tableview/abstracttablemodel/main.qml
+++ b/tests/manual/tableview/abstracttablemodel/main.qml
@@ -37,10 +37,11 @@
**
****************************************************************************/
-import QtQuick 2.12
+import QtQuick 2.14
import QtQuick.Window 2.3
import QtQml.Models 2.2
import TestTableModel 0.1
+import QtQuick.Controls 2.5
Window {
id: window
@@ -54,7 +55,7 @@ Window {
TestTableModel {
id: tableModel
rowCount: 200
- columnCount: 5000
+ columnCount: 200
}
Rectangle {
@@ -62,45 +63,150 @@ Window {
anchors.margins: 10
color: "darkgray"
- Row {
+ Column {
id: menu
x: 2
y: 2
- spacing: 1
- Button {
- text: "Add row"
- onClicked: tableModel.insertRows(selectedY, 1)
+
+ Row {
+ spacing: 1
+ Button {
+ text: "Add row"
+ onClicked: tableModel.insertRows(selectedY, 1)
+ }
+ Button {
+ text: "Remove row"
+ onClicked: tableModel.removeRows(selectedY, 1)
+ }
+ Button {
+ text: "Add column"
+ onClicked: tableModel.insertColumns(selectedX, 1)
+ }
+ Button {
+ text: "Remove column"
+ onClicked: tableModel.removeColumns(selectedX, 1)
+ }
}
- Button {
- text: "Remove row"
- onClicked: tableModel.removeRows(selectedY, 1)
+
+ Row {
+ spacing: 1
+ Button {
+ text: "fast-flick<br>center table"
+ onClicked: {
+ tableView.contentX += tableView.width * 1.2
+ }
+ }
+ Button {
+ text: "flick to end<br>center table"
+ onClicked: {
+ tableView.contentX = tableView.contentWidth - tableView.width
+ }
+ }
+ Button {
+ text: "fast-flick<br>headers"
+ onClicked: {
+ leftHeader.contentY += 1000
+ topHeader.contentX += 1000
+ }
+ }
+ Button {
+ text: "set/unset<br>master bindings"
+ onClicked: {
+ leftHeader.syncView = leftHeader.syncView ? null : tableView
+ topHeader.syncView = topHeader.syncView ? null : tableView
+ }
+ }
+ Button {
+ text: "inc space"
+ onClicked: {
+ tableView.columnSpacing += 1
+ tableView.rowSpacing += 1
+ }
+ }
+ }
+ Text {
+ text: "Selected: x:" + selectedX + ", y:" + selectedY
}
- Button {
- text: "Add column"
- onClicked: tableModel.insertColumns(selectedX, 1)
+ }
+
+ TableView {
+ id: topHeader
+ objectName: "topHeader"
+ anchors.left: tableView.left
+ width: tableView.width
+ anchors.top: menu.bottom
+ height: 30
+ clip: true
+ ScrollBar.horizontal: ScrollBar {}
+
+ model: TestTableModel {
+ rowCount: 1
+ columnCount: 200
}
- Button {
- text: "Remove column"
- onClicked: tableModel.removeColumns(selectedX, 1)
+
+ delegate: Rectangle {
+ implicitHeight: topHeader.height
+ implicitWidth: 20
+ color: "lightgray"
+ Text { text: column }
}
+
+ columnSpacing: 1
+ rowSpacing: 1
+
+ syncDirection: Qt.Horizontal
}
- Text {
- anchors.right: parent.right
- anchors.top: parent.top
- anchors.margins: 2
- text: "x:" + selectedX + ", y:" + selectedY
+
+ TableView {
+ id: leftHeader
+ objectName: "leftHeader"
+ anchors.left: parent.left
+ anchors.top: tableView.top
+ height: tableView.height
+ width: 30
+ clip: true
+ ScrollBar.vertical: ScrollBar {}
+
+ model: TestTableModel {
+ rowCount: 200
+ columnCount: 1
+ }
+
+ delegate: Rectangle {
+ implicitHeight: 50
+ implicitWidth: leftHeader.width
+ color: "lightgray"
+ Text { text: row }
+ }
+
+ columnSpacing: 1
+ rowSpacing: 1
+
+ syncDirection: Qt.Vertical
}
TableView {
id: tableView
- anchors.left: parent.left
+ objectName: "tableview"
+ anchors.left: leftHeader.right
anchors.right: parent.right
- anchors.top: menu.bottom
+ anchors.top: topHeader.bottom
anchors.bottom: parent.bottom
- anchors.margins: 2
+ width: 200
clip: true
+ columnWidthProvider: function(c) {
+ if (c > 30)
+ return 100
+ else
+ return 200;
+ }
+ ScrollBar.horizontal: ScrollBar {}
+ ScrollBar.vertical: ScrollBar {}
- model: tableModel
+ model: TestTableModel {
+ rowCount: 200
+ columnCount: 60
+ }
delegate: tableViewDelegate
columnSpacing: 1
rowSpacing: 1