[vlc-devel] [PATCH] qml: fix invalid artist in MusicArtistAlbumView

Prince Gupta guptaprince8832 at gmail.com
Fri Jan 22 16:20:01 UTC 2021


data is loaded asyncronously so on initial query invalid artist id will be set, make sure to update the id on model change
---
 .../gui/qt/medialibrary/qml/MusicArtist.qml   |  5 ++--
 .../medialibrary/qml/MusicArtistsAlbums.qml   | 23 +++++++------------
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/modules/gui/qt/medialibrary/qml/MusicArtist.qml b/modules/gui/qt/medialibrary/qml/MusicArtist.qml
index 4cb8d5cd13..48d11dddf2 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtist.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtist.qml
@@ -30,7 +30,6 @@ import "qrc:///style/"
 Widgets.NavigableFocusScope {
     id: root
 
-    property alias parentId: albumModel.parentId
     property var artist: ({})
     readonly property var currentIndex: headerItem.albumsListView.currentIndex || view.currentItem.currentIndex
     property Item headerItem: view.currentItem.headerItem
@@ -199,7 +198,9 @@ Widgets.NavigableFocusScope {
 
     MLAlbumModel {
         id: albumModel
+
         ml: medialib
+        parentId: artist.id
 
         onCountChanged: {
             if (albumModel.count > 0 && !albumSelectionModel.hasSelection) {
@@ -238,7 +239,7 @@ Widgets.NavigableFocusScope {
         id: trackModel
 
         ml: medialib
-        parentId: root.parentId
+        parentId: albumModel.parentId
 
         onCountChanged: {
             if (trackModel.count > 0) {
diff --git a/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml b/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
index c82c01410f..2f72223fae 100644
--- a/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
+++ b/modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
@@ -29,20 +29,21 @@ import "qrc:///style/"
 
 Widgets.NavigableFocusScope {
     id: root
+
     property alias model: artistModel
     property var sortModel: [
         { text: i18n.qtr("Alphabetic"),  criteria: "title" }
     ]
 
-    property var artistId
-
     property alias currentIndex: artistList.currentIndex
     property alias currentAlbumIndex: albumSubView.currentIndex
     property int initialIndex: 0
     property int initialAlbumIndex: 0
+    property alias currentArtist: albumSubView.artist
 
     onInitialAlbumIndexChanged: resetFocus()
     onInitialIndexChanged: resetFocus()
+    onCurrentIndexChanged: currentArtist = model.getDataAt(currentIndex)
 
     function resetFocus() {
         if (artistModel.count === 0) {
@@ -76,6 +77,11 @@ Widgets.NavigableFocusScope {
                 artistList.currentIndex = initialIndex
             }
         }
+
+        onDataChanged: {
+            if (topLeft.row <= currentIndex && bottomRight.row >= currentIndex)
+                currentArtist = artistModel.getDataAt(currentIndex)
+        }
     }
 
     Util.SelectableDelegateModel {
@@ -114,14 +120,6 @@ Widgets.NavigableFocusScope {
             footer: MainInterface.MiniPlayerBottomMargin {
             }
 
-            onCurrentIndexChanged: {
-                if (artistList.currentIndex < artistModel.count) {
-                    root.artistId =  artistModel.getIdForIndex(artistList.currentIndex)
-                } else {
-                    root.artistId = undefined
-                }
-            }
-
             navigationParent: root
             navigationRightItem: albumSubView
             navigationCancel: function() {
@@ -196,7 +194,6 @@ Widgets.NavigableFocusScope {
                     hoverEnabled: true
 
                     onClicked: {
-                        artistId = model.id
                         selectionModel.updateSelection( mouse.modifiers , artistList.currentIndex, index)
                         artistList.currentIndex = index
                         artistList.forceActiveFocus()
@@ -239,13 +236,9 @@ Widgets.NavigableFocusScope {
             height: parent.height
             width: root.width - artistList.width
             focus: true
-            parentId: root.artistId
             initialIndex: root.initialAlbumIndex
             navigationParent: root
             navigationLeftItem: artistList
-            artist: (artistList.currentIndex >= 0)
-                    ? artistModel.getDataAt(artistList.currentIndex)
-                    : ({})
         }
     }
     }
-- 
2.25.1



More information about the vlc-devel mailing list