summaryrefslogtreecommitdiff
path: root/examples/quick/controls/tableview/main.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/controls/tableview/main.qml')
-rw-r--r--examples/quick/controls/tableview/main.qml96
1 files changed, 40 insertions, 56 deletions
diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml
index 0e568314..1a9246f8 100644
--- a/examples/quick/controls/tableview/main.qml
+++ b/examples/quick/controls/tableview/main.qml
@@ -104,9 +104,9 @@ Window {
ListModel {
id: nestedModel
- ListElement{controlState: ListElement { description: "Core" ; color:"#ffaacc"}}
- ListElement{controlState: ListElement { description: "Second" ; color:"#ffccaa"}}
- ListElement{controlState: ListElement { description: "Third" ; color:"#ffffaa"}}
+ ListElement{content: ListElement { description: "Core" ; color:"#ffaacc"}}
+ ListElement{content: ListElement { description: "Second" ; color:"#ffccaa"}}
+ ListElement{content: ListElement { description: "Third" ; color:"#ffffaa"}}
}
ListModel {
@@ -129,7 +129,7 @@ Window {
focus:true
enabled: enabledCheck.checked
- property int margins: Qt.platform.os === "mac" ? 16 : 0
+ property int margins: Qt.platform.os === "osx" ? 16 : 0
height: parent.height - 34
anchors.right: parent.right
@@ -176,14 +176,14 @@ Window {
anchors.margins: 12
TableViewColumn {
- role: "controlState"
+ role: "content"
title: "Text and Color"
width: 220
}
itemDelegate: Item {
Rectangle{
- color: itemValue.get(0).color
+ color: styleData.value.get(0).color
anchors.top:parent.top
anchors.right:parent.right
anchors.bottom:parent.bottom
@@ -196,9 +196,9 @@ Window {
anchors.margins: 4
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue.get(0).description
- color: itemTextColor
+ elide: styleData.elideMode
+ text: styleData.value.get(0).description
+ color: styleData.textColor
}
}
@@ -251,32 +251,23 @@ Window {
anchors.margins: 4
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue !== undefined ? itemValue : ""
- color: itemTextColor
+ elide: styleData.elideMode
+ text: styleData.value !== undefined ? styleData.value : ""
+ color: styleData.textColor
}
}
}
Component {
- id: slickRowDelegate
- Rectangle { color: alternateBackground ? "#cef" : "white" }
- }
-
- Component {
id: delegate2
- Item {
- height: itemSelected? 60 : 20
- Behavior on height{ NumberAnimation{} }
- Text {
- width: parent.width
- anchors.margins: 4
- anchors.left: parent.left
- anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue !== undefined ? itemValue : ""
- color: itemTextColor
- }
+ Text {
+ width: parent.width
+ anchors.margins: 4
+ anchors.left: parent.left
+ anchors.verticalCenter: parent.verticalCenter
+ elide: styleData.elideMode
+ text: styleData.value !== undefined ? styleData.value : ""
+ color: styleData.textColor
}
}
@@ -289,10 +280,10 @@ Window {
anchors.margins: 4
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
- elide: itemElideMode
- text: itemValue !== undefined ? itemValue : ""
- color: itemTextColor
- visible: !itemSelected
+ elide: styleData.elideMode
+ text: styleData.value !== undefined ? styleData.value : ""
+ color: styleData.textColor
+ visible: !styleData.selected
}
Loader { // Initialize text editor lazily to improve performance
id: loaderEditor
@@ -301,19 +292,19 @@ Window {
Connections {
target: loaderEditor.item
onAccepted: {
- if (typeof itemValue === 'number')
- model.setProperty(row, role, Number(parseFloat(loaderEditor.item.text).toFixed(0)))
+ if (typeof styleData.value === 'number')
+ model.setProperty(styleData.row, styleData.role, Number(parseFloat(loaderEditor.item.text).toFixed(0)))
else
- model.setProperty(row, role, loaderEditor.item.text)
+ model.setProperty(styleData.row, styleData.role, loaderEditor.item.text)
}
}
- sourceComponent: itemSelected ? editor : null
+ sourceComponent: styleData.selected ? editor : null
Component {
id: editor
TextInput {
id: textinput
- color: itemTextColor
- text: itemValue
+ color: styleData.textColor
+ text: styleData.value
MouseArea {
id: mouseArea
anchors.fill: parent
@@ -354,25 +345,22 @@ Window {
source: "images/header.png"
border{left:2;right:2;top:2;bottom:2}
Text {
- text: itemValue
+ text: styleData.value
anchors.centerIn:parent
color:"#333"
}
}
rowDelegate: Rectangle {
- height: 20
- color: rowSelected ? "#448" : (alternateBackground ? "#eee" : "#fff")
- border.color:"#ccc"
- border.width: 1
- anchors.left: parent ? parent.left : undefined
- anchors.leftMargin: -2
- anchors.rightMargin: -1
+ height: (delegateChooser.currentIndex == 1 && styleData.selected) ? 30 : 20
+ Behavior on height{ NumberAnimation{} }
+
+ color: styleData.selected ? "#448" : (styleData.alternate? "#eee" : "#fff")
BorderImage{
id: selected
anchors.fill: parent
source: "images/selectedrow.png"
- visible: rowSelected
+ visible: styleData.selected
border{left:2; right:2; top:2; bottom:2}
SequentialAnimation {
running: true; loops: Animation.Infinite
@@ -383,14 +371,10 @@ Window {
}
itemDelegate: {
- switch (delegateChooser.currentIndex) {
- case 0:
- return delegate1
- case 1:
- return delegate2
- case 2:
- return editableDelegate
- }
+ if (delegateChooser.currentIndex == 2)
+ return editableDelegate;
+ else
+ return delegate1;
}
}
}