private void OnRefreshSmartPlaylist(object o, EventArgs args) { SmartPlaylistSource playlist = ActionSource as SmartPlaylistSource; if (playlist != null && playlist.CanRefresh) { playlist.RefreshAndReload(); } }
private void PrimarySourceInitialize() { // Scope the tracks to this primary source DatabaseTrackModel.AddCondition(String.Format("CoreTracks.PrimarySourceID = {0}", DbId)); primary_sources[DbId] = this; // If there was a crash, tracks can be left behind, for example in DaapSource. // Temporary playlists are cleaned up by the PlaylistSource.LoadAll call below if (IsTemporary && SavedCount > 0) { PurgeTracks(); } // Load our playlists and smart playlists foreach (PlaylistSource pl in PlaylistSource.LoadAll(this)) { AddChildSource(pl); } int sp_count = 0; foreach (SmartPlaylistSource pl in SmartPlaylistSource.LoadAll(this)) { AddChildSource(pl); sp_count++; } // Create default smart playlists if we haven't done it ever before, and if the // user has zero smart playlists. if (!HaveCreatedSmartPlaylists) { if (sp_count == 0) { foreach (SmartPlaylistDefinition def in DefaultSmartPlaylists) { SmartPlaylistSource pl = def.ToSmartPlaylistSource(this); pl.Save(); AddChildSource(pl); pl.RefreshAndReload(); sp_count++; } } // Only save it if we already had some smart playlists, or we actually created some (eg not // if we didn't have any and the list of default ones is empty atm). if (sp_count > 0) { HaveCreatedSmartPlaylists = true; } } expanded_schema = new SchemaEntry <bool> ( String.Format("sources.{0}", ParentConfigurationId), "expanded", true, "Is source expanded", "Is source expanded" ); }
internal void CalculateSync() { if (SyncEntireLibrary) { sync_src.ConditionTree = null; }/* else if (SyncPlaylistIds.Length > 0) { * QueryListNode playlists_node = new QueryListNode (Keyword.Or); * foreach (AbstractPlaylistSource src in SyncPlaylists) { * if (src is PlaylistSource) { * playlists_node.AddChild (UserQueryParser.Parse (String.Format ("playlistid:{0}", src.DbId), BansheeQuery.FieldSet)); * } else if (src is SmartPlaylistSource) { * playlists_node.AddChild (UserQueryParser.Parse (String.Format ("smartplaylistid:{0}", src.DbId), BansheeQuery.FieldSet)); * } * } * sync_src.ConditionTree = playlists_node; * }*/ sync_src.RefreshAndReload(); to_add.RefreshAndReload(); to_remove.RefreshAndReload(); enabled_pref.Name = String.Format("{0} ({1})", enabled.ShortDescription, String.Format(Catalog.GetString("{0} to add, {1} to remove"), to_add.Count, to_remove.Count)); }
protected override void OnResponse(ResponseType response) { //int w = -1, h = -1; //dialog.GetSize (out w, out h); //Console.WriteLine ("w = {0}, h = {1}", w, h); QueryNode node = builder.QueryNode; if (node == null) { //Console.WriteLine ("Editor query is null"); } else { //Console.WriteLine ("Editor query is: {0}", node.ToXml (BansheeQuery.FieldSet, true)); } if (response == ResponseType.Ok) { string name = PlaylistName; QueryNode condition_tree = Condition; QueryLimit limit = Limit; QueryOrder order = Order; IntegerQueryValue limit_value = LimitValue; ThreadAssist.Spawn (delegate { //Console.WriteLine ("Name = {0}, Cond = {1}, OrderAndLimit = {2}", name, condition, order_by, limit_number); if (playlist == null) { playlist = new SmartPlaylistSource (name, primary_source); playlist.ConditionTree = condition_tree; playlist.QueryOrder = order; playlist.Limit = limit; playlist.LimitValue = limit_value; playlist.Save (); primary_source.AddChildSource (playlist); playlist.RefreshAndReload (); //SmartPlaylistCore.Instance.StartTimer (playlist); } else { playlist.ConditionTree = condition_tree; playlist.QueryOrder = order; playlist.LimitValue = limit_value; playlist.Limit = limit; playlist.Name = name; playlist.Save (); playlist.RefreshAndReload (); /*if (playlist.TimeDependent) SmartPlaylistCore.Instance.StartTimer (playlist); else SmartPlaylistCore.Instance.StopTimer ();*/ //playlist.ListenToPlaylists (); //SmartPlaylistCore.Instance.SortPlaylists (); } }); } currently_editing = null; }