diff --git a/gui/collection.cpp b/gui/collection.cpp index 18139941..a69fe4e8 100644 --- a/gui/collection.cpp +++ b/gui/collection.cpp @@ -2,6 +2,7 @@ * Copyright 2014 (c) Anna Schumaker. */ #include +#include #include @@ -10,6 +11,7 @@ public: CollectionTab(); ~CollectionTab(); void on_post_init(); + bool on_key_press_event(const std::string &); }; @@ -35,6 +37,20 @@ void CollectionTab :: on_post_init() tab_init_random(); } +bool CollectionTab :: on_key_press_event(const std::string &key) +{ + std::vector ids; + + if (key != "Delete") + return Tab :: on_key_press_event(key); + + tab_selected_ids(ids); + for (unsigned int i = 0; i < ids.size(); i++) + playlist :: add("Banned", ids[i]); + + return true; +} + static CollectionTab *collection_tab; diff --git a/gui/tabs.cpp b/gui/tabs.cpp index 80b9b9dc..0bb309da 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -139,25 +139,29 @@ void Tab :: tab_focus_search() tab_search->grab_focus(); } -void Tab :: tab_queue_add(Playqueue *pq) +void Tab :: tab_selected_ids(std::vector &ids) { Glib::RefPtr sel = tab_treeview->get_selection(); std::vector rows = sel->get_selected_rows(); + Gtk::TreeModel::Path path; for (unsigned int i = 0; i < rows.size(); i++) { - Gtk::TreeModel::Path path = tab_filter->convert_path_to_child_path(rows[i]); - unsigned int track_id = tab_model->path_to_id(path); - pq->add(track_id); + path = tab_filter->convert_path_to_child_path(rows[i]); + ids.push_back(tab_model->path_to_id(path)); } +} - sel->unselect_all(); +void Tab :: tab_queue_add(Playqueue *pq) +{ + std::vector ids; + + tab_selected_ids(ids); + for (unsigned int i = 0; i < ids.size(); i++) + pq->add(ids[i]); } bool Tab :: tab_queue_selected(bool random) { - if (tab_treeview->get_selection()->count_selected_rows() == 0) - return false; - if (deck :: size() >= 10) return true; @@ -168,11 +172,8 @@ bool Tab :: tab_queue_selected(bool random) bool Tab :: tab_add_to_queue(unsigned int n) { - if (tab_treeview->get_selection()->count_selected_rows() == 0) - return false; - if (n >= deck :: size()) - return false; + return true; Playqueue *pq = deck :: get(n); tab_queue_add(pq); diff --git a/include/tabs.h b/include/tabs.h index 8bfae562..251ecc69 100644 --- a/include/tabs.h +++ b/include/tabs.h @@ -58,6 +58,7 @@ public: void tab_runtime_changed(); void tab_display_sorting(); void tab_focus_search(); + void tab_selected_ids(std::vector &); void tab_queue_add(Playqueue *); bool tab_queue_selected(bool); bool tab_add_to_queue(unsigned int);