Commit d3da0c14 authored by Pierre Lamot's avatar Pierre Lamot
Browse files

qml: don't positionViewAtIndex before view is loaded

parent ccb22bae
......@@ -68,7 +68,8 @@ Widgets.NavigableFocusScope {
if (initialIndex >= albumModelId.count)
initialIndex = 0
selectionModel.select(model.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
if (view.currentItem)
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
function _actionAtIndex(index) {
......
......@@ -181,8 +181,10 @@ Widgets.NavigableFocusScope {
initialIndex = 0
albumSelectionModel.select(albumModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
var albumsListView = medialib.gridView ? view.currentItem : headerItem.albumsListView
albumsListView.currentIndex = initialIndex
albumsListView.positionViewAtIndex(initialIndex, ItemView.Contain)
if (albumsListView) {
albumsListView.currentIndex = initialIndex
albumsListView.positionViewAtIndex(initialIndex, ItemView.Contain)
}
}
function _actionAtIndex(index, model, selectionModel) {
......
......@@ -52,8 +52,10 @@ Widgets.NavigableFocusScope {
initialIndex = 0
if (initialIndex !== artistList.currentIndex) {
selectionModel.select(artistModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
artistList.currentIndex = initialIndex
artistList.positionViewAtIndex(initialIndex, ItemView.Contain)
if (artistList) {
artistList.currentIndex = initialIndex
artistList.positionViewAtIndex(initialIndex, ItemView.Contain)
}
}
}
......
......@@ -102,8 +102,10 @@ Widgets.NavigableFocusScope {
if (initialIndex >= artistModel.count)
initialIndex = 0
selectionModel.select(artistModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
view.currentItem.currentIndex = initialIndex
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
if (view.currentItem) {
view.currentItem.currentIndex = initialIndex
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
}
MLArtistModel {
......
......@@ -67,7 +67,8 @@ Widgets.NavigableFocusScope {
if (initialIndex >= genreModel.count)
initialIndex = 0
selectionModel.select(genreModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
if (view.currentItem)
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
Connections {
......
......@@ -58,7 +58,8 @@ Widgets.NavigableFocusScope {
if (initialIndex >= videoModel.count)
initialIndex = 0
selectionModel.select(videoModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
if (view.currentItem)
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
function _actionAtIndex(index) {
......
......@@ -54,8 +54,10 @@ Widgets.NavigableFocusScope {
if (initialIndex >= providerModel.count)
initialIndex = 0
selectionModel.select(providerModel.index(initialIndex, 0), ItemSelectionModel.ClearAndSelect)
view.currentItem.currentIndex = initialIndex
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
if (view.currentItem) {
view.currentItem.currentIndex = initialIndex
view.currentItem.positionViewAtIndex(initialIndex, ItemView.Contain)
}
}
......
Supports Markdown
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