[vlc-commits] qml: fix invalid artist in MusicArtistAlbumView
Prince Gupta
git at videolan.org
Wed Jan 27 09:25:31 UTC 2021
vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Fri Jan 8 00:14:31 2021 +0530| [cd89555e27a3803fa6b485e07922226d01f77ce2] | committer: Pierre Lamot
qml: fix invalid artist in MusicArtistAlbumView
data is loaded asyncronously so on initial query invalid artist id will be set, make sure to update the id on model change
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cd89555e27a3803fa6b485e07922226d01f77ce2
---
modules/gui/qt/medialibrary/qml/MusicArtist.qml | 5 +++--
.../gui/qt/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)
- : ({})
}
}
}
More information about the vlc-commits
mailing list