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:
parent
c5598293d6
commit
91fc9436a5
|
@ -14,6 +14,7 @@
|
||||||
static class DefaultNotifier : public QNotifier {
|
static class DefaultNotifier : public QNotifier {
|
||||||
public:
|
public:
|
||||||
DefaultNotifier() {};
|
DefaultNotifier() {};
|
||||||
|
void on_track_added(unsigned int pos) {};
|
||||||
} def_notify;
|
} def_notify;
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,6 +148,7 @@ unsigned int Queue :: _add_at(Track *track, unsigned int pos)
|
||||||
{
|
{
|
||||||
_tracks.insert(_tracks.begin() + pos, track);
|
_tracks.insert(_tracks.begin() + pos, track);
|
||||||
_length += track->length();
|
_length += track->length();
|
||||||
|
_notify->on_track_added(pos);
|
||||||
get_callbacks()->on_queue_track_add(this, pos);
|
get_callbacks()->on_queue_track_add(this, pos);
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,13 @@ enum sort_t {
|
||||||
class QNotifier {
|
class QNotifier {
|
||||||
public:
|
public:
|
||||||
QNotifier() {}; /**< Notifier constructor. */
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ Track *TRACK_NULL = NULL;
|
||||||
static class TestNotifier : public QNotifier {
|
static class TestNotifier : public QNotifier {
|
||||||
public:
|
public:
|
||||||
TestNotifier() : QNotifier() {}
|
TestNotifier() : QNotifier() {}
|
||||||
|
void on_track_added(unsigned int i) { count_add++; }
|
||||||
} test_notifier;
|
} test_notifier;
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +34,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
TestQueue *Q = NULL, *R = NULL;
|
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) { }
|
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);
|
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)
|
void test_del_cb(Queue *q, unsigned int id)
|
||||||
{
|
{
|
||||||
count_del++;
|
count_del++;
|
||||||
|
@ -137,7 +132,6 @@ void test_add_remove()
|
||||||
TestQueue q(0);
|
TestQueue q(0);
|
||||||
Q = &q;
|
Q = &q;
|
||||||
|
|
||||||
get_callbacks()->on_queue_track_add = test_add_cb;
|
|
||||||
get_callbacks()->on_queue_track_del = test_del_cb;
|
get_callbacks()->on_queue_track_del = test_del_cb;
|
||||||
|
|
||||||
test_equal(q.length(), expected);
|
test_equal(q.length(), expected);
|
||||||
|
@ -212,7 +206,6 @@ void test_updated()
|
||||||
TestQueue q(0);
|
TestQueue q(0);
|
||||||
|
|
||||||
Q = &q;
|
Q = &q;
|
||||||
get_callbacks()->on_queue_track_add = test_add_cb_noop;
|
|
||||||
get_callbacks()->on_queue_track_changed = test_updated_cb;
|
get_callbacks()->on_queue_track_changed = test_updated_cb;
|
||||||
|
|
||||||
test_fill_q();
|
test_fill_q();
|
||||||
|
|
Loading…
Reference in New Issue