[gnome-music/wip/mschraal/coremodel-flatten-search-models] 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] coremodel: Use flattened wrapper models for all searches
- Date: Mon, 31 Aug 2020 21:43:00 +0000 (UTC)
commit 946fbe695c3323eacd8222e6f6afc2e689446fc2
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 | 14 +++++++----
2 files changed, 32 insertions(+), 16 deletions(-)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 7d8f8173..d6550952 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 96b19897..fcea1a74 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -104,8 +104,6 @@ class GrlTrackerWrapper(GObject.GObject):
self._artist_ids = {}
self._hash = {}
self._song_search_proxy = coremodel.props.songs_search_proxy
- self._album_search_model = coremodel.props.albums_search
- self._artist_search_model = coremodel.props.artists_search
self._batch_changed_media_ids = {}
self._content_changed_timeout = None
self._tracker_playlists = None
@@ -116,6 +114,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)
+ coremodel.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)
+ coremodel.props.artists_search_proxy.append(self._artists_search)
+
self._fast_options = Grl.OperationOptions()
self._fast_options.set_resolution_flags(
Grl.ResolutionFlags.FAST_ONLY | Grl.ResolutionFlags.IDLE_RELAY)
@@ -913,7 +919,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
@@ -980,7 +986,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]