[vlc-devel] [PATCH 08/12] qml/VideoListDisplay: Add configuration for the 'mainCriteria'

Benjamin Arnaud benjamin.arnaud at videolabs.io
Wed Apr 14 08:05:55 UTC 2021


This makes the item more versatile. Also a little bit of cleanup.
---
 .../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 = ""
-            }
-        }
-    }
 }
-- 
2.25.1



More information about the vlc-devel mailing list