[gnome-music/wip/mschraal/core: 98/164] coremodel: Sort artists model



commit 4fc7db15a3e7e9fb25e6cb30d3579ec13c47fb2f
Author: Marinus Schraal <mschraal gnome org>
Date:   Sun Jun 23 15:25:04 2019 +0200

    coremodel: Sort artists model

 gnomemusic/coremodel.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 24ad6866..dc25ce47 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -53,6 +53,9 @@ class CoreModel(GObject.GObject):
             self._wrap_list_store_sort_func(self._albums_sort))
 
         self._artist_model = Gio.ListStore.new(CoreArtist)
+        self._artist_model_sort = Gfm.SortListModel.new(self._artist_model)
+        self._artist_model_sort.set_sort_func(
+            self._wrap_list_store_sort_func(self._artist_sort))
 
         self._playlist_model = Gio.ListStore.new(CoreSong)
         self._playlist_model_sort = Gfm.SortListModel.new(self._playlist_model)
@@ -79,6 +82,9 @@ class CoreModel(GObject.GObject):
     def _albums_sort(self, album_a, album_b):
         return album_b.props.title.lower() < album_a.props.title.lower()
 
+    def _artist_sort(self, artist_a, artist_b):
+        return artist_b.props.artist.lower() < artist_a.props.artist.lower()
+
     @log
     def get_model(self):
         return self._model
@@ -185,7 +191,7 @@ class CoreModel(GObject.GObject):
         return self._album_model_sort
 
     def get_artists_model(self):
-        return self._artist_model
+        return self._artist_model_sort
 
     def get_artist_albums(self, artist):
         albums = self._grilo.get_artist_albums(artist)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]