diff --git a/gui/tabs.cpp b/gui/tabs.cpp index 8518b840..cf58f506 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -112,45 +112,43 @@ void Tab :: tab_focus_search() tab_search->grab_focus(); } -bool Tab :: tab_queue_selected(bool random) +void Tab :: tab_queue_add(Playqueue *pq) { Glib::RefPtr sel = tab_treeview->get_selection(); - if (sel->count_selected_rows() == 0) + std::vector rows = sel->get_selected_rows(); + + 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); + } + + sel->unselect_all(); +} + +bool Tab :: tab_queue_selected(bool random) +{ + if (tab_treeview->get_selection()->count_selected_rows() == 0) return false; if (deck :: size() >= 10) return true; Playqueue *pq = deck :: create(random); - std::vector rows = sel->get_selected_rows(); - 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); - } - - sel->unselect_all(); + tab_queue_add(pq); return true; } bool Tab :: tab_add_to_queue(unsigned int n) { - Glib::RefPtr sel = tab_treeview->get_selection(); - if (sel->count_selected_rows() == 0) + if (tab_treeview->get_selection()->count_selected_rows() == 0) return false; if (n >= deck :: size()) return false; Playqueue *pq = deck :: get(n); - std::vector rows = sel->get_selected_rows(); - 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); - } - - sel->unselect_all(); + tab_queue_add(pq); return true; } diff --git a/include/tabs.h b/include/tabs.h index 7e55e1f6..4d84b7f2 100644 --- a/include/tabs.h +++ b/include/tabs.h @@ -54,6 +54,7 @@ public: int tab_page_num(); void tab_runtime_changed(); void tab_focus_search(); + void tab_queue_add(Playqueue *); bool tab_queue_selected(bool); bool tab_add_to_queue(unsigned int);