libsaria: Move recent playlist to the new deck file
I also created a new playlist flag for unique playlists so I don't need to handle this elsewhere. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
b091df8ec4
commit
3a486082af
|
@ -16,8 +16,6 @@ namespace libsaria
|
|||
namespace deck
|
||||
{
|
||||
|
||||
void push_front(Playlist *);
|
||||
void push_back(Playlist *);
|
||||
void garbage_collect();
|
||||
|
||||
void next();
|
||||
|
|
|
@ -17,6 +17,7 @@ enum PlaylistFlags {
|
|||
PL_DISABLED = (1 << 2),
|
||||
PL_RANDOM = (1 << 3),
|
||||
PL_SORTED = (1 << 4),
|
||||
PL_UNIQUE = (1 << 5),
|
||||
};
|
||||
|
||||
namespace libsaria
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
// Copyright (c) 2012 Bryan Schumaker.
|
||||
#include <deck.h>
|
||||
#include <track.h>
|
||||
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
static vector<libsaria::Playlist *> playlist_deck;
|
||||
static libsaria::Playlist recent_playlist(PL_STATIC | PL_NO_DRAIN | PL_UNIQUE);
|
||||
|
||||
static void read_playlist(ifstream &stream)
|
||||
{
|
||||
|
@ -15,6 +18,23 @@ static void read_playlist(ifstream &stream)
|
|||
|
||||
namespace libsaria
|
||||
{
|
||||
void deck::prev()
|
||||
{
|
||||
Track *track = recent_playlist.next();
|
||||
if (track)
|
||||
track->load_unlisted(true);
|
||||
}
|
||||
|
||||
Playlist *deck::get_recent_plist()
|
||||
{
|
||||
return &recent_playlist;
|
||||
}
|
||||
|
||||
void deck::list_recent(Track *track)
|
||||
{
|
||||
recent_playlist.push_front(track);
|
||||
recent_playlist.reset_iterator();
|
||||
}
|
||||
|
||||
Playlist *deck::get_playlist(unsigned int n)
|
||||
{
|
||||
|
|
|
@ -61,6 +61,9 @@ namespace libsaria
|
|||
|
||||
void Playlist::push_front(Track *track)
|
||||
{
|
||||
if (check_flag(PL_UNIQUE))
|
||||
remove_track(track);
|
||||
|
||||
plist.insert(plist.begin(), track);
|
||||
add_track(track, 0);
|
||||
|
||||
|
@ -70,6 +73,9 @@ namespace libsaria
|
|||
|
||||
void Playlist::push_back(Track *track)
|
||||
{
|
||||
if (check_flag(PL_UNIQUE))
|
||||
remove_track(track);
|
||||
|
||||
plist.push_back(track);
|
||||
add_track(track, plist.size());
|
||||
|
||||
|
|
|
@ -59,16 +59,6 @@ static bool check_play()
|
|||
namespace libsaria
|
||||
{
|
||||
|
||||
void deck::push_front(Playlist *plist)
|
||||
{
|
||||
playlist_deck.push_front(plist);
|
||||
}
|
||||
|
||||
void deck::push_back(Playlist *plist)
|
||||
{
|
||||
playlist_deck.push_back(plist);
|
||||
}
|
||||
|
||||
void deck::garbage_collect()
|
||||
{
|
||||
int n = 0;
|
||||
|
@ -97,13 +87,6 @@ namespace libsaria
|
|||
garbage_collect();
|
||||
}
|
||||
|
||||
void deck::prev()
|
||||
{
|
||||
Track *track = recent_plist.next();
|
||||
if (track)
|
||||
track->load_unlisted(true);
|
||||
}
|
||||
|
||||
Playlist *deck::new_playlist(list<Track *> &tracks, unsigned int flags, bool front)
|
||||
{
|
||||
Playlist *plist;
|
||||
|
@ -113,9 +96,9 @@ namespace libsaria
|
|||
plist = new Playlist(flags);
|
||||
|
||||
if (front)
|
||||
deck::push_front(plist);
|
||||
playlist_deck.push_front(plist);
|
||||
else
|
||||
deck::push_back(plist);
|
||||
playlist_deck.push_back(plist);
|
||||
notify(PLAYLIST_NEW, plist);
|
||||
|
||||
renumber_playlists();
|
||||
|
@ -156,18 +139,6 @@ namespace libsaria
|
|||
return playlist_deck.size();
|
||||
}
|
||||
|
||||
void deck::list_recent(Track *track)
|
||||
{
|
||||
recent_plist.remove_track(track);
|
||||
recent_plist.push_front(track);
|
||||
recent_plist.reset_iterator();
|
||||
}
|
||||
|
||||
Playlist *deck::get_recent_plist()
|
||||
{
|
||||
return &recent_plist;
|
||||
}
|
||||
|
||||
void deck::track_removed(Track *track)
|
||||
{
|
||||
list<Playlist *>::iterator it;
|
||||
|
|
Loading…
Reference in New Issue