queue: Give notifiers an "on_track_added()" function

So they can tell GUIs that something has been added.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-04-03 11:35:23 -04:00
parent c5598293d6
commit 91fc9436a5
3 changed files with 10 additions and 8 deletions

View File

@ -14,6 +14,7 @@
static class DefaultNotifier : public QNotifier {
public:
DefaultNotifier() {};
void on_track_added(unsigned int pos) {};
} def_notify;
@ -147,6 +148,7 @@ unsigned int Queue :: _add_at(Track *track, unsigned int pos)
{
_tracks.insert(_tracks.begin() + pos, track);
_length += track->length();
_notify->on_track_added(pos);
get_callbacks()->on_queue_track_add(this, pos);
return pos;
}

View File

@ -46,6 +46,13 @@ enum sort_t {
class QNotifier {
public:
QNotifier() {}; /**< Notifier constructor. */
/**
* Called when a track is added to a queue.
*
* @param pos Position in the queue that the track was added.
*/
virtual void on_track_added(unsigned int) = 0;
};

View File

@ -19,6 +19,7 @@ Track *TRACK_NULL = NULL;
static class TestNotifier : public QNotifier {
public:
TestNotifier() : QNotifier() {}
void on_track_added(unsigned int i) { count_add++; }
} test_notifier;
@ -33,7 +34,6 @@ public:
};
TestQueue *Q = NULL, *R = NULL;
void test_add_cb_noop(Queue *q, unsigned int id) { }
void test_del_cb_noop(Queue *q, unsigned int id) { }
@ -82,11 +82,6 @@ void test_flags()
test_equal(q.has_flag(Q_NO_SORT), false);
}
void test_add_cb(Queue *q, unsigned int id)
{
count_add++;
}
void test_del_cb(Queue *q, unsigned int id)
{
count_del++;
@ -137,7 +132,6 @@ void test_add_remove()
TestQueue q(0);
Q = &q;
get_callbacks()->on_queue_track_add = test_add_cb;
get_callbacks()->on_queue_track_del = test_del_cb;
test_equal(q.length(), expected);
@ -212,7 +206,6 @@ void test_updated()
TestQueue q(0);
Q = &q;
get_callbacks()->on_queue_track_add = test_add_cb_noop;
get_callbacks()->on_queue_track_changed = test_updated_cb;
test_fill_q();