From 4d851e14ebf0ec9bbfd899e71fe95c18ea1e658d Mon Sep 17 00:00:00 2001
From: Topi Reinio <topi.reinio@digia.com>
Date: Tue, 30 Sep 2014 10:58:54 +0200
Subject: [PATCH] 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>
---
 .../controls/tableview/images/sort-up.png     | Bin 0 -> 205 bytes
 examples/quick/controls/tableview/main.qml    |  20 +++++++++++++++++-
 .../quick/controls/tableview/resources.qrc    |   1 +
 3 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 examples/quick/controls/tableview/images/sort-up.png

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 0000000000000000000000000000000000000000..27fcb19153992dbc4003103460fd74004e6778e8
GIT binary patch
literal 205
zcmeAS@N?(olHy`uVBq!ia0vp^>_E)I!3HFqj;YoHDaPU;cPEB*=VV?2Ic!PZ?k)`f
zL2$v|<&%LToCO|{#X#+^L734gSv3$S$X?><>&kwQQ;tJd|IWR|IzS;`PZ!4!j_al;
zHwrcf2pqXkZt{p}8(Z7KseuBf77FD*idQ_5k(lCn>FzG+XDYovGlfI0PI}Uy;vT9S
s5HY#t&(04`hR3Q8mG$eF&DoxBA1@|3Ls8CTBG6z4Pgg&ebxsLQ0I)kkxc~qF

literal 0
HcmV?d00001

diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml
index e90e11043..b85f2d1d9 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 f395013f5..83d3f6a76 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>
-- 
GitLab