playlist: Add an "unplayed tracks" dynamic playlist
Unplayed tracks is a dynamic playlist generated whenever we are asked to select the "Unplayed" playlist. Note that dynamic playlists aren't hooked up to the other playlist functions (has, add, del, or get_tracks). This is to avoid adding them to the index and potentially writing out to disk. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
93c9877d57
commit
64291ff02c
|
@ -32,6 +32,21 @@ public:
|
|||
add(tags :: get_track(*it));
|
||||
}
|
||||
|
||||
void dynamic_fill(const std::string &name)
|
||||
{
|
||||
Track *track;
|
||||
|
||||
if (name != "Unplayed")
|
||||
return;
|
||||
|
||||
clear();
|
||||
for (unsigned int i = 0; i < tags :: track_size(); i++) {
|
||||
track = tags :: get_track(i);
|
||||
if ((track != NULL) && (track->count() == 0))
|
||||
add(track);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -89,13 +104,13 @@ void playlist :: del(Track *track, const std::string &name)
|
|||
|
||||
void playlist :: select(const std::string &name)
|
||||
{
|
||||
IndexEntry *ent;
|
||||
IndexEntry *ent = playlist_db.find(name);
|
||||
|
||||
ent = playlist_db.find(name);
|
||||
if (ent == NULL)
|
||||
return;
|
||||
if (ent != NULL)
|
||||
playlist_q.fill(ent);
|
||||
else
|
||||
playlist_q.dynamic_fill(name);
|
||||
|
||||
playlist_q.fill(ent);
|
||||
cur_plist = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@ static void test_queue()
|
|||
|
||||
playlist :: select("Favorites");
|
||||
test_equal(q->size(), (unsigned)8);
|
||||
|
||||
playlist :: select("Unplayed");
|
||||
test_equal(q->size(), (unsigned)3);
|
||||
}
|
||||
|
||||
static void test_add()
|
||||
|
@ -53,6 +56,8 @@ static void test_add()
|
|||
Queue *q = playlist :: get_queue();
|
||||
Queue *l = library :: get_queue();
|
||||
|
||||
playlist :: select("Favorites");
|
||||
|
||||
playlist :: add(tags :: get_track(5), "Banned");
|
||||
ent = playlist :: get_tracks("Banned");
|
||||
test_equal(ent->size(), (size_t)5);
|
||||
|
|
Loading…
Reference in New Issue