[gnome-music/wip/mschraal/core: 75/118] coremodel: Sort albums



commit 64836e514c728418490994588c0609b9db5c1bf4
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Jun 20 15:41:42 2019 +0200

    coremodel: Sort albums

 gnomemusic/coremodel.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index d0b13e5a..7f413cb2 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -49,7 +49,12 @@ class CoreModel(GObject.GObject):
 
         self._test = Gfm.FilterListModel()
         self._model = Gio.ListStore.new(CoreSong)
+
         self._album_model = Gio.ListStore()
+        self._album_model_sort = Gfm.SortListModel.new(self._album_model)
+        self._album_model_sort.set_sort_func(
+            self._wrap_list_store_sort_func(self._albums_sort))
+
         self._artist_model = Gio.ListStore.new(CoreArtist)
 
         self._playlist_model = Gio.ListStore.new(CoreSong)
@@ -63,6 +68,9 @@ class CoreModel(GObject.GObject):
             self._model, self._hash, self._url_hash, self._album_model,
             self._artist_model)
 
+    def _albums_sort(self, album_a, album_b):
+        return album_b.props.title.lower() < album_a.props.title.lower()
+
     @log
     def get_model(self):
         return self._model
@@ -200,7 +208,7 @@ class CoreModel(GObject.GObject):
 
     @log
     def get_albums_model(self):
-        return self._album_model
+        return self._album_model_sort
 
     def get_artists_model(self):
         return self._artist_model


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