Browse Source

qml: make use of sort and search properties in list mode in `MusicArtist`

The horizontal album view is gone, so the sort menu should
be applicable to the audio model that is used by the sole
vertical list view.
pull/200/head
Fatih Uzunoglu 6 months ago
committed by Steve Lhomme
parent
commit
4786e505ff
  1. 43
      modules/gui/qt/medialibrary/qml/MusicArtist.qml
  2. 11
      modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
  3. 15
      modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml

43
modules/gui/qt/medialibrary/qml/MusicArtist.qml

@ -52,9 +52,46 @@ FocusScope {
property bool isSearchable: true
property alias searchPattern: albumModel.searchPattern
property alias sortOrder: albumModel.sortOrder
property alias sortCriteria: albumModel.sortCriteria
property string searchPattern
property int sortOrder
property string sortCriteria
readonly property MLBaseModel _effectiveModel: MainCtx.gridView ? albumModel : trackModel
onSearchPatternChanged: {
_effectiveModel.searchPattern = root.searchPattern
}
onSortOrderChanged: {
_effectiveModel.sortOrder = root.sortOrder
}
onSortCriteriaChanged: {
// FIXME: Criteria is set to empty for a brief period during initialization,
// call later prevents setting the criteria empty.
Qt.callLater(() => {
_effectiveModel.sortCriteria = root.sortCriteria
})
}
Connections {
target: root._effectiveModel
function onSearchPatternChanged() {
if (root.searchPattern !== root._effectiveModel.searchPattern)
root.searchPattern = root._effectiveModel.searchPattern
}
function onSortOrderChanged() {
if (root.sortOrder !== root._effectiveModel.sortOrder)
root.sortOrder = root._effectiveModel.sortOrder
}
function onSortCriteriaChanged() {
if (root.sortCriteria !== root._effectiveModel.sortCriteria)
root.sortCriteria = root._effectiveModel.sortCriteria
}
}
// current index of album model
readonly property int currentIndex: {

11
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml

@ -36,9 +36,14 @@ FocusScope {
property int leftPadding: 0
property int rightPadding: 0
property var sortModel: [
{ text: qsTr("Alphabetic"), criteria: "title" },
{ text: qsTr("Release Year"), criteria: "release_year" }
property var sortModel: MainCtx.gridView ? [
{ text: qsTr("Title"), criteria: "title" },
{ text: qsTr("Release Year"), criteria: "release_year" },
] : [
{ text: qsTr("Title"), criteria: "title" },
{ text: qsTr("Release Year"), criteria: "release_year" },
{ text: qsTr("Album Title"), criteria: "album_title" },
{ text: qsTr("Duration"), criteria: "duration" }
]
property SortMenuAlbums sortMenu: SortMenuAlbums {

15
modules/gui/qt/medialibrary/qml/MusicArtistsDisplay.qml

@ -86,6 +86,21 @@ Widgets.PageLoader {
sortOrder: MainCtx.sort.order
sortCriteria: MainCtx.sort.criteria
onSearchPatternChanged: {
MainCtx.search.pattern = searchPattern
seachPattern = Qt.binding(() => { return MainCtx.search.pattern })
}
onSortOrderChanged: {
MainCtx.sort.order = sortOrder
sortOrder = Qt.binding(() => { return MainCtx.sort.order })
}
onSortCriteriaChanged: {
MainCtx.sort.criteria = sortCriteria
sortCriteria = Qt.binding(() => { return MainCtx.sort.criteria })
}
displayMarginBeginning: root.displayMarginBeginning
displayMarginEnd: root.displayMarginEnd

Loading…
Cancel
Save