diff --git a/core/deck.cpp b/core/deck.cpp index bf50a04f..3d1954a7 100644 --- a/core/deck.cpp +++ b/core/deck.cpp @@ -38,7 +38,7 @@ void TempQueue :: del(struct track *track) void TempQueue :: del(unsigned int id) { - queue :: del(id); + queue_remove(this, id); deck :: write(); } diff --git a/core/playlist.cpp b/core/playlist.cpp index efb9e223..0ccad289 100644 --- a/core/playlist.cpp +++ b/core/playlist.cpp @@ -11,7 +11,7 @@ public: void clear() { while (queue_size(this) > 0) - del((unsigned)0); + queue_remove(this, (unsigned)0); } void fill(index_entry *ent) diff --git a/core/queue.cpp b/core/queue.cpp index 23e67605..39bc59bd 100644 --- a/core/queue.cpp +++ b/core/queue.cpp @@ -131,21 +131,21 @@ unsigned int queue_add(struct queue *queue, struct track *track) return pos; } -void queue :: del(unsigned int index) +void queue_remove(struct queue *queue, unsigned int index) { - q_length -= q_tracks[index]->tr_length; - q_tracks.erase(q_tracks.begin() + index); - q_notify->on_track_removed(index); + queue->q_length -= queue->q_tracks[index]->tr_length; + queue->q_tracks.erase(queue->q_tracks.begin() + index); + queue->q_notify->on_track_removed(index); - if (q_cur == index) - q_cur--; + if (queue->q_cur == index) + queue->q_cur--; } void queue :: del(struct track *track) { for (unsigned int i = 0; i < q_tracks.size(); i++) { while ((i < q_tracks.size()) && (q_tracks[i] == track)) - del(i); + queue_remove(this, i); } } @@ -161,7 +161,7 @@ void queue_selected(struct queue *queue, unsigned int index) { queue->q_cur = index; if (queue_has_flag(queue, Q_REPEAT) == false) - queue->del(index); + queue_remove(queue, index); } struct track *queue_next(struct queue *queue) diff --git a/gui/queue.cpp b/gui/queue.cpp index 65e62d19..adbb18bf 100644 --- a/gui/queue.cpp +++ b/gui/queue.cpp @@ -141,7 +141,7 @@ bool QueueTab :: on_key_press_event(const std::string &key) } for (unsigned int i = ids.size(); i > 0; i--) - tab_pq->del(ids[i-1]); + queue_remove(tab_pq, ids[i-1]); return true; } diff --git a/include/core/queue.h b/include/core/queue.h index 0a3ae804..6a4f6c2d 100644 --- a/include/core/queue.h +++ b/include/core/queue.h @@ -110,13 +110,6 @@ struct queue { void read(file &); - /** - * Remove a track based on its queue index. - * - * @param index Track index to remove from the queue. - */ - virtual void del(unsigned int); - /** * Remove all instances of a track from the queue. * @@ -158,6 +151,9 @@ static inline struct track *queue_at(struct queue *queue, unsigned int index) /* Called to add a track to the queue. */ unsigned int queue_add(struct queue *, struct track *); +/* Called to remove a track from the queue by index. */ +void queue_remove(struct queue *, unsigned int); + /* Called to tell the queue that a track has been updated. */ void queue_updated(struct queue *, struct track *); diff --git a/tests/core/queue.cpp b/tests/core/queue.cpp index ca2fdac4..be0c9153 100644 --- a/tests/core/queue.cpp +++ b/tests/core/queue.cpp @@ -176,13 +176,13 @@ static void test_stress(unsigned int N) test_equal(q.q_length, ex_length); test_equal(queue_size(&q), ex_size); - /* Queue :: del(unsigned int) */ + /* queue_remove() */ track = track_get(1); ex_length -= track->tr_length * (N / 13); ex_size -= (N / 13); for (i = 0; i < ex_size; i += 11) { test_loop_equal(queue_at(&q, i), track, i); - q.del(i); + queue_remove(&q, i); } test_loop_passed(); test_equal(q.q_length, ex_length); test_equal(queue_size(&q), ex_size);