Change playlists when the ban button is pressed
I remove the track from the library playlist and add it to the banned list. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
bb7a662f92
commit
4718bf77f3
|
@ -0,0 +1,17 @@
|
|||
#ifndef LIBSARIA_BAN_H
|
||||
#define LIBSARIA_BAN_H
|
||||
#include <libsaria/track.h>
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
namespace ban
|
||||
{
|
||||
|
||||
Playlist *get_banned_plist();
|
||||
void track_banned(Track *);
|
||||
void track_unbanned(Track *);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LIBSARIA_BAN_H */
|
|
@ -1,2 +1,39 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker.
|
||||
#include <libsaria/playlist.h>
|
||||
#include <libsaria/ban.h>
|
||||
|
||||
static libsaria::Set banned_plist("Banned", PL_STATIC | PL_NO_DRAIN);
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
||||
Playlist *ban::get_banned_plist()
|
||||
{
|
||||
return &banned_plist;
|
||||
}
|
||||
|
||||
void ban::track_banned(Track *track)
|
||||
{
|
||||
list<Track *> tracks;
|
||||
tracks.push_back(track);
|
||||
|
||||
/* Remove from library playlist */
|
||||
library::get_playlist()->remove_tracks(tracks);
|
||||
|
||||
/* Add to banned list */
|
||||
banned_plist.add_tracks(tracks);
|
||||
}
|
||||
|
||||
void ban::track_unbanned(Track *track)
|
||||
{
|
||||
list<Track *> tracks;
|
||||
tracks.push_back(track);
|
||||
|
||||
/* Remove from banned list */
|
||||
banned_plist.remove_tracks(tracks);
|
||||
|
||||
/* Add to library playlist */
|
||||
library::get_playlist()->add_tracks(tracks);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Copyright (c) 2011 Bryan Schumaker.
|
||||
#include <libsaria/track.h>
|
||||
#include <libsaria/ban.h>
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
@ -9,6 +10,11 @@ namespace libsaria
|
|||
banned = state;
|
||||
path->data_state = DIRTY;
|
||||
libsaria::library::save_path(path);
|
||||
|
||||
if (state)
|
||||
libsaria::ban::track_banned(this);
|
||||
else
|
||||
libsaria::ban::track_unbanned(this);
|
||||
}
|
||||
|
||||
}; /* Namespace: libsaria */
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
#include <libsaria/library.h>
|
||||
#include <libsaria/print.h>
|
||||
#include <libsaria/deck.h>
|
||||
#include <libsaria/ban.h>
|
||||
|
||||
static ocarina::Playlist library_renderer(PL_STATIC);
|
||||
static ocarina::Playlist recent_renderer(PL_STATIC);
|
||||
static ocarina::Playlist banned_renderer(PL_STATIC);
|
||||
|
||||
namespace ocarina
|
||||
{
|
||||
|
@ -41,6 +43,7 @@ namespace ocarina
|
|||
void playlist::init()
|
||||
{
|
||||
libsaria::set_on_new_playlist(on_new_playlist);
|
||||
banned_renderer.set_playlist(libsaria::ban::get_banned_plist());
|
||||
recent_renderer.set_playlist(libsaria::deck::get_recent_plist());
|
||||
library_renderer.set_playlist(libsaria::library::get_playlist());
|
||||
library_renderer.switch_to();
|
||||
|
|
Loading…
Reference in New Issue