[vlc-commits] qml: allow views to define Component to show before table headers in KeyNavigableTableView

Prince Gupta git at videolan.org
Wed Jun 24 17:41:57 CEST 2020


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Wed Jun 10 18:23:22 2020 +0530| [d7fc6bb880041b0790d71f1b240cbf075b098b43] | committer: Pierre Lamot

qml: allow views to define Component to show before table headers in KeyNavigableTableView

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d7fc6bb880041b0790d71f1b240cbf075b098b43
---

 modules/gui/qt/widgets/qml/KeyNavigableTableView.qml | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
index 0b48747df6..ac134dd84f 100644
--- a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
+++ b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
@@ -41,7 +41,7 @@ NavigableFocusScope {
         anchors.fill: parent
         text: !rowModel ? "" : (rowModel[model.criteria] || "")
     }
-    property Component headerDelegate: Widgets.CaptionLabel {
+    property Component tableHeaderDelegate: Widgets.CaptionLabel {
         text: model.text || ""
     }
 
@@ -56,7 +56,9 @@ NavigableFocusScope {
     property alias currentIndex: view.currentIndex
     property alias currentItem: view.currentItem
 
-    property alias headerItem: view.headerItem
+    property Component header: undefined
+    property var headerItem: view.headerItem.loadedHeader
+    property alias tableHeaderItem: view.headerItem
     property color headerColor
 
     property alias selectionModel: selectionModel
@@ -91,6 +93,7 @@ NavigableFocusScope {
 
             readonly property alias contentX: row.x
             readonly property alias contentWidth: row.width
+            property alias loadedHeader: headerLoader.item
 
             width: parent.width
             height: childrenRect.height
@@ -102,6 +105,12 @@ NavigableFocusScope {
                 width: parent.width
                 height: childrenRect.height
 
+                Loader {
+                    id: headerLoader
+
+                    sourceComponent: root.header
+                }
+
                 Row {
                     id: row
 
@@ -124,7 +133,7 @@ NavigableFocusScope {
                             Loader {
                                 property var model: modelData
 
-                                sourceComponent: model.headerDelegate || root.headerDelegate
+                                sourceComponent: model.headerDelegate || root.tableHeaderDelegate
                             }
 
                             Text {
@@ -157,7 +166,7 @@ NavigableFocusScope {
         }
 
         section.delegate: Text {
-            x: headerItem.contentX - VLCStyle.table_section_width
+            x: view.headerItem.contentX - VLCStyle.table_section_width
             topPadding: VLCStyle.margin_xsmall
             bottomPadding: VLCStyle.margin_xxsmall
             leftPadding: VLCStyle.table_section_text_margin



More information about the vlc-commits mailing list