Inheritance: TrackListModel, IExportableModel, ICacheableDatabaseModel, IFilterable, ISortable, ICareAboutView, ISearchable
Ejemplo n.º 1
0
        public static CachedList <DatabaseTrackInfo> CreateFromModel(DatabaseTrackListModel model)
        {
            Selection selection = new Selection();

            selection.MaxIndex = model.Count;
            selection.SelectAll();
            return(CreateFromModelAndSelection(model, selection));
        }
Ejemplo n.º 2
0
        public void SetModelAndCache(DatabaseTrackListModel model, IDatabaseTrackModelCache cache)
        {
            this.model = model;

            foreach (var random in random_modes)
            {
                random.SetModelAndCache(model, cache);
            }
        }
Ejemplo n.º 3
0
        public AudiobookModel(AudiobookLibrarySource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid)
            : base(source, trackModel, connection, uuid)
        {
            Selection = new Hyena.Collections.Selection ();
            HasSelectAllItem = false;

            ReloadFragmentFormat = String.Format (@"
                FROM CoreAlbums WHERE CoreAlbums.AlbumID IN (SELECT AlbumID FROM CoreTracks WHERE PrimarySourceID = {0})
                ORDER BY CoreAlbums.TitleSortKey, CoreAlbums.ArtistNameSortKey",
                source.DbId);
        }
 public DatabaseAlbumListModel(Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid)
     : base(Banshee.Query.BansheeQuery.AlbumField.Name, Banshee.Query.BansheeQuery.AlbumField.Label,
            source, trackModel, connection, DatabaseAlbumInfo.Provider, new AlbumInfo(null), uuid)
 {
     ReloadFragmentFormat = @"
         FROM CoreAlbums WHERE CoreAlbums.AlbumID IN
                 (SELECT CoreTracks.AlbumID FROM CoreTracks, CoreCache{0}
                     WHERE CoreCache.ModelID = {1} AND
                           CoreCache.ItemId = {2} {3})
             ORDER BY CoreAlbums.TitleSortKey, CoreAlbums.ArtistNameSortKey";
 }
Ejemplo n.º 5
0
        public DatabaseQueryFilterModel(Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel,
                                        HyenaSqliteConnection connection, string select_all_fmt, string uuid, QueryField field, string filter_column)
            : base(field.Name, field.Label, source, trackModel, connection, QueryFilterInfo <T> .CreateProvider(filter_column, field), new QueryFilterInfo <T> (), String.Format("{0}-{1}", uuid, field.Name))
        {
            this.field          = field;
            this.select_all_fmt = select_all_fmt;

            ReloadFragmentFormat = @"
                FROM CoreTracks, CoreCache{0}
                    WHERE CoreCache.ModelID = {1} AND CoreCache.ItemID = {2} {3}
                    ORDER BY Value";
        }
Ejemplo n.º 6
0
 public DatabaseArtistListModel(Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid)
     : base(Banshee.Query.BansheeQuery.ArtistField.Name, Banshee.Query.BansheeQuery.ArtistField.Label,
            source, trackModel, connection, DatabaseArtistInfo.Provider, new ArtistInfo(null, null), uuid)
 {
     QueryFields          = new QueryFieldSet(Banshee.Query.BansheeQuery.ArtistField);
     ReloadFragmentFormat = @"
         FROM CoreArtists WHERE CoreArtists.ArtistID IN
             (SELECT CoreTracks.ArtistID FROM CoreTracks, CoreCache{0}
                 WHERE {4}(CoreCache.ModelID = {1}) AND
                       CoreCache.ItemID = {2} {3})
             ORDER BY NameSortKey";
 }
Ejemplo n.º 7
0
        public void SetModelAndCache(DatabaseTrackListModel model, IDatabaseTrackModelCache cache)
        {
            if (Model != model)
            {
                Model = model;
                Cache = cache;
                Reset();

                OnModelAndCacheUpdated();
            }

            shuffler_query = null;
        }
Ejemplo n.º 8
0
        public DatabaseFilterListModel(string name, string label, Banshee.Sources.DatabaseSource source,
                                       DatabaseTrackListModel trackModel, HyenaSqliteConnection connection, SqliteModelProvider <T> provider, U selectAllItem, string uuid)
            : base(trackModel)
        {
            this.source     = source;
            FilterName      = name;
            FilterLabel     = label;
            select_all_item = selectAllItem;

            this.connection  = connection;
            cache            = new BansheeModelCache <T> (connection, uuid, this, provider);
            HasSelectAllItem = true;
        }
Ejemplo n.º 9
0
 public DatabaseYearListModel(Banshee.Sources.DatabaseSource source, DatabaseTrackListModel trackModel, BansheeDbConnection connection, string uuid)
     : base(Banshee.Query.BansheeQuery.YearField.Name, Banshee.Query.BansheeQuery.YearField.Label,
            source, trackModel, connection, DatabaseYearInfo.Provider, new YearInfo(), uuid)
 {
     QueryFields          = new QueryFieldSet(Banshee.Query.BansheeQuery.YearField);
     ReloadFragmentFormat = @"
         FROM (SELECT MIN(CoreTracks.TrackID) AS TrackID, CoreTracks.Year FROM CoreTracks GROUP BY CoreTracks.Year) AS CoreTracks
         WHERE CoreTracks.Year IN
             (SELECT CoreTracks.Year FROM CoreTracks, CoreCache{0}
                 WHERE CoreCache.ModelID = {1} AND
                       CoreCache.ItemID = {2} {3})
             ORDER BY Year";
 }
Ejemplo n.º 10
0
        public static CachedList <DatabaseTrackInfo> CreateFromSourceModel(DatabaseTrackListModel model)
        {
            CachedList <DatabaseTrackInfo> list = new CachedList <DatabaseTrackInfo> (DatabaseTrackInfo.Provider);

            HyenaSqliteCommand model_cache_command = new HyenaSqliteCommand(String.Format(@"
                INSERT INTO CoreCache (ModelID, ItemID)
                    SELECT ?, CoreTracks.TrackID {0}", model.UnfilteredQuery
                                                                                          ));

            lock (model) {
                ServiceManager.DbConnection.Execute(model_cache_command, list.CacheId);
            }

            list.cache.UpdateAggregates();

            return(list);
        }
Ejemplo n.º 11
0
        public static CachedList <DatabaseTrackInfo> CreateFromModelAndSelection(DatabaseTrackListModel model, Selection selection)
        {
            CachedList <DatabaseTrackInfo> list = new CachedList <DatabaseTrackInfo> (DatabaseTrackInfo.Provider);

            HyenaSqliteCommand add_range_command = new HyenaSqliteCommand(String.Format(@"
                INSERT INTO CoreCache (ModelID, ItemID)
                    SELECT ?, {0}", model.TrackIdsSql
                                                                                        ));

            lock (model) {
                foreach (RangeCollection.Range range in selection.Ranges)
                {
                    ServiceManager.DbConnection.Execute(add_range_command, list.CacheId, model.CacheId, range.Start, range.Count);
                }
            }

            list.cache.UpdateAggregates();
            return(list);
        }
Ejemplo n.º 12
0
 public void RecordShuffleModifications (DatabaseTrackListModel model, RangeCollection.Range range, ShuffleModificationType type)
 {
     ServiceManager.DbConnection.Execute (String.Format ("{0} SELECT ?, ?, ?, {1}", modify_sql, model.TrackIdsSql),
                                          DbId, DateTime.Now, (int)type, model.CacheId, range.Start, range.Count);
 }
Ejemplo n.º 13
0
 public void RecordInsertions (DatabaseTrackListModel model, RangeCollection.Range range)
 {
     RecordShuffleModifications (model, range, ShuffleModificationType.Insertion);
 }
Ejemplo n.º 14
0
        public void SetModelAndCache (DatabaseTrackListModel model, IDatabaseTrackModelCache cache)
        {
            this.model = model;

            foreach (var random in random_modes) {
                random.SetModelAndCache (model, cache);
            }
        }
 public virtual void RemoveSelectedTracks (DatabaseTrackListModel model)
 {
     WithTrackSelection (model, RemoveTrackRange);
     OnTracksRemoved ();
 }
Ejemplo n.º 16
0
 public void RecordShuffleModifications(DatabaseTrackListModel model, RangeCollection.Range range, ShuffleModificationType type)
 {
     ServiceManager.DbConnection.Execute(String.Format("{0} SELECT ?, ?, ?, {1}", modify_sql, model.TrackIdsSql),
                                         DbId, DateTime.Now, (int)type, model.CacheId, range.Start, range.Count);
 }
Ejemplo n.º 17
0
        protected void FindFirstNotRemovedTrack (DatabaseTrackListModel model, Selection selection)
        {
            first_nonremoved_track = null;

            var playback_src = ServiceManager.PlaybackController.Source as DatabaseSource;
            if (playback_src != this && playback_src.Parent != this)
                return;

            int i = model.IndexOf (ServiceManager.PlayerEngine.CurrentTrack);
            if (!selection.Contains (i))
                return;

            var range = selection.Ranges.First (r => r.Start <= i && i <= r.End);
            first_nonremoved_track = model[range.Start - 1];
        }
Ejemplo n.º 18
0
        protected override void RemoveTrackRange (DatabaseTrackListModel model, RangeCollection.Range range)
        {
            shuffler.RecordShuffleModifications (model, range, ShuffleModificationType.Discard);
            base.RemoveTrackRange (model, range);

            model.Selection.UnselectRange (range.Start, range.End);

            int index = TrackModel.IndexOf (current_track);
            if (range.Start <= index && index <= range.End) {
                SetCurrentTrack (range.End + 1 < Count ? TrackModel[range.End + 1] as DatabaseTrackInfo : null);
            }
        }
        protected override void DeleteSelectedTracks (DatabaseTrackListModel model)
        {
            if (model == null || model.Count < 1) {
                return;
            }

            ThreadAssist.SpawnFromMain (delegate {
                CachedList<DatabaseTrackInfo> list = CachedList<DatabaseTrackInfo>.CreateFromModelSelection (model);
                DeleteTrackList (list);
            });
        }
Ejemplo n.º 20
0
        public void SetModelAndCache(DatabaseTrackListModel model, IDatabaseTrackModelCache cache)
        {
            if (Model != model) {
                Model = model;
                Cache = cache;
                Reset ();

                OnModelAndCacheUpdated ();
            }

            shuffler_query = null;
            filtered_shuffler_condition = null;
        }
Ejemplo n.º 21
0
 protected override void RemoveTrackRange (DatabaseTrackListModel model, RangeCollection.Range range)
 {
     ServiceManager.DbConnection.Execute (
         String.Format (remove_range_sql, model.TrackIdsSql),
         DateTime.Now,
         model.CacheId, range.Start, range.End - range.Start + 1,
         model.CacheId, range.Start, range.End - range.Start + 1
     );
 }
Ejemplo n.º 22
0
        protected override void AddTrackRange(DatabaseTrackListModel from, RangeCollection.Range range)
        {
            last_add_range_command = (!from.CachesJoinTableEntries)
                ? add_track_range_command
                : from == last_add_range_from_model
                    ? last_add_range_command
                    : new HyenaSqliteCommand (String.Format (add_track_range_from_joined_model_sql, from.JoinTable, from.JoinPrimaryKey));

            long first_order_id = ServiceManager.DbConnection.Query<long> ("SELECT OrderID FROM CoreCache WHERE ModelID = ? LIMIT 1 OFFSET ?", from.CacheId, range.Start);
            ServiceManager.DbConnection.Execute (last_add_range_command, DbId, MaxViewOrder - first_order_id, from.CacheId, range.Start, range.Count);

            last_add_range_from_model = from;
        }
Ejemplo n.º 23
0
        public virtual void RateSelectedTracks (DatabaseTrackListModel model, int rating)
        {
            Selection selection = model.Selection;
            if (selection.Count == 0)
                return;

            lock (model) {
                foreach (RangeCollection.Range range in selection.Ranges) {
                    RateTrackRange (model, range, rating);
                }
            }
            OnTracksChanged (BansheeQuery.RatingField);

            // In case we updated the currently playing track
            DatabaseTrackInfo track = ServiceManager.PlayerEngine.CurrentTrack as DatabaseTrackInfo;
            if (track != null) {
                track.Refresh ();
                ServiceManager.PlayerEngine.TrackInfoUpdated ();
            }
        }
Ejemplo n.º 24
0
        public virtual void DeleteTracks (DatabaseTrackListModel model, Selection selection)
        {
            if (model == null)
                return;

            FindFirstNotRemovedTrack (model, selection);
            WithTrackSelection (model, selection, DeleteTrackRange);
            OnTracksDeleted ();
        }
        protected virtual void DeleteSelectedTracks (DatabaseTrackListModel model)
        {
            if (model == null)
                return;

            WithTrackSelection (model, DeleteTrackRange);
            OnTracksDeleted ();
        }
Ejemplo n.º 26
0
 public static CachedList <DatabaseTrackInfo> CreateFromModelSelection(DatabaseTrackListModel model)
 {
     return(CreateFromModelAndSelection(model, model.Selection));
 }
Ejemplo n.º 27
0
 public void RecordInsertions(DatabaseTrackListModel model, RangeCollection.Range range)
 {
     RecordShuffleModifications(model, range, ShuffleModificationType.Insertion);
 }
Ejemplo n.º 28
0
 protected virtual void AddTrackRange (DatabaseTrackListModel model, RangeCollection.Range range)
 {
     Log.ErrorFormat ("AddTrackRange not implemented by {0}", this);
 }
Ejemplo n.º 29
0
 public void RemoveTracks (DatabaseTrackListModel model, Selection selection)
 {
     FindFirstNotRemovedTrack (model, selection);
     WithTrackSelection (model, selection, RemoveTrackRange);
     OnTracksRemoved ();
 }
Ejemplo n.º 30
0
 protected override void RemoveTrackRange(DatabaseTrackListModel from, RangeCollection.Range range)
 {
     ServiceManager.DbConnection.Execute (remove_track_range_command,
         DbId, from.CacheId, range.Start, range.Count);
 }
Ejemplo n.º 31
0
 protected virtual void RateTrackRange (DatabaseTrackListModel model, RangeCollection.Range range, int rating)
 {
     ServiceManager.DbConnection.Execute (RateTrackRangeCommand,
         rating, DateTime.Now, range.Start, range.End - range.Start + 1);
 }
Ejemplo n.º 32
0
        public override void DeleteTracks (DatabaseTrackListModel model, Selection selection)
        {
            if (model == null || model.Count < 1) {
                return;
            }

            var list = CachedList<DatabaseTrackInfo>.CreateFromModelAndSelection (model, selection);
            ThreadAssist.SpawnFromMain (delegate {
                DeleteTrackList (list);
            });
        }
Ejemplo n.º 33
0
 protected void WithTrackSelection (DatabaseTrackListModel model, TrackRangeHandler handler)
 {
     WithTrackSelection (model, model.Selection, handler);
 }
Ejemplo n.º 34
0
 // Have our parent handle deleting tracks
 public override void DeleteTracks (DatabaseTrackListModel model, Selection selection)
 {
     if (Parent is PrimarySource) {
         (Parent as PrimarySource).DeleteTracks (model, selection);
     }
 }
Ejemplo n.º 35
0
        protected void WithTrackSelection (DatabaseTrackListModel model, Selection selection, TrackRangeHandler handler)
        {
            if (selection.Count == 0)
                return;

            lock (model) {
                foreach (RangeCollection.Range range in selection.Ranges) {
                    handler (model, range);
                }
            }
        }