diff --git a/gui/collection.cpp b/gui/collection.cpp index dbf21ba8..5a6fab0e 100644 --- a/gui/collection.cpp +++ b/gui/collection.cpp @@ -5,32 +5,22 @@ #include #include #include -#include class CollectionTab : public Tab { private: CollectionLabel *collection_label; - QueueWindow *collection_window; public: CollectionTab() : Tab(library::get_queue()) { - tab_builder->add_from_file(gui :: share_file("QueueWindow.ui")); tab_builder->add_from_file(gui :: share_file("QueueLabel.ui")); - tab_builder->get_widget_derived("CollectionLabel", collection_label); - tab_builder->get_widget_derived("QueueWindow", collection_window); + tab_toolbar->init(tab_pq, collection_label, tab_window, T_RANDOM); - tab_toolbar->init(tab_pq, collection_label, collection_window, T_RANDOM); - collection_window->init(tab_pq); + tab_vbox.pack_start(*tab_window, true, true); - tab_vbox.pack_start(*collection_window, true, true); - - tab_model = collection_window->q_model; - tab_filter = collection_window->q_filter; tab_size = collection_label->collection_size; - tab_treeview = collection_window->q_treeview; tab_finish_init(); gui :: get_widget("o_notebook")->insert_page(tab_vbox, *collection_label, 0); diff --git a/gui/history.cpp b/gui/history.cpp index 2e20ede6..0f86ac90 100644 --- a/gui/history.cpp +++ b/gui/history.cpp @@ -4,32 +4,22 @@ #include #include #include -#include class HistoryTab : public Tab { private: HistoryLabel *history_label; - QueueWindow *history_window; public: HistoryTab() : Tab(deck :: get_queue()) { - tab_builder->add_from_file(gui :: share_file("QueueWindow.ui")); tab_builder->add_from_file(gui :: share_file("QueueLabel.ui")); - tab_builder->get_widget_derived("HistoryLabel", history_label); - tab_builder->get_widget_derived("QueueWindow", history_window); + tab_toolbar->init(tab_pq, history_label, tab_window, 0); - tab_toolbar->init(tab_pq, history_label, history_window, 0); - history_window->init(tab_pq); + tab_vbox.pack_start(*tab_window, true, true); - tab_vbox.pack_start(*history_window, true, true); - - tab_model = history_window->q_model; - tab_filter = history_window->q_filter; tab_size = history_label->history_size; - tab_treeview = history_window->q_treeview; tab_finish_init(); gui :: get_widget("o_notebook")->insert_page(tab_vbox, *history_label, 0); diff --git a/gui/playlist.cpp b/gui/playlist.cpp index a30030b0..8ca550da 100644 --- a/gui/playlist.cpp +++ b/gui/playlist.cpp @@ -5,7 +5,6 @@ #include #include #include -#include static Gtk::ToggleButton *o_ban; @@ -74,31 +73,24 @@ private: PlaylistLabel *playlist_label; PlaylistWindow *playlist_window; - QueueWindow *playlist_tracks; public: PlaylistTab() : Tab(playlist :: get_queue()) { - tab_builder->add_from_file(gui :: share_file("QueueWindow.ui")); tab_builder->add_from_file(gui :: share_file("QueueLabel.ui")); tab_builder->add_from_file(gui :: share_file("PlaylistWindow.ui")); tab_builder->get_widget_derived("PlaylistLabel", playlist_label); tab_builder->get_widget_derived("PlaylistWindow", playlist_window); - tab_builder->get_widget_derived("QueueWindow", playlist_tracks); - tab_toolbar->init(tab_pq, playlist_label, playlist_tracks, 0); - playlist_tracks->init(tab_pq); + tab_toolbar->init(tab_pq, playlist_label, tab_window, 0); playlist_hbox.pack_start(*playlist_window, false, true); - playlist_hbox.pack_start(*playlist_tracks, true, true); + playlist_hbox.pack_start(*tab_window, true, true); playlist_hbox.show(); tab_vbox.pack_start(playlist_hbox, true, true); - tab_model = playlist_tracks->q_model; - tab_filter = playlist_tracks->q_filter; - tab_treeview = playlist_tracks->q_treeview; tab_finish_init(); gui :: get_widget("o_notebook")->insert_page(tab_vbox, *playlist_label, 0); diff --git a/gui/queue.cpp b/gui/queue.cpp index 113b9337..133eeee1 100644 --- a/gui/queue.cpp +++ b/gui/queue.cpp @@ -5,7 +5,6 @@ #include #include #include -#include static void renumber_queues(); @@ -39,10 +38,6 @@ private: */ TempLabel *q_label; - /* Treeview widgets */ - QueueWindow *q_window; - - public: QueueTab(Queue *, unsigned int num); ~QueueTab(); @@ -70,9 +65,7 @@ static std::map queue_mapping; QueueTab :: QueueTab(Queue *pq, unsigned int num) : Tab(pq) { - tab_builder->add_from_file(gui :: share_file("QueueWindow.ui")); tab_builder->add_from_file(gui :: share_file("QueueLabel.ui")); - tab_builder->add_from_file(gui :: share_file("QueueToolbar.ui")); /* * Create our tab widget @@ -86,34 +79,24 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num) queue_set_number(num); - /* - * And the treeview with scrolled window - */ - tab_builder->get_widget_derived("QueueWindow", q_window); - q_window->init(pq); - - /* * Now set up the toolbar */ - tab_toolbar->init(pq, q_label, q_window, T_RANDOM | T_REPEAT | T_SWITCH); + tab_toolbar->init(pq, q_label, tab_window, T_RANDOM | T_REPEAT | T_SWITCH); /* * Fill in the page! */ - tab_vbox.pack_start(*q_window, true, true); + tab_vbox.pack_start(*tab_window, true, true); /* * Set generic tab widgets */ - tab_model = q_window->q_model; - tab_filter = q_window->q_filter; tab_size = q_label->temp_size; - tab_treeview = q_window->q_treeview; tab_finish_init(); queue_mapping[&tab_vbox] = this; @@ -156,12 +139,12 @@ bool QueueTab :: on_key_press_event(const std::string &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(); + Glib::RefPtr sel = tab_window->q_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]); + path = tab_window->q_filter->convert_path_to_child_path(rows[i]); ids.push_back(path[0]); } diff --git a/gui/tabs.cpp b/gui/tabs.cpp index bb20fb3a..6741b6a5 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -34,7 +34,11 @@ Tab :: Tab(Queue *pq) tab_builder = Gtk::Builder::create(); tab_builder->add_from_file(gui :: share_file("QueueToolbar.ui")); + tab_builder->add_from_file(gui :: share_file("QueueWindow.ui")); tab_builder->get_widget_derived("QueueToolbar", tab_toolbar); + tab_builder->get_widget_derived("QueueWindow", tab_window); + + tab_window->init(tab_pq); tab_vbox.set_margin_start(1); tab_vbox.set_margin_end(1); @@ -48,12 +52,12 @@ Tab :: ~Tab() {} void Tab :: tab_finish_init() { - tab_treeview->signal_key_press_event().connect(sigc::mem_fun(*this, + tab_window->q_treeview->signal_key_press_event().connect(sigc::mem_fun(*this, &Tab :: on_key_pressed)); - tab_treeview->signal_button_press_event().connect(sigc::mem_fun(*this, + tab_window->q_treeview->signal_button_press_event().connect(sigc::mem_fun(*this, &Tab :: on_button_pressed), false); - std::vector columns = tab_treeview->get_columns(); + std::vector columns = tab_window->q_treeview->get_columns(); for (unsigned int i = 0; i < columns.size(); i++) { columns[i]->signal_clicked().connect(sigc::bind ( sigc::mem_fun(*this, &Tab::on_column_clicked), i)); @@ -72,21 +76,21 @@ void Tab :: tab_finish_init() void Tab :: on_track_added(unsigned int row) { - tab_model->on_row_inserted(row); + tab_window->q_model->on_row_inserted(row); tab_set_size(); tab_runtime_changed(); } void Tab :: on_track_removed(unsigned int row) { - tab_model->on_row_deleted(row); + tab_window->q_model->on_row_deleted(row); tab_set_size(); tab_runtime_changed(); } void Tab :: on_track_updated(unsigned int row) { - tab_model->on_row_changed(row); + tab_window->q_model->on_row_changed(row); tab_runtime_changed(); } @@ -147,13 +151,13 @@ void Tab :: tab_focus_search() void Tab :: tab_selected_ids(std::vector &ids) { - Glib::RefPtr sel = tab_treeview->get_selection(); + Glib::RefPtr sel = tab_window->q_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(tab_model->path_to_id(path)); + path = tab_window->q_filter->convert_path_to_child_path(rows[i]); + ids.push_back(tab_window->q_model->path_to_id(path)); } sel->unselect_all(); } @@ -279,7 +283,7 @@ bool Tab :: on_key_pressed(GdkEventKey *event) void Tab :: on_column_clicked(unsigned int col) { if (tab_sorting_count == 0) { - tab_sorting_title = tab_treeview->get_column(col)->get_title(); + tab_sorting_title = tab_window->q_treeview->get_column(col)->get_title(); tab_pq->sort(sort_fields[col], true); } else tab_pq->sort(sort_fields[col], false); @@ -296,8 +300,8 @@ bool Tab :: on_button_pressed(GdkEventButton *button) return false; Gtk::TreeModel::Path path; - if (tab_treeview->get_path_at_pos(button->x, button->y, path)) - tab_treeview->get_selection()->select(path); + if (tab_window->q_treeview->get_path_at_pos(button->x, button->y, path)) + tab_window->q_treeview->get_selection()->select(path); on_show_rc_menu(); gui :: get_widget("o_rc_menu")->popup(button->button, button->time); diff --git a/include/gui/tabs.h b/include/gui/tabs.h index 71781001..6006ec36 100644 --- a/include/gui/tabs.h +++ b/include/gui/tabs.h @@ -7,6 +7,7 @@ #include #include #include +#include #include class Tab : public QNotifier { @@ -20,14 +21,7 @@ protected: Gtk::VBox tab_vbox; QueueToolbar *tab_toolbar; - - /** - * Widgets that MUST be set by a child class - */ - Glib::RefPtr tab_model; - Glib::RefPtr tab_filter; - - Gtk::TreeView *tab_treeview; + QueueWindow *tab_window; /** * Optional widgets that MAY be set