[vlc-commits] [Git][videolan/vlc][master] 9 commits: qml/MusicAllArtists: Add a small TableView model

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Feb 10 16:48:03 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
7be7ead0 by Benjamin Arnaud at 2023-02-10T16:25:19+00:00
qml/MusicAllArtists: Add a small TableView model

- - - - -
8268323d by Benjamin Arnaud at 2023-02-10T16:25:19+00:00
qml/MusicAlbums: Add a small TableView model

- - - - -
4dd28e66 by Benjamin Arnaud at 2023-02-10T16:25:19+00:00
qml/MusicArtist: Add a small TableView model

- - - - -
2cd4e9bb by Benjamin Arnaud at 2023-02-10T16:25:19+00:00
qml/MusicGenres: Add a small TableView model

- - - - -
07a9dac1 by Benjamin Arnaud at 2023-02-10T16:25:19+00:00
qml/MusicTrackListDisplay: Add a small TableView model

- - - - -
2160d045 by Benjamin Arnaud at 2023-02-10T16:25:19+00:00
qml/PlaylistMedia: Add a small TableView model

- - - - -
a992bbb4 by Benjamin Arnaud at 2023-02-10T16:25:19+00:00
qml/PlaylistMediaList: Add a small TableView model

- - - - -
ecb517bb by Benjamin Arnaud at 2023-02-10T16:25:19+00:00
qml/TableColumns: Fix the 'getCriterias' function

- - - - -
fb14c6a1 by Benjamin Arnaud at 2023-02-10T16:25:19+00:00
qml/TableColumns: Add the 'nb_tracks' support

- - - - -


8 changed files:

- modules/gui/qt/medialibrary/qml/MusicAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
- modules/gui/qt/medialibrary/qml/MusicArtist.qml
- modules/gui/qt/medialibrary/qml/MusicGenres.qml
- modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
- modules/gui/qt/widgets/qml/TableColumns.qml


Changes:

=====================================
modules/gui/qt/medialibrary/qml/MusicAlbums.qml
=====================================
@@ -218,18 +218,24 @@ FocusScope {
 
             readonly property int _nbCols: VLCStyle.gridColumnsForWidth(tableView_id.availableRowWidth)
 
-            model: albumModelId
-            selectionDelegateModel: selectionModel
-            headerColor: VLCStyle.colors.bg
-            onActionForSelection: _actionAtIndex(selection[0]);
-            Navigation.parentItem: root
-            section.property: "title_first_symbol"
-            header: root.header
-            dragItem: albumDragItem
-            rowHeight: VLCStyle.tableCoverRow_height
-            headerTopPadding: VLCStyle.margin_normal
+            property var _modelSmall: [{
+                size: Math.max(2, tableView_id._nbCols),
+
+                model: ({
+                    criteria: "title",
+
+                    subCriterias: [ "main_artist", "duration" ],
+
+                    text: I18n.qtr("Title"),
+
+                    headerDelegate: tableColumns.titleHeaderDelegate,
+                    colDelegate: tableColumns.titleDelegate,
 
-            sortModel: [{
+                    placeHolder: VLCStyle.noArtAlbumCover
+                })
+            }]
+
+            property var _modelMedium: [{
                 size: 2,
 
                 model: {
@@ -243,7 +249,7 @@ FocusScope {
                     placeHolder: VLCStyle.noArtAlbumCover
                 }
             }, {
-                size: Math.max(tableView_id._nbCols - 3, 1),
+                size: Math.max(1, tableView_id._nbCols - 3),
 
                 model: {
                     criteria: "main_artist",
@@ -263,6 +269,20 @@ FocusScope {
                 }
             }]
 
+            model: albumModelId
+            selectionDelegateModel: selectionModel
+            headerColor: VLCStyle.colors.bg
+            onActionForSelection: _actionAtIndex(selection[0]);
+            Navigation.parentItem: root
+            section.property: "title_first_symbol"
+            header: root.header
+            dragItem: albumDragItem
+            rowHeight: VLCStyle.tableCoverRow_height
+            headerTopPadding: VLCStyle.margin_normal
+
+            sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+                                                                  : _modelMedium
+
             Navigation.cancelAction: root._onNavigationCancel
 
             onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
@@ -271,6 +291,8 @@ FocusScope {
 
             Widgets.TableColumns {
                 id: tableColumns
+
+                showCriterias: (tableView_id.sortModel === tableView_id._modelSmall)
             }
 
             Connections {


=====================================
modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
=====================================
@@ -174,29 +174,25 @@ FocusScope {
 
             readonly property int _nbCols: VLCStyle.gridColumnsForWidth(artistTable.availableRowWidth)
 
-            anchors.fill: parent
-            selectionDelegateModel: selectionModel
-            model: artistModel
-            focus: true
-            headerColor: VLCStyle.colors.bg
-            dragItem: artistsDragItem
-            rowHeight: VLCStyle.tableCoverRow_height
-            headerTopPadding: VLCStyle.margin_normal
+            property var _modelSmall: [{
+                size: Math.max(2, artistTable._nbCols),
 
-            Navigation.parentItem: root
-            Navigation.cancelAction: root._onNavigationCancel
+                model: ({
+                    criteria: "name",
 
-            onActionForSelection: {
-                if (selection.length > 1) {
-                    MediaLib.addAndPlay( artistModel.getIdsForIndexes( selection ) )
-                } else if ( selection.length === 1) {
-                    requestArtistAlbumView(Qt.TabFocusReason)
-                    MediaLib.addAndPlay( artistModel.getIdForIndex( selection[0] ) )
-                }
-            }
+                    subCriterias: [ "nb_tracks" ],
+
+                    text: I18n.qtr("Name"),
+
+                    headerDelegate: tableColumns.titleHeaderDelegate,
+                    colDelegate: tableColumns.titleDelegate,
+
+                    placeHolder: VLCStyle.noArtArtistSmall
+                })
+            }]
 
-            sortModel: [{
-                size: Math.max(artistTable._nbCols - 1, 1),
+            property var _modelMedium: [{
+                size: Math.max(1, artistTable._nbCols - 1),
 
                 model: {
                     criteria: "name",
@@ -218,6 +214,30 @@ FocusScope {
                 }
             }]
 
+            anchors.fill: parent
+            selectionDelegateModel: selectionModel
+            model: artistModel
+            focus: true
+            headerColor: VLCStyle.colors.bg
+            dragItem: artistsDragItem
+            rowHeight: VLCStyle.tableCoverRow_height
+            headerTopPadding: VLCStyle.margin_normal
+
+            Navigation.parentItem: root
+            Navigation.cancelAction: root._onNavigationCancel
+
+            onActionForSelection: {
+                if (selection.length > 1) {
+                    MediaLib.addAndPlay( artistModel.getIdsForIndexes( selection ) )
+                } else if ( selection.length === 1) {
+                    requestArtistAlbumView(Qt.TabFocusReason)
+                    MediaLib.addAndPlay( artistModel.getIdForIndex( selection[0] ) )
+                }
+            }
+
+            sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+                                                                  : _modelMedium
+
             onItemDoubleClicked: root.requestArtistAlbumView(Qt.MouseFocusReason)
 
             onContextMenuButtonClicked: contextMenu.popup(selectionModel.selectedIndexes, globalMousePos)
@@ -225,6 +245,8 @@ FocusScope {
 
             Widgets.TableColumns {
                 id: tableColumns
+
+                showCriterias: (artistTable.sortModel === artistTable._modelSmall)
             }
         }
     }


=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -408,7 +408,22 @@ FocusScope {
             headerPositioning: ListView.InlineHeader
             rowHeight: VLCStyle.tableCoverRow_height
 
-            sortModel: [{
+            property var _modelSmall: [{
+                size: Math.max(2, tableView_id._nbCols),
+
+                model: {
+                    criteria: "title",
+
+                    subCriterias: [ "duration", "album_title" ],
+
+                    text: I18n.qtr("Title"),
+
+                    headerDelegate: tableColumns.titleHeaderDelegate,
+                    colDelegate: tableColumns.titleDelegate
+                }
+            }]
+
+            property var _modelMedium: [{
                 size: 2,
 
                 model: {
@@ -420,7 +435,7 @@ FocusScope {
                     colDelegate: tableColumns.titleDelegate
                 }
             }, {
-                size: Math.max(tableView_id._nbCols - 3, 1),
+                size: Math.max(1, tableView_id._nbCols - 3),
 
                 model: {
                     criteria: "album_title",
@@ -440,6 +455,9 @@ FocusScope {
                 }
             }]
 
+            sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+                                                                  : _modelMedium
+
             Navigation.parentItem: root
 
             Navigation.upAction: function() {
@@ -464,6 +482,8 @@ FocusScope {
 
             Widgets.TableColumns {
                 id: tableColumns
+
+                showCriterias: (tableView_id.sortModel === tableView_id._modelSmall)
             }
 
             Util.SelectableDelegateModel {


=====================================
modules/gui/qt/medialibrary/qml/MusicGenres.qml
=====================================
@@ -236,25 +236,24 @@ FocusScope {
         MainInterface.MainTableView {
             id: tableView_id
 
-            property int _nameColSpan: Math.max(1, VLCStyle.gridColumnsForWidth(availableRowWidth) - 2)
+            property int _nbCols: VLCStyle.gridColumnsForWidth(availableRowWidth)
 
-            model: genreModel
-            selectionDelegateModel: selectionModel
-            headerColor: VLCStyle.colors.bg
-            focus: true
-            onActionForSelection: _actionAtIndex(selection)
-            Navigation.parentItem: root
-            Navigation.cancelAction: function() {
-                if (_currentView.currentIndex <= 0)
-                    root.Navigation.defaultNavigationCancel()
-                else
-                    _currentView.currentIndex = 0;
-            }
-            dragItem: genreDragItem
-            rowHeight: VLCStyle.tableCoverRow_height
-            headerTopPadding: VLCStyle.margin_normal
+            property var _modelSmall: [{
+                size: Math.max(2, tableView_id._nbCols),
+
+                model: {
+                    criteria: "name",
+
+                    subCriterias: [ "nb_tracks" ],
+
+                    text: I18n.qtr("Name"),
+
+                    headerDelegate: tableColumns.titleHeaderDelegate,
+                    colDelegate: tableColumns.titleDelegate
+                }
+            }]
 
-            sortModel: [{
+            property var _modelMedium: [{
                 size: 1,
 
                 model: {
@@ -264,7 +263,7 @@ FocusScope {
                     colDelegate: tableColumns.titleDelegate
                 }
             }, {
-                size: _nameColSpan,
+                size: Math.max(1, _nbCols - 2),
 
                 model: {
                     criteria: "name",
@@ -281,6 +280,26 @@ FocusScope {
                 }
             }]
 
+            model: genreModel
+
+            sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+                                                                  : _modelMedium
+
+            selectionDelegateModel: selectionModel
+            headerColor: VLCStyle.colors.bg
+            focus: true
+            onActionForSelection: _actionAtIndex(selection)
+            Navigation.parentItem: root
+            Navigation.cancelAction: function() {
+                if (_currentView.currentIndex <= 0)
+                    root.Navigation.defaultNavigationCancel()
+                else
+                    _currentView.currentIndex = 0;
+            }
+            dragItem: genreDragItem
+            rowHeight: VLCStyle.tableCoverRow_height
+            headerTopPadding: VLCStyle.margin_normal
+
             onItemDoubleClicked: {
                 root.showAlbumView(model.id, model.name, Qt.MouseFocusReason)
             }
@@ -291,7 +310,9 @@ FocusScope {
             Widgets.TableColumns {
                 id: tableColumns
 
-                showTitleText: false
+                showTitleText: (tableView_id.sortModel === tableView_id._modelSmall)
+                showCriterias: showTitleText
+
                 titleCover_height: VLCStyle.listAlbumCover_height
                 titleCover_width: VLCStyle.listAlbumCover_width
                 titleCover_radius: VLCStyle.listAlbumCover_radius


=====================================
modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
=====================================
@@ -32,9 +32,10 @@ Widgets.KeyNavigableTableView {
 
     // Properties
 
-    readonly property int _expandingColsSpan: Math.floor((VLCStyle.gridColumnsForWidth(root.availableRowWidth) - 3 /* static cols (track_number, etc)*/) / 3)
+    property int _nbCols: VLCStyle.gridColumnsForWidth(availableRowWidth)
 
-    property alias parentId: rootmodel.parentId
+    readonly property int _sizeA: Math.floor((_nbCols - 3) / 3)
+    readonly property int _sizeB: Math.floor((_nbCols - 2) / 2)
 
     // Private
 
@@ -95,15 +96,15 @@ Widgets.KeyNavigableTableView {
     })
 
     property var _modelLarge: [{
-        size: _expandingColsSpan,
+        size: _sizeA,
 
         model: _lineTitle
     }, {
-        size: _expandingColsSpan,
+        size: _sizeA,
 
         model: _lineAlbum
     }, {
-        size: _expandingColsSpan,
+        size: _sizeA,
 
         model: _lineArtist
     }, {
@@ -121,11 +122,11 @@ Widgets.KeyNavigableTableView {
     }]
 
     property var _modelMedium: [{
-        size: 2,
+        size: _sizeB,
 
         model: _lineTitle
     }, {
-        size: 2,
+        size: _sizeB,
 
         model: _lineAlbum
     }, {
@@ -139,25 +140,32 @@ Widgets.KeyNavigableTableView {
     }]
 
     property var _modelSmall: [{
-        size: 1,
+        size: Math.max(2, _nbCols),
 
-        model: _lineTitle
-    }, {
-        size: 1,
+        model: ({
+            criteria: "title",
 
-        model: _lineAlbum
-    }, {
-        size: 1,
+            subCriterias: [ "duration", "album_title" ],
 
-        model: _lineArtist
-    }, {
-        size: 1,
+            text: I18n.qtr("Title"),
 
-        model: _lineDuration
+            showSection: "title",
+
+            colDelegate: tableColumns.titleDelegate,
+            headerDelegate: tableColumns.titleHeaderDelegate,
+
+            placeHolder: VLCStyle.noArtAlbumCover
+        })
     }]
 
+    // Aliases
+
+    property alias parentId: rootmodel.parentId
+
+    // Settings
+
     sortModel: {
-        if (availableRowWidth < VLCStyle.colWidth(6))
+        if (availableRowWidth < VLCStyle.colWidth(4))
             return _modelSmall
         else if (availableRowWidth < VLCStyle.colWidth(9))
             return _modelMedium
@@ -186,6 +194,8 @@ Widgets.KeyNavigableTableView {
 
     Widgets.TableColumns {
         id: tableColumns
+
+        showCriterias: (root.sortModel === root._modelSmall)
     }
 
     MLAlbumTrackModel {


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
=====================================
@@ -44,17 +44,24 @@ MainInterface.MainTableView {
 
     property bool _before: true
 
-    //---------------------------------------------------------------------------------------------
-    // Settings
-    //---------------------------------------------------------------------------------------------
+    property var _modelSmall: [{
+        size: Math.max(2, columns),
 
-    rowHeight: VLCStyle.tableCoverRow_height
+        model: {
+            criteria: "title",
 
-    headerColor: VLCStyle.colors.bg
+            subCriterias: [ "duration" ],
 
-    acceptDrop: true
+            text: I18n.qtr("Title"),
+
+            headerDelegate: table.titleHeaderDelegate,
+            colDelegate   : table.titleDelegate,
+
+            placeHolder: VLCStyle.noArtAlbumCover
+        }
+    }]
 
-    sortModel: [{
+    property var _modelMedium: [{
         size: 1,
 
         model: {
@@ -68,7 +75,7 @@ MainInterface.MainTableView {
             placeHolder: VLCStyle.noArtAlbumCover
         }
     }, {
-        size: Math.max(columns - 2, 1),
+        size: Math.max(1, columns - 2),
 
         model: {
             criteria: "title",
@@ -86,6 +93,19 @@ MainInterface.MainTableView {
         }
     }]
 
+    //---------------------------------------------------------------------------------------------
+    // Settings
+    //---------------------------------------------------------------------------------------------
+
+    rowHeight: VLCStyle.tableCoverRow_height
+
+    headerColor: VLCStyle.colors.bg
+
+    acceptDrop: true
+
+    sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+                                                          : _modelMedium
+
     //---------------------------------------------------------------------------------------------
     // Events
     //---------------------------------------------------------------------------------------------
@@ -196,7 +216,8 @@ MainInterface.MainTableView {
         titleCover_height: VLCStyle.listAlbumCover_height
         titleCover_radius: VLCStyle.listAlbumCover_radius
 
-        showTitleText: false
+        showTitleText: (root.sortModel === root._modelSmall)
+        showCriterias: showTitleText
 
         criteriaCover: "thumbnail"
 


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
=====================================
@@ -329,22 +329,22 @@ FocusScope {
 
             property int _columns: Math.max(1, VLCStyle.gridColumnsForWidth(availableRowWidth) - 2)
 
-            //-------------------------------------------------------------------------------------
-            // Settings
-
-            rowHeight: VLCStyle.tableCoverRow_height
+            property var _modelSmall: [{
+                size: Math.max(2, _columns),
 
-            headerTopPadding: VLCStyle.margin_normal
-
-            model: root.model
+                model: {
+                    criteria: "name",
 
-            selectionDelegateModel: modelSelect
+                    subCriterias: [ "count" ],
 
-            dragItem: dragItemPlaylist
+                    text: I18n.qtr("Name"),
 
-            headerColor: VLCStyle.colors.bg
+                    headerDelegate: columns.titleHeaderDelegate,
+                    colDelegate   : columns.titleDelegate
+                }
+            }]
 
-            sortModel: [{
+            property var _modelMedium: [{
                 size: 1,
 
                 model: {
@@ -371,6 +371,24 @@ FocusScope {
                 }
             }]
 
+            //-------------------------------------------------------------------------------------
+            // Settings
+
+            rowHeight: VLCStyle.tableCoverRow_height
+
+            headerTopPadding: VLCStyle.margin_normal
+
+            model: root.model
+
+            sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+                                                                  : _modelMedium
+
+            selectionDelegateModel: modelSelect
+
+            dragItem: dragItemPlaylist
+
+            headerColor: VLCStyle.colors.bg
+
             Navigation.parentItem: root
             Navigation.cancelAction: root._onNavigationCancel
 
@@ -392,7 +410,8 @@ FocusScope {
             Widgets.TableColumns {
                 id: columns
 
-                showTitleText: false
+                showTitleText: (tableView.sortModel === tableView._modelSmall)
+                showCriterias: showTitleText
 
                 criteriaCover: "thumbnail"
 


=====================================
modules/gui/qt/widgets/qml/TableColumns.qml
=====================================
@@ -49,6 +49,9 @@ Item {
     }
 
     function getCriterias(colModel, rowModel) {
+        if (colModel === null || rowModel === null)
+            return ""
+
         var criterias = colModel.subCriterias
 
         if (criterias === undefined || criterias.length === 0)
@@ -59,13 +62,20 @@ Item {
         for (var i = 0; i < criterias.length; i++) {
             if (i) string += " • "
 
-            var criteria = rowModel[criterias[i]]
+            var criteria = criterias[i]
+
+            var value = rowModel[criteria]
 
             // NOTE: We can't use 'instanceof' because VLCTick is uncreatable.
-            if (criteria.toString().indexOf("VLCTick(") === 0)
-                string += criteria.formatShort()
-            else
-                string += criteria
+            if (value.toString().indexOf("VLCTick(") === 0) {
+
+                string += value.formatShort()
+            } else if (criteria === "nb_tracks") {
+
+                string += I18n.qtr("%1 tracks").arg(value)
+            } else {
+                string += value
+            }
         }
 
         return string
@@ -173,8 +183,7 @@ Item {
 
                 visible: root.showCriterias
 
-                text: (visible && titleDel.rowModel) ? root.getCriterias(titleDel.model,
-                                                                         titleDel.rowModel) : ""
+                text: (visible) ? root.getCriterias(titleDel.model, titleDel.rowModel) : ""
             }
         }
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/98266d395488590927f66e397de1cbdd11e2b1ad...fb14c6a1114ba2c5227eaf9d61cdc0831c66a0ed

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/98266d395488590927f66e397de1cbdd11e2b1ad...fb14c6a1114ba2c5227eaf9d61cdc0831c66a0ed
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list