private void PrimarySourceInitialize ()
{
// Scope the tracks to this primary source
DatabaseTrackModel.AddCondition (String.Format ("CoreTracks.PrimarySourceID = {0}", DbId));
primary_sources[DbId] = this;
// 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"
);
}