[vlc-commits] qml/VideoListDisplay: Add configuration for the 'mainCriteria'

Benjamin Arnaud git at videolan.org
Tue Apr 20 12:49:09 UTC 2021


vlc | branch: master | Benjamin Arnaud <benjamin.arnaud at videolabs.io> | Fri Mar 26 11:44:15 2021 +0100| [514f411a65e1091133f70eb868bef13ef20d9856] | committer: Pierre Lamot

qml/VideoListDisplay: Add configuration for the 'mainCriteria'

This makes the item more versatile. Also a little bit of cleanup.

Signed-off-by: Pierre Lamot <pierre at videolabs.io>

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

 .../gui/qt/medialibrary/qml/VideoListDisplay.qml   | 84 ++++++++++++++++------
 1 file changed, 64 insertions(+), 20 deletions(-)

diff --git a/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml b/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
index d0412dfae4..0e24c0d618 100644
--- a/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
+++ b/modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
@@ -29,13 +29,52 @@ import "qrc:///style/"
 MainInterface.MainTableView {
     id: listView_id
 
+    //---------------------------------------------------------------------------------------------
+    // Properties
+    //---------------------------------------------------------------------------------------------
+
+    // NOTE: This is useful for groups because our main criteria is 'name' instead of 'title'.
+    property string mainCriteria: "title"
+
+    //---------------------------------------------------------------------------------------------
+    // Private
+
     readonly property int _nbCols: VLCStyle.gridColumnsForWidth(listView_id.availableRowWidth)
 
-    sortModel: [
-        { type: "image", criteria: "thumbnail", width: VLCStyle.colWidth(1), showSection: "", colDelegate: tableColumns.titleDelegate, headerDelegate: tableColumns.titleHeaderDelegate },
-        { isPrimary: true, criteria: "title",   width: VLCStyle.colWidth(Math.max(listView_id._nbCols - 2, 1)), text: i18n.qtr("Title"),    showSection: "title" },
-        { criteria: "duration",                 width: VLCStyle.colWidth(1), showSection: "", colDelegate: tableColumns.timeColDelegate, headerDelegate: tableColumns.timeHeaderDelegate, showContextButton: true },
-    ]
+    //---------------------------------------------------------------------------------------------
+    // Settings
+    //---------------------------------------------------------------------------------------------
+
+    sortModel: [{
+        type: "image",
+
+        criteria: "thumbnail",
+
+        width: VLCStyle.colWidth(1),
+
+        showSection: "",
+
+        headerDelegate: tableColumns.titleHeaderDelegate,
+        colDelegate   : tableColumns.titleDelegate,
+    }, {
+        isPrimary: true,
+        criteria: mainCriteria,
+
+        width: VLCStyle.colWidth(Math.max(listView_id._nbCols - 2, 1)),
+
+        showSection: "title",
+
+        text: i18n.qtr("Title")
+    }, {
+        criteria: "duration_short",
+
+        width: VLCStyle.colWidth(1),
+
+        showSection: "",
+
+        headerDelegate: tableColumns.timeHeaderDelegate, showContextButton: true,
+        colDelegate   : tableColumns.timeColDelegate
+    }]
 
     section.property: "title_first_symbol"
 
@@ -43,8 +82,26 @@ MainInterface.MainTableView {
 
     headerColor: VLCStyle.colors.bg
 
-    onActionForSelection: medialib.addAndPlay(model.getIdsForIndexes( selection ))
-    onItemDoubleClicked: medialib.addAndPlay(model.id)
+    //---------------------------------------------------------------------------------------------
+    // Connections
+    //---------------------------------------------------------------------------------------------
+
+    Connections {
+        target: model
+        onSortCriteriaChanged: {
+            switch (model.sortCriteria) {
+            case "title":
+                listView_id.section.property = "title_first_symbol"
+                break;
+            default:
+                listView_id.section.property = ""
+            }
+        }
+    }
+
+    //---------------------------------------------------------------------------------------------
+    // Childs
+    //---------------------------------------------------------------------------------------------
 
     Widgets.TableColumns {
         id: tableColumns
@@ -60,17 +117,4 @@ MainInterface.MainTableView {
                     ].filter(function(a) { return a !== "" })
         }
     }
-
-    Connections {
-        target: model
-        onSortCriteriaChanged: {
-            switch (model.sortCriteria) {
-            case "title":
-                listView_id.section.property = "title_first_symbol"
-                break;
-            default:
-                listView_id.section.property = ""
-            }
-        }
-    }
 }



More information about the vlc-commits mailing list