diff --git a/gui/queue.cpp b/gui/queue.cpp index f587b263..71cff8e7 100644 --- a/gui/queue.cpp +++ b/gui/queue.cpp @@ -70,6 +70,7 @@ public: */ void setup_treeview(); void on_post_init(); + bool on_key_press_event(const std::string &); void tab_set_size(); void queue_set_number(unsigned int); void on_tab_reordered(); @@ -214,6 +215,31 @@ void QueueTab :: on_post_init() tab_init_repeat(); } +bool QueueTab :: on_key_press_event(const std::string &key) +{ + std::vector ids; + + if (key != "Delete") + return Tab :: on_key_press_event(key); + + /* + * tab_selected_ids() returns track_ids and not + * playlist_ids,so we can't use it here =( + */ + 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++) { + path = tab_filter->convert_path_to_child_path(rows[i]); + ids.push_back(path[0]); + } + + for (unsigned int i = ids.size(); i > 0; i--) + tab_pq->del(ids[i-1]); + return true; +} + void QueueTab :: tab_set_size() { std::stringstream ss; diff --git a/gui/tabs.cpp b/gui/tabs.cpp index 0bb309da..6027ff4c 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -541,24 +541,6 @@ public: void on_focus_search(); }; -bool OcarinaPage::on_delete_selected() -{ - Glib::RefPtr sel = page_view.get_selection(); - if (sel->count_selected_rows() == 0) - return true; - - if ((unsigned int)notebook->page_num(*this) >= deck :: size()) - return true; - - std::vector::reverse_iterator it; - std::vector rows = sel->get_selected_rows(); - for (it = rows.rbegin(); it != rows.rend(); it++) { - unsigned int id = filter->convert_path_to_child_path(*it)[0]; - model->queue->del(id); - } - return true; -} - bool OcarinaPage::on_favorite_selected() { Glib::RefPtr sel = page_view.get_selection(); diff --git a/include/tabs.h b/include/tabs.h index 251ecc69..6a97ed92 100644 --- a/include/tabs.h +++ b/include/tabs.h @@ -11,13 +11,13 @@ class Tab { private: std::set visible_ids; - Glib::RefPtr tab_filter; unsigned int tab_sorting_count; std::string tab_sorting_title; protected: Playqueue *tab_pq; Glib::RefPtr tab_model; + Glib::RefPtr tab_filter; /**