[vlc-commits] qml: allow header and selective column delegation in KeyNavigableTableView

Prince Gupta git at videolan.org
Wed Jun 3 13:23:39 CEST 2020


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Mon May 18 09:40:54 2020 +0530| [ce8d3e45fa7acc6db0360f91e582910da800b543] | committer: Pierre Lamot

qml: allow header and selective column delegation in KeyNavigableTableView

this also remove margins from provided column delegation inside KeyNavigableTableView as they are now managed by column system

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

 .../gui/qt/medialibrary/qml/VideoListDisplay.qml   | 22 ++++--------
 .../gui/qt/widgets/qml/KeyNavigableTableView.qml   | 42 ++++++++++++----------
 2 files changed, 30 insertions(+), 34 deletions(-)

diff --git a/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml b/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
index 78d6ef152f..25ed3d2386 100644
--- a/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
@@ -58,14 +58,15 @@ Widgets.KeyNavigableTableView {
     rowHeight: VLCStyle.video_small_height + VLCStyle.margin_normal
 
     property bool isFocusOnContextButton: false
+
     colDelegate: Item {
         id: colDel
-        anchors.fill: parent
-        anchors.leftMargin: VLCStyle.margin_normal
-        anchors.rightMargin: VLCStyle.margin_normal
 
         property var rowModel: parent.rowModel
         property var model: parent.colModel
+
+        anchors.fill: parent
+
         FocusScope{
             anchors.fill: parent
             focus: isFocusOnContextButton && colDel.rowModel.index === currentIndex
@@ -132,19 +133,10 @@ Widgets.KeyNavigableTableView {
             Loader{
                 anchors.fill:parent
                 active: model.type !== "image"
-                sourceComponent: Text {
+                sourceComponent: Widgets.ListLabel {
+                    anchors.fill: parent
+                    anchors.rightMargin: VLCStyle.margin_xxxsmall // without this text is not initially visible
                     text: !rowModel ? "" : rowModel[model.criteria] || ""
-                    elide: Text.ElideRight
-                    font.pixelSize: VLCStyle.fontSize_normal
-                    color: (model.isPrimary)? VLCStyle.colors.text : VLCStyle.colors.textDisabled
-
-                    anchors {
-                        fill: parent
-                        leftMargin: VLCStyle.margin_xsmall
-                        rightMargin: VLCStyle.margin_xsmall
-                    }
-                    verticalAlignment: Text.AlignVCenter
-                    horizontalAlignment: Text.AlignLeft
                 }
             }
         }
diff --git a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
index c2684675dd..feeb4c4418 100644
--- a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
+++ b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
@@ -34,7 +34,17 @@ NavigableFocusScope {
     signal rightClick(Item menuParent, var menuModel)
 
     property var sortModel: []
-    property Component colDelegate: Item { }
+    property Component colDelegate: Widgets.ListLabel {
+        property var rowModel: parent.rowModel
+        property var model: parent.colModel
+
+        anchors.fill: parent
+        text: !rowModel ? "" : (rowModel[model.criteria] || "")
+    }
+    property Component headerDelegate: Widgets.CaptionLabel {
+        text: model.text || ""
+    }
+
     property alias model: view.model
 
     property alias contentHeight: view.contentHeight
@@ -88,32 +98,26 @@ NavigableFocusScope {
                 height: childrenRect.height
 
                 Row {
-                    x: VLCStyle.margin_normal
-                    anchors.horizontalCenter: parent.horizontalCenter
+                    anchors {
+                        leftMargin: VLCStyle.margin_xxxsmall
+                        rightMargin: VLCStyle.margin_xxxsmall
+                        horizontalCenter: parent.horizontalCenter
+                    }
                     height: childrenRect.height + VLCStyle.margin_xxsmall
-                    spacing: VLCStyle.column_margin_width
+                    topPadding: VLCStyle.margin_xxsmall
+                    spacing: root.horizontalSpacing
 
                     Repeater {
                         model: sortModel
                         MouseArea {
-                            height: VLCStyle.fontHeight_normal
+                            height: childrenRect.height
                             width: modelData.width || 1
                             //Layout.alignment: Qt.AlignVCenter
 
-                            Text {
-                                text: modelData.text || ""
-                                elide: Text.ElideRight
-                                font {
-                                    pixelSize: VLCStyle.fontSize_normal
+                            Loader {
+                                property var model: modelData
 
-                                }
-                                color: VLCStyle.colors.buttonText
-                                horizontalAlignment: Text.AlignLeft
-                                anchors {
-                                    fill: parent
-                                    leftMargin: VLCStyle.margin_xsmall
-                                    rightMargin: VLCStyle.margin_xsmall
-                                }
+                                sourceComponent: model.headerDelegate || root.headerDelegate
                             }
 
                             Text {
@@ -211,7 +215,7 @@ NavigableFocusScope {
                                 property var colModel: modelData
 
                                 anchors.fill: parent
-                                sourceComponent: colDelegate
+                                sourceComponent: colModel.colDelegate || root.colDelegate
 
                             }
                         }



More information about the vlc-commits mailing list