core/tempq: Move tempq_get() out of the deck namespace
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
6bdc481cb4
commit
c22b93b2cf
|
@ -106,6 +106,20 @@ void tempq_free(struct queue *queue)
|
|||
return;
|
||||
}
|
||||
|
||||
struct queue *tempq_get(unsigned int index)
|
||||
{
|
||||
std::list<TempQueue>::iterator it;
|
||||
unsigned int i;
|
||||
|
||||
it = queue_deck.begin();
|
||||
for (i = 0; i < queue_deck.size(); i++) {
|
||||
if (i == index)
|
||||
return &(*it);
|
||||
it++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void deck :: write()
|
||||
{
|
||||
std::list<TempQueue>::iterator it;
|
||||
|
@ -148,18 +162,6 @@ void deck :: move(queue *queue, unsigned int index)
|
|||
write();
|
||||
}
|
||||
|
||||
queue *deck :: get(unsigned int index)
|
||||
{
|
||||
std::list<TempQueue>::iterator it;
|
||||
|
||||
for (it = queue_deck.begin(); it != queue_deck.end(); it++) {
|
||||
if (index == 0)
|
||||
return &(*it);
|
||||
index--;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct track *deck :: next()
|
||||
{
|
||||
struct track *track = NULL;
|
||||
|
|
|
@ -217,7 +217,7 @@ bool Tab :: tab_add_to_queue(unsigned int n)
|
|||
if (n >= deck :: get_queues().size())
|
||||
return true;
|
||||
|
||||
queue *pq = deck :: get(n);
|
||||
queue *pq = tempq_get(n);
|
||||
tab_queue_add(pq);
|
||||
return true;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ void post_init_tabs()
|
|||
|
||||
unsigned int tab = 0;
|
||||
for (tab = 0; tab < deck::get_queues().size(); tab++) {
|
||||
if (queue_has_flag(deck :: get(tab), Q_ENABLED))
|
||||
if (queue_has_flag(tempq_get(tab), Q_ENABLED))
|
||||
break;
|
||||
}
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->set_current_page(tab);
|
||||
|
|
|
@ -54,14 +54,6 @@ namespace deck
|
|||
*/
|
||||
void move(queue *, unsigned int);
|
||||
|
||||
/**
|
||||
* Access the queue at the specified index.
|
||||
*
|
||||
* @param index The index of the queue that should be accessed.
|
||||
* @return The queue at the requested index.
|
||||
*/
|
||||
queue *get(unsigned int);
|
||||
|
||||
/**
|
||||
* @return A track from the first enabled queue. If no queues are
|
||||
* enabled, return a track from the Library.
|
||||
|
@ -86,4 +78,7 @@ struct queue *tempq_alloc(struct queue_ops *, unsigned int);
|
|||
/* Called to free a temporary queue. */
|
||||
void tempq_free(struct queue *);
|
||||
|
||||
/* Called to find a temporary queue by index. */
|
||||
struct queue *tempq_get(unsigned int);
|
||||
|
||||
#endif /* OCARINA_CORE_DECK_H */
|
||||
|
|
|
@ -25,7 +25,7 @@ static void test_init()
|
|||
test_equal(deck :: next(), NULL);
|
||||
tempq_init(NULL);
|
||||
test_equal(deck :: next(), NULL);
|
||||
test_equal(deck :: get(0), NULL);
|
||||
test_equal(tempq_get(0), NULL);
|
||||
test_equal(deck :: get_queues().size(), (size_t)0);
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ static void test_tempq()
|
|||
test_equal(queue_has_flag(q0, Q_RANDOM), false);
|
||||
test_equal(queue_has_flag(q0, Q_SAVE_SORT), true);
|
||||
test_equal(queue_has_flag(q0, Q_SAVE_FLAGS), true);
|
||||
test_equal(tempq_get(0), q0);
|
||||
|
||||
q1 = tempq_alloc(NULL, Q_RANDOM);
|
||||
test_not_equal(q1, NULL);
|
||||
|
@ -46,9 +47,14 @@ static void test_tempq()
|
|||
test_equal(queue_has_flag(q1, Q_RANDOM), true);
|
||||
test_equal(queue_has_flag(q1, Q_SAVE_SORT), true);
|
||||
test_equal(queue_has_flag(q1, Q_SAVE_FLAGS), true);
|
||||
test_equal(tempq_get(1), q1);
|
||||
|
||||
tempq_free(q0);
|
||||
test_equal(tempq_get(0), q1);
|
||||
|
||||
tempq_free(q1);
|
||||
test_equal(tempq_get(0), NULL);
|
||||
|
||||
history_deinit();
|
||||
collection_deinit();
|
||||
playlist_deinit();
|
||||
|
@ -72,13 +78,13 @@ static void test_create_mv_destroy()
|
|||
test_not_equal(q1, Q_NULL);
|
||||
test_equal(queue_has_flag(q1, Q_ENABLED), true);
|
||||
test_equal(queue_has_flag(q1, Q_RANDOM), true);
|
||||
test_equal(deck :: get(2), q1);
|
||||
test_equal(tempq_get(2), q1);
|
||||
|
||||
q2 = tempq_alloc(NULL, 0);
|
||||
test_not_equal(q2, Q_NULL);
|
||||
test_equal(queue_has_flag(q2, Q_ENABLED), true);
|
||||
test_equal(queue_has_flag(q2, Q_RANDOM), false);
|
||||
test_equal(deck :: get(3), q2);
|
||||
test_equal(tempq_get(3), q2);
|
||||
|
||||
deck :: move(q1, 3);
|
||||
deck :: move(q1, 3);
|
||||
|
@ -87,15 +93,15 @@ static void test_create_mv_destroy()
|
|||
tempq_free(q1);
|
||||
tempq_free(q2);
|
||||
|
||||
test_equal(deck :: get(3), Q_NULL);
|
||||
test_equal(tempq_get(3), Q_NULL);
|
||||
}
|
||||
|
||||
static void test_next_prev()
|
||||
{
|
||||
std::list<TempQueue>::iterator it = deck :: get_queues().begin();
|
||||
queue *q = history_get_queue();
|
||||
queue *q0 = deck :: get(0);
|
||||
queue *q1 = deck :: get(1);
|
||||
queue *q0 = tempq_get(0);
|
||||
queue *q1 = tempq_get(1);
|
||||
|
||||
queue_unset_flag(q0, Q_RANDOM);
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
|
|
Loading…
Reference in New Issue