aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-03-07 10:21:53 +0100
committerMitch Curtis <mitch.curtis@qt.io>2019-04-08 07:42:08 +0000
commit7a303424f2095c53889f8102f115ec38013ef8d9 (patch)
tree883debcf88b5a9ce3da8acef37b86fc865f79294 /tests/manual
parent74313fd30a79e6f26734127157870c4491331501 (diff)
Add TableModelColumn
This allows us to support simple object rows by default, which we expect to be the most common use case for TableModel. Complex rows are supported, but with a limited subset of functionality. Things that could be improved: - Would be nice if we could get arbitrary/dynamic properties like ListModel has, without the complex code that comes with it. That way we could get rid of all of the role properties and users could have their own custom roles. The limitation of only having built-in roles becomes too restrictive very quickly. Change-Id: Icbdb6b39665851c55c69c0b79e0aa523c5d46dfe Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r--tests/manual/tableview/tablemodel/form/RowForm.qml36
-rw-r--r--tests/manual/tableview/tablemodel/form/main.qml60
2 files changed, 45 insertions, 51 deletions
diff --git a/tests/manual/tableview/tablemodel/form/RowForm.qml b/tests/manual/tableview/tablemodel/form/RowForm.qml
index 428682008a..bb03e685c0 100644
--- a/tests/manual/tableview/tablemodel/form/RowForm.qml
+++ b/tests/manual/tableview/tablemodel/form/RowForm.qml
@@ -45,13 +45,13 @@ ScrollView {
clip: true
function inputAsRow() {
- return [
- { checkable: checkableCheckBox.checked, checked: checkedCheckBox.checked },
- { amount: amountSpinBox.value },
- { fruitType: fruitTypeTextField.text },
- { fruitName: fruitNameTextField.text },
- { fruitPrice: parseFloat(fruitPriceTextField.text) },
- ]
+ return {
+ checked: checkedCheckBox.checked,
+ amount: amountSpinBox.value,
+ fruitType: fruitTypeTextField.text,
+ fruitName: fruitNameTextField.text,
+ fruitPrice: parseFloat(fruitPriceTextField.text)
+ }
}
default property alias content: gridLayout.children
@@ -60,23 +60,11 @@ ScrollView {
id: gridLayout
columns: 2
- RowLayout {
- Layout.columnSpan: 2
-
- Label {
- text: "checkable"
- }
- CheckBox {
- id: checkableCheckBox
- checked: true
- }
-
- Label {
- text: "checked"
- }
- CheckBox {
- id: checkedCheckBox
- }
+ Label {
+ text: "checked"
+ }
+ CheckBox {
+ id: checkedCheckBox
}
Label {
diff --git a/tests/manual/tableview/tablemodel/form/main.qml b/tests/manual/tableview/tablemodel/form/main.qml
index 21ecd8edbb..6c6874fb4b 100644
--- a/tests/manual/tableview/tablemodel/form/main.qml
+++ b/tests/manual/tableview/tablemodel/form/main.qml
@@ -64,31 +64,37 @@ ApplicationWindow {
Layout.fillHeight: true
model: TableModel {
+ TableModelColumn { display: "checked" }
+ TableModelColumn { display: "amount" }
+ TableModelColumn { display: "fruitType" }
+ TableModelColumn { display: "fruitName" }
+ TableModelColumn { display: "fruitPrice" }
+
// One row = one type of fruit that can be ordered
rows: [
- [
- // Each object (line) is one cell/column,
- // and each property in that object is a role.
- { checked: false, checkable: true },
- { amount: 1 },
- { fruitType: "Apple" },
- { fruitName: "Granny Smith" },
- { fruitPrice: 1.50 }
- ],
- [
- { checked: true, checkable: true },
- { amount: 4 },
- { fruitType: "Orange" },
- { fruitName: "Navel" },
- { fruitPrice: 2.50 }
- ],
- [
- { checked: false, checkable: true },
- { amount: 1 },
- { fruitType: "Banana" },
- { fruitName: "Cavendish" },
- { fruitPrice: 3.50 }
- ]
+ {
+ // Each object (line) is one column,
+ // and each property in that object represents a role.
+ checked: false,
+ amount: 1,
+ fruitType: "Apple",
+ fruitName: "Granny Smith",
+ fruitPrice: 1.50
+ },
+ {
+ checked: true,
+ amount: 4,
+ fruitType: "Orange",
+ fruitName: "Navel",
+ fruitPrice: 2.50
+ },
+ {
+ checked: false,
+ amount: 1,
+ fruitType: "Banana",
+ fruitName: "Cavendish",
+ fruitPrice: 3.50
+ }
]
}
@@ -97,16 +103,16 @@ ApplicationWindow {
column: 0
delegate: CheckBox {
objectName: "tableViewCheckBoxDelegate"
- checked: model.checked
- onToggled: model.checked = checked
+ checked: model.display
+ onToggled: model.display = display
}
}
DelegateChoice {
column: 1
delegate: SpinBox {
objectName: "tableViewSpinBoxDelegate"
- value: model.amount
- onValueModified: model.amount = value
+ value: model.display
+ onValueModified: model.display = value
}
}
DelegateChoice {