gui: Turn the Tab class into a QNotifier
Now we can respond to notifications directly. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
91fc9436a5
commit
67228ef8b1
29
gui/tabs.cpp
29
gui/tabs.cpp
|
@ -32,6 +32,7 @@ Tab :: Tab(Queue *pq)
|
||||||
: tab_sorting_count(0), tab_pq(pq), tab_size(NULL)
|
: tab_sorting_count(0), tab_pq(pq), tab_size(NULL)
|
||||||
{
|
{
|
||||||
tab_model = Glib::RefPtr<QueueModel>(new QueueModel(tab_pq));
|
tab_model = Glib::RefPtr<QueueModel>(new QueueModel(tab_pq));
|
||||||
|
pq->set_notifier(this);
|
||||||
queue_mapping[tab_pq] = this;
|
queue_mapping[tab_pq] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +67,19 @@ void Tab :: tab_finish_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* QNotifier implementation.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
void Tab :: on_track_added(unsigned int row)
|
||||||
|
{
|
||||||
|
tab_model->on_row_inserted(row);
|
||||||
|
tab_set_size();
|
||||||
|
tab_runtime_changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -217,13 +231,6 @@ void Tab :: tab_ban_selected()
|
||||||
|
|
||||||
void Tab :: on_post_init() {}
|
void Tab :: on_post_init() {}
|
||||||
|
|
||||||
void Tab :: on_track_added(unsigned int row)
|
|
||||||
{
|
|
||||||
tab_model->on_row_inserted(row);
|
|
||||||
tab_set_size();
|
|
||||||
tab_runtime_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Tab :: on_track_deleted(unsigned int row)
|
void Tab :: on_track_deleted(unsigned int row)
|
||||||
{
|
{
|
||||||
tab_model->on_row_deleted(row);
|
tab_model->on_row_deleted(row);
|
||||||
|
@ -410,13 +417,6 @@ static Tab *cur_tab()
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_track_added(Queue *pq, unsigned int row)
|
|
||||||
{
|
|
||||||
Tab *tab = find_tab(pq);
|
|
||||||
if (tab)
|
|
||||||
tab->on_track_added(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void on_track_deleted(Queue *pq, unsigned int row)
|
static void on_track_deleted(Queue *pq, unsigned int row)
|
||||||
{
|
{
|
||||||
Tab *tab = find_tab(pq);
|
Tab *tab = find_tab(pq);
|
||||||
|
@ -487,7 +487,6 @@ static void init_menu_item(const std::string &pq, unsigned int n)
|
||||||
void init_tabs()
|
void init_tabs()
|
||||||
{
|
{
|
||||||
struct Callbacks *cb = get_callbacks();
|
struct Callbacks *cb = get_callbacks();
|
||||||
cb->on_queue_track_add = on_track_added;
|
|
||||||
cb->on_queue_track_del = on_track_deleted;
|
cb->on_queue_track_del = on_track_deleted;
|
||||||
cb->on_queue_track_changed = on_track_changed;
|
cb->on_queue_track_changed = on_track_changed;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <core/queue.h>
|
#include <core/queue.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
class Tab {
|
class Tab : public QNotifier {
|
||||||
private:
|
private:
|
||||||
std::set<unsigned int> visible_ids;
|
std::set<unsigned int> visible_ids;
|
||||||
unsigned int tab_sorting_count;
|
unsigned int tab_sorting_count;
|
||||||
|
@ -50,6 +50,11 @@ public:
|
||||||
Tab(Queue *);
|
Tab(Queue *);
|
||||||
virtual ~Tab();
|
virtual ~Tab();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QNotifier implementation
|
||||||
|
*/
|
||||||
|
void on_track_added(unsigned int);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More helper functions
|
* More helper functions
|
||||||
*/
|
*/
|
||||||
|
@ -71,7 +76,6 @@ public:
|
||||||
* internal callback functions that can be overridden if necessary
|
* internal callback functions that can be overridden if necessary
|
||||||
*/
|
*/
|
||||||
virtual void on_post_init();
|
virtual void on_post_init();
|
||||||
virtual void on_track_added(unsigned int);
|
|
||||||
virtual void on_track_deleted(unsigned int);
|
virtual void on_track_deleted(unsigned int);
|
||||||
virtual void on_track_changed(unsigned int);
|
virtual void on_track_changed(unsigned int);
|
||||||
virtual bool on_key_press_event(const std::string &);
|
virtual bool on_key_press_event(const std::string &);
|
||||||
|
|
Loading…
Reference in New Issue