playlist: Remove banned songs from the library queue
And put them back when they are unbanned. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
9ba4dbc218
commit
e4db93b8e2
9
DESIGN
9
DESIGN
|
@ -1133,7 +1133,8 @@ Playlist:
|
|||
|
||||
- API
|
||||
void playlist :: init():
|
||||
Load the playlist index from file.
|
||||
Load the playlist index from file. Remove every banned song
|
||||
from the LibraryQueue in the library layer.
|
||||
|
||||
void playlist :: add(Track *track, const std::string &name);
|
||||
Add track->id to the playlist named "name" and return true.
|
||||
|
@ -1142,6 +1143,9 @@ Playlist:
|
|||
If "name" is the currently selected playlist, add the track
|
||||
to the PlaylistQueue.
|
||||
|
||||
If "name" is "Banned", remove the track from the LibraryQueue
|
||||
in the library layer.
|
||||
|
||||
void playlist :: del(Track *track, const std::string &name);
|
||||
Remove track->id from the playlist named "name" and return true.
|
||||
Return false if the playlist does not exist or if the track
|
||||
|
@ -1150,6 +1154,9 @@ Playlist:
|
|||
If "name" is the currently selected playlist, remove the track
|
||||
from the PlaylistQueue.
|
||||
|
||||
If "name" is "Banned", add the track to the LibraryQueue in the
|
||||
library layer.
|
||||
|
||||
bool playlist :: has(Track *track, const std::string &name);
|
||||
Return true if the chosen playlist has the given track.
|
||||
Return false otherwise.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 2013 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <library.h>
|
||||
#include <playlist.h>
|
||||
|
||||
|
||||
|
@ -36,7 +37,13 @@ static std::string cur_plist;
|
|||
|
||||
void playlist :: init()
|
||||
{
|
||||
std::set<unsigned int>::iterator it;
|
||||
|
||||
playlist_db.load();
|
||||
|
||||
IndexEntry *ent = get_tracks("Banned");
|
||||
for (it = ent->values.begin(); it != ent->values.end(); it++)
|
||||
library :: get_queue()->del(tagdb :: lookup(*it));
|
||||
}
|
||||
|
||||
bool playlist :: has(Track *track, const std::string &name)
|
||||
|
@ -60,6 +67,8 @@ void playlist :: add(Track *track, const std::string &name)
|
|||
playlist_db.insert(name, track->id);
|
||||
if (cur_plist == name)
|
||||
playlist_q.add(track);
|
||||
if (name == "Banned")
|
||||
library :: get_queue()->del(track);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,6 +77,9 @@ void playlist :: del(Track *track, const std::string &name)
|
|||
playlist_db.remove(name, track->id);
|
||||
if (cur_plist == name)
|
||||
playlist_q.del(track);
|
||||
if (name == "Banned")
|
||||
library :: get_queue()->add(track);
|
||||
|
||||
}
|
||||
|
||||
void playlist :: select(const std::string &name)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright 2013 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <library.h>
|
||||
#include <playlist.h>
|
||||
#include "test.h"
|
||||
|
||||
|
@ -18,10 +19,12 @@ static void test_init()
|
|||
test_equal(q->has_flag(Q_NO_SORT), true);
|
||||
|
||||
tagdb :: init();
|
||||
library :: init();
|
||||
playlist :: init();
|
||||
|
||||
ent = playlist :: get_tracks("Banned");
|
||||
test_equal(ent->values.size(), (size_t)4);
|
||||
test_equal(library :: get_queue()->size(), (unsigned)20);
|
||||
ent = playlist :: get_tracks("Favorites");
|
||||
test_equal(ent->values.size(), (size_t)8);
|
||||
ent = playlist :: get_tracks("No Such Playlist");
|
||||
|
@ -43,11 +46,13 @@ static void test_add()
|
|||
{
|
||||
IndexEntry *ent;
|
||||
Queue *q = playlist :: get_queue();
|
||||
Queue *l = library :: get_queue();
|
||||
|
||||
playlist :: add(tagdb :: lookup(5), "Banned");
|
||||
ent = playlist :: get_tracks("Banned");
|
||||
test_equal(ent->values.size(), (size_t)5);
|
||||
test_equal(q->size(), (unsigned)8);
|
||||
test_equal(l->size(), (unsigned)19);
|
||||
|
||||
playlist :: add(tagdb :: lookup(16), "Favorites");
|
||||
playlist :: add(tagdb :: lookup(5), "Favorites");
|
||||
|
@ -63,11 +68,13 @@ static void test_delete()
|
|||
{
|
||||
IndexEntry *ent;
|
||||
Queue *q = playlist :: get_queue();
|
||||
Queue *l = library :: get_queue();
|
||||
|
||||
playlist :: del(tagdb :: lookup(5), "Banned");
|
||||
ent = playlist :: get_tracks("Banned");
|
||||
test_equal(ent->values.size(), (size_t)4);
|
||||
test_equal(q->size(), (unsigned)9);
|
||||
test_equal(l->size(), (unsigned)20);
|
||||
|
||||
playlist :: del(tagdb :: lookup(5), "Favorites");
|
||||
ent = playlist :: get_tracks("Favorites");
|
||||
|
|
Loading…
Reference in New Issue