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:
Anna Schumaker 2015-04-03 12:02:49 -04:00
parent 91fc9436a5
commit 67228ef8b1
2 changed files with 20 additions and 17 deletions

View File

@ -32,6 +32,7 @@ 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;
}
@ -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_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)
{
tab_model->on_row_deleted(row);
@ -410,13 +417,6 @@ static Tab *cur_tab()
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)
{
Tab *tab = find_tab(pq);
@ -487,7 +487,6 @@ static void init_menu_item(const std::string &pq, unsigned int n)
void init_tabs()
{
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_changed = on_track_changed;

View File

@ -9,7 +9,7 @@
#include <core/queue.h>
#include <set>
class Tab {
class Tab : public QNotifier {
private:
std::set<unsigned int> visible_ids;
unsigned int tab_sorting_count;
@ -50,6 +50,11 @@ public:
Tab(Queue *);
virtual ~Tab();
/**
* QNotifier implementation
*/
void on_track_added(unsigned int);
/**
* More helper functions
*/
@ -71,7 +76,6 @@ public:
* internal callback functions that can be overridden if necessary
*/
virtual void on_post_init();
virtual void on_track_added(unsigned int);
virtual void on_track_deleted(unsigned int);
virtual void on_track_changed(unsigned int);
virtual bool on_key_press_event(const std::string &);