[vlc-devel] [PATCH 08/17] qml: allow views to define Component to show before table headers in KeyNavigableTableView

Prince Gupta guptaprince8832 at gmail.com
Fri Jun 19 16:06:21 CEST 2020


---
 .../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
-- 
2.25.1



More information about the vlc-devel mailing list