gui: Remove banned songs from Collection when re-enabling

I wasn't doing this before, so banned songs were showing up in the
collection list again.  I think this is kind of an ugly fix, though.
Perhaps there is a better way to do it?

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-08-17 17:16:48 -04:00
parent cfa61fa816
commit 41506f3177
1 changed files with 18 additions and 0 deletions

View File

@ -2,7 +2,9 @@
* Copyright 2014 (c) Anna Schumaker.
*/
#include <core/callback.h>
#include <core/index.h>
#include <core/library.h>
#include <core/playlist.h>
#include <gui/ocarina.h>
static void on_library_add(unsigned int id, Library *library);
@ -80,6 +82,18 @@ static bool on_collection_key_pressed(GdkEventKey *event)
return false;
}
static void on_enabled_remove_banned()
{
std::set<unsigned int>::iterator it;
IndexEntry *ent = playlist :: get_tracks("Banned");
if (!ent)
return;
for (it = ent->values.begin(); it != ent->values.end(); it++)
library :: get_queue()->del(tagdb :: lookup(*it));
}
#ifndef CONFIG_TEST
static
#endif /* CONFIG_TEST */
@ -87,9 +101,13 @@ void on_collection_toggled(const Glib::ustring &path)
{
Glib::RefPtr<Gtk::ListStore> list = get_collection_list();
Gtk::TreeModel::Row row = *(list->get_iter(path));
row[collection_cols.c_col_enabled] = !row[collection_cols.c_col_enabled];
library :: set_enabled(tagdb :: lookup_library(row[collection_cols.c_col_id]),
row[collection_cols.c_col_enabled]);
if (row[collection_cols.c_col_enabled] == true)
on_enabled_remove_banned();
}
static void on_library_add(unsigned int id, Library *library)