From 41506f31770757afb45d94d7be582771a4fb77ed Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 17 Aug 2014 17:16:48 -0400 Subject: [PATCH] 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 --- gui/collection_mgr.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gui/collection_mgr.cpp b/gui/collection_mgr.cpp index 6cafc087..63d237b3 100644 --- a/gui/collection_mgr.cpp +++ b/gui/collection_mgr.cpp @@ -2,7 +2,9 @@ * Copyright 2014 (c) Anna Schumaker. */ #include +#include #include +#include #include 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::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 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)