banshee r3950 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Sources src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/Models



Author: gburt
Date: Thu May 22 00:57:07 2008
New Revision: 3950
URL: http://svn.gnome.org/viewvc/banshee?rev=3950&view=rev

Log:
2008-05-21  Gabriel Burt  <gabriel burt gmail com>

	* src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/PodcastSource.cs:
	* src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/Models/PodcastFeedModel.cs:
	* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseBrowsableListModel.cs:
	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs:
	Change BrowsableListModels to automatically filter on any 'upstream'
	filters (ones defined before them), so upshot is albums filters on artists
	again.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseBrowsableListModel.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
   trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/Models/PodcastFeedModel.cs
   trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/PodcastSource.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumListModel.cs	Thu May 22 00:57:07 2008
@@ -41,8 +41,8 @@
 {
     public class DatabaseAlbumListModel : DatabaseBrowsableListModel<DatabaseAlbumInfo, AlbumInfo>
     {
-        public DatabaseAlbumListModel (DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid) 
-            : base (trackModel, connection, DatabaseAlbumInfo.Provider, new AlbumInfo (null), uuid)
+        public DatabaseAlbumListModel ( Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid) 
+            : base (source, trackModel, connection, DatabaseAlbumInfo.Provider, new AlbumInfo (null), uuid)
         {
             ReloadFragmentFormat = @"
                 FROM CoreAlbums INNER JOIN CoreArtists ON CoreAlbums.ArtistID = CoreArtists.ArtistID
@@ -50,6 +50,7 @@
                         (SELECT CoreTracks.AlbumID FROM CoreTracks, CoreCache{0}
                             WHERE CoreCache.ModelID = {1} AND
                                   CoreCache.ItemId = {2})
+                    {3}
                     ORDER BY CoreAlbums.TitleLowered, CoreArtists.NameLowered";
         }
         

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseArtistListModel.cs	Thu May 22 00:57:07 2008
@@ -40,8 +40,8 @@
 {
     public class DatabaseArtistListModel : DatabaseBrowsableListModel<DatabaseArtistInfo, ArtistInfo>
     {
-        public DatabaseArtistListModel (DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid) 
-            : base (trackModel, connection, DatabaseArtistInfo.Provider, new ArtistInfo (null), uuid)
+        public DatabaseArtistListModel ( Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid) 
+            : base (source, trackModel, connection, DatabaseArtistInfo.Provider, new ArtistInfo (null), uuid)
         {
             ReloadFragmentFormat = @"
                 FROM CoreArtists 
@@ -53,7 +53,7 @@
         }
         
         public override string FilterColumn {
-            get { return "CoreTracks.ArtistID"; }
+            get { return "CoreArtists.ArtistID"; }
         }
         
         public override string ItemToFilterValue (object item)
@@ -66,4 +66,4 @@
             select_all_item.Name = String.Format ("All Artists ({0})", count);
         }
     }
-}
\ No newline at end of file
+}

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseBrowsableListModel.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseBrowsableListModel.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseBrowsableListModel.cs	Thu May 22 00:57:07 2008
@@ -55,6 +55,7 @@
     {
         private readonly BansheeModelCache<T> cache;
         private readonly DatabaseTrackListModel browsing_model;
+        private readonly Banshee.Sources.DatabaseSource source;
         
         private long count;
         private string reload_fragment;
@@ -67,9 +68,10 @@
         
         protected readonly U select_all_item;
 
-        public DatabaseBrowsableListModel (DatabaseTrackListModel trackModel, BansheeDbConnection connection, SqliteModelProvider<T> provider, U selectAllItem, string uuid)
+        public DatabaseBrowsableListModel ( Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, SqliteModelProvider<T> provider, U selectAllItem, string uuid)
             : base ()
         {
+            this.source = source;
             browsing_model = trackModel;
             select_all_item = selectAllItem;
             
@@ -110,10 +112,51 @@
                 browsing_model.CachesJoinTableEntries ? browsing_model.JoinFragment : null,
                 browsing_model.CacheId,
                 browsing_model.CachesJoinTableEntries
-                    ? String.Format ("{0}.{1} AND CoreTracks.TrackID = {0}.{2}", browsing_model.JoinTable, browsing_model.JoinPrimaryKey, browsing_model.JoinColumn)
-                    : "CoreTracks.TrackID"
+                    ? String.Format (
+                        "{0}.{1} AND CoreTracks.TrackID = {0}.{2}",
+                        browsing_model.JoinTable, browsing_model.JoinPrimaryKey, browsing_model.JoinColumn
+                    ) : "CoreTracks.TrackID",
+                GetFilterFragment ()
             );
         }
+
+        private string GetFilterFragment ()
+        {
+            StringBuilder qb = new StringBuilder ();
+            foreach (IFilterListModel model in UpstreamFilters) {
+                string filter = GetFilterFromModel (model);
+                if (filter != null) {
+                    qb.Append ("AND");
+                    qb.Append (filter);
+                }
+            }
+            return qb.ToString ();
+        }
+
+        private IEnumerable<IFilterListModel> UpstreamFilters {
+            get {
+                foreach (IFilterListModel model in source.FilterModels) {
+                    if (this == model) {
+                        break;
+                    } else {
+                        yield return model;
+                    }
+                }
+            }
+        }
+
+        // Ick, duplicated from DatabaseTrackListModel
+        private string GetFilterFromModel (IFilterListModel model)
+        {
+            string filter = null;
+            
+            ModelHelper.BuildIdFilter<object> (model.GetSelectedObjects (), model.FilterColumn, null,
+                delegate (object item) { return model.ItemToFilterValue (item); },
+                delegate (string new_filter) { filter = new_filter; }
+            );
+            
+            return filter;
+        }
         
         public abstract void UpdateSelectAllItem (long count);
 

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs	Thu May 22 00:57:07 2008
@@ -109,8 +109,8 @@
             InitializeTrackModel ();
 
             if (HasArtistAlbum) {
-                artist_model = new DatabaseArtistListModel (DatabaseTrackModel, ServiceManager.DbConnection, UniqueId);
-                album_model = new DatabaseAlbumListModel (DatabaseTrackModel, ServiceManager.DbConnection, UniqueId);
+                artist_model = new DatabaseArtistListModel (this, DatabaseTrackModel, ServiceManager.DbConnection, UniqueId);
+                album_model = new DatabaseAlbumListModel (this, DatabaseTrackModel, ServiceManager.DbConnection, UniqueId);
             }
 
             reload_limiter = new RateLimiter (RateLimitedReload);

Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/Models/PodcastFeedModel.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/Models/PodcastFeedModel.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/Models/PodcastFeedModel.cs	Thu May 22 00:57:07 2008
@@ -42,8 +42,8 @@
 {
     public class PodcastFeedModel : DatabaseBrowsableListModel<Feed, Feed>
     {
-        public PodcastFeedModel (DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid) 
-            : base (trackModel, connection, Feed.Provider, new Feed (null, FeedAutoDownload.None), uuid)
+        public PodcastFeedModel (Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid) 
+            : base (source, trackModel, connection, Feed.Provider, new Feed (null, FeedAutoDownload.None), uuid)
         {
             ReloadFragmentFormat = @"
                 FROM PodcastSyndications WHERE FeedID IN

Modified: trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/PodcastSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/PodcastSource.cs	(original)
+++ trunk/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastManager/Source/PodcastSource.cs	Thu May 22 00:57:07 2008
@@ -198,7 +198,7 @@
             TrackCache = new DatabaseTrackModelCache<PodcastTrackInfo> (ServiceManager.DbConnection,
                     UniqueId, track_model, track_provider);
                     
-            feed_model = new PodcastFeedModel (DatabaseTrackModel, ServiceManager.DbConnection, "PodcastFeeds");
+            feed_model = new PodcastFeedModel (this, DatabaseTrackModel, ServiceManager.DbConnection, "PodcastFeeds");
             
             AfterInitialized ();
         }



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