[gnome-music/wip/mschraal/coremodel-flatten-search-models: 42/42] coremodel: Use flattened wrapper models for all searches
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/coremodel-flatten-search-models: 42/42] coremodel: Use flattened wrapper models for all searches
- Date: Sat, 31 Oct 2020 10:16:14 +0000 (UTC)
commit a3ffdc1aa84688fde91eae40c668fe4445391545
Author: Marinus Schraal <mschraal gnome org>
Date: Mon Aug 31 23:21:16 2020 +0200
coremodel: Use flattened wrapper models for all searches
Using per-wrapper models for searches makes for a lot cleaner object
handling within the wrappers. This was already the case for songs, not
yet for albums and artists. This commit fixes that omission.
gnomemusic/coremodel.py | 34 +++++++++++++++++----------
gnomemusic/grilowrappers/grltrackerwrapper.py | 15 ++++++++----
2 files changed, 32 insertions(+), 17 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 2a3f7967..8e1cf8c4 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -116,19 +116,19 @@ class CoreModel(GObject.GObject):
self._songs_search_flatten = Gfm.FlattenListModel.new(CoreSong)
self._songs_search_flatten.set_model(self._songs_search_proxy)
- self._albums_search_model = Gfm.FilterListModel.new(
- self._albums_model)
- self._albums_search_model.set_filter_func(lambda a: False)
+ self._albums_search_proxy = Gio.ListStore.new(Gfm.FilterListModel)
+ self._albums_search_flatten = Gfm.FlattenListModel.new(CoreAlbum)
+ self._albums_search_flatten.set_model(self._albums_search_proxy)
self._albums_search_filter = Gfm.FilterListModel.new(
- self._albums_search_model)
+ self._albums_search_flatten)
- self._artists_search_model = Gfm.FilterListModel.new(
- self._artists_model)
- self._artists_search_model.set_filter_func(lambda a: False)
+ self._artists_search_proxy = Gio.ListStore.new(Gfm.FilterListModel)
+ self._artists_search_flatten = Gfm.FlattenListModel.new(CoreArtist)
+ self._artists_search_flatten.set_model(self._artists_search_proxy)
self._artists_search_filter = Gfm.FilterListModel.new(
- self._artists_search_model)
+ self._artists_search_flatten)
self._playlists_model = Gio.ListStore.new(Playlist)
self._playlists_model_filter = Gfm.FilterListModel.new(
@@ -421,10 +421,10 @@ class CoreModel(GObject.GObject):
return self._songs_search_proxy
@GObject.Property(
- type=Gfm.FilterListModel, default=None,
+ type=Gfm.FlattenListModel, default=None,
flags=GObject.ParamFlags.READABLE)
def albums_search(self):
- return self._albums_search_model
+ return self._albums_search_flatten
@GObject.Property(
type=Gfm.FilterListModel, default=None,
@@ -433,10 +433,15 @@ class CoreModel(GObject.GObject):
return self._albums_search_filter
@GObject.Property(
- type=Gfm.FilterListModel, default=None,
+ type=Gio.ListStore, default=None, flags=GObject.ParamFlags.READABLE)
+ def albums_search_proxy(self):
+ return self._albums_search_proxy
+
+ @GObject.Property(
+ type=Gfm.FlattenListModel, default=None,
flags=GObject.ParamFlags.READABLE)
def artists_search(self):
- return self._artists_search_model
+ return self._artists_search_flatten
@GObject.Property(
type=Gfm.FilterListModel, default=None,
@@ -444,6 +449,11 @@ class CoreModel(GObject.GObject):
def artists_search_filter(self):
return self._artists_search_filter
+ @GObject.Property(
+ type=Gio.ListStore, default=None, flags=GObject.ParamFlags.READABLE)
+ def artists_search_proxy(self):
+ return self._artists_search_proxy
+
@GObject.Property(
type=Gtk.ListStore, default=None, flags=GObject.ParamFlags.READABLE)
def songs_gtkliststore(self):
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 92d65cb8..41314cd2 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -117,9 +117,6 @@ class GrlTrackerWrapper(GObject.GObject):
self._artist_ids: Dict[str, CoreArtist] = {}
self._hash: Dict[str, CoreSong] = {}
self._song_search_proxy: Gio.ListStore = cm.props.songs_search_proxy
- self._album_search_model: Gfm.FilterListModel = cm.props.albums_search
- self._artist_search_model: Gfm.FilterListModel = (
- cm.props.artists_search)
self._batch_changed_media_ids: Dict[
Grl.SourceChangeType, List[str]] = {}
self._content_changed_timeout: int = 0
@@ -132,6 +129,14 @@ class GrlTrackerWrapper(GObject.GObject):
self._song_search_tracker.set_filter_func(lambda a: False)
self._song_search_proxy.append(self._song_search_tracker)
+ self._albums_search = Gfm.FilterListModel.new(self._albums_model)
+ self._albums_search.set_filter_func(lambda a: False)
+ cm.props.albums_search_proxy.append(self._albums_search)
+
+ self._artists_search = Gfm.FilterListModel.new(self._artists_model)
+ self._artists_search.set_filter_func(lambda a: False)
+ cm.props.artists_search_proxy.append(self._artists_search)
+
self._fast_options: Grl.OperationOptions = Grl.OperationOptions()
self._fast_options.set_resolution_flags(
Grl.ResolutionFlags.FAST_ONLY | Grl.ResolutionFlags.IDLE_RELAY)
@@ -960,7 +965,7 @@ class GrlTrackerWrapper(GObject.GObject):
return
if not media:
- self._artist_search_model.set_filter_func(artist_filter)
+ self._artists_search.set_filter_func(artist_filter)
self._notificationmanager.pop_loading()
return
@@ -1029,7 +1034,7 @@ class GrlTrackerWrapper(GObject.GObject):
return
if not media:
- self._album_search_model.set_filter_func(album_filter)
+ self._albums_search.set_filter_func(album_filter)
self._notificationmanager.pop_loading()
return
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]