gui: Delete key removes tracks from queues

This was the behavior before I started my rewrite.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-02-28 20:31:25 -05:00 committed by Anna Schumaker
parent 463409acdf
commit d83609bc21
3 changed files with 27 additions and 19 deletions

View File

@ -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<unsigned int> 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<Gtk::TreeSelection> sel = tab_treeview->get_selection();
std::vector<Gtk::TreeModel::Path> 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;

View File

@ -541,24 +541,6 @@ public:
void on_focus_search();
};
bool OcarinaPage::on_delete_selected()
{
Glib::RefPtr<Gtk::TreeSelection> 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<Gtk::TreeModel::Path>::reverse_iterator it;
std::vector<Gtk::TreeModel::Path> 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<Gtk::TreeSelection> sel = page_view.get_selection();

View File

@ -11,13 +11,13 @@
class Tab {
private:
std::set<unsigned int> visible_ids;
Glib::RefPtr<Gtk::TreeModelFilter> tab_filter;
unsigned int tab_sorting_count;
std::string tab_sorting_title;
protected:
Playqueue *tab_pq;
Glib::RefPtr<PlayqueueModel> tab_model;
Glib::RefPtr<Gtk::TreeModelFilter> tab_filter;
/**