libsaria: Alert the PlaylistRenderer when the playlist becomes empty

This allows for bookkeeping and other cleanup (schedule playlist
removal, remove from UI, and so on).

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-02-27 11:55:32 -05:00
parent d41c64c798
commit ef62f5d2b0
4 changed files with 23 additions and 1 deletions

View File

@ -9,6 +9,7 @@ namespace libsaria
class PlaylistRenderer {
private:
Playlist *playlist;
virtual void on_playlist_empty();
public:
PlaylistRenderer();
@ -16,6 +17,7 @@ namespace libsaria
void set_playlist(Playlist *);
Playlist *get_playlist();
void playlist_empty();
void fill();
virtual void insert(Track *) = 0;

View File

@ -89,8 +89,11 @@ namespace libsaria
if (flags & PL_DRAIN) {
index = distance(cur, plist.begin());
plist.erase(cur);
if (renderer)
if (renderer) {
renderer->index_removed(index);
if (plist.size() == 0)
renderer->playlist_empty();
}
cur = plist.end();
save();
}

View File

@ -89,6 +89,9 @@ namespace libsaria
removed++;
}
save();
if (renderer && (plist.size() == 0))
renderer->playlist_empty();
}
void Playlist::rm_track(Track *track)

View File

@ -31,4 +31,18 @@ namespace libsaria
playlist->for_each_insert();
}
void PlaylistRenderer::playlist_empty()
{
on_playlist_empty();
}
void PlaylistRenderer::on_playlist_empty()
{
/*
* This function is meant to be overridden by
* inherited classes so they can do whatever
* cleanup is necessary on the UI end.
*/
}
}; /* Namespace: libsaria */