libsaria: Find nth playlist

Gives access to a specific playlist on the stack.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-03-28 08:30:12 -04:00
parent d23469dfa7
commit c6bf52a516
2 changed files with 25 additions and 9 deletions

View File

@ -18,6 +18,7 @@ namespace libsaria
void init();
Playlist *get_recent_plist();
PlaylistRenderer *get_nth_renderer(unsigned int);
void add_to_nth_plist(unsigned int, list<Track *> &);
};

View File

@ -51,6 +51,20 @@ static void rename_playlists()
}
}
libsaria::Playlist *find_nth_plist(unsigned int n)
{
list<libsaria::Playlist *>::iterator it = playlist_stack.begin();
unsigned int max = (playlist_stack.size() - num_static);
println("n: %u, max: %u", n, max);
if (n >= max)
return NULL;
for (unsigned int i = 0; i < n; i++)
it++;
return (*it);
}
namespace libsaria
{
@ -129,16 +143,17 @@ namespace libsaria
PlaylistRenderer *stack::get_nth_renderer(unsigned int n)
{
list<Playlist *>::iterator it = playlist_stack.begin();
unsigned int max = (playlist_stack.size() - num_static);
println("n: %u, max: %u", n, max);
Playlist *plist = find_nth_plist(n);
if (plist)
return plist->get_renderer();
return NULL;
}
if (n >= max)
return NULL;
for (unsigned int i = 0; i < n; i++)
it++;
return (*it)->get_renderer();
void stack::add_to_nth_plist(unsigned int n, list<Track *> &tracks)
{
Playlist *plist = find_nth_plist(n);
if (plist)
plist->add_tracks(tracks);
}
}; /* Namespace: libsaria */