diff options
Diffstat (limited to 'tests/manual/tableview/abstracttablemodel/main.qml')
-rw-r--r-- | tests/manual/tableview/abstracttablemodel/main.qml | 79 |
1 files changed, 76 insertions, 3 deletions
diff --git a/tests/manual/tableview/abstracttablemodel/main.qml b/tests/manual/tableview/abstracttablemodel/main.qml index 316d04131a..5578e86dba 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,6 +80,7 @@ ApplicationWindow { id: resizableColumnsEnabled checkable: true checked: false + Layout.fillWidth: false text: "Resizable columns" } @@ -81,6 +88,7 @@ ApplicationWindow { id: enableAnimation checkable: true checked: true + Layout.fillWidth: false text: "Enable animation" } @@ -88,6 +96,7 @@ ApplicationWindow { id: drawText checkable: true checked: true + Layout.fillWidth: false text: "Draw text" } @@ -95,6 +104,7 @@ ApplicationWindow { id: useRandomColor checkable: true checked: false + Layout.fillWidth: false text: "Use colors" } @@ -103,6 +113,7 @@ ApplicationWindow { checkable: true checked: false text: "Use large cells" + Layout.fillWidth: false onCheckedChanged: Qt.callLater(tableView.forceLayout) } @@ -110,6 +121,7 @@ ApplicationWindow { id: useSubRect checkable: true checked: false + Layout.fillWidth: false text: "Use subRect" } @@ -117,6 +129,7 @@ ApplicationWindow { id: useOffset checkable: true checked: false + Layout.fillWidth: false text: "Use offset" } @@ -124,6 +137,7 @@ ApplicationWindow { id: highlightCurrentRow checkable: true checked: false + Layout.fillWidth: false text: "Highlight row/col" } @@ -132,17 +146,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 +183,7 @@ ApplicationWindow { "Drag", "PressAndHold", ] + Layout.fillWidth: false } ComboBox { id: editCombo @@ -163,6 +196,11 @@ ApplicationWindow { "EditKeyPressed", "AnyKeyPressed", ] + Layout.fillWidth: false + } + Button { + text: "Clear selection" + onClicked: tableView.selectionModel.clearSelection() } } } @@ -171,6 +209,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 +220,7 @@ ApplicationWindow { to: 1000 value: 200 editable: true + Layout.fillWidth: false } Label { text: "Spacing:" } SpinBox { @@ -188,6 +229,7 @@ ApplicationWindow { to: 100 value: 1 editable: true + Layout.fillWidth: false } Label { text: "Margins:" } SpinBox { @@ -196,6 +238,7 @@ ApplicationWindow { to: 100 value: 0 editable: true + Layout.fillWidth: false } } } @@ -204,10 +247,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 +262,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 +275,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 +322,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 +338,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 +348,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 +358,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 +368,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 +381,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 +395,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 +416,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 +429,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 +438,7 @@ ApplicationWindow { Button { text: "ForceLayout()" + Layout.fillWidth: false onClicked: tableView.forceLayout() } } @@ -480,6 +551,7 @@ ApplicationWindow { } return TableView.SelectionDisabled } + selectionMode: selectionModeTv.currentValue editTriggers: { switch (editCombo.currentText) { case "NoEditTriggers": return TableView.NoEditTriggers @@ -512,6 +584,7 @@ ApplicationWindow { SelectionRectangle { id: selectionRectangle target: tableView + enabled: selectionCombo.currentText != "SelectionDisabled" topLeftHandle: Rectangle { width: 20 height: 20 |