summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2014-09-30 10:58:54 +0200
committerTopi Reiniƶ <topi.reinio@digia.com>2014-10-01 22:14:20 +0200
commit4d851e14ebf0ec9bbfd899e71fe95c18ea1e658d (patch)
tree723759433165b21f442e6e436b1ed6d69d6f8774 /examples
parentd8b9259b90e3d51f96e0436001edc5ac20854f14 (diff)
downloadqtquickcontrols-4d851e14ebf0ec9bbfd899e71fe95c18ea1e658d.tar.gz
Table View Example: Sort indicator for the custom header delegate
The Delegates tab in the example shows how to use custom types as TableView header, row, and item. The UI has a checkbox to toggle a sort indicator for the header - this change implements the indicator for the custom header delegate, and adjusts the header text accordingly. Task-number: QTBUG-41396 Change-Id: Iab917b87b9b91c3dcc468f87aa14ec9293afd5f6 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/controls/tableview/images/sort-up.pngbin0 -> 205 bytes
-rw-r--r--examples/quick/controls/tableview/main.qml20
-rw-r--r--examples/quick/controls/tableview/resources.qrc1
3 files changed, 20 insertions, 1 deletions
diff --git a/examples/quick/controls/tableview/images/sort-up.png b/examples/quick/controls/tableview/images/sort-up.png
new file mode 100644
index 00000000..27fcb191
--- /dev/null
+++ b/examples/quick/controls/tableview/images/sort-up.png
Binary files differ
diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml
index e90e1104..b85f2d1d 100644
--- a/examples/quick/controls/tableview/main.qml
+++ b/examples/quick/controls/tableview/main.qml
@@ -310,6 +310,7 @@ Window {
}
}
TableView {
+ id: delegatesView
model: largeModel
anchors.margins: 12
anchors.fill:parent
@@ -338,10 +339,27 @@ Window {
source: "images/header.png"
border{left:2;right:2;top:2;bottom:2}
Text {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+ anchors.right: indicator.visible ? indicator.left : parent.right
+ anchors.margins: 6
text: styleData.value
- anchors.centerIn:parent
+ elide: Text.ElideRight
color:"#333"
}
+ // Sort indicator
+ Image {
+ id: indicator
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+ anchors.rightMargin: 6
+ source: "images/sort-up.png"
+ visible: delegatesView.sortIndicatorVisible &&
+ styleData.column === delegatesView.sortIndicatorColumn
+ rotation: delegatesView.sortIndicatorOrder === Qt.AscendingOrder ? 180 : 0
+ Behavior on rotation { NumberAnimation { } }
+ }
+
}
rowDelegate: Rectangle {
diff --git a/examples/quick/controls/tableview/resources.qrc b/examples/quick/controls/tableview/resources.qrc
index f395013f..83d3f6a7 100644
--- a/examples/quick/controls/tableview/resources.qrc
+++ b/examples/quick/controls/tableview/resources.qrc
@@ -3,5 +3,6 @@
<file>main.qml</file>
<file>images/selectedrow.png</file>
<file>images/header.png</file>
+ <file>images/sort-up.png</file>
</qresource>
</RCC>