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:
parent
d41c64c798
commit
ef62f5d2b0
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -89,6 +89,9 @@ namespace libsaria
|
|||
removed++;
|
||||
}
|
||||
save();
|
||||
|
||||
if (renderer && (plist.size() == 0))
|
||||
renderer->playlist_empty();
|
||||
}
|
||||
|
||||
void Playlist::rm_track(Track *track)
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue