From 1c743239a0a44e03ab13832b01b9bea40b83735d Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 1 Apr 2014 20:28:19 -0400 Subject: [PATCH] Rename playqueue -> queue Signed-off-by: Anna Schumaker --- gui/model.cpp | 52 +++++++++++------------ gui/queue.cpp | 14 +++---- gui/tabs.cpp | 40 +++++++++--------- include/audio.h | 4 +- include/callback.h | 14 +++---- include/deck.h | 10 ++--- include/ocarina.h | 8 ++-- include/playlist.h | 4 +- include/{playqueue.h => queue.h} | 30 ++++++------- include/tabs.h | 14 +++---- lib/audio.cpp | 10 ++--- lib/callback.cpp | 4 +- lib/deck.cpp | 50 +++++++++++----------- lib/playlist.cpp | 8 ++-- lib/{playqueue.cpp => queue.cpp} | 72 ++++++++++++++++---------------- 15 files changed, 167 insertions(+), 167 deletions(-) rename include/{playqueue.h => queue.h} (73%) rename lib/{playqueue.cpp => queue.cpp} (77%) diff --git a/gui/model.cpp b/gui/model.cpp index 07fee583..07f2b3bc 100644 --- a/gui/model.cpp +++ b/gui/model.cpp @@ -10,8 +10,8 @@ #include -PlayqueueModel::PlayqueueModel(Playqueue *q) - : Glib::ObjectBase( typeid(PlayqueueModel) ), +QueueModel::QueueModel(Queue *q) + : Glib::ObjectBase( typeid(QueueModel) ), Glib::Object(), queue(q) { do { @@ -19,14 +19,14 @@ PlayqueueModel::PlayqueueModel(Playqueue *q) } while (stamp == 0); } -void PlayqueueModel::increment_stamp() +void QueueModel::increment_stamp() { do { stamp++; } while (stamp == 0); } -void PlayqueueModel::on_row_inserted(unsigned int row) +void QueueModel::on_row_inserted(unsigned int row) { Gtk::TreePath path; Gtk::TreeIter iter; @@ -36,7 +36,7 @@ void PlayqueueModel::on_row_inserted(unsigned int row) row_inserted(path, iter); } -void PlayqueueModel::on_row_deleted(unsigned int row) +void QueueModel::on_row_deleted(unsigned int row) { Gtk::TreePath path; @@ -45,7 +45,7 @@ void PlayqueueModel::on_row_deleted(unsigned int row) row_deleted(path); } -void PlayqueueModel::on_row_changed(unsigned int row) +void QueueModel::on_row_changed(unsigned int row) { Gtk::TreePath path; Gtk::TreeIter iter; @@ -55,19 +55,19 @@ void PlayqueueModel::on_row_changed(unsigned int row) row_changed(path, iter); } -void PlayqueueModel::on_path_selected(const Gtk::TreePath &path) +void QueueModel::on_path_selected(const Gtk::TreePath &path) { audio :: load_trackid(path_to_id(path)); queue->path_selected(path[0]); audio :: play(); } -unsigned int PlayqueueModel :: iter_to_id(const Gtk::TreeIter &iter) +unsigned int QueueModel :: iter_to_id(const Gtk::TreeIter &iter) { return GPOINTER_TO_UINT(iter.gobj()->user_data); } -unsigned int PlayqueueModel::path_to_id(const Gtk::TreePath &path) +unsigned int QueueModel::path_to_id(const Gtk::TreePath &path) { return queue->operator[](path[0]); } @@ -80,17 +80,17 @@ unsigned int PlayqueueModel::path_to_id(const Gtk::TreePath &path) * */ -Gtk::TreeModelFlags PlayqueueModel::get_flags_vfunc() const +Gtk::TreeModelFlags QueueModel::get_flags_vfunc() const { return Gtk::TREE_MODEL_LIST_ONLY; } -int PlayqueueModel::get_n_columns_vfunc() const +int QueueModel::get_n_columns_vfunc() const { return 10; } -GType PlayqueueModel::get_column_type_vfunc(int index) const +GType QueueModel::get_column_type_vfunc(int index) const { switch (index) { case 0: @@ -110,7 +110,7 @@ GType PlayqueueModel::get_column_type_vfunc(int index) const } } -void PlayqueueModel::get_value_uint(Track *track, int column, +void QueueModel::get_value_uint(Track *track, int column, Glib::ValueBase &value) const { Glib::Value specific; @@ -131,7 +131,7 @@ void PlayqueueModel::get_value_uint(Track *track, int column, value = specific; } -void PlayqueueModel::get_value_str(Track *track, int column, +void QueueModel::get_value_str(Track *track, int column, Glib::ValueBase &value) const { std::stringstream ss; @@ -173,7 +173,7 @@ void PlayqueueModel::get_value_str(Track *track, int column, } -void PlayqueueModel::get_value_vfunc(const Gtk::TreeIter &iter, int column, +void QueueModel::get_value_vfunc(const Gtk::TreeIter &iter, int column, Glib::ValueBase &value) const { unsigned int row; @@ -199,7 +199,7 @@ void PlayqueueModel::get_value_vfunc(const Gtk::TreeIter &iter, int column, } } -bool PlayqueueModel::iter_next_vfunc(const Gtk::TreeIter &iter, +bool QueueModel::iter_next_vfunc(const Gtk::TreeIter &iter, Gtk::TreeIter &iter_next) const { unsigned int index; @@ -213,35 +213,35 @@ bool PlayqueueModel::iter_next_vfunc(const Gtk::TreeIter &iter, return iter_nth_root_child_vfunc(++index, iter_next); } -bool PlayqueueModel::iter_children_vfunc(const Gtk::TreeIter &parent, +bool QueueModel::iter_children_vfunc(const Gtk::TreeIter &parent, Gtk::TreeIter &iter) const { return iter_nth_child_vfunc(parent, 0, iter); } -bool PlayqueueModel::iter_has_child_vfunc(const Gtk::TreeIter &iter) const +bool QueueModel::iter_has_child_vfunc(const Gtk::TreeIter &iter) const { return (iter_n_children_vfunc(iter) > 0); } -int PlayqueueModel::iter_n_children_vfunc(const Gtk::TreeIter &iter) const +int QueueModel::iter_n_children_vfunc(const Gtk::TreeIter &iter) const { return 0; } -int PlayqueueModel::iter_n_root_children_vfunc() const +int QueueModel::iter_n_root_children_vfunc() const { return queue->size(); } -bool PlayqueueModel::iter_nth_child_vfunc(const Gtk::TreeIter &parent, +bool QueueModel::iter_nth_child_vfunc(const Gtk::TreeIter &parent, int n, Gtk::TreeIter &iter) const { iter = Gtk::TreeIter(); return false; } -bool PlayqueueModel::iter_nth_root_child_vfunc(int n, Gtk::TreeIter &iter) const +bool QueueModel::iter_nth_root_child_vfunc(int n, Gtk::TreeIter &iter) const { iter = Gtk::TreeIter(); if (n >= (int)queue->size()) @@ -252,14 +252,14 @@ bool PlayqueueModel::iter_nth_root_child_vfunc(int n, Gtk::TreeIter &iter) const return true; } -bool PlayqueueModel::iter_parent_vfunc(const Gtk::TreeIter &child, +bool QueueModel::iter_parent_vfunc(const Gtk::TreeIter &child, Gtk::TreeIter &iter) const { iter = Gtk::TreeIter(); return false; } -Gtk::TreeModel::Path PlayqueueModel::get_path_vfunc(const Gtk::TreeIter &iter) const +Gtk::TreeModel::Path QueueModel::get_path_vfunc(const Gtk::TreeIter &iter) const { Gtk::TreeModel::Path path; @@ -268,7 +268,7 @@ Gtk::TreeModel::Path PlayqueueModel::get_path_vfunc(const Gtk::TreeIter &iter) c return path; } -bool PlayqueueModel::get_iter_vfunc(const Gtk::TreePath &path, +bool QueueModel::get_iter_vfunc(const Gtk::TreePath &path, Gtk::TreeIter &iter) const { if (path.size() != 1) { @@ -278,7 +278,7 @@ bool PlayqueueModel::get_iter_vfunc(const Gtk::TreePath &path, return iter_nth_root_child_vfunc(path[0], iter); } -bool PlayqueueModel::check_iter_validity(const Gtk::TreeIter &iter) const +bool QueueModel::check_iter_validity(const Gtk::TreeIter &iter) const { return stamp == iter.get_stamp(); } diff --git a/gui/queue.cpp b/gui/queue.cpp index 1d0686ed..94c5e6fc 100644 --- a/gui/queue.cpp +++ b/gui/queue.cpp @@ -63,7 +63,7 @@ private: public: - QueueTab(Playqueue *, unsigned int num); + QueueTab(Queue *, unsigned int num); ~QueueTab(); /** @@ -88,7 +88,7 @@ public: static std::map queue_mapping; -QueueTab :: QueueTab(Playqueue *pq, unsigned int num) +QueueTab :: QueueTab(Queue *pq, unsigned int num) : Tab(pq) { /* @@ -218,7 +218,7 @@ void QueueTab :: on_post_init() tab_init_random(); tab_init_repeat(); - bool active = (tab_pq->get_flags() & PQ_ENABLED) == PQ_ENABLED; + bool active = (tab_pq->get_flags() & Q_ENABLED) == Q_ENABLED; q_switch.set_active(active); q_switch.property_active().signal_changed().connect( sigc::mem_fun(*this, &QueueTab :: on_switch_changed)); @@ -297,10 +297,10 @@ void QueueTab :: on_close_clicked() void QueueTab :: on_switch_changed() { if (q_switch.get_active()) { - tab_pq->set_flag(PQ_ENABLED); + tab_pq->set_flag(Q_ENABLED); queue_set_sensitive(true); } else { - tab_pq->unset_flag(PQ_ENABLED); + tab_pq->unset_flag(Q_ENABLED); queue_set_sensitive(false); } } @@ -319,13 +319,13 @@ static void renumber_queues() it->second->on_tab_reordered(); } -static void on_pq_created(Playqueue *pq, unsigned int num) +static void on_pq_created(Queue *pq, unsigned int num) { QueueTab *tab = new QueueTab(pq, num); tab->on_post_init(); } -static void on_pq_removed(Playqueue *pq) +static void on_pq_removed(Queue *pq) { Tab *tab = find_tab(pq); if (tab) { diff --git a/gui/tabs.cpp b/gui/tabs.cpp index d9776de6..74e7e938 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -11,7 +11,7 @@ #include -static std::map queue_mapping; +static std::map queue_mapping; static sort_t sort_fields[] = { SORT_TRACK, SORT_TITLE, SORT_LENGTH, @@ -27,10 +27,10 @@ static sort_t sort_fields[] = { * */ -Tab :: Tab(Playqueue *pq) +Tab :: Tab(Queue *pq) : tab_sorting_count(0), tab_pq(pq), tab_size(NULL) { - tab_model = Glib::RefPtr(new PlayqueueModel(tab_pq)); + tab_model = Glib::RefPtr(new QueueModel(tab_pq)); queue_mapping[tab_pq] = this; } @@ -71,19 +71,19 @@ void Tab :: tab_finish_init() void Tab :: tab_init_random() { - tab_random->set_active(tab_pq->get_flags() & PQ_RANDOM); + tab_random->set_active(tab_pq->get_flags() & Q_RANDOM); tab_random->signal_toggled().connect(sigc::mem_fun(*this, &Tab::on_random_toggled)); } void Tab :: tab_init_repeat() { - tab_repeat->set_active(tab_pq->get_flags() & PQ_REPEAT); + tab_repeat->set_active(tab_pq->get_flags() & Q_REPEAT); tab_repeat->signal_toggled().connect(sigc::mem_fun(*this, &Tab::on_repeat_toggled)); } -void Tab :: tab_toggle_button(Gtk::ToggleButton *button, playqueue_flags flag) +void Tab :: tab_toggle_button(Gtk::ToggleButton *button, queue_flags flag) { if (button->get_active()) tab_pq->set_flag(flag); @@ -155,7 +155,7 @@ void Tab :: tab_selected_ids(std::vector &ids) sel->unselect_all(); } -void Tab :: tab_queue_add(Playqueue *pq) +void Tab :: tab_queue_add(Queue *pq) { std::vector ids; @@ -169,7 +169,7 @@ bool Tab :: tab_queue_selected(bool random) if (deck :: size() >= 10) return true; - Playqueue *pq = deck :: create(random); + Queue *pq = deck :: create(random); tab_queue_add(pq); return true; } @@ -179,7 +179,7 @@ bool Tab :: tab_add_to_queue(unsigned int n) if (n >= deck :: size()) return true; - Playqueue *pq = deck :: get(n); + Queue *pq = deck :: get(n); tab_queue_add(pq); return true; } @@ -284,12 +284,12 @@ void Tab :: on_show_rc_menu() void Tab :: on_random_toggled() { - tab_toggle_button(tab_random, PQ_RANDOM); + tab_toggle_button(tab_random, Q_RANDOM); } void Tab :: on_repeat_toggled() { - tab_toggle_button(tab_repeat, PQ_REPEAT); + tab_toggle_button(tab_repeat, Q_REPEAT); } void Tab :: on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) @@ -379,9 +379,9 @@ void Tab :: on_entry_changed() * */ -Tab *find_tab(Playqueue *pq) +Tab *find_tab(Queue *pq) { - std::map::iterator it; + std::map::iterator it; it = queue_mapping.find(pq); if (it != queue_mapping.end()) return it->second; @@ -390,7 +390,7 @@ Tab *find_tab(Playqueue *pq) static Tab *find_tab(int num) { - std::map::iterator it; + std::map::iterator it; for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) { if (it->second->tab_page_num() == num) return it->second; @@ -400,7 +400,7 @@ static Tab *find_tab(int num) static Tab *cur_tab() { - std::map::iterator it; + std::map::iterator it; for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) { if (it->second->tab_is_cur()) return it->second; @@ -408,21 +408,21 @@ static Tab *cur_tab() return NULL; } -static void on_track_added(Playqueue *pq, unsigned int row) +static void on_track_added(Queue *pq, unsigned int row) { Tab *tab = find_tab(pq); if (tab) tab->on_track_added(row); } -static void on_track_deleted(Playqueue *pq, unsigned int row) +static void on_track_deleted(Queue *pq, unsigned int row) { Tab *tab = find_tab(pq); if (tab) tab->on_track_deleted(row); } -static void on_track_changed(Playqueue *pq, unsigned int row) +static void on_track_changed(Queue *pq, unsigned int row) { Tab *tab = find_tab(pq); if (tab) @@ -516,13 +516,13 @@ void init_tabs() void post_init_tabs() { - std::map::iterator it; + std::map::iterator it; for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) it->second->on_post_init(); unsigned int tab = 0; for (tab = 0; tab < deck::size(); tab++) { - if ((deck :: get(tab)->get_flags() & PQ_ENABLED) == PQ_ENABLED) + if ((deck :: get(tab)->get_flags() & Q_ENABLED) == Q_ENABLED) break; } get_widget("o_notebook")->set_current_page(tab); diff --git a/include/audio.h b/include/audio.h index 427d39e7..d4c42e73 100644 --- a/include/audio.h +++ b/include/audio.h @@ -4,7 +4,7 @@ #ifndef OCARINA_AUDIO_H #define OCARINA_AUDIO_H -#include +#include extern "C" { #include @@ -27,7 +27,7 @@ namespace audio void previous(); void load_trackid(unsigned int); unsigned int current_trackid(); - Playqueue *get_recent_pq(); + Queue *get_recent_pq(); void seek_to(long); long position(); diff --git a/include/callback.h b/include/callback.h index 230643af..e7397b53 100644 --- a/include/callback.h +++ b/include/callback.h @@ -5,7 +5,7 @@ #define OCARINA_CALLBACK_H #include -#include +#include struct Callbacks { @@ -16,8 +16,8 @@ struct Callbacks { void (*on_pause_count_changed)(bool, unsigned int); /* Deck callbacks */ - void (*on_pq_created)(Playqueue *, unsigned int); - void (*on_pq_removed)(Playqueue *); + void (*on_pq_created)(Queue *, unsigned int); + void (*on_pq_removed)(Queue *); /* Library callbacks */ void (*on_library_add)(unsigned int, Library *); @@ -31,10 +31,10 @@ struct Callbacks { void (*on_playlist_ban)(unsigned int); void (*on_playlist_unban)(unsigned int); - /* Playqueue callbacks */ - void (*on_queue_track_add)(Playqueue *, unsigned int); - void (*on_queue_track_del)(Playqueue *, unsigned int); - void (*on_queue_track_changed)(Playqueue *, unsigned int); + /* Queue callbacks */ + void (*on_queue_track_add)(Queue *, unsigned int); + void (*on_queue_track_del)(Queue *, unsigned int); + void (*on_queue_track_changed)(Queue *, unsigned int); void (*on_queue_changed)(); }; diff --git a/include/deck.h b/include/deck.h index 0c3005cb..4ef8a10a 100644 --- a/include/deck.h +++ b/include/deck.h @@ -4,7 +4,7 @@ #ifndef OCARINA_DECK_H #define OCARINA_DECK_H -#include +#include namespace deck { @@ -13,14 +13,14 @@ namespace deck void read(); void write(); - Playqueue *create(bool); + Queue *create(bool); void remove(unsigned int); - Playqueue *get(unsigned int); + Queue *get(unsigned int); unsigned int size(); void move(unsigned int, unsigned int); - void move(Playqueue *, unsigned int); + void move(Queue *, unsigned int); unsigned int next(); - Playqueue *get_library_pq(); + Queue *get_library_pq(); #ifdef CONFIG_TEST void reset(); diff --git a/include/ocarina.h b/include/ocarina.h index 7815c5ac..deae5f52 100644 --- a/include/ocarina.h +++ b/include/ocarina.h @@ -4,7 +4,7 @@ #ifndef OCARINA_H #define OCARINA_H -#include +#include #include @@ -18,7 +18,7 @@ Gtk::Window *ocarina_init(int *, char ***); /* model.cpp */ -class PlayqueueModel : public Gtk::TreeModel, public Glib::Object { +class QueueModel : public Gtk::TreeModel, public Glib::Object { private: void increment_stamp(); void get_value_uint(Track *, int, Glib::ValueBase &) const; @@ -44,8 +44,8 @@ protected: public: int stamp; - Playqueue *queue; - PlayqueueModel(Playqueue *); + Queue *queue; + QueueModel(Queue *); void on_row_inserted(unsigned int); void on_row_deleted(unsigned int); diff --git a/include/playlist.h b/include/playlist.h index c9fec9e7..c188aff6 100644 --- a/include/playlist.h +++ b/include/playlist.h @@ -4,7 +4,7 @@ #ifndef OCARINA_PLAYLIST_H #define OCARINA_PLAYLIST_H -#include +#include #include #include @@ -18,7 +18,7 @@ namespace playlist void del(const std::string &, unsigned int); void select(const std::string &); const std::set &get_tracks(const std::string &); - Playqueue *get_pq(); + Queue *get_pq(); #ifdef CONFIG_TEST void clear(); diff --git a/include/playqueue.h b/include/queue.h similarity index 73% rename from include/playqueue.h rename to include/queue.h index ec943163..b4d78bf6 100644 --- a/include/playqueue.h +++ b/include/queue.h @@ -1,20 +1,20 @@ /* * Copyright 2013 (c) Anna Schumaker. */ -#ifndef OCARINA_PLAYQUEUE_H -#define OCARINA_PLAYQUEUE_H +#ifndef OCARINA_QUEUE_H +#define OCARINA_QUEUE_H #include #include #include #include -enum playqueue_flags { - PQ_ENABLED = (1 << 0), - PQ_RANDOM = (1 << 1), - PQ_REPEAT = (1 << 2), - PQ_NEVER_SORT = (1 << 3), - PQ_DISABLE_CHANGED_SIZE = (1 << 31), +enum queue_flags { + Q_ENABLED = (1 << 0), + Q_RANDOM = (1 << 1), + Q_REPEAT = (1 << 2), + Q_NEVER_SORT = (1 << 3), + Q_DISABLE_CHANGED_SIZE = (1 << 31), }; struct sort_info { @@ -22,7 +22,7 @@ struct sort_info { bool ascending; }; -class Playqueue { +class Queue { private: std :: vector tracks; std :: list sort_order; @@ -34,14 +34,14 @@ private: void _add_sort(sort_t, bool); public: - Playqueue(); - Playqueue(playqueue_flags); - ~Playqueue(); + Queue(); + Queue(queue_flags); + ~Queue(); void write(File &); void read(File &); - void set_flag(playqueue_flags); - void unset_flag(playqueue_flags); + void set_flag(queue_flags); + void unset_flag(queue_flags); const unsigned int get_flags(); unsigned int get_length(); std::string get_length_str(); @@ -67,4 +67,4 @@ public: #endif /* CONFIG_TEST */ }; -#endif /* OCARINA_PLAYQUEUE_H */ +#endif /* OCARINA_QUEUE_H */ diff --git a/include/tabs.h b/include/tabs.h index aae9a158..90e20bc3 100644 --- a/include/tabs.h +++ b/include/tabs.h @@ -5,7 +5,7 @@ #define OCARINA_TABS_H #include -#include +#include #include class Tab { @@ -15,8 +15,8 @@ private: std::string tab_sorting_title; protected: - Playqueue *tab_pq; - Glib::RefPtr tab_model; + Queue *tab_pq; + Glib::RefPtr tab_model; Glib::RefPtr tab_filter; @@ -40,13 +40,13 @@ protected: */ void tab_init_random(); void tab_init_repeat(); - void tab_toggle_button(Gtk::ToggleButton *, playqueue_flags); + void tab_toggle_button(Gtk::ToggleButton *, queue_flags); void tab_dec_sort_count(); virtual void tab_set_size(); void tab_unmap(); public: - Tab(Playqueue *); + Tab(Queue *); virtual ~Tab(); /** @@ -59,7 +59,7 @@ public: void tab_display_sorting(); void tab_focus_search(); void tab_selected_ids(std::vector &); - void tab_queue_add(Playqueue *); + 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 &); @@ -93,7 +93,7 @@ public: }; -Tab *find_tab(Playqueue *); +Tab *find_tab(Queue *); void tab_focus_search(); void init_tabs(); void post_init_tabs(); diff --git a/lib/audio.cpp b/lib/audio.cpp index eb06602a..039bdd8c 100644 --- a/lib/audio.cpp +++ b/lib/audio.cpp @@ -19,7 +19,7 @@ static bool o_pause_enabled = false; static unsigned int o_pause_count = 0; static bool o_should_pause = false; -static Playqueue o_recently_played(PQ_ENABLED); +static Queue o_recently_played(Q_ENABLED); static File f_cur_track("cur_track", FILE_TYPE_DATA); static void parse_error(GstMessage *error) @@ -117,9 +117,9 @@ void audio :: init(int *argc, char ***argv) { GstBus *bus; - o_recently_played.set_flag(PQ_REPEAT); - o_recently_played.set_flag(PQ_NEVER_SORT); - o_recently_played.set_flag(PQ_DISABLE_CHANGED_SIZE); + o_recently_played.set_flag(Q_REPEAT); + o_recently_played.set_flag(Q_NEVER_SORT); + o_recently_played.set_flag(Q_DISABLE_CHANGED_SIZE); gst_init(argc, argv); ocarina_player = gst_element_factory_make("playbin", "ocarina_player"); @@ -251,7 +251,7 @@ unsigned int audio :: current_trackid() return cur_trackid; } -Playqueue *audio :: get_recent_pq() +Queue *audio :: get_recent_pq() { return &o_recently_played; } diff --git a/lib/callback.cpp b/lib/callback.cpp index d732934e..f67054cd 100644 --- a/lib/callback.cpp +++ b/lib/callback.cpp @@ -8,8 +8,8 @@ static void no_op() {} static void no_op(unsigned int) {} static void no_op(bool, unsigned int) {} static void no_op(unsigned int id, Library *path) {} -static void no_op(Playqueue *, unsigned int) {} -static void no_op(Playqueue *) {} +static void no_op(Queue *, unsigned int) {} +static void no_op(Queue *) {} static void no_op(Track *) {} diff --git a/lib/deck.cpp b/lib/deck.cpp index f5661aac..384801b4 100644 --- a/lib/deck.cpp +++ b/lib/deck.cpp @@ -9,8 +9,8 @@ #include -static std::list playqueue_deck; -static Playqueue library_playqueue(PQ_ENABLED); +static std::list playqueue_deck; +static Queue library_playqueue(Q_ENABLED); static File deck_file("deck", FILE_TYPE_DATA); static void add_library_track(unsigned int id) @@ -30,8 +30,8 @@ static void change_library_track(unsigned int id) void deck :: init() { - library_playqueue.set_flag(PQ_REPEAT); - library_playqueue.set_flag(PQ_DISABLE_CHANGED_SIZE); + library_playqueue.set_flag(Q_REPEAT); + library_playqueue.set_flag(Q_DISABLE_CHANGED_SIZE); library_playqueue.add_sort(SORT_ARTIST); library_playqueue.add_sort(SORT_YEAR); library_playqueue.add_sort(SORT_TRACK); @@ -51,7 +51,7 @@ void deck :: read() int random; unsigned int field; bool ascending; - std::list::iterator it; + std::list::iterator it; if (!deck_file.exists()) return; @@ -69,7 +69,7 @@ void deck :: read() deck_file >> num; if (random) - library_playqueue.set_flag(PQ_RANDOM); + library_playqueue.set_flag(Q_RANDOM); playqueue_deck.resize(num); @@ -84,7 +84,7 @@ void deck :: read() void deck :: write() { - std::list::iterator it; + std::list::iterator it; std::list::iterator st; std::list sort_order; @@ -92,7 +92,7 @@ void deck :: write() /* Save library playqueue */ sort_order = library_playqueue.get_sort_order(); - deck_file << (library_playqueue.get_flags() & PQ_RANDOM) << " "; + deck_file << (library_playqueue.get_flags() & Q_RANDOM) << " "; deck_file << sort_order.size() << " "; for (st = sort_order.begin(); st != sort_order.end(); st++) deck_file << st->field << " " << st->ascending << " "; @@ -105,20 +105,20 @@ void deck :: write() deck_file.close(); } -Playqueue *deck :: create(bool random) +Queue *deck :: create(bool random) { - Playqueue *pq; - playqueue_deck.push_back(Playqueue(PQ_ENABLED)); + Queue *pq; + playqueue_deck.push_back(Queue(Q_ENABLED)); pq = &playqueue_deck.back(); if (random == true) - pq->set_flag(PQ_RANDOM); + pq->set_flag(Q_RANDOM); get_callbacks()->on_pq_created(pq, playqueue_deck.size() - 1); return pq; } void deck :: remove(unsigned int id) { - std::list::iterator it = playqueue_deck.begin(); + std::list::iterator it = playqueue_deck.begin(); for (unsigned int i = 0; i < id; i++) it++; get_callbacks()->on_pq_removed(&(*it)); @@ -126,9 +126,9 @@ void deck :: remove(unsigned int id) write(); } -Playqueue *deck :: get(unsigned int id) +Queue *deck :: get(unsigned int id) { - std::list::iterator it = playqueue_deck.begin(); + std::list::iterator it = playqueue_deck.begin(); for (unsigned int i = 0; i < id; i++) it++; return &(*it); @@ -141,8 +141,8 @@ unsigned int deck :: size() void deck :: move(unsigned int old_pos, unsigned int new_pos) { - std::list::iterator it_old = playqueue_deck.begin(); - std::list::iterator it_new = playqueue_deck.begin(); + std::list::iterator it_old = playqueue_deck.begin(); + std::list::iterator it_new = playqueue_deck.begin(); for (unsigned int i = 0; i < playqueue_deck.size(); i++) { if (i < old_pos) @@ -157,11 +157,11 @@ void deck :: move(unsigned int old_pos, unsigned int new_pos) playqueue_deck.splice(it_new, playqueue_deck, it_old); } -void deck :: move(Playqueue *pq, unsigned int new_pos) +void deck :: move(Queue *pq, unsigned int new_pos) { unsigned int old_pos = 0; - std::list::iterator it_old = playqueue_deck.begin(); - std::list::iterator it_new = playqueue_deck.begin(); + std::list::iterator it_old = playqueue_deck.begin(); + std::list::iterator it_new = playqueue_deck.begin(); for (unsigned int i = 0; i < playqueue_deck.size(); i++) { if (&(*it_old) != pq) { @@ -181,10 +181,10 @@ void deck :: move(Playqueue *pq, unsigned int new_pos) unsigned int deck :: next() { unsigned int id = 0; - std::list::iterator it; + std::list::iterator it; for (it = playqueue_deck.begin(); it != playqueue_deck.end(); it++) { - if (it->get_flags() & PQ_ENABLED) { + if (it->get_flags() & Q_ENABLED) { if (it->size() == 0) { playqueue_deck.erase(it); get_callbacks()->on_pq_removed(&(*it)); @@ -203,7 +203,7 @@ unsigned int deck :: next() return library_playqueue.next(); } -Playqueue *deck :: get_library_pq() +Queue *deck :: get_library_pq() { return &library_playqueue; } @@ -221,10 +221,10 @@ void deck :: reset() void deck :: print_info() { unsigned int i = 0; - std::list::iterator it; + std::list::iterator it; for (it = playqueue_deck.begin(); it != playqueue_deck.end(); it++) { - print("deck[%u] = Playqueue { size = %u, flags = %u }\n", + print("deck[%u] = Queue { size = %u, flags = %u }\n", i, it->size(), it->get_flags()); i++; } diff --git a/lib/playlist.cpp b/lib/playlist.cpp index fb33c553..cf338dae 100644 --- a/lib/playlist.cpp +++ b/lib/playlist.cpp @@ -8,7 +8,7 @@ static std::set empty_set; static Index playlist_db("playlist.db", false); -static Playqueue playlist_pq(PQ_ENABLED); +static Queue playlist_pq(Q_ENABLED); static std::string cur_pq; static void import_ban_track(unsigned int track_id) @@ -24,8 +24,8 @@ void playlist :: init() playlist_pq.add_sort(SORT_ARTIST); playlist_pq.add_sort(SORT_YEAR); playlist_pq.add_sort(SORT_TRACK); - playlist_pq.set_flag(PQ_REPEAT); - playlist_pq.set_flag(PQ_NEVER_SORT); + playlist_pq.set_flag(Q_REPEAT); + playlist_pq.set_flag(Q_NEVER_SORT); get_callbacks()->on_library_import_ban = import_ban_track; @@ -93,7 +93,7 @@ const std::set &playlist :: get_tracks(const std::string &name) throw -E_EXIST; } -Playqueue *playlist :: get_pq() +Queue *playlist :: get_pq() { return &playlist_pq; } diff --git a/lib/playqueue.cpp b/lib/queue.cpp similarity index 77% rename from lib/playqueue.cpp rename to lib/queue.cpp index 15440487..c07d7d36 100644 --- a/lib/playqueue.cpp +++ b/lib/queue.cpp @@ -3,7 +3,7 @@ */ #include #include -#include +#include #include #include @@ -13,28 +13,28 @@ #define O_HOURS (60 * O_MINUTES) #define O_DAYS (24 * O_HOURS) -Playqueue :: Playqueue() +Queue :: Queue() : flags(0), cur(-1), length(0) { } -Playqueue :: Playqueue(playqueue_flags f) +Queue :: Queue(queue_flags f) : flags(f), cur(-1), length(0) { } -Playqueue :: ~Playqueue() +Queue :: ~Queue() { } -void Playqueue :: write(File &f) +void Queue :: write(File &f) { f << flags << " " << tracks.size(); for (unsigned int i = 0; i < tracks.size(); i++) f << " " << tracks[i]; } -void Playqueue :: read(File &f) +void Queue :: read(File &f) { unsigned int n; f >> flags >> n; @@ -43,24 +43,24 @@ void Playqueue :: read(File &f) f >> tracks[i]; } -void Playqueue :: set_flag(playqueue_flags f) +void Queue :: set_flag(queue_flags f) { flags |= f; get_callbacks()->on_queue_changed(); } -void Playqueue :: unset_flag(playqueue_flags f) +void Queue :: unset_flag(queue_flags f) { flags &= ~f; get_callbacks()->on_queue_changed(); } -const unsigned int Playqueue :: get_flags() +const unsigned int Queue :: get_flags() { return flags; } -unsigned int Playqueue :: get_length() +unsigned int Queue :: get_length() { return length; } @@ -77,7 +77,7 @@ static inline void add_duration(std::stringstream &ss, unsigned int dur, } } -std::string Playqueue :: get_length_str() +std::string Queue :: get_length_str() { std::stringstream ss; unsigned int len = length; @@ -127,7 +127,7 @@ static bool track_less_than(Track *lhs, Track *rhs, std::list &order) return res; } -unsigned int Playqueue :: find_sorted_id(Track *rhs) +unsigned int Queue :: find_sorted_id(Track *rhs) { Track *lhs; unsigned int begin = 0, end = (tracks.size() - 1), mid; @@ -154,7 +154,7 @@ unsigned int Playqueue :: find_sorted_id(Track *rhs) return begin; } -unsigned int Playqueue :: add(unsigned int track_id) +unsigned int Queue :: add(unsigned int track_id) { unsigned int id = tracks.size(); Track *track = tagdb :: lookup(track_id); @@ -165,12 +165,12 @@ unsigned int Playqueue :: add(unsigned int track_id) tracks.insert(tracks.begin() + id, track_id); length += track->length; get_callbacks()->on_queue_track_add(this, id); - if (!(flags & PQ_DISABLE_CHANGED_SIZE)) + if (!(flags & Q_DISABLE_CHANGED_SIZE)) get_callbacks()->on_queue_changed(); return id; } -unsigned int Playqueue :: add_front(unsigned int track_id) +unsigned int Queue :: add_front(unsigned int track_id) { Track *track; tracks.insert(tracks.begin(), track_id); @@ -178,12 +178,12 @@ unsigned int Playqueue :: add_front(unsigned int track_id) track = tagdb :: lookup(track_id); length += track->length; get_callbacks()->on_queue_track_add(this, 0); - if (!(flags & PQ_DISABLE_CHANGED_SIZE)) + if (!(flags & Q_DISABLE_CHANGED_SIZE)) get_callbacks()->on_queue_changed(); return 0; } -void Playqueue :: del(unsigned int plist_id) +void Queue :: del(unsigned int plist_id) { Track *track; unsigned int track_id = tracks[plist_id]; @@ -192,11 +192,11 @@ void Playqueue :: del(unsigned int plist_id) track = tagdb :: lookup(track_id); length -= track->length; get_callbacks()->on_queue_track_del(this, plist_id); - if (!(flags & PQ_DISABLE_CHANGED_SIZE)) + if (!(flags & Q_DISABLE_CHANGED_SIZE)) get_callbacks()->on_queue_changed(); } -void Playqueue :: del_track(unsigned int track_id) +void Queue :: del_track(unsigned int track_id) { unsigned int i = 0; while (i < tracks.size()) { @@ -207,7 +207,7 @@ void Playqueue :: del_track(unsigned int track_id) } } -void Playqueue :: track_updated(unsigned int track_id) +void Queue :: track_updated(unsigned int track_id) { for (unsigned int i = 0; i < tracks.size(); i++) { if (tracks[i] == track_id) @@ -215,7 +215,7 @@ void Playqueue :: track_updated(unsigned int track_id) } } -unsigned int Playqueue :: size() +unsigned int Queue :: size() { return tracks.size(); } @@ -235,7 +235,7 @@ public: } }; -void Playqueue :: _add_sort(sort_t field, bool ascending) +void Queue :: _add_sort(sort_t field, bool ascending) { struct sort_info info; std::list::iterator it; @@ -255,9 +255,9 @@ void Playqueue :: _add_sort(sort_t field, bool ascending) sort_order.erase(sort_order.begin()); } -void Playqueue :: add_sort(sort_t field, bool ascending) +void Queue :: add_sort(sort_t field, bool ascending) { - if (flags & PQ_NEVER_SORT) + if (flags & Q_NEVER_SORT) return; _add_sort(field, ascending); @@ -268,31 +268,31 @@ void Playqueue :: add_sort(sort_t field, bool ascending) get_callbacks()->on_queue_changed(); } -void Playqueue :: reset_sort(sort_t field, bool ascending) +void Queue :: reset_sort(sort_t field, bool ascending) { - if (flags & PQ_NEVER_SORT) + if (flags & Q_NEVER_SORT) return; if (sort_order.front().field != field) sort_order.clear(); add_sort(field, ascending); } -void Playqueue :: force_clear_sort() +void Queue :: force_clear_sort() { sort_order.clear(); } -std::list &Playqueue :: get_sort_order() +std::list &Queue :: get_sort_order() { return sort_order; } -unsigned int Playqueue :: operator[](unsigned int i) +unsigned int Queue :: operator[](unsigned int i) { return tracks[i]; } -unsigned int Playqueue :: next() +unsigned int Queue :: next() { unsigned int res; @@ -300,7 +300,7 @@ unsigned int Playqueue :: next() throw -E_EXIST; else if (tracks.size() == 1) cur = 0; - else if (flags & PQ_RANDOM) + else if (flags & Q_RANDOM) cur += rand() % (tracks.size() / 2) + 1; else cur++; @@ -309,29 +309,29 @@ unsigned int Playqueue :: next() cur -= tracks.size(); res = tracks[cur]; - if (!(flags & PQ_REPEAT)) { + if (!(flags & Q_REPEAT)) { del(cur); cur--; } return res; } -void Playqueue :: set_cur(unsigned int c) +void Queue :: set_cur(unsigned int c) { cur = c; } -void Playqueue :: path_selected(unsigned int id) +void Queue :: path_selected(unsigned int id) { cur = id; - if (!(flags &PQ_REPEAT)) { + if (!(flags &Q_REPEAT)) { del(cur); cur--; } } #ifdef CONFIG_TEST -void Playqueue :: reset() +void Queue :: reset() { tracks.clear(); set_cur(0);