aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/tableview/abstracttablemodel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/tableview/abstracttablemodel')
-rw-r--r--tests/manual/tableview/abstracttablemodel/Button.qml2
-rw-r--r--tests/manual/tableview/abstracttablemodel/main.cpp2
-rw-r--r--tests/manual/tableview/abstracttablemodel/main.qml115
3 files changed, 112 insertions, 7 deletions
diff --git a/tests/manual/tableview/abstracttablemodel/Button.qml b/tests/manual/tableview/abstracttablemodel/Button.qml
index b3ca5dd260..d49f2102a2 100644
--- a/tests/manual/tableview/abstracttablemodel/Button.qml
+++ b/tests/manual/tableview/abstracttablemodel/Button.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.12
diff --git a/tests/manual/tableview/abstracttablemodel/main.cpp b/tests/manual/tableview/abstracttablemodel/main.cpp
index a765f66272..6b7d38c9ec 100644
--- a/tests/manual/tableview/abstracttablemodel/main.cpp
+++ b/tests/manual/tableview/abstracttablemodel/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QGuiApplication>
#include <QQmlApplicationEngine>
diff --git a/tests/manual/tableview/abstracttablemodel/main.qml b/tests/manual/tableview/abstracttablemodel/main.qml
index 316d04131a..9c43af2f99 100644
--- a/tests/manual/tableview/abstracttablemodel/main.qml
+++ b/tests/manual/tableview/abstracttablemodel/main.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2018 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Window
@@ -12,7 +12,7 @@ import Qt.labs.qmlmodels
ApplicationWindow {
id: window
width: 1000
- height: 800
+ height: 600
visible: true
readonly property var currentIndex: tableView.selectionModel.currentIndex
@@ -33,11 +33,14 @@ ApplicationWindow {
Layout.rightMargin: menu.menuMargin
Layout.leftMargin: menu.menuMargin
Layout.topMargin: menu.menuMargin
+ Layout.fillWidth: false
+ Layout.fillHeight: false
ColumnLayout {
CheckBox {
text: "Use Syncview"
checkable: true
checked: true
+ Layout.fillWidth: false
onCheckedChanged: {
if (checked) {
leftHeader.syncView = tableView
@@ -52,7 +55,8 @@ ApplicationWindow {
CheckBox {
id: flickingMode
checkable: true
- checked: true
+ checked: false
+ Layout.fillWidth: false
text: "Interactive"
}
@@ -60,6 +64,7 @@ ApplicationWindow {
id: indexNavigation
checkable: true
checked: true
+ Layout.fillWidth: false
text: "Enable navigation"
}
@@ -67,6 +72,7 @@ ApplicationWindow {
id: resizableRowsEnabled
checkable: true
checked: false
+ Layout.fillWidth: false
text: "Resizable rows"
}
@@ -74,13 +80,31 @@ ApplicationWindow {
id: resizableColumnsEnabled
checkable: true
checked: false
+ Layout.fillWidth: false
text: "Resizable columns"
}
CheckBox {
+ id: movableColumnEnabled
+ checkable: true
+ checked: false
+ Layout.fillWidth: false
+ text: "Reorder columns"
+ }
+
+ CheckBox {
+ id: movableRowEnabled
+ checkable: true
+ checked: false
+ Layout.fillWidth: false
+ text: "Reorder rows"
+ }
+
+ CheckBox {
id: enableAnimation
checkable: true
checked: true
+ Layout.fillWidth: false
text: "Enable animation"
}
@@ -88,6 +112,7 @@ ApplicationWindow {
id: drawText
checkable: true
checked: true
+ Layout.fillWidth: false
text: "Draw text"
}
@@ -95,6 +120,7 @@ ApplicationWindow {
id: useRandomColor
checkable: true
checked: false
+ Layout.fillWidth: false
text: "Use colors"
}
@@ -103,6 +129,7 @@ ApplicationWindow {
checkable: true
checked: false
text: "Use large cells"
+ Layout.fillWidth: false
onCheckedChanged: Qt.callLater(tableView.forceLayout)
}
@@ -110,6 +137,7 @@ ApplicationWindow {
id: useSubRect
checkable: true
checked: false
+ Layout.fillWidth: false
text: "Use subRect"
}
@@ -117,6 +145,7 @@ ApplicationWindow {
id: useOffset
checkable: true
checked: false
+ Layout.fillWidth: false
text: "Use offset"
}
@@ -124,6 +153,7 @@ ApplicationWindow {
id: highlightCurrentRow
checkable: true
checked: false
+ Layout.fillWidth: false
text: "Highlight row/col"
}
@@ -132,17 +162,35 @@ ApplicationWindow {
checkable: true
checked: tableView.interactive
text: "Show selection handles"
+ Layout.fillWidth: false
}
ComboBox {
id: selectionCombo
+ currentIndex: 1
model: [
"SelectionDisabled",
"SelectCells",
"SelectRows",
"SelectColumns",
]
+ Layout.fillWidth: false
}
+
+ ComboBox {
+ id: selectionModeTv
+ textRole: "text"
+ valueRole: "value"
+ implicitContentWidthPolicy: ComboBox.WidestText
+ currentIndex: 2
+ model: [
+ { text: "SingleSelection", value: TableView.SingleSelection },
+ { text: "ContiguousSelection", value: TableView.ContiguousSelection },
+ { text: "ExtendedSelection", value: TableView.ExtendedSelection }
+ ]
+ Layout.fillWidth: false
+ }
+
ComboBox {
id: selectionModeCombo
enabled: selectionCombo.currentText != "SelectionDisabled"
@@ -151,6 +199,7 @@ ApplicationWindow {
"Drag",
"PressAndHold",
]
+ Layout.fillWidth: false
}
ComboBox {
id: editCombo
@@ -163,6 +212,19 @@ ApplicationWindow {
"EditKeyPressed",
"AnyKeyPressed",
]
+ Layout.fillWidth: false
+ }
+ Button {
+ text: "Clear selection"
+ onClicked: tableView.selectionModel.clearSelection()
+ }
+ Button {
+ text: "Clear column reordering"
+ onClicked: tableView.clearColumnReordering()
+ }
+ Button {
+ text: "Clear row reordering"
+ onClicked: tableView.clearRowReordering()
}
}
}
@@ -171,6 +233,8 @@ ApplicationWindow {
Layout.minimumWidth: menu.availableWidth - (menu.menuMargin * 2)
Layout.rightMargin: menu.menuMargin
Layout.leftMargin: menu.menuMargin
+ Layout.fillWidth: false
+ Layout.fillHeight: false
GridLayout {
columns: 2
Label { text: "Model size:" }
@@ -180,6 +244,7 @@ ApplicationWindow {
to: 1000
value: 200
editable: true
+ Layout.fillWidth: false
}
Label { text: "Spacing:" }
SpinBox {
@@ -188,6 +253,7 @@ ApplicationWindow {
to: 100
value: 1
editable: true
+ Layout.fillWidth: false
}
Label { text: "Margins:" }
SpinBox {
@@ -196,6 +262,7 @@ ApplicationWindow {
to: 100
value: 0
editable: true
+ Layout.fillWidth: false
}
}
}
@@ -204,10 +271,13 @@ ApplicationWindow {
Layout.minimumWidth: menu.availableWidth - (menu.menuMargin * 2)
Layout.rightMargin: menu.menuMargin
Layout.leftMargin: menu.menuMargin
+ Layout.fillWidth: false
+ Layout.fillHeight: false
RowLayout {
id: positionRow
Button {
text: "<<"
+ Layout.fillWidth: false
onClicked: {
tableView.positionViewAtRow(0, Qt.AlignTop, -tableView.topMargin)
tableView.positionViewAtColumn(0, Qt.AlignLeft, -tableView.leftMargin)
@@ -216,6 +286,7 @@ ApplicationWindow {
Button {
text: ">>"
+ Layout.fillWidth: false
onClicked: {
tableView.positionViewAtRow(tableView.rows - 1, Qt.AlignBottom, tableView.bottomMargin)
tableView.positionViewAtColumn(tableView.columns - 1, Qt.AlignRight, tableView.rightMargin)
@@ -228,34 +299,41 @@ ApplicationWindow {
Layout.minimumWidth: menu.availableWidth - (menu.menuMargin * 2)
Layout.rightMargin: menu.menuMargin
Layout.leftMargin: menu.menuMargin
+ Layout.fillWidth: false
+ Layout.fillHeight: false
ColumnLayout {
Button {
text: "Add row"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: tableView.model.insertRows(currentIndex.row, 1)
}
Button {
text: "Remove row"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: tableView.model.removeRows(currentIndex.row, 1)
}
Button {
text: "Add column"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: tableView.model.insertColumns(currentIndex.column, 1)
}
Button {
text: "Remove column"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: tableView.model.removeColumns(currentIndex.column, 1)
}
Button {
text: "Hide column"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: {
hiddenColumn = currentIndex.column
tableView.forceLayout()
@@ -268,10 +346,13 @@ ApplicationWindow {
Layout.minimumWidth: menu.availableWidth - (menu.menuMargin * 2)
Layout.rightMargin: menu.menuMargin
Layout.leftMargin: menu.menuMargin
+ Layout.fillWidth: false
+ Layout.fillHeight: false
ColumnLayout {
Button {
text: "Current to top-left"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: {
let cell = Qt.point(currentIndex.column, currentIndex.row)
tableView.positionViewAtCell(cell, Qt.AlignTop | Qt.AlignLeft, positionOffset, positionSubRect)
@@ -281,6 +362,7 @@ ApplicationWindow {
Button {
text: "Current to center"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: {
let cell = Qt.point(currentIndex.column, currentIndex.row)
tableView.positionViewAtCell(cell, Qt.AlignCenter, positionOffset, positionSubRect)
@@ -290,6 +372,7 @@ ApplicationWindow {
Button {
text: "Current to bottom-right"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: {
let cell = Qt.point(currentIndex.column, currentIndex.row)
tableView.positionViewAtCell(cell, Qt.AlignBottom | Qt.AlignRight, positionOffset, positionSubRect)
@@ -299,6 +382,7 @@ ApplicationWindow {
Button {
text: "Current to Visible"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: {
let cell = Qt.point(currentIndex.column, currentIndex.row)
tableView.positionViewAtCell(cell, TableView.Visible, positionOffset, positionSubRect)
@@ -308,6 +392,7 @@ ApplicationWindow {
Button {
text: "Current to Contain"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: {
let cell = Qt.point(currentIndex.column, currentIndex.row)
tableView.positionViewAtCell(cell, TableView.Contain, positionOffset, positionSubRect)
@@ -320,10 +405,13 @@ ApplicationWindow {
Layout.minimumWidth: menu.availableWidth - (menu.menuMargin * 2)
Layout.rightMargin: menu.menuMargin
Layout.leftMargin: menu.menuMargin
+ Layout.fillWidth: false
+ Layout.fillHeight: false
ColumnLayout {
Button {
text: "Open editor"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: {
tableView.edit(currentIndex, true)
}
@@ -331,12 +419,14 @@ ApplicationWindow {
Button {
text: "Close editor"
enabled: currentIndex.valid
+ Layout.fillWidth: false
onClicked: {
tableView.closeEditor()
}
}
Button {
text: "Set current index"
+ Layout.fillWidth: false
onClicked: {
let index = tableView.modelIndex(1, 1);
tableView.selectionModel.setCurrentIndex(index, ItemSelectionModel.NoUpdate)
@@ -350,9 +440,12 @@ ApplicationWindow {
Layout.rightMargin: menu.menuMargin
Layout.leftMargin: menu.menuMargin
Layout.bottomMargin: menu.menuMargin
+ Layout.fillWidth: false
+ Layout.fillHeight: false
ColumnLayout {
Button {
text: "Fast-flick table"
+ Layout.fillWidth: false
onClicked: {
tableView.contentX += tableView.width * 1.2
}
@@ -360,6 +453,7 @@ ApplicationWindow {
Button {
text: "Fast-flick headers"
+ Layout.fillWidth: false
onClicked: {
topHeader.contentX += tableView.width * 1.2
leftHeader.contentY += tableView.height * 1.2
@@ -368,6 +462,7 @@ ApplicationWindow {
Button {
text: "ForceLayout()"
+ Layout.fillWidth: false
onClicked: tableView.forceLayout()
}
}
@@ -379,7 +474,7 @@ ApplicationWindow {
}
}
- TableView {
+ HorizontalHeaderView {
id: topHeader
objectName: "topHeader"
anchors.left: centerScrollView.left
@@ -394,8 +489,11 @@ ApplicationWindow {
}
delegate: Rectangle {
+ required property bool containsDrag
implicitHeight: topHeader.height
implicitWidth: 20
+ border.width: containsDrag ? 1 : 0
+ border.color: containsDrag ? window.palette.text : window.palette.alternateBase
color: window.palette.alternateBase
Label {
anchors.centerIn: parent
@@ -410,10 +508,11 @@ ApplicationWindow {
syncView: tableView
syncDirection: Qt.Horizontal
+ movableColumns: movableColumnEnabled.checked
resizableColumns: resizableColumnsEnabled.checked
}
- TableView {
+ VerticalHeaderView {
id: leftHeader
objectName: "leftHeader"
anchors.left: menu.right
@@ -428,8 +527,11 @@ ApplicationWindow {
}
delegate: Rectangle {
+ required property bool containsDrag
implicitHeight: 50
implicitWidth: leftHeader.width
+ border.width: containsDrag ? 1 : 0
+ border.color: containsDrag ? window.palette.text : window.palette.alternateBase
color: window.palette.alternateBase
Label {
anchors.centerIn: parent
@@ -444,6 +546,7 @@ ApplicationWindow {
syncView: tableView
syncDirection: Qt.Vertical
+ movableRows: movableRowEnabled.checked
resizableRows: resizableRowsEnabled.checked
}
@@ -480,6 +583,7 @@ ApplicationWindow {
}
return TableView.SelectionDisabled
}
+ selectionMode: selectionModeTv.currentValue
editTriggers: {
switch (editCombo.currentText) {
case "NoEditTriggers": return TableView.NoEditTriggers
@@ -512,6 +616,7 @@ ApplicationWindow {
SelectionRectangle {
id: selectionRectangle
target: tableView
+ enabled: selectionCombo.currentText != "SelectionDisabled"
topLeftHandle: Rectangle {
width: 20
height: 20