gui: Set up queue model and filter inside the QueueWindow
This lets me move functions affecting the treeview into the QueueWindow class. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
5bf861b9f3
commit
8c3b1489bd
|
@ -29,7 +29,9 @@ public:
|
|||
builder->get_widget_derived("CollectionLabel", collection_label);
|
||||
builder->get_widget_derived("QueueToolbar", collection_toolbar);
|
||||
builder->get_widget_derived("QueueWindow", collection_window);
|
||||
|
||||
collection_toolbar->init(tab_pq, collection_label, collection_window, T_RANDOM);
|
||||
collection_window->init(tab_pq);
|
||||
|
||||
collection_vbox.set_margin_left(1);
|
||||
collection_vbox.set_margin_right(1);
|
||||
|
@ -38,6 +40,8 @@ public:
|
|||
collection_vbox.pack_start(*collection_window, true, true);
|
||||
collection_vbox.show();
|
||||
|
||||
tab_model = collection_window->q_model;
|
||||
tab_filter = collection_window->q_filter;
|
||||
tab_search = collection_toolbar->q_search;
|
||||
tab_size = collection_label->collection_size;
|
||||
tab_treeview = collection_window->q_treeview;
|
||||
|
|
|
@ -28,7 +28,9 @@ public:
|
|||
builder->get_widget_derived("HistoryLabel", history_label);
|
||||
builder->get_widget_derived("QueueToolbar", history_toolbar);
|
||||
builder->get_widget_derived("QueueWindow", history_window);
|
||||
|
||||
history_toolbar->init(tab_pq, history_label, history_window, 0);
|
||||
history_window->init(tab_pq);
|
||||
|
||||
history_vbox.set_margin_left(1);
|
||||
history_vbox.set_margin_right(1);
|
||||
|
@ -37,6 +39,8 @@ public:
|
|||
history_vbox.pack_start(*history_window, true, true);
|
||||
history_vbox.show();
|
||||
|
||||
tab_model = history_window->q_model;
|
||||
tab_filter = history_window->q_filter;
|
||||
tab_search = history_toolbar->q_search;
|
||||
tab_size = history_label->history_size;
|
||||
tab_treeview = history_window->q_treeview;
|
||||
|
|
|
@ -93,7 +93,9 @@ public:
|
|||
builder->get_widget_derived("PlaylistWindow", playlist_window);
|
||||
builder->get_widget_derived("QueueToolbar", playlist_toolbar);
|
||||
builder->get_widget_derived("QueueWindow", playlist_tracks);
|
||||
|
||||
playlist_toolbar->init(tab_pq, playlist_label, playlist_tracks, 0);
|
||||
playlist_tracks->init(tab_pq);
|
||||
|
||||
playlist_hbox.pack_start(*playlist_window, false, true);
|
||||
playlist_hbox.pack_start(*playlist_tracks, true, true);
|
||||
|
@ -106,6 +108,8 @@ public:
|
|||
playlist_vbox.pack_start(playlist_hbox, true, true);
|
||||
playlist_vbox.show();
|
||||
|
||||
tab_model = playlist_tracks->q_model;
|
||||
tab_filter = playlist_tracks->q_filter;
|
||||
tab_search = playlist_toolbar->q_search;
|
||||
tab_treeview = playlist_tracks->q_treeview;
|
||||
tab_widget = &playlist_vbox;
|
||||
|
|
|
@ -104,6 +104,7 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
* And the treeview with scrolled window
|
||||
*/
|
||||
builder->get_widget_derived("QueueWindow", q_window);
|
||||
q_window->init(pq);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -129,6 +130,8 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
* Set generic tab widgets
|
||||
*/
|
||||
|
||||
tab_model = q_window->q_model;
|
||||
tab_filter = q_window->q_filter;
|
||||
tab_search = q_toolbar->q_search;
|
||||
tab_size = q_label->temp_size;
|
||||
tab_treeview = q_window->q_treeview;
|
||||
|
|
|
@ -13,3 +13,11 @@ QueueWindow :: QueueWindow(BaseObjectType *cobject,
|
|||
QueueWindow :: ~QueueWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void QueueWindow :: init(Queue *queue)
|
||||
{
|
||||
_queue = queue;
|
||||
q_model = Glib::RefPtr<QueueModel>(new QueueModel(queue));
|
||||
q_filter = Gtk::TreeModelFilter::create(q_model);
|
||||
q_treeview->set_model(q_filter);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ static sort_t sort_fields[] = {
|
|||
Tab :: Tab(Queue *pq)
|
||||
: tab_sorting_count(0), tab_pq(pq), tab_size(NULL)
|
||||
{
|
||||
tab_model = Glib::RefPtr<QueueModel>(new QueueModel(tab_pq));
|
||||
pq->set_notifier(this);
|
||||
queue_mapping[tab_pq] = this;
|
||||
}
|
||||
|
@ -39,7 +38,6 @@ Tab :: ~Tab() {}
|
|||
|
||||
void Tab :: tab_finish_init()
|
||||
{
|
||||
tab_filter = Gtk::TreeModelFilter::create(tab_model);
|
||||
tab_filter->set_visible_func(sigc::mem_fun(*this,
|
||||
&Tab::on_filter_visible));
|
||||
tab_search->signal_key_release_event().connect(sigc::mem_fun(*this,
|
||||
|
@ -47,7 +45,6 @@ void Tab :: tab_finish_init()
|
|||
tab_search->signal_search_changed().connect(sigc::mem_fun(*this,
|
||||
&Tab::on_entry_changed));
|
||||
|
||||
tab_treeview->set_model(tab_filter);
|
||||
tab_treeview->signal_row_activated().connect(sigc::mem_fun(*this,
|
||||
&Tab :: on_row_activated));
|
||||
tab_treeview->signal_key_press_event().connect(sigc::mem_fun(*this,
|
||||
|
|
|
@ -4,17 +4,23 @@
|
|||
#ifndef OCARINA_GUI_QUEUE_WINDOW_H
|
||||
#define OCARINA_GUI_QUEUE_WINDOW_H
|
||||
|
||||
#include <gui/queue/model.h>
|
||||
#include <gtkmm.h>
|
||||
|
||||
class QueueWindow : public Gtk::ScrolledWindow {
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> _builder;
|
||||
Queue *_queue;
|
||||
|
||||
public:
|
||||
Gtk::TreeView *q_treeview;
|
||||
Glib::RefPtr<QueueModel> q_model;
|
||||
Glib::RefPtr<Gtk::TreeModelFilter> q_filter;
|
||||
|
||||
QueueWindow(BaseObjectType *, const Glib::RefPtr<Gtk::Builder>);
|
||||
~QueueWindow();
|
||||
|
||||
void init(Queue *);
|
||||
};
|
||||
|
||||
#endif /* OCARINA_GUI_QUEUE_WINDOW_H */
|
||||
|
|
|
@ -17,13 +17,13 @@ private:
|
|||
|
||||
protected:
|
||||
Queue *tab_pq;
|
||||
Glib::RefPtr<QueueModel> tab_model;
|
||||
Glib::RefPtr<Gtk::TreeModelFilter> tab_filter;
|
||||
|
||||
|
||||
/**
|
||||
* Widgets that MUST be set by a child class
|
||||
*/
|
||||
Glib::RefPtr<QueueModel> tab_model;
|
||||
Glib::RefPtr<Gtk::TreeModelFilter> tab_filter;
|
||||
|
||||
Gtk::SearchEntry *tab_search;
|
||||
Gtk::TreeView *tab_treeview;
|
||||
Gtk::Widget *tab_widget;
|
||||
|
|
Loading…
Reference in New Issue