libsaria: Use a tighter loop to fill in the playlist
Rather than exposing iterator functions, I now have a function to walk the playlist and call the renderer insert() function for each track. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
055f349cd1
commit
4ebfd8a33b
|
@ -62,6 +62,7 @@ namespace libsaria
|
|||
Track *next();
|
||||
|
||||
/* Iterator functions */
|
||||
void for_each_insert();
|
||||
void iter_reset();
|
||||
Track *iter_next();
|
||||
bool iter_end();
|
||||
|
|
|
@ -15,6 +15,9 @@ namespace libsaria
|
|||
~PlaylistRenderer();
|
||||
|
||||
void set_playlist(Playlist *);
|
||||
|
||||
void fill();
|
||||
virtual void insert(Track *) = 0;
|
||||
};
|
||||
|
||||
}; /* Namespace: libsaria */
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <libsaria/index.h>
|
||||
#include <libsaria/library.h>
|
||||
#include <libsaria/playlist.h>
|
||||
#include <libsaria/renderer.h>
|
||||
|
||||
static bool compare_tracks(libsaria::Track *one, libsaria::Track *two)
|
||||
{
|
||||
|
@ -90,4 +91,14 @@ namespace libsaria
|
|||
return index::size();
|
||||
return plist.size();
|
||||
}
|
||||
|
||||
void Playlist::for_each_insert()
|
||||
{
|
||||
list<Track *>::iterator it;
|
||||
if (renderer == NULL)
|
||||
return;
|
||||
|
||||
for (it = plist.begin(); it != plist.end(); it++)
|
||||
renderer->insert(*it);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,11 @@ namespace libsaria
|
|||
playlist->set_renderer(this);
|
||||
}
|
||||
|
||||
void PlaylistRenderer::fill()
|
||||
{
|
||||
if (playlist == NULL)
|
||||
return;
|
||||
playlist->for_each_insert();
|
||||
}
|
||||
|
||||
}; /* Namespace: libsaria */
|
||||
|
|
|
@ -47,9 +47,7 @@ void SongList::fill()
|
|||
{
|
||||
freeze();
|
||||
ins_next = 0;
|
||||
list_funcs->iter_reset();
|
||||
while (list_funcs->iter_end() == false)
|
||||
insert(list_funcs->iter_next());
|
||||
PlaylistRenderer::fill();
|
||||
thaw();
|
||||
set_label_text();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue