gui: Use common code for adding tracks to queue
Called both for adding and for creating a new queue Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
f0006873b6
commit
58423c92e5
38
gui/tabs.cpp
38
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<Gtk::TreeSelection> sel = tab_treeview->get_selection();
|
||||
if (sel->count_selected_rows() == 0)
|
||||
std::vector<Gtk::TreeModel::Path> 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<Gtk::TreeModel::Path> 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<Gtk::TreeSelection> 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<Gtk::TreeModel::Path> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue