[vlc-devel] [PATCH 06/55] qml: use backend function for sorting in Playlist

Fatih Uzunoglu fuzun54 at outlook.com
Thu Jan 7 21:36:19 UTC 2021


---
 .../gui/qt/playlist/qml/PlaylistListView.qml  | 12 -----------
 .../qt/playlist/qml/PlaylistOverlayMenu.qml   | 20 +++++++++----------
 .../gui/qt/playlist/qml/PlaylistToolbar.qml   |  2 +-
 3 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/modules/gui/qt/playlist/qml/PlaylistListView.qml b/modules/gui/qt/playlist/qml/PlaylistListView.qml
index 1def0d4c61..fc0e8ecea0 100644
--- a/modules/gui/qt/playlist/qml/PlaylistListView.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistListView.qml
@@ -61,18 +61,6 @@ Widgets.NavigableFocusScope {
         drop.accept(Qt.IgnoreAction)
     }
 
-    function sortPL(key) {
-        if (mainPlaylistController.sortKey !== key) {
-            mainPlaylistController.setSortOrder(PlaylistControllerModel.SORT_ORDER_ASC)
-            mainPlaylistController.setSortKey(key)
-        }
-        else {
-            mainPlaylistController.switchSortOrder()
-        }
-
-        mainPlaylistController.sort()
-    }
-
     PlaylistOverlayMenu {
         id: overlayMenu
         anchors.fill: parent
diff --git a/modules/gui/qt/playlist/qml/PlaylistOverlayMenu.qml b/modules/gui/qt/playlist/qml/PlaylistOverlayMenu.qml
index 01d3f89bff..37a5f66236 100644
--- a/modules/gui/qt/playlist/qml/PlaylistOverlayMenu.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistOverlayMenu.qml
@@ -199,7 +199,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortTitleAction
         text: i18n.qtr("Title")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_TITLE
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
@@ -208,7 +208,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortDurationAction
         text: i18n.qtr("Duration")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_DURATION
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
@@ -217,7 +217,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortArtistAction
         text: i18n.qtr("Artist")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_ARTIST
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
@@ -226,7 +226,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortAlbumAction
         text: i18n.qtr("Album")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_ALBUM
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
@@ -235,7 +235,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortAlbumArtistAction
         text: i18n.qtr("Album Artist")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_ALBUM_ARTIST
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
@@ -244,7 +244,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortGenreAction
         text: i18n.qtr("Genre")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_GENRE
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
@@ -253,7 +253,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortDateAction
         text: i18n.qtr("Date")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_DATE
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
@@ -262,7 +262,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortTrackNumberAction
         text: i18n.qtr("Track Number")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_TRACK_NUMBER
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
@@ -271,7 +271,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortURLAction
         text: i18n.qtr("URL")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_URL
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
@@ -280,7 +280,7 @@ Widgets.OverlayMenu {
     Action {
         id: sortRatingAction
         text: i18n.qtr("Rating")
-        onTriggered: root.sortPL(key)
+        onTriggered: mainPlaylistController.sort(key)
         readonly property int key: PlaylistControllerModel.SORT_KEY_RATING
         readonly property string marking: sortOrderMarkRetriever(key)
         readonly property bool tickMark: (key === mainPlaylistController.sortKey)
diff --git a/modules/gui/qt/playlist/qml/PlaylistToolbar.qml b/modules/gui/qt/playlist/qml/PlaylistToolbar.qml
index 44be0441d7..6a3c4fdf8b 100644
--- a/modules/gui/qt/playlist/qml/PlaylistToolbar.qml
+++ b/modules/gui/qt/playlist/qml/PlaylistToolbar.qml
@@ -102,7 +102,7 @@ Widgets.NavigableFocusScope {
 
                 listWidth: VLCStyle.widthSortBox
                 onSortSelected: {
-                    root.sortPL(modelData.criteria)
+                    mainPlaylistController.sort(modelData.criteria)
                 }
 
                 colors: playlistToolbar.colors
-- 
2.27.0



More information about the vlc-devel mailing list