Inheritance: Source, ITrackModelSource, IFilterableSource, IDurationAggregator, IFileSizeAggregator
Exemplo n.º 1
0
        protected virtual IEnumerable <IFilterListModel> CreateFiltersFor(DatabaseSource src)
        {
            if (!HasArtistAlbum)
            {
                yield break;
            }

            DatabaseAlbumArtistListModel      albumartist_model = new DatabaseAlbumArtistListModel(src, src.DatabaseTrackModel, ServiceManager.DbConnection, src.UniqueId);
            DatabaseArtistListModel           artist_model      = new DatabaseArtistListModel(src, src.DatabaseTrackModel, ServiceManager.DbConnection, src.UniqueId);
            DatabaseAlbumListModel            album_model       = new DatabaseAlbumListModel(src, src.DatabaseTrackModel, ServiceManager.DbConnection, src.UniqueId);
            DatabaseQueryFilterModel <string> genre_model       = new DatabaseQueryFilterModel <string> (src, src.DatabaseTrackModel, ServiceManager.DbConnection,
                                                                                                         Catalog.GetString("All Genres ({0})"), src.UniqueId, BansheeQuery.GenreField, "Genre");
            DatabaseYearListModel year_model = new DatabaseYearListModel(src, src.DatabaseTrackModel, ServiceManager.DbConnection, src.UniqueId);

            if (this == src)
            {
                this.artist_model = artist_model;
                this.album_model  = album_model;
                this.genre_model  = genre_model;
            }

            yield return(genre_model);

            yield return(albumartist_model);

            yield return(artist_model);

            yield return(year_model);

            yield return(album_model);
        }
Exemplo n.º 2
0
        public void DeleteSelectedTracksFromChild(DatabaseSource source)
        {
            if (source.Parent != this)
            {
                return;
            }

            DeleteSelectedTracks(source.TrackModel as DatabaseTrackListModel);
        }
        public PodcastTrackListModel (BansheeDbConnection conn, IDatabaseTrackModelProvider provider, DatabaseSource source) : base (conn, provider, source)
        {
            From = String.Format ("{0}, {1}, {2}, {3}", provider.From, Feed.Provider.TableName, FeedItem.Provider.TableName, FeedEnclosure.Provider.TableName);

            int podcast_library_dbid = (source as PodcastSource ?? source.Parent as PodcastSource).DbId;
            AddCondition (From, String.Format (
                "CoreTracks.PrimarySourceID = {3} AND {0}.FeedID = {1}.FeedID AND CoreTracks.ExternalID = {1}.ItemID AND {1}.ItemID = {2}.ItemID",
                Feed.Provider.TableName, FeedItem.Provider.TableName, FeedEnclosure.Provider.TableName, podcast_library_dbid
            ));
        }
Exemplo n.º 4
0
        private void DatabaseSourceInitialize()
        {
            InitializeTrackModel();

            current_filters_schema = CreateSchema <string[]> ("current_filters");

            DatabaseSource filter_src = Parent as DatabaseSource ?? this;

            foreach (IFilterListModel filter in filter_src.CreateFiltersFor(this))
            {
                AvailableFilters.Add(filter);
                DefaultFilters.Add(filter);
            }

            reload_limiter = new RateLimiter(RateLimitedReload);
        }
Exemplo n.º 5
0
        public PodcastTrackListModel (BansheeDbConnection conn, IDatabaseTrackModelProvider provider, DatabaseSource source) : base (conn, provider, source)
        {
            From = String.Format ("{0}, {1}, {2}, {3}", provider.From, Feed.Provider.TableName, FeedItem.Provider.TableName, FeedEnclosure.Provider.TableName);

            int podcast_library_dbid = (source as PodcastSource ?? source.Parent as PodcastSource).DbId;
            AddCondition (From, String.Format (
                "CoreTracks.PrimarySourceID = {3} AND {0}.FeedID = {1}.FeedID AND CoreTracks.ExternalID = {1}.ItemID AND {1}.ItemID = {2}.ItemID",
                Feed.Provider.TableName, FeedItem.Provider.TableName, FeedEnclosure.Provider.TableName, podcast_library_dbid
            ));

            SelectAggregates += ",COUNT(NULLIF(CoreTracks.Uri LIKE 'file:%', 0)), COUNT(NULLIF(CoreTracks.PlayCount = 0, 0)), COUNT(DISTINCT(CoreTracks.AlbumID))";
            SelectionAggregatesHandler = (reader) => {
                SelectionDownloadedCount = Convert.ToInt32 (reader[3]);
                SelectionUnheardCount = Convert.ToInt32 (reader[4]);
                SelectionPodcastCount = Convert.ToInt32 (reader[5]);
            };
        }
Exemplo n.º 6
0
        protected override IEnumerable<IFilterListModel> CreateFiltersFor (DatabaseSource src)
        {
            DatabaseQueryFilterModel<string> genre_model = new DatabaseQueryFilterModel<string> (src, src.DatabaseTrackModel, ServiceManager.DbConnection,
                        Catalog.GetString ("All Genres ({0})"), src.UniqueId, Banshee.Query.BansheeQuery.GenreField, "Genre");

            if (this == src) {
                this.genre_model = genre_model;
            }

            yield return genre_model;
        }
Exemplo n.º 7
0
        private void HandleActiveSourceChanged(SourceEventArgs args)
        {
            if (last_source != null) {
                foreach (IFilterListModel filter in last_source.AvailableFilters) {
                    filter.Selection.Changed -= OnSelectionChanged;
                }
                last_source.TrackModel.Selection.Changed -= OnSelectionChanged;
                last_source = null;
            }

            last_source = args.Source as DatabaseSource;
            if (IsPodcastSource) {
                if (last_source != null) {
                    foreach (IFilterListModel filter in last_source.AvailableFilters) {
                        filter.Selection.Changed += OnSelectionChanged;
                    }
                    last_source.TrackModel.Selection.Changed += OnSelectionChanged;
                }
            } else {
                last_source = null;
            }

            OnSelectionChanged (null, null);
        }
Exemplo n.º 8
0
        protected override IEnumerable<IFilterListModel> CreateFiltersFor(DatabaseSource src)
        {
            var books_model = new AudiobookModel (this, this.DatabaseTrackModel, ServiceManager.DbConnection, this.UniqueId);
            if (src == this) {
                this.books_model = books_model;
            }

            yield return books_model;
        }
Exemplo n.º 9
0
        public PlayQueueSource () : base (Catalog.GetString ("Play Queue"), null)
        {
            BindToDatabase ();
            TypeUniqueId = DbId.ToString ();
            Initialize ();
            AfterInitialized ();

            Order = 20;
            Properties.SetString ("Icon.Name", "source-playlist");
            Properties.SetString ("RemoveTracksActionLabel", Catalog.GetString ("Remove From Play Queue"));

            DatabaseTrackModel.ForcedSortQuery = "CorePlaylistEntries.ViewOrder ASC, CorePlaylistEntries.EntryID ASC";
            DatabaseTrackModel.CanReorder = true;

            ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent);
            ServiceManager.PlaybackController.TrackStarted += OnTrackStarted;

            // TODO change this Gtk.Action code so that the actions can be removed.  And so this
            // class doesn't depend on Gtk/ThickClient.
            actions = new PlayQueueActions (this);

            Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
            Properties.SetString ("GtkActionPath", "/PlayQueueContextMenu");

            // TODO listen to all primary sources, and handle transient primary sources
            ServiceManager.SourceManager.MusicLibrary.TracksChanged += HandleTracksChanged;
            ServiceManager.SourceManager.MusicLibrary.TracksDeleted += HandleTracksDeleted;
            ServiceManager.SourceManager.VideoLibrary.TracksChanged += HandleTracksChanged;
            ServiceManager.SourceManager.VideoLibrary.TracksDeleted += HandleTracksDeleted;

            populate_from = ServiceManager.SourceManager.Sources.FirstOrDefault (
                source => source.Name == populate_from_name) as DatabaseSource;
            if (populate_from != null) {
                populate_from.Reload ();
            }

            TrackModel.Reloaded += HandleReloaded;

            int saved_offset = DatabaseConfigurationClient.Client.Get (CurrentOffsetSchema, CurrentOffsetSchema.Get ());
            Offset = Math.Min (
                saved_offset,
                ServiceManager.DbConnection.Query<long> (@"
                    SELECT MAX(ViewOrder) + 1
                    FROM CorePlaylistEntries
                    WHERE PlaylistID = ?", DbId));

            ServiceManager.SourceManager.AddSource (this);
        }
Exemplo n.º 10
0
        protected override DatabaseTrackListModel CreateTrackModelFor (DatabaseSource src)
        {
            var model = new PodcastTrackListModel (ServiceManager.DbConnection, DatabaseTrackInfo.Provider, src);

            if (PodcastTrackModel == null) {
                PodcastTrackModel = model;
            }

            return model;
        }
Exemplo n.º 11
0
        public HeaderWidget CreateHeaderWidget ()
        {
            var header_widget = new HeaderWidget (shuffler, populate_shuffle_mode, populate_from_name);
            header_widget.ModeChanged += delegate (object sender, EventArgs<RandomBy> e) {
                populate_shuffle_mode = e.Value.Id;
                PopulateModeSchema.Set (populate_shuffle_mode);
                UpdatePlayQueue ();
                OnUpdated ();
            };

            populate_shuffle_mode = header_widget.ShuffleModeId;

            header_widget.SourceChanged += delegate (object sender, EventArgs<DatabaseSource> e) {
                populate_from = e.Value;
                if (populate_from == null) {
                    populate_from_name = String.Empty;
                    PopulateFromSchema.Set (String.Empty);
                    return;
                }

                populate_from_name = e.Value.Name;
                PopulateFromSchema.Set (e.Value.Name);
                source_set_at = DateTime.Now;
                populate_from.Reload ();
                Refresh ();
            };

            return header_widget;
        }
        protected override IEnumerable<IFilterListModel> CreateFiltersFor (DatabaseSource src)
        {
            PodcastFeedModel feed_model;
            yield return new PodcastUnheardFilterModel (src.DatabaseTrackModel);
            yield return new DownloadStatusFilterModel (src.DatabaseTrackModel);
            yield return feed_model = new PodcastFeedModel (src, src.DatabaseTrackModel, ServiceManager.DbConnection, String.Format ("PodcastFeeds-{0}", src.UniqueId));

            if (src == this) {
                this.feed_model = feed_model;
                AfterInitialized ();
            }
        }
Exemplo n.º 13
0
        protected virtual IEnumerable<IFilterListModel> CreateFiltersFor (DatabaseSource src)
        {
            if (!HasArtistAlbum) {
                yield break;
            }

            DatabaseArtistListModel artist_model = new DatabaseArtistListModel (src, src.DatabaseTrackModel, ServiceManager.DbConnection, src.UniqueId);
            DatabaseAlbumListModel album_model = new DatabaseAlbumListModel (src, src.DatabaseTrackModel, ServiceManager.DbConnection, src.UniqueId);
            DatabaseQueryFilterModel<string> genre_model = new DatabaseQueryFilterModel<string> (src, src.DatabaseTrackModel, ServiceManager.DbConnection,
                        Catalog.GetString ("All Genres ({0})"), src.UniqueId, BansheeQuery.GenreField, "Genre");

            if (this == src) {
                this.artist_model = artist_model;
                this.album_model = album_model;
                this.genre_model = genre_model;
            }

            yield return artist_model;
            yield return album_model;
            yield return genre_model;
        }
Exemplo n.º 14
0
 protected virtual DatabaseTrackListModel CreateTrackModelFor (DatabaseSource src)
 {
     return new DatabaseTrackListModel (ServiceManager.DbConnection, TrackProvider, src);
 }
Exemplo n.º 15
0
 protected virtual DatabaseTrackListModel CreateTrackModelFor(DatabaseSource src)
 {
     return(new DatabaseTrackListModel(ServiceManager.DbConnection, TrackProvider, src));
 }
Exemplo n.º 16
0
 protected override DatabaseTrackListModel CreateTrackModelFor (DatabaseSource src)
 {
     return new PlayQueueTrackListModel (ServiceManager.DbConnection, DatabaseTrackInfo.Provider, (PlayQueueSource) src);
 }
        public void DeleteSelectedTracksFromChild (DatabaseSource source)
        {
            if (source.Parent != this)
                return;

            DeleteSelectedTracks (source.TrackModel as DatabaseTrackListModel);
        }