core/queue: Convert from class to struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
626eb48933
commit
281947aded
|
@ -6,15 +6,15 @@
|
|||
#include <core/library.h>
|
||||
|
||||
|
||||
class RecentQueue : public Queue
|
||||
class RecentQueue : public queue
|
||||
{
|
||||
public:
|
||||
RecentQueue() : Queue(Q_ENABLED | Q_REPEAT | Q_NO_SORT) {}
|
||||
RecentQueue() : queue(Q_ENABLED | Q_REPEAT | Q_NO_SORT) {}
|
||||
|
||||
unsigned int add(struct track *track)
|
||||
{
|
||||
del(track);
|
||||
_cur = 0;
|
||||
q_cur = 0;
|
||||
return _add_at(track, 0);
|
||||
}
|
||||
};
|
||||
|
@ -27,42 +27,42 @@ static struct file deck_file;
|
|||
|
||||
TempQueue :: TempQueue() {}
|
||||
TempQueue :: TempQueue(bool random)
|
||||
: Queue(Q_ENABLED | (random ? Q_RANDOM : 0)) {}
|
||||
: queue(Q_ENABLED | (random ? Q_RANDOM : 0)) {}
|
||||
|
||||
void TempQueue :: set_flag(queue_flags flag)
|
||||
{
|
||||
Queue :: set_flag(flag);
|
||||
queue :: set_flag(flag);
|
||||
deck :: write();
|
||||
}
|
||||
|
||||
void TempQueue :: unset_flag(queue_flags flag)
|
||||
{
|
||||
Queue :: unset_flag(flag);
|
||||
queue :: unset_flag(flag);
|
||||
deck :: write();
|
||||
}
|
||||
|
||||
unsigned int TempQueue :: add(struct track *track)
|
||||
{
|
||||
unsigned int res = Queue :: add(track);
|
||||
unsigned int res = queue :: add(track);
|
||||
deck :: write();
|
||||
return res;
|
||||
}
|
||||
|
||||
void TempQueue :: del(struct track *track)
|
||||
{
|
||||
Queue :: del(track);
|
||||
queue :: del(track);
|
||||
deck :: write();
|
||||
}
|
||||
|
||||
void TempQueue :: del(unsigned int id)
|
||||
{
|
||||
Queue :: del(id);
|
||||
queue :: del(id);
|
||||
deck :: write();
|
||||
}
|
||||
|
||||
void TempQueue :: sort(compare_t field, bool ascending)
|
||||
{
|
||||
Queue :: sort(field, ascending);
|
||||
queue :: sort(field, ascending);
|
||||
deck :: write();
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ static void upgrade_v0()
|
|||
{
|
||||
int random, ascending;
|
||||
unsigned int num, field;
|
||||
Queue *library = collection :: get_queue();
|
||||
queue *library = collection :: get_queue();
|
||||
|
||||
file_readf(&deck_file, "%d %u", &random, &num);
|
||||
if (random)
|
||||
|
@ -127,7 +127,7 @@ void deck :: write()
|
|||
file_close(&deck_file);
|
||||
}
|
||||
|
||||
Queue *deck :: create(bool random)
|
||||
queue *deck :: create(bool random)
|
||||
{
|
||||
queue_deck.push_back(TempQueue(random));
|
||||
return &queue_deck.back();
|
||||
|
@ -139,7 +139,7 @@ static void _destroy(std::list<TempQueue>::iterator &it)
|
|||
deck :: write();
|
||||
}
|
||||
|
||||
void deck :: destroy(Queue *queue)
|
||||
void deck :: destroy(queue *queue)
|
||||
{
|
||||
std::list<TempQueue>::iterator it;
|
||||
|
||||
|
@ -151,7 +151,7 @@ void deck :: destroy(Queue *queue)
|
|||
}
|
||||
}
|
||||
|
||||
void deck :: move(Queue *queue, unsigned int index)
|
||||
void deck :: move(queue *queue, unsigned int index)
|
||||
{
|
||||
unsigned int old_pos = deck :: index(queue);
|
||||
std::list<TempQueue>::iterator it_old = queue_deck.begin();
|
||||
|
@ -172,7 +172,7 @@ void deck :: move(Queue *queue, unsigned int index)
|
|||
write();
|
||||
}
|
||||
|
||||
unsigned int deck :: index(Queue *queue)
|
||||
unsigned int deck :: index(queue *queue)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
std::list<TempQueue>::iterator it;
|
||||
|
@ -186,7 +186,7 @@ unsigned int deck :: index(Queue *queue)
|
|||
return queue_deck.size();
|
||||
}
|
||||
|
||||
Queue *deck :: get(unsigned int index)
|
||||
queue *deck :: get(unsigned int index)
|
||||
{
|
||||
std::list<TempQueue>::iterator it;
|
||||
|
||||
|
@ -230,7 +230,7 @@ std::list<TempQueue> &deck :: get_queues()
|
|||
return queue_deck;
|
||||
}
|
||||
|
||||
Queue *deck :: get_queue()
|
||||
queue *deck :: get_queue()
|
||||
{
|
||||
return &recent_queue;
|
||||
}
|
||||
|
|
|
@ -10,18 +10,18 @@ extern "C" {
|
|||
#include <glib.h>
|
||||
|
||||
|
||||
class LibraryQueue : public Queue {
|
||||
class LibraryQueue : public queue {
|
||||
private:
|
||||
file f;
|
||||
|
||||
public:
|
||||
|
||||
LibraryQueue() : Queue(Q_ENABLED | Q_REPEAT)
|
||||
LibraryQueue() : queue(Q_ENABLED | Q_REPEAT)
|
||||
{
|
||||
file_init(&f, "library.q", 0);
|
||||
Queue :: sort(COMPARE_ARTIST, true);
|
||||
Queue :: sort(COMPARE_YEAR, false);
|
||||
Queue :: sort(COMPARE_TRACK, false);
|
||||
queue :: sort(COMPARE_ARTIST, true);
|
||||
queue :: sort(COMPARE_YEAR, false);
|
||||
queue :: sort(COMPARE_TRACK, false);
|
||||
}
|
||||
|
||||
void save()
|
||||
|
@ -29,8 +29,8 @@ public:
|
|||
std::vector<struct sort_info>::iterator it;
|
||||
|
||||
file_open(&f, OPEN_WRITE);
|
||||
file_writef(&f, "%u %u", _flags, _sort_order.size());
|
||||
for (it = _sort_order.begin(); it != _sort_order.end(); it++)
|
||||
file_writef(&f, "%u %u", q_flags, q_sort.size());
|
||||
for (it = q_sort.begin(); it != q_sort.end(); it++)
|
||||
file_writef(&f, " %u %d", it->field, it->ascending);
|
||||
file_writef(&f, "\n");
|
||||
file_close(&f);
|
||||
|
@ -45,22 +45,22 @@ public:
|
|||
if (!file_open(&f, OPEN_READ))
|
||||
return;
|
||||
|
||||
file_readf(&f, "%u %u", &_flags, &n);
|
||||
file_readf(&f, "%u %u", &q_flags, &n);
|
||||
for (unsigned int i = 0; i < n; i++) {
|
||||
file_readf(&f, "%u %d", &field, &ascending);
|
||||
Queue :: sort((compare_t)field, (i == 0) ? true : false);
|
||||
queue :: sort((compare_t)field, (i == 0) ? true : false);
|
||||
if (ascending == false)
|
||||
Queue :: sort((compare_t)field, false);
|
||||
queue :: sort((compare_t)field, false);
|
||||
}
|
||||
file_close(&f);
|
||||
}
|
||||
|
||||
void set_flag(queue_flags f) { Queue :: set_flag(f); save(); }
|
||||
void unset_flag(queue_flags f) { Queue :: unset_flag(f); save(); }
|
||||
void set_flag(queue_flags f) { queue :: set_flag(f); save(); }
|
||||
void unset_flag(queue_flags f) { queue :: unset_flag(f); save(); }
|
||||
|
||||
void sort(compare_t field, bool ascending)
|
||||
{
|
||||
Queue :: sort(field, ascending);
|
||||
queue :: sort(field, ascending);
|
||||
save();
|
||||
};
|
||||
|
||||
|
@ -225,7 +225,7 @@ void collection :: set_enabled(struct library *library, bool enabled)
|
|||
}
|
||||
}
|
||||
|
||||
Queue *collection :: get_queue()
|
||||
queue *collection :: get_queue()
|
||||
{
|
||||
return &library_q;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
#include <core/playlist.h>
|
||||
|
||||
|
||||
class PlaylistQueue : public Queue {
|
||||
class PlaylistQueue : public queue {
|
||||
public:
|
||||
|
||||
PlaylistQueue() : Queue(Q_ENABLED | Q_REPEAT)
|
||||
PlaylistQueue() : queue(Q_ENABLED | Q_REPEAT)
|
||||
{
|
||||
sort(COMPARE_ARTIST, true);
|
||||
sort(COMPARE_YEAR, false);
|
||||
|
@ -137,7 +137,7 @@ index_entry *playlist :: get_tracks(const std::string &name)
|
|||
return INDEX_ENTRY(db_get(&playlist_db, name.c_str()));
|
||||
}
|
||||
|
||||
Queue *playlist :: get_queue()
|
||||
queue *playlist :: get_queue()
|
||||
{
|
||||
return &playlist_q;
|
||||
}
|
||||
|
|
160
core/queue.cpp
160
core/queue.cpp
|
@ -20,54 +20,54 @@ public:
|
|||
} def_notify;
|
||||
|
||||
|
||||
Queue :: Queue(unsigned int flags)
|
||||
: _cur(-1), _flags(flags), _length(0), _notify(&def_notify)
|
||||
queue :: queue(unsigned int flags)
|
||||
: q_cur(-1), q_flags(flags), q_length(0), q_notify(&def_notify)
|
||||
{}
|
||||
|
||||
Queue :: Queue()
|
||||
: _cur(-1), _flags(0), _length(0), _notify(&def_notify)
|
||||
queue :: queue()
|
||||
: q_cur(-1), q_flags(0), q_length(0), q_notify(&def_notify)
|
||||
{}
|
||||
|
||||
Queue :: ~Queue()
|
||||
queue :: ~queue()
|
||||
{}
|
||||
|
||||
void Queue :: write(file &file)
|
||||
void queue :: write(file &file)
|
||||
{
|
||||
file_writef(&file, "%u %zu", _flags, _tracks.size());
|
||||
for (unsigned int i = 0; i < _tracks.size(); i++)
|
||||
file_writef(&file, " %u", _tracks[i]->tr_dbe.dbe_index);
|
||||
file_writef(&file, "%u %zu", q_flags, q_tracks.size());
|
||||
for (unsigned int i = 0; i < q_tracks.size(); i++)
|
||||
file_writef(&file, " %u", q_tracks[i]->tr_dbe.dbe_index);
|
||||
}
|
||||
|
||||
void Queue :: read(file &file)
|
||||
void queue :: read(file &file)
|
||||
{
|
||||
unsigned int n, id;
|
||||
file_readf(&file, "%u %u", &_flags, &n);
|
||||
_tracks.resize(n);
|
||||
file_readf(&file, "%u %u", &q_flags, &n);
|
||||
q_tracks.resize(n);
|
||||
for (unsigned int i = 0; i < n; i++) {
|
||||
file_readf(&file, "%u", &id);
|
||||
_tracks[i] = track_get(id);
|
||||
_length += _tracks[i]->tr_length;
|
||||
q_tracks[i] = track_get(id);
|
||||
q_length += q_tracks[i]->tr_length;
|
||||
}
|
||||
}
|
||||
|
||||
void Queue :: set_flag(queue_flags flag)
|
||||
void queue :: set_flag(queue_flags flag)
|
||||
{
|
||||
_flags |= flag;
|
||||
q_flags |= flag;
|
||||
}
|
||||
|
||||
void Queue :: unset_flag(queue_flags flag)
|
||||
void queue :: unset_flag(queue_flags flag)
|
||||
{
|
||||
_flags &= ~flag;
|
||||
q_flags &= ~flag;
|
||||
}
|
||||
|
||||
bool Queue :: has_flag(queue_flags flag)
|
||||
bool queue :: has_flag(queue_flags flag)
|
||||
{
|
||||
return (_flags & flag) == (unsigned int)flag;
|
||||
return (q_flags & flag) == (unsigned int)flag;
|
||||
}
|
||||
|
||||
void Queue :: set_notifier(QNotifier *notify)
|
||||
void queue :: set_notifier(QNotifier *notify)
|
||||
{
|
||||
_notify = notify;
|
||||
q_notify = notify;
|
||||
}
|
||||
|
||||
static bool track_less_than(struct track *lhs, struct track *rhs,
|
||||
|
@ -87,18 +87,18 @@ static bool track_less_than(struct track *lhs, struct track *rhs,
|
|||
return res < 0;
|
||||
}
|
||||
|
||||
unsigned int Queue :: find_sorted_id(struct track *rhs)
|
||||
unsigned int queue :: find_sorted_id(struct track *rhs)
|
||||
{
|
||||
struct track *lhs;
|
||||
unsigned int begin = 0, end = (_tracks.size() - 1), mid;
|
||||
unsigned int begin = 0, end = (q_tracks.size() - 1), mid;
|
||||
|
||||
if (_tracks.size() == 0)
|
||||
if (q_tracks.size() == 0)
|
||||
return 0;
|
||||
|
||||
while (end > begin) {
|
||||
mid = begin + ((end - begin) / 2);
|
||||
lhs = _tracks[mid];
|
||||
if (track_less_than(lhs, rhs, _sort_order))
|
||||
lhs = q_tracks[mid];
|
||||
if (track_less_than(lhs, rhs, q_sort))
|
||||
begin = mid + 1;
|
||||
else {
|
||||
if (mid == begin)
|
||||
|
@ -108,83 +108,83 @@ unsigned int Queue :: find_sorted_id(struct track *rhs)
|
|||
}
|
||||
}
|
||||
|
||||
lhs = _tracks[begin];
|
||||
if (track_less_than(lhs, rhs, _sort_order))
|
||||
lhs = q_tracks[begin];
|
||||
if (track_less_than(lhs, rhs, q_sort))
|
||||
return begin + 1;
|
||||
return begin;
|
||||
}
|
||||
|
||||
unsigned int Queue :: _add_at(struct track *track, unsigned int pos)
|
||||
unsigned int queue :: _add_at(struct track *track, unsigned int pos)
|
||||
{
|
||||
_tracks.insert(_tracks.begin() + pos, track);
|
||||
_length += track->tr_length;
|
||||
_notify->on_track_added(pos);
|
||||
q_tracks.insert(q_tracks.begin() + pos, track);
|
||||
q_length += track->tr_length;
|
||||
q_notify->on_track_added(pos);
|
||||
return pos;
|
||||
}
|
||||
|
||||
unsigned int Queue :: add(struct track *track)
|
||||
unsigned int queue :: add(struct track *track)
|
||||
{
|
||||
unsigned int id = _tracks.size();
|
||||
if (_sort_order.size() > 0)
|
||||
unsigned int id = q_tracks.size();
|
||||
if (q_sort.size() > 0)
|
||||
id = find_sorted_id(track);
|
||||
return _add_at(track, id);
|
||||
}
|
||||
|
||||
void Queue :: del(unsigned int index)
|
||||
void queue :: del(unsigned int index)
|
||||
{
|
||||
_length -= _tracks[index]->tr_length;
|
||||
_tracks.erase(_tracks.begin() + index);
|
||||
_notify->on_track_removed(index);
|
||||
q_length -= q_tracks[index]->tr_length;
|
||||
q_tracks.erase(q_tracks.begin() + index);
|
||||
q_notify->on_track_removed(index);
|
||||
}
|
||||
|
||||
void Queue :: del(struct track *track)
|
||||
void queue :: del(struct track *track)
|
||||
{
|
||||
for (unsigned int i = 0; i < _tracks.size(); i++) {
|
||||
while ((i < _tracks.size()) && (_tracks[i] == track))
|
||||
for (unsigned int i = 0; i < q_tracks.size(); i++) {
|
||||
while ((i < q_tracks.size()) && (q_tracks[i] == track))
|
||||
del(i);
|
||||
}
|
||||
}
|
||||
|
||||
void Queue :: updated(struct track *track)
|
||||
void queue :: updated(struct track *track)
|
||||
{
|
||||
for (unsigned int i = 0; i < _tracks.size(); i++) {
|
||||
if (_tracks[i] == track)
|
||||
_notify->on_track_updated(i);
|
||||
for (unsigned int i = 0; i < q_tracks.size(); i++) {
|
||||
if (q_tracks[i] == track)
|
||||
q_notify->on_track_updated(i);
|
||||
}
|
||||
}
|
||||
|
||||
struct track *Queue :: next()
|
||||
struct track *queue :: next()
|
||||
{
|
||||
struct track *res;
|
||||
|
||||
if (!(_flags & Q_ENABLED))
|
||||
if (!(q_flags & Q_ENABLED))
|
||||
return NULL;
|
||||
else if (_tracks.size() == 0)
|
||||
else if (q_tracks.size() == 0)
|
||||
return NULL;
|
||||
else if (_tracks.size() == 1)
|
||||
_cur = 0;
|
||||
else if (_flags & Q_RANDOM)
|
||||
_cur += random_range(1, _tracks.size() / 2);
|
||||
else if (q_tracks.size() == 1)
|
||||
q_cur = 0;
|
||||
else if (q_flags & Q_RANDOM)
|
||||
q_cur += random_range(1, q_tracks.size() / 2);
|
||||
else
|
||||
_cur++;
|
||||
q_cur++;
|
||||
|
||||
_cur %= _tracks.size();
|
||||
res = _tracks[_cur];
|
||||
if (!(_flags & Q_REPEAT)) {
|
||||
del(_cur);
|
||||
_cur--;
|
||||
q_cur %= q_tracks.size();
|
||||
res = q_tracks[q_cur];
|
||||
if (!(q_flags & Q_REPEAT)) {
|
||||
del(q_cur);
|
||||
q_cur--;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
unsigned int Queue :: size()
|
||||
unsigned int queue :: size()
|
||||
{
|
||||
return _tracks.size();
|
||||
return q_tracks.size();
|
||||
}
|
||||
|
||||
unsigned int Queue :: length()
|
||||
unsigned int queue :: length()
|
||||
{
|
||||
return _length;
|
||||
return q_length;
|
||||
}
|
||||
|
||||
class SortTracks {
|
||||
|
@ -197,43 +197,43 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
void Queue :: sort(compare_t field, bool reset)
|
||||
void queue :: sort(compare_t field, bool reset)
|
||||
{
|
||||
bool found = false;
|
||||
struct sort_info info = { field, true };
|
||||
|
||||
if (_flags & Q_NO_SORT)
|
||||
if (q_flags & Q_NO_SORT)
|
||||
return;
|
||||
if (reset)
|
||||
_sort_order.clear();
|
||||
q_sort.clear();
|
||||
|
||||
for (unsigned int i = 0; i < _sort_order.size(); i++) {
|
||||
if (_sort_order[i].field == info.field) {
|
||||
_sort_order[i].ascending = !_sort_order[i].ascending;
|
||||
for (unsigned int i = 0; i < q_sort.size(); i++) {
|
||||
if (q_sort[i].field == info.field) {
|
||||
q_sort[i].ascending = !q_sort[i].ascending;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
_sort_order.push_back(info);
|
||||
q_sort.push_back(info);
|
||||
|
||||
std::stable_sort(_tracks.begin(), _tracks.end(), SortTracks(_sort_order));
|
||||
std::stable_sort(q_tracks.begin(), q_tracks.end(), SortTracks(q_sort));
|
||||
|
||||
for (unsigned int i = 0; i < _tracks.size(); i++)
|
||||
_notify->on_track_updated(i);
|
||||
for (unsigned int i = 0; i < q_tracks.size(); i++)
|
||||
q_notify->on_track_updated(i);
|
||||
}
|
||||
|
||||
struct track *Queue :: operator[](unsigned int index)
|
||||
struct track *queue :: operator[](unsigned int index)
|
||||
{
|
||||
return _tracks[index];
|
||||
return q_tracks[index];
|
||||
}
|
||||
|
||||
void Queue :: track_selected(unsigned int index)
|
||||
void queue :: track_selected(unsigned int index)
|
||||
{
|
||||
_cur = index;
|
||||
q_cur = index;
|
||||
if (has_flag(Q_REPEAT) == false) {
|
||||
del(_cur);
|
||||
_cur--;
|
||||
del(q_cur);
|
||||
q_cur--;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ private:
|
|||
TempLabel *q_label;
|
||||
|
||||
public:
|
||||
QueueTab(Queue *, unsigned int num);
|
||||
QueueTab(queue *, unsigned int num);
|
||||
~QueueTab();
|
||||
|
||||
void on_track_removed(unsigned int);
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
static std::map<Gtk::Widget *, QueueTab *> queue_mapping;
|
||||
|
||||
|
||||
QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
||||
QueueTab :: QueueTab(queue *pq, unsigned int num)
|
||||
: Tab(pq)
|
||||
{
|
||||
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
|
||||
|
@ -190,7 +190,7 @@ static void renumber_queues()
|
|||
it->second->on_tab_reordered();
|
||||
}
|
||||
|
||||
void on_pq_created(Queue *pq, unsigned int num)
|
||||
void on_pq_created(queue *pq, unsigned int num)
|
||||
{
|
||||
new QueueTab(pq, num);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ QueueLabel :: ~QueueLabel()
|
|||
{
|
||||
}
|
||||
|
||||
void QueueLabel :: init(Queue *queue)
|
||||
void QueueLabel :: init(queue *queue)
|
||||
{
|
||||
_queue = queue;
|
||||
set_size();
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
#include <stdlib.h>
|
||||
|
||||
|
||||
QueueModel::QueueModel(Queue *q)
|
||||
QueueModel::QueueModel(queue *q)
|
||||
: Glib::ObjectBase( typeid(QueueModel) ),
|
||||
Glib::Object(), _stamp(1), _queue(q)
|
||||
{
|
||||
|
|
|
@ -22,7 +22,7 @@ QueueToolbar :: ~QueueToolbar()
|
|||
{
|
||||
}
|
||||
|
||||
void QueueToolbar :: init(Queue *queue, QueueLabel *label,
|
||||
void QueueToolbar :: init(queue *queue, QueueLabel *label,
|
||||
QueueWindow *window, unsigned int flags)
|
||||
{
|
||||
_queue = queue;
|
||||
|
|
|
@ -19,7 +19,7 @@ QueueWindow :: ~QueueWindow()
|
|||
set_deinit(&_q_search_res);
|
||||
}
|
||||
|
||||
void QueueWindow :: init(Queue *queue)
|
||||
void QueueWindow :: init(queue *queue)
|
||||
{
|
||||
_queue = queue;
|
||||
q_model = Glib::RefPtr<QueueModel>(new QueueModel(queue));
|
||||
|
|
18
gui/tabs.cpp
18
gui/tabs.cpp
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
#include <sstream>
|
||||
|
||||
|
||||
static std::map<Queue *, Tab *> queue_mapping;
|
||||
static std::map<queue *, Tab *> queue_mapping;
|
||||
|
||||
static compare_t sort_fields[] = {
|
||||
COMPARE_TRACK, COMPARE_TITLE, COMPARE_LENGTH,
|
||||
|
@ -28,7 +28,7 @@ static compare_t sort_fields[] = {
|
|||
*
|
||||
*/
|
||||
|
||||
Tab :: Tab(Queue *pq)
|
||||
Tab :: Tab(queue *pq)
|
||||
: tab_sorting_count(0), tab_pq(pq), tab_label(NULL)
|
||||
{
|
||||
pq->set_notifier(this);
|
||||
|
@ -154,7 +154,7 @@ void Tab :: tab_selected_ids(std::vector<unsigned int> &ids)
|
|||
sel->unselect_all();
|
||||
}
|
||||
|
||||
void Tab :: tab_queue_add(Queue *pq)
|
||||
void Tab :: tab_queue_add(queue *pq)
|
||||
{
|
||||
std::vector<unsigned int> ids;
|
||||
|
||||
|
@ -168,7 +168,7 @@ bool Tab :: tab_queue_selected(bool random)
|
|||
if (deck :: get_queues().size() >= 10)
|
||||
return true;
|
||||
|
||||
Queue *pq = deck :: create(random);
|
||||
queue *pq = deck :: create(random);
|
||||
on_pq_created(pq, deck :: get_queues().size() - 1);
|
||||
tab_queue_add(pq);
|
||||
return true;
|
||||
|
@ -179,7 +179,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 = deck :: get(n);
|
||||
tab_queue_add(pq);
|
||||
return true;
|
||||
}
|
||||
|
@ -308,9 +308,9 @@ bool Tab :: on_button_pressed(GdkEventButton *button)
|
|||
*
|
||||
*/
|
||||
|
||||
Tab *find_tab(Queue *pq)
|
||||
Tab *find_tab(queue *pq)
|
||||
{
|
||||
std::map<Queue *, Tab *>::iterator it;
|
||||
std::map<queue *, Tab *>::iterator it;
|
||||
it = queue_mapping.find(pq);
|
||||
if (it != queue_mapping.end())
|
||||
return it->second;
|
||||
|
@ -319,7 +319,7 @@ Tab *find_tab(Queue *pq)
|
|||
|
||||
static Tab *find_tab(int num)
|
||||
{
|
||||
std::map<Queue *, Tab *>::iterator it;
|
||||
std::map<queue *, Tab *>::iterator it;
|
||||
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) {
|
||||
if (it->second->tab_page_num() == num)
|
||||
return it->second;
|
||||
|
@ -329,7 +329,7 @@ static Tab *find_tab(int num)
|
|||
|
||||
static Tab *cur_tab()
|
||||
{
|
||||
std::map<Queue *, Tab *>::iterator it;
|
||||
std::map<queue *, Tab *>::iterator it;
|
||||
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) {
|
||||
if (it->second->tab_is_cur())
|
||||
return it->second;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* A TempQueue is a wrapper around the Queue class that
|
||||
* allows us to save the list of queues when necessary.
|
||||
*/
|
||||
class TempQueue : public Queue
|
||||
class TempQueue : public queue
|
||||
{
|
||||
public:
|
||||
TempQueue();
|
||||
|
@ -60,14 +60,14 @@ namespace deck
|
|||
* track when queue->next() is called.
|
||||
* @return The newly created queue.
|
||||
*/
|
||||
Queue *create(bool);
|
||||
queue *create(bool);
|
||||
|
||||
/**
|
||||
* Removes the queue from the deck.
|
||||
*
|
||||
* @param queue The queue to be removed.
|
||||
*/
|
||||
void destroy(Queue *);
|
||||
void destroy(queue *);
|
||||
|
||||
/**
|
||||
* Move the queue to a new location in the deck.
|
||||
|
@ -75,7 +75,7 @@ namespace deck
|
|||
* @param queue The queue to be moved.
|
||||
* @param index The new index of the queue.
|
||||
*/
|
||||
void move(Queue *, unsigned int);
|
||||
void move(queue *, unsigned int);
|
||||
|
||||
/**
|
||||
* Find the index of the requested queue.
|
||||
|
@ -83,7 +83,7 @@ namespace deck
|
|||
* @param queue The queue in question.
|
||||
* @return The index of the requested queue.
|
||||
*/
|
||||
unsigned int index(Queue *);
|
||||
unsigned int index(queue *);
|
||||
|
||||
/**
|
||||
* Access the queue at the specified index.
|
||||
|
@ -91,7 +91,7 @@ namespace deck
|
|||
* @param index The index of the queue that should be accessed.
|
||||
* @return The queue at the requested index.
|
||||
*/
|
||||
Queue *get(unsigned int);
|
||||
queue *get(unsigned int);
|
||||
|
||||
/**
|
||||
* @return A track from the first enabled queue. If no queues are
|
||||
|
@ -112,7 +112,7 @@ namespace deck
|
|||
/**
|
||||
* @return The queue of recent tracks.
|
||||
*/
|
||||
Queue *get_queue();
|
||||
queue *get_queue();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace collection
|
|||
*
|
||||
* @return The queue of tracks currently in the library.
|
||||
*/
|
||||
Queue *get_queue();
|
||||
queue *get_queue();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace playlist
|
|||
/**
|
||||
* @return The playlist queue.
|
||||
*/
|
||||
Queue *get_queue();
|
||||
queue *get_queue();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -72,28 +72,28 @@ struct sort_info {
|
|||
*
|
||||
* ... << _flags << _tracks.size() << tracks[N]->index() << ...;
|
||||
*/
|
||||
class Queue {
|
||||
protected:
|
||||
std :: vector <struct track *> _tracks; /**< List of tracks in this queue. */
|
||||
std :: vector <struct sort_info> _sort_order; /**< Current sort settings. */
|
||||
unsigned int _cur; /**< The index of the last track played. */
|
||||
unsigned int _flags; /**< Mask of queue_flags. */
|
||||
unsigned int _length; /**< Total runtime of the queue. */
|
||||
QNotifier *_notify; /**< Notification object associated with this queue. */
|
||||
struct queue {
|
||||
unsigned int q_cur; /* The queue's last-played index. */
|
||||
unsigned int q_flags; /* The queue's set of flags. */
|
||||
unsigned int q_length; /* The queue's total runtime (in seconds). */
|
||||
QNotifier *q_notify; /* The queue's notification functions. */
|
||||
|
||||
std :: vector <struct track *> q_tracks; /* The queue's list of tracks. */
|
||||
std :: vector <struct sort_info> q_sort; /* The queue's sort settings. */
|
||||
|
||||
unsigned int find_sorted_id(struct track *);
|
||||
unsigned int _add_at(struct track *, unsigned int);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Alternate queue constructor.
|
||||
*
|
||||
* @param flags Create a queue with _flags set to flags.
|
||||
*/
|
||||
Queue(unsigned int);
|
||||
queue(unsigned int);
|
||||
|
||||
Queue(); /**< Default queue constructor. */
|
||||
virtual ~Queue(); /**< Queue destructor. */
|
||||
queue(); /**< Default queue constructor. */
|
||||
virtual ~queue(); /**< Queue destructor. */
|
||||
|
||||
/**
|
||||
* Write a queue to disk.
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace gui
|
|||
}
|
||||
|
||||
|
||||
void on_pq_created(Queue *, unsigned int);
|
||||
void on_pq_created(queue *, unsigned int);
|
||||
void post_init_queue_tabs();
|
||||
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
class QueueLabel : public Gtk::HBox {
|
||||
protected:
|
||||
Glib::RefPtr<Gtk::Builder> _builder;
|
||||
Queue *_queue;
|
||||
queue *_queue;
|
||||
|
||||
public:
|
||||
QueueLabel(BaseObjectType *, const Glib::RefPtr<Gtk::Builder>);
|
||||
~QueueLabel();
|
||||
virtual void init(Queue *);
|
||||
virtual void init(queue *);
|
||||
virtual void set_sensitive(bool) {};
|
||||
virtual void set_size() {};
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
class QueueModel : public Gtk::TreeModel, public Glib::Object {
|
||||
private:
|
||||
int _stamp;
|
||||
Queue *_queue;
|
||||
queue *_queue;
|
||||
|
||||
void increment_stamp();
|
||||
bool check_iter_validity(const Gtk::TreeIter &) const;
|
||||
|
@ -28,7 +28,7 @@ protected:
|
|||
bool get_iter_vfunc(const Gtk::TreePath &, Gtk::TreeIter &) const;
|
||||
|
||||
public:
|
||||
QueueModel(Queue *);
|
||||
QueueModel(queue *);
|
||||
|
||||
void on_row_inserted(unsigned int);
|
||||
void on_row_deleted(unsigned int);
|
||||
|
|
|
@ -19,7 +19,7 @@ enum toolbar_flags {
|
|||
class QueueToolbar : public Gtk::HBox {
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> _builder;
|
||||
Queue *_queue;
|
||||
queue *_queue;
|
||||
QueueLabel *_q_label;
|
||||
QueueWindow *_q_window;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
QueueToolbar(BaseObjectType *, const Glib::RefPtr<Gtk::Builder>);
|
||||
~QueueToolbar();
|
||||
|
||||
void init(Queue *, QueueLabel*, QueueWindow*, unsigned int);
|
||||
void init(queue *, QueueLabel*, QueueWindow*, unsigned int);
|
||||
|
||||
void on_random_toggled();
|
||||
void on_repeat_toggled();
|
||||
|
|
|
@ -13,7 +13,7 @@ extern "C" {
|
|||
class QueueWindow : public Gtk::ScrolledWindow {
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> _builder;
|
||||
Queue *_queue;
|
||||
queue *_queue;
|
||||
|
||||
struct set _q_search_res;
|
||||
bool _q_search_empty;
|
||||
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
QueueWindow(BaseObjectType *, const Glib::RefPtr<Gtk::Builder>);
|
||||
~QueueWindow();
|
||||
void init(Queue *);
|
||||
void init(queue *);
|
||||
|
||||
void filter(std::string &);
|
||||
bool filter_ids(const Gtk::TreeIter &);
|
||||
|
|
|
@ -17,7 +17,7 @@ private:
|
|||
|
||||
protected:
|
||||
Glib::RefPtr<Gtk::Builder> tab_builder;
|
||||
Queue *tab_pq;
|
||||
queue *tab_pq;
|
||||
Gtk::VBox tab_vbox;
|
||||
|
||||
QueueToolbar *tab_toolbar;
|
||||
|
@ -31,7 +31,7 @@ protected:
|
|||
void tab_unmap();
|
||||
|
||||
public:
|
||||
Tab(Queue *);
|
||||
Tab(queue *);
|
||||
virtual ~Tab();
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
void tab_display_sorting();
|
||||
void tab_focus_search();
|
||||
void tab_selected_ids(std::vector<unsigned int> &);
|
||||
void tab_queue_add(Queue *);
|
||||
void tab_queue_add(queue *);
|
||||
bool tab_queue_selected(bool);
|
||||
bool tab_add_to_queue(unsigned int);
|
||||
bool tab_add_to_playlist(const std::string &);
|
||||
|
@ -73,7 +73,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
Tab *find_tab(Queue *);
|
||||
Tab *find_tab(queue *);
|
||||
void tab_focus_search();
|
||||
void init_tabs();
|
||||
void post_init_tabs();
|
||||
|
|
|
@ -9,7 +9,7 @@ extern "C" {
|
|||
#include <core/library.h>
|
||||
#include "test.h"
|
||||
|
||||
static Queue *Q_NULL = NULL;
|
||||
static queue *Q_NULL = NULL;
|
||||
static struct track *TRACK_NULL = NULL;
|
||||
|
||||
static void test_init()
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
static void test_create_mv_destroy()
|
||||
{
|
||||
Queue *q1, *q2;
|
||||
queue *q1, *q2;
|
||||
|
||||
q1 = deck :: create(true);
|
||||
q1->set_notifier(&test_notifier);
|
||||
|
@ -112,9 +112,9 @@ static void test_create_mv_destroy()
|
|||
static void test_next_prev()
|
||||
{
|
||||
std::list<TempQueue>::iterator it = deck :: get_queues().begin();
|
||||
Queue *q = deck :: get_queue();
|
||||
Queue *q0 = &(*it++);
|
||||
Queue *q1 = &(*it++);
|
||||
queue *q = deck :: get_queue();
|
||||
queue *q0 = &(*it++);
|
||||
queue *q1 = &(*it++);
|
||||
|
||||
q0->unset_flag(Q_RANDOM);
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
|
|
|
@ -9,12 +9,12 @@ extern "C" {
|
|||
#include <core/library.h>
|
||||
#include "test.h"
|
||||
|
||||
static Queue *Q_NULL = NULL;
|
||||
static queue *Q_NULL = NULL;
|
||||
static struct library *LIB_NULL = NULL;
|
||||
|
||||
static void test_init()
|
||||
{
|
||||
Queue *q = collection :: get_queue();
|
||||
queue *q = collection :: get_queue();
|
||||
|
||||
test_not_equal(q, Q_NULL);
|
||||
test_equal(q->has_flag(Q_ENABLED), true);
|
||||
|
@ -30,7 +30,7 @@ static void test_init()
|
|||
|
||||
static void test_enable()
|
||||
{
|
||||
Queue *q = collection :: get_queue();
|
||||
queue *q = collection :: get_queue();
|
||||
struct library *library = library_get(0);
|
||||
|
||||
collection :: set_enabled(LIB_NULL, true);
|
||||
|
@ -54,7 +54,7 @@ static void test_enable()
|
|||
|
||||
static void test_remove()
|
||||
{
|
||||
Queue *q = collection :: get_queue();
|
||||
queue *q = collection :: get_queue();
|
||||
struct library *library = library_get(0);
|
||||
|
||||
collection :: remove(LIB_NULL);
|
||||
|
@ -69,7 +69,7 @@ static void test_remove()
|
|||
|
||||
static void test_add()
|
||||
{
|
||||
Queue *q = collection :: get_queue();
|
||||
queue *q = collection :: get_queue();
|
||||
|
||||
test_generate_library();
|
||||
collection :: add("/tmp/ocarina/");
|
||||
|
@ -86,7 +86,7 @@ static void test_add()
|
|||
|
||||
static void test_update()
|
||||
{
|
||||
Queue *q = collection :: get_queue();
|
||||
queue *q = collection :: get_queue();
|
||||
test_rm_library_dirs();
|
||||
|
||||
collection :: update_all();
|
||||
|
|
|
@ -10,12 +10,12 @@ extern "C" {
|
|||
#include "test.h"
|
||||
|
||||
static index_entry *IDX_NULL = NULL;
|
||||
static Queue *Q_NULL = NULL;
|
||||
static queue *Q_NULL = NULL;
|
||||
|
||||
static void test_init()
|
||||
{
|
||||
index_entry *ent;
|
||||
Queue *q = playlist :: get_queue();
|
||||
queue *q = playlist :: get_queue();
|
||||
|
||||
test_not_equal(q, Q_NULL);
|
||||
test_equal(q->has_flag(Q_ENABLED), true);
|
||||
|
@ -42,7 +42,7 @@ static void test_init()
|
|||
|
||||
static void test_queue()
|
||||
{
|
||||
Queue *q = playlist :: get_queue();
|
||||
queue *q = playlist :: get_queue();
|
||||
|
||||
playlist :: select("Banned");
|
||||
test_equal(q->size(), (unsigned)4);
|
||||
|
@ -63,8 +63,8 @@ static void test_queue()
|
|||
static void test_add()
|
||||
{
|
||||
index_entry *ent;
|
||||
Queue *q = playlist :: get_queue();
|
||||
Queue *l = collection :: get_queue();
|
||||
queue *q = playlist :: get_queue();
|
||||
queue *l = collection :: get_queue();
|
||||
|
||||
playlist :: select("Favorites");
|
||||
|
||||
|
@ -87,8 +87,8 @@ static void test_add()
|
|||
static void test_delete()
|
||||
{
|
||||
index_entry *ent;
|
||||
Queue *q = playlist :: get_queue();
|
||||
Queue *l = collection :: get_queue();
|
||||
queue *q = playlist :: get_queue();
|
||||
queue *l = collection :: get_queue();
|
||||
|
||||
playlist :: del(track_get(5), "Banned");
|
||||
ent = playlist :: get_tracks("Banned");
|
||||
|
|
|
@ -24,18 +24,6 @@ public:
|
|||
} test_notifier;
|
||||
|
||||
|
||||
class TestQueue : public Queue {
|
||||
public:
|
||||
TestQueue() : Queue() { set_notifier(&test_notifier); }
|
||||
TestQueue(unsigned int f) : Queue(f) { set_notifier(&test_notifier); }
|
||||
~TestQueue() {}
|
||||
unsigned int get_cur() { return _cur; }
|
||||
unsigned int get_flags() { return _flags; }
|
||||
QNotifier *get_notify() { return _notify; }
|
||||
std::vector <sort_info> get_sorder() { return _sort_order; };
|
||||
};
|
||||
|
||||
|
||||
static void __test_init_core()
|
||||
{
|
||||
struct library *library;
|
||||
|
@ -68,40 +56,43 @@ static void __test_deinit_core()
|
|||
|
||||
static void test_init()
|
||||
{
|
||||
TestQueue q;
|
||||
unsigned int flags = Q_ENABLED | Q_RANDOM;
|
||||
struct queue q;
|
||||
|
||||
test_equal(q.get_cur(), (unsigned int)-1);
|
||||
test_equal(q.get_flags(), 0);
|
||||
test_equal(q.length(), 0);
|
||||
test_equal(q.get_sorder().size(), (size_t)0);
|
||||
test_equal(q.next(), (struct track *)NULL);
|
||||
test_equal(q.get_notify(), &test_notifier);
|
||||
__test_init_core();
|
||||
|
||||
q = TestQueue(flags);
|
||||
test_equal(q.get_cur(), (unsigned int )-1);
|
||||
test_equal(q.get_flags(), flags);
|
||||
test_equal(q.q_cur, (unsigned int)-1);
|
||||
test_equal(q.q_flags, 0);
|
||||
test_equal(q.length(), 0);
|
||||
test_equal(q.get_sorder().size(), 0);
|
||||
test_equal(q.q_sort.size(), (size_t)0);
|
||||
test_equal(q.next(), (struct track *)NULL);
|
||||
test_equal(q.get_notify(), &test_notifier);
|
||||
test_not_equal(q.q_notify, NULL);
|
||||
|
||||
q = queue(Q_ENABLED | Q_RANDOM);
|
||||
q.set_notifier(&test_notifier);
|
||||
|
||||
test_equal(q.q_cur, (unsigned int )-1);
|
||||
test_equal(q.q_flags, Q_ENABLED | Q_RANDOM);
|
||||
test_equal(q.length(), 0);
|
||||
test_equal(q.q_sort.size(), 0);
|
||||
test_equal(q.next(), (struct track *)NULL);
|
||||
test_equal(q.q_notify, &test_notifier);
|
||||
}
|
||||
|
||||
static void test_flags()
|
||||
{
|
||||
TestQueue q(0);
|
||||
struct queue q(0);
|
||||
|
||||
test_equal(q.get_flags(), 0);
|
||||
test_equal(q.q_flags, 0);
|
||||
test_equal(q.has_flag(Q_ENABLED), false);
|
||||
test_equal(q.has_flag(Q_RANDOM), false);
|
||||
test_equal(q.has_flag(Q_REPEAT), false);
|
||||
test_equal(q.has_flag(Q_NO_SORT), false);
|
||||
|
||||
q.set_flag(Q_ENABLED);
|
||||
test_equal(q.get_flags(), Q_ENABLED);
|
||||
test_equal(q.q_flags, Q_ENABLED);
|
||||
|
||||
q.unset_flag(Q_ENABLED);
|
||||
test_equal(q.get_flags(), 0);
|
||||
test_equal(q.q_flags, 0);
|
||||
|
||||
q.set_flag(Q_ENABLED);
|
||||
q.set_flag(Q_RANDOM);
|
||||
|
@ -118,13 +109,13 @@ static void test_stress(unsigned int N)
|
|||
unsigned int ex_length = 0;
|
||||
unsigned int ex_size = N;
|
||||
struct track *track;
|
||||
struct queue q(0);
|
||||
unsigned int i;
|
||||
TestQueue q(0);
|
||||
|
||||
count_added = 0;
|
||||
count_deleted = 0;
|
||||
count_updated = 0;
|
||||
__test_init_core();
|
||||
q.set_notifier(&test_notifier);
|
||||
|
||||
/* Queue :: add() */
|
||||
for (i = 0; i < N; i++) {
|
||||
|
@ -189,7 +180,7 @@ static void test_stress_100K() { test_stress(100009); }
|
|||
|
||||
static void test_rand_select()
|
||||
{
|
||||
TestQueue q(Q_ENABLED | Q_RANDOM);
|
||||
struct queue q(Q_ENABLED | Q_RANDOM);
|
||||
unsigned int i;
|
||||
|
||||
random_seed(0);
|
||||
|
@ -265,7 +256,7 @@ static void test_sorting()
|
|||
unsigned int ex_title[] = { 6, 9, 8, 3, 2, 5, 1, 4, 11, 10, 12, 0, 7 };
|
||||
unsigned int ex_co_ti[] = { 3, 2, 5, 1, 4, 0, 6, 9, 8, 11, 10, 12, 7 };
|
||||
struct track *track;
|
||||
TestQueue q(0);
|
||||
struct queue q(0);
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < 13; i++) {
|
||||
|
@ -309,7 +300,7 @@ static void test_sorting()
|
|||
|
||||
static void test_save_load()
|
||||
{
|
||||
TestQueue q(Q_RANDOM), r(0);
|
||||
struct queue q(Q_RANDOM), r(0);
|
||||
unsigned int i;
|
||||
struct file f;
|
||||
|
||||
|
|
Loading…
Reference in New Issue