queue: Create an on_track_removed() notification
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
89a13ff6f7
commit
9eef2ad35d
|
@ -14,7 +14,8 @@
|
||||||
static class DefaultNotifier : public QNotifier {
|
static class DefaultNotifier : public QNotifier {
|
||||||
public:
|
public:
|
||||||
DefaultNotifier() {};
|
DefaultNotifier() {};
|
||||||
void on_track_added(unsigned int pos) {};
|
void on_track_added(unsigned int pos) {};
|
||||||
|
void on_track_removed(unsigned int pos) {};
|
||||||
} def_notify;
|
} def_notify;
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,6 +165,7 @@ void Queue :: del(unsigned int index)
|
||||||
{
|
{
|
||||||
_length -= _tracks[index]->length();
|
_length -= _tracks[index]->length();
|
||||||
_tracks.erase(_tracks.begin() + index);
|
_tracks.erase(_tracks.begin() + index);
|
||||||
|
_notify->on_track_removed(index);
|
||||||
get_callbacks()->on_queue_track_del(this, index);
|
get_callbacks()->on_queue_track_del(this, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,13 @@ public:
|
||||||
* @param pos Position in the queue that the track was added.
|
* @param pos Position in the queue that the track was added.
|
||||||
*/
|
*/
|
||||||
virtual void on_track_added(unsigned int) = 0;
|
virtual void on_track_added(unsigned int) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a track is removed from a queue.
|
||||||
|
*
|
||||||
|
* @param pos Position in the queue that the track was removed from.
|
||||||
|
*/
|
||||||
|
virtual void on_track_removed(unsigned int) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ 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++; }
|
void on_track_added(unsigned int i) { count_add++; }
|
||||||
|
void on_track_removed(unsigned int i) { count_del++; }
|
||||||
} test_notifier;
|
} test_notifier;
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +35,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
TestQueue *Q = NULL, *R = NULL;
|
TestQueue *Q = NULL, *R = NULL;
|
||||||
void test_del_cb_noop(Queue *q, unsigned int id) { }
|
|
||||||
|
|
||||||
|
|
||||||
void test_default()
|
void test_default()
|
||||||
|
@ -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_del_cb(Queue *q, unsigned int id)
|
|
||||||
{
|
|
||||||
count_del++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int _test_add_loop(unsigned int i)
|
unsigned int _test_add_loop(unsigned int i)
|
||||||
{
|
{
|
||||||
|
@ -132,12 +127,9 @@ void test_add_remove()
|
||||||
TestQueue q(0);
|
TestQueue q(0);
|
||||||
Q = &q;
|
Q = &q;
|
||||||
|
|
||||||
get_callbacks()->on_queue_track_del = test_del_cb;
|
|
||||||
|
|
||||||
test_equal(q.length(), expected);
|
test_equal(q.length(), expected);
|
||||||
test_equal(q.size(), (unsigned)0);
|
test_equal(q.size(), (unsigned)0);
|
||||||
|
|
||||||
|
|
||||||
/* Add tracks */
|
/* Add tracks */
|
||||||
test_for_each(0, 24, 1, _test_add_loop);
|
test_for_each(0, 24, 1, _test_add_loop);
|
||||||
test_equal(q.length(), expected);
|
test_equal(q.length(), expected);
|
||||||
|
@ -244,7 +236,6 @@ void test_next()
|
||||||
TestQueue q(0);
|
TestQueue q(0);
|
||||||
|
|
||||||
Q = &q;
|
Q = &q;
|
||||||
get_callbacks()->on_queue_track_del = test_del_cb_noop;
|
|
||||||
test_fill_q();
|
test_fill_q();
|
||||||
|
|
||||||
test_for_each(0, 24, 1, _test_next_loop);
|
test_for_each(0, 24, 1, _test_next_loop);
|
||||||
|
|
Loading…
Reference in New Issue