Commit cd89555e authored by Prince Gupta's avatar Prince Gupta Committed by Pierre Lamot
Browse files

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's avatarPierre Lamot <pierre@videolabs.io>
parent 03394c2d
......@@ -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) {
......
......@@ -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)
: ({})
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment