[vlc-commits] qml: transfer titleHeaderDelegate and titleDelegate to TableColumns

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


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Mon Jun  8 20:34:32 2020 +0530| [f87e7388c321fdf49449ecc00376d71c582c8c5a] | committer: Pierre Lamot

qml: transfer titleHeaderDelegate and titleDelegate to TableColumns

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

 .../qt/medialibrary/qml/MusicTrackListDisplay.qml  | 54 ++--------------------
 modules/gui/qt/widgets/qml/TableColumns.qml        | 49 ++++++++++++++++++++
 2 files changed, 52 insertions(+), 51 deletions(-)

diff --git a/modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml b/modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
index b23e9ee9ce..509372251b 100644
--- a/modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
@@ -29,21 +29,21 @@ Widgets.KeyNavigableTableView {
     id: root
 
     property var sortModelSmall: [
-        { isPrimary: true, criteria: "title",       width: VLCStyle.colWidth(1), text: i18n.qtr("Title"),    showSection: "title", colDelegate: titleDelegate, headerDelegate: titleHeaderDelegate },
+        { isPrimary: true, criteria: "title",       width: VLCStyle.colWidth(1), text: i18n.qtr("Title"),    showSection: "title", colDelegate: tableColumns.titleDelegate, headerDelegate: tableColumns.titleHeaderDelegate },
         { criteria: "album_title", width: VLCStyle.colWidth(1), text: i18n.qtr("Album"),    showSection: "album_title" },
         { criteria: "main_artist", width: VLCStyle.colWidth(1), text: i18n.qtr("Artist"),   showSection: "main_artist" },
         { criteria: "durationShort", width: VLCStyle.colWidth(1), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
     ]
 
     property var sortModelMedium: [
-        { isPrimary: true, criteria: "title",       width: VLCStyle.colWidth(2), text: i18n.qtr("Title"),    showSection: "title", colDelegate: titleDelegate, headerDelegate: titleHeaderDelegate },
+        { isPrimary: true, criteria: "title",       width: VLCStyle.colWidth(2), text: i18n.qtr("Title"),    showSection: "title", colDelegate: tableColumns.titleDelegate, headerDelegate: tableColumns.titleHeaderDelegate },
         { criteria: "album_title", width: VLCStyle.colWidth(2), text: i18n.qtr("Album"),    showSection: "album_title" },
         { criteria: "main_artist", width: VLCStyle.colWidth(1), text: i18n.qtr("Artist"),   showSection: "main_artist" },
         { criteria: "durationShort", width: VLCStyle.colWidth(1), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
     ]
 
     property var sortModelLarge: [
-        { isPrimary: true, criteria: "title",       width: VLCStyle.colWidth(2), text: i18n.qtr("Title"),    showSection: "title", colDelegate: titleDelegate, headerDelegate: titleHeaderDelegate },
+        { isPrimary: true, criteria: "title",       width: VLCStyle.colWidth(2), text: i18n.qtr("Title"),    showSection: "title", colDelegate: tableColumns.titleDelegate, headerDelegate: tableColumns.titleHeaderDelegate },
         { criteria: "album_title", width: VLCStyle.colWidth(2), text: i18n.qtr("Album"),    showSection: "album_title" },
         { criteria: "main_artist", width: VLCStyle.colWidth(2), text: i18n.qtr("Artist"),   showSection: "main_artist" },
         { criteria: "durationShort", width: VLCStyle.colWidth(1), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate },
@@ -51,54 +51,6 @@ Widgets.KeyNavigableTableView {
         { criteria: "disc_number", width: VLCStyle.colWidth(1), text: i18n.qtr("Disc"),  showSection: "" },
     ]
 
-    property Component titleDelegate: RowLayout {
-        property var rowModel: parent.rowModel
-        property var model: parent.colModel
-        readonly property bool containsMouse: parent.containsMouse
-        readonly property bool currentlyFocused: parent.currentlyFocused
-
-        anchors.fill: parent
-        spacing: VLCStyle.margin_normal
-
-        Image {
-            source: !rowModel ? VLCStyle.noArtCover : (rowModel.cover || VLCStyle.noArtCover)
-            mipmap: true // this widget can down scale the source a lot, so for better visuals we use mipmap
-
-            Layout.preferredHeight: VLCStyle.trackListAlbumCover_heigth
-            Layout.preferredWidth: VLCStyle.trackListAlbumCover_width
-
-            Widgets.PlayCover {
-                anchors.fill: parent
-                iconSize: VLCStyle.play_cover_small
-                visible: currentlyFocused || containsMouse
-
-                onIconClicked: medialib.addAndPlay( rowModel.id )
-            }
-        }
-
-        Widgets.ListLabel {
-            text: !rowModel ? "" : (rowModel[model.criteria] || "")
-
-            Layout.fillHeight: true
-            Layout.fillWidth: true
-        }
-    }
-
-    property Component titleHeaderDelegate: Row {
-        spacing: VLCStyle.margin_normal
-
-        Widgets.IconLabel {
-            width: VLCStyle.heightAlbumCover_xsmall
-            horizontalAlignment: Text.AlignHCenter
-            text: VLCIcons.album_cover
-            color: VLCStyle.colors.caption
-        }
-
-        Widgets.CaptionLabel {
-            text: model.text || ""
-        }
-    }
-
     sortModel: ( availableRowWidth < VLCStyle.colWidth(6) ) ? sortModelSmall
                                                             : ( availableRowWidth < VLCStyle.colWidth(9) )
                                                               ? sortModelMedium : sortModelLarge
diff --git a/modules/gui/qt/widgets/qml/TableColumns.qml b/modules/gui/qt/widgets/qml/TableColumns.qml
index b04839677c..aa91e587b2 100644
--- a/modules/gui/qt/widgets/qml/TableColumns.qml
+++ b/modules/gui/qt/widgets/qml/TableColumns.qml
@@ -17,12 +17,61 @@
  *****************************************************************************/
 import QtQuick 2.11
 import QtQuick.Controls 2.4
+import QtQuick.Layouts 1.4
 
 import "qrc:///widgets/" as Widgets
 import "qrc:///style/"
 
 Item {
 
+    property Component titleDelegate: RowLayout {
+        property var rowModel: parent.rowModel
+        property var model: parent.colModel
+        readonly property bool containsMouse: parent.containsMouse
+        readonly property bool currentlyFocused: parent.currentlyFocused
+
+        anchors.fill: parent
+        spacing: VLCStyle.margin_normal
+
+        Image {
+            source: !rowModel ? VLCStyle.noArtCover : (rowModel.cover || VLCStyle.noArtCover)
+            mipmap: true // this widget can down scale the source a lot, so for better visuals we use mipmap
+
+            Layout.preferredHeight: VLCStyle.trackListAlbumCover_heigth
+            Layout.preferredWidth: VLCStyle.trackListAlbumCover_width
+
+            Widgets.PlayCover {
+                anchors.fill: parent
+                iconSize: VLCStyle.play_cover_small
+                visible: currentlyFocused || containsMouse
+
+                onIconClicked: medialib.addAndPlay( rowModel.id )
+            }
+        }
+
+        Widgets.ListLabel {
+            text: !rowModel ? "" : (rowModel[model.criteria] || "")
+
+            Layout.fillHeight: true
+            Layout.fillWidth: true
+        }
+    }
+
+    property Component titleHeaderDelegate: Row {
+        spacing: VLCStyle.margin_normal
+
+        Widgets.IconLabel {
+            width: VLCStyle.heightAlbumCover_xsmall
+            horizontalAlignment: Text.AlignHCenter
+            text: VLCIcons.album_cover
+            color: VLCStyle.colors.caption
+        }
+
+        Widgets.CaptionLabel {
+            text: model.text || ""
+        }
+    }
+
     property Component timeHeaderDelegate: Widgets.IconLabel {
         width: timeTextMetric.width
         horizontalAlignment: Text.AlignHCenter



More information about the vlc-commits mailing list