Rename playqueue -> queue
Signed-off-by: Anna Schumaker <anna@ocarinaproject.net>
This commit is contained in:
parent
57fa16d289
commit
1c743239a0
|
@ -10,8 +10,8 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
PlayqueueModel::PlayqueueModel(Playqueue *q)
|
QueueModel::QueueModel(Queue *q)
|
||||||
: Glib::ObjectBase( typeid(PlayqueueModel) ),
|
: Glib::ObjectBase( typeid(QueueModel) ),
|
||||||
Glib::Object(), queue(q)
|
Glib::Object(), queue(q)
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
|
@ -19,14 +19,14 @@ PlayqueueModel::PlayqueueModel(Playqueue *q)
|
||||||
} while (stamp == 0);
|
} while (stamp == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayqueueModel::increment_stamp()
|
void QueueModel::increment_stamp()
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
stamp++;
|
stamp++;
|
||||||
} while (stamp == 0);
|
} while (stamp == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayqueueModel::on_row_inserted(unsigned int row)
|
void QueueModel::on_row_inserted(unsigned int row)
|
||||||
{
|
{
|
||||||
Gtk::TreePath path;
|
Gtk::TreePath path;
|
||||||
Gtk::TreeIter iter;
|
Gtk::TreeIter iter;
|
||||||
|
@ -36,7 +36,7 @@ void PlayqueueModel::on_row_inserted(unsigned int row)
|
||||||
row_inserted(path, iter);
|
row_inserted(path, iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayqueueModel::on_row_deleted(unsigned int row)
|
void QueueModel::on_row_deleted(unsigned int row)
|
||||||
{
|
{
|
||||||
Gtk::TreePath path;
|
Gtk::TreePath path;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ void PlayqueueModel::on_row_deleted(unsigned int row)
|
||||||
row_deleted(path);
|
row_deleted(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayqueueModel::on_row_changed(unsigned int row)
|
void QueueModel::on_row_changed(unsigned int row)
|
||||||
{
|
{
|
||||||
Gtk::TreePath path;
|
Gtk::TreePath path;
|
||||||
Gtk::TreeIter iter;
|
Gtk::TreeIter iter;
|
||||||
|
@ -55,19 +55,19 @@ void PlayqueueModel::on_row_changed(unsigned int row)
|
||||||
row_changed(path, iter);
|
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));
|
audio :: load_trackid(path_to_id(path));
|
||||||
queue->path_selected(path[0]);
|
queue->path_selected(path[0]);
|
||||||
audio :: play();
|
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);
|
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]);
|
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;
|
return Gtk::TREE_MODEL_LIST_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PlayqueueModel::get_n_columns_vfunc() const
|
int QueueModel::get_n_columns_vfunc() const
|
||||||
{
|
{
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
GType PlayqueueModel::get_column_type_vfunc(int index) const
|
GType QueueModel::get_column_type_vfunc(int index) const
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
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::ValueBase &value) const
|
||||||
{
|
{
|
||||||
Glib::Value<unsigned int> specific;
|
Glib::Value<unsigned int> specific;
|
||||||
|
@ -131,7 +131,7 @@ void PlayqueueModel::get_value_uint(Track *track, int column,
|
||||||
value = specific;
|
value = specific;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayqueueModel::get_value_str(Track *track, int column,
|
void QueueModel::get_value_str(Track *track, int column,
|
||||||
Glib::ValueBase &value) const
|
Glib::ValueBase &value) const
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
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
|
Glib::ValueBase &value) const
|
||||||
{
|
{
|
||||||
unsigned int row;
|
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
|
Gtk::TreeIter &iter_next) const
|
||||||
{
|
{
|
||||||
unsigned int index;
|
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);
|
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
|
Gtk::TreeIter &iter) const
|
||||||
{
|
{
|
||||||
return iter_nth_child_vfunc(parent, 0, iter);
|
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);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PlayqueueModel::iter_n_root_children_vfunc() const
|
int QueueModel::iter_n_root_children_vfunc() const
|
||||||
{
|
{
|
||||||
return queue->size();
|
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
|
int n, Gtk::TreeIter &iter) const
|
||||||
{
|
{
|
||||||
iter = Gtk::TreeIter();
|
iter = Gtk::TreeIter();
|
||||||
return false;
|
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();
|
iter = Gtk::TreeIter();
|
||||||
if (n >= (int)queue->size())
|
if (n >= (int)queue->size())
|
||||||
|
@ -252,14 +252,14 @@ bool PlayqueueModel::iter_nth_root_child_vfunc(int n, Gtk::TreeIter &iter) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayqueueModel::iter_parent_vfunc(const Gtk::TreeIter &child,
|
bool QueueModel::iter_parent_vfunc(const Gtk::TreeIter &child,
|
||||||
Gtk::TreeIter &iter) const
|
Gtk::TreeIter &iter) const
|
||||||
{
|
{
|
||||||
iter = Gtk::TreeIter();
|
iter = Gtk::TreeIter();
|
||||||
return false;
|
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;
|
Gtk::TreeModel::Path path;
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ Gtk::TreeModel::Path PlayqueueModel::get_path_vfunc(const Gtk::TreeIter &iter) c
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayqueueModel::get_iter_vfunc(const Gtk::TreePath &path,
|
bool QueueModel::get_iter_vfunc(const Gtk::TreePath &path,
|
||||||
Gtk::TreeIter &iter) const
|
Gtk::TreeIter &iter) const
|
||||||
{
|
{
|
||||||
if (path.size() != 1) {
|
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);
|
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();
|
return stamp == iter.get_stamp();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ private:
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QueueTab(Playqueue *, unsigned int num);
|
QueueTab(Queue *, unsigned int num);
|
||||||
~QueueTab();
|
~QueueTab();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,7 +88,7 @@ public:
|
||||||
static std::map<Gtk::Widget *, QueueTab *> queue_mapping;
|
static std::map<Gtk::Widget *, QueueTab *> queue_mapping;
|
||||||
|
|
||||||
|
|
||||||
QueueTab :: QueueTab(Playqueue *pq, unsigned int num)
|
QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
||||||
: Tab(pq)
|
: Tab(pq)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -218,7 +218,7 @@ void QueueTab :: on_post_init()
|
||||||
tab_init_random();
|
tab_init_random();
|
||||||
tab_init_repeat();
|
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.set_active(active);
|
||||||
q_switch.property_active().signal_changed().connect(
|
q_switch.property_active().signal_changed().connect(
|
||||||
sigc::mem_fun(*this, &QueueTab :: on_switch_changed));
|
sigc::mem_fun(*this, &QueueTab :: on_switch_changed));
|
||||||
|
@ -297,10 +297,10 @@ void QueueTab :: on_close_clicked()
|
||||||
void QueueTab :: on_switch_changed()
|
void QueueTab :: on_switch_changed()
|
||||||
{
|
{
|
||||||
if (q_switch.get_active()) {
|
if (q_switch.get_active()) {
|
||||||
tab_pq->set_flag(PQ_ENABLED);
|
tab_pq->set_flag(Q_ENABLED);
|
||||||
queue_set_sensitive(true);
|
queue_set_sensitive(true);
|
||||||
} else {
|
} else {
|
||||||
tab_pq->unset_flag(PQ_ENABLED);
|
tab_pq->unset_flag(Q_ENABLED);
|
||||||
queue_set_sensitive(false);
|
queue_set_sensitive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,13 +319,13 @@ static void renumber_queues()
|
||||||
it->second->on_tab_reordered();
|
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);
|
QueueTab *tab = new QueueTab(pq, num);
|
||||||
tab->on_post_init();
|
tab->on_post_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_pq_removed(Playqueue *pq)
|
static void on_pq_removed(Queue *pq)
|
||||||
{
|
{
|
||||||
Tab *tab = find_tab(pq);
|
Tab *tab = find_tab(pq);
|
||||||
if (tab) {
|
if (tab) {
|
||||||
|
|
40
gui/tabs.cpp
40
gui/tabs.cpp
|
@ -11,7 +11,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
static std::map<Playqueue *, Tab *> queue_mapping;
|
static std::map<Queue *, Tab *> queue_mapping;
|
||||||
|
|
||||||
static sort_t sort_fields[] = {
|
static sort_t sort_fields[] = {
|
||||||
SORT_TRACK, SORT_TITLE, SORT_LENGTH,
|
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_sorting_count(0), tab_pq(pq), tab_size(NULL)
|
||||||
{
|
{
|
||||||
tab_model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(tab_pq));
|
tab_model = Glib::RefPtr<QueueModel>(new QueueModel(tab_pq));
|
||||||
queue_mapping[tab_pq] = this;
|
queue_mapping[tab_pq] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,19 +71,19 @@ void Tab :: tab_finish_init()
|
||||||
|
|
||||||
void Tab :: tab_init_random()
|
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_random->signal_toggled().connect(sigc::mem_fun(*this,
|
||||||
&Tab::on_random_toggled));
|
&Tab::on_random_toggled));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab :: tab_init_repeat()
|
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_repeat->signal_toggled().connect(sigc::mem_fun(*this,
|
||||||
&Tab::on_repeat_toggled));
|
&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())
|
if (button->get_active())
|
||||||
tab_pq->set_flag(flag);
|
tab_pq->set_flag(flag);
|
||||||
|
@ -155,7 +155,7 @@ void Tab :: tab_selected_ids(std::vector<unsigned int> &ids)
|
||||||
sel->unselect_all();
|
sel->unselect_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab :: tab_queue_add(Playqueue *pq)
|
void Tab :: tab_queue_add(Queue *pq)
|
||||||
{
|
{
|
||||||
std::vector<unsigned int> ids;
|
std::vector<unsigned int> ids;
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ bool Tab :: tab_queue_selected(bool random)
|
||||||
if (deck :: size() >= 10)
|
if (deck :: size() >= 10)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Playqueue *pq = deck :: create(random);
|
Queue *pq = deck :: create(random);
|
||||||
tab_queue_add(pq);
|
tab_queue_add(pq);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ bool Tab :: tab_add_to_queue(unsigned int n)
|
||||||
if (n >= deck :: size())
|
if (n >= deck :: size())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Playqueue *pq = deck :: get(n);
|
Queue *pq = deck :: get(n);
|
||||||
tab_queue_add(pq);
|
tab_queue_add(pq);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -284,12 +284,12 @@ void Tab :: on_show_rc_menu()
|
||||||
|
|
||||||
void Tab :: on_random_toggled()
|
void Tab :: on_random_toggled()
|
||||||
{
|
{
|
||||||
tab_toggle_button(tab_random, PQ_RANDOM);
|
tab_toggle_button(tab_random, Q_RANDOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tab :: on_repeat_toggled()
|
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)
|
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<Playqueue *, Tab *>::iterator it;
|
std::map<Queue *, Tab *>::iterator it;
|
||||||
it = queue_mapping.find(pq);
|
it = queue_mapping.find(pq);
|
||||||
if (it != queue_mapping.end())
|
if (it != queue_mapping.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -390,7 +390,7 @@ Tab *find_tab(Playqueue *pq)
|
||||||
|
|
||||||
static Tab *find_tab(int num)
|
static Tab *find_tab(int num)
|
||||||
{
|
{
|
||||||
std::map<Playqueue *, Tab *>::iterator it;
|
std::map<Queue *, Tab *>::iterator it;
|
||||||
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) {
|
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) {
|
||||||
if (it->second->tab_page_num() == num)
|
if (it->second->tab_page_num() == num)
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -400,7 +400,7 @@ static Tab *find_tab(int num)
|
||||||
|
|
||||||
static Tab *cur_tab()
|
static Tab *cur_tab()
|
||||||
{
|
{
|
||||||
std::map<Playqueue *, Tab *>::iterator it;
|
std::map<Queue *, Tab *>::iterator it;
|
||||||
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) {
|
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) {
|
||||||
if (it->second->tab_is_cur())
|
if (it->second->tab_is_cur())
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -408,21 +408,21 @@ static Tab *cur_tab()
|
||||||
return NULL;
|
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);
|
Tab *tab = find_tab(pq);
|
||||||
if (tab)
|
if (tab)
|
||||||
tab->on_track_added(row);
|
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);
|
Tab *tab = find_tab(pq);
|
||||||
if (tab)
|
if (tab)
|
||||||
tab->on_track_deleted(row);
|
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);
|
Tab *tab = find_tab(pq);
|
||||||
if (tab)
|
if (tab)
|
||||||
|
@ -516,13 +516,13 @@ void init_tabs()
|
||||||
|
|
||||||
void post_init_tabs()
|
void post_init_tabs()
|
||||||
{
|
{
|
||||||
std::map<Playqueue *, Tab *>::iterator it;
|
std::map<Queue *, Tab *>::iterator it;
|
||||||
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++)
|
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++)
|
||||||
it->second->on_post_init();
|
it->second->on_post_init();
|
||||||
|
|
||||||
unsigned int tab = 0;
|
unsigned int tab = 0;
|
||||||
for (tab = 0; tab < deck::size(); tab++) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
get_widget<Gtk::Notebook>("o_notebook")->set_current_page(tab);
|
get_widget<Gtk::Notebook>("o_notebook")->set_current_page(tab);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#ifndef OCARINA_AUDIO_H
|
#ifndef OCARINA_AUDIO_H
|
||||||
#define OCARINA_AUDIO_H
|
#define OCARINA_AUDIO_H
|
||||||
|
|
||||||
#include <playqueue.h>
|
#include <queue.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
@ -27,7 +27,7 @@ namespace audio
|
||||||
void previous();
|
void previous();
|
||||||
void load_trackid(unsigned int);
|
void load_trackid(unsigned int);
|
||||||
unsigned int current_trackid();
|
unsigned int current_trackid();
|
||||||
Playqueue *get_recent_pq();
|
Queue *get_recent_pq();
|
||||||
|
|
||||||
void seek_to(long);
|
void seek_to(long);
|
||||||
long position();
|
long position();
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#define OCARINA_CALLBACK_H
|
#define OCARINA_CALLBACK_H
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <playqueue.h>
|
#include <queue.h>
|
||||||
|
|
||||||
|
|
||||||
struct Callbacks {
|
struct Callbacks {
|
||||||
|
@ -16,8 +16,8 @@ struct Callbacks {
|
||||||
void (*on_pause_count_changed)(bool, unsigned int);
|
void (*on_pause_count_changed)(bool, unsigned int);
|
||||||
|
|
||||||
/* Deck callbacks */
|
/* Deck callbacks */
|
||||||
void (*on_pq_created)(Playqueue *, unsigned int);
|
void (*on_pq_created)(Queue *, unsigned int);
|
||||||
void (*on_pq_removed)(Playqueue *);
|
void (*on_pq_removed)(Queue *);
|
||||||
|
|
||||||
/* Library callbacks */
|
/* Library callbacks */
|
||||||
void (*on_library_add)(unsigned int, Library *);
|
void (*on_library_add)(unsigned int, Library *);
|
||||||
|
@ -31,10 +31,10 @@ struct Callbacks {
|
||||||
void (*on_playlist_ban)(unsigned int);
|
void (*on_playlist_ban)(unsigned int);
|
||||||
void (*on_playlist_unban)(unsigned int);
|
void (*on_playlist_unban)(unsigned int);
|
||||||
|
|
||||||
/* Playqueue callbacks */
|
/* Queue callbacks */
|
||||||
void (*on_queue_track_add)(Playqueue *, unsigned int);
|
void (*on_queue_track_add)(Queue *, unsigned int);
|
||||||
void (*on_queue_track_del)(Playqueue *, unsigned int);
|
void (*on_queue_track_del)(Queue *, unsigned int);
|
||||||
void (*on_queue_track_changed)(Playqueue *, unsigned int);
|
void (*on_queue_track_changed)(Queue *, unsigned int);
|
||||||
void (*on_queue_changed)();
|
void (*on_queue_changed)();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#ifndef OCARINA_DECK_H
|
#ifndef OCARINA_DECK_H
|
||||||
#define OCARINA_DECK_H
|
#define OCARINA_DECK_H
|
||||||
|
|
||||||
#include <playqueue.h>
|
#include <queue.h>
|
||||||
|
|
||||||
namespace deck
|
namespace deck
|
||||||
{
|
{
|
||||||
|
@ -13,14 +13,14 @@ namespace deck
|
||||||
void read();
|
void read();
|
||||||
void write();
|
void write();
|
||||||
|
|
||||||
Playqueue *create(bool);
|
Queue *create(bool);
|
||||||
void remove(unsigned int);
|
void remove(unsigned int);
|
||||||
Playqueue *get(unsigned int);
|
Queue *get(unsigned int);
|
||||||
unsigned int size();
|
unsigned int size();
|
||||||
void move(unsigned int, unsigned int);
|
void move(unsigned int, unsigned int);
|
||||||
void move(Playqueue *, unsigned int);
|
void move(Queue *, unsigned int);
|
||||||
unsigned int next();
|
unsigned int next();
|
||||||
Playqueue *get_library_pq();
|
Queue *get_library_pq();
|
||||||
|
|
||||||
#ifdef CONFIG_TEST
|
#ifdef CONFIG_TEST
|
||||||
void reset();
|
void reset();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#ifndef OCARINA_H
|
#ifndef OCARINA_H
|
||||||
#define OCARINA_H
|
#define OCARINA_H
|
||||||
|
|
||||||
#include <playqueue.h>
|
#include <queue.h>
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ Gtk::Window *ocarina_init(int *, char ***);
|
||||||
|
|
||||||
|
|
||||||
/* model.cpp */
|
/* model.cpp */
|
||||||
class PlayqueueModel : public Gtk::TreeModel, public Glib::Object {
|
class QueueModel : public Gtk::TreeModel, public Glib::Object {
|
||||||
private:
|
private:
|
||||||
void increment_stamp();
|
void increment_stamp();
|
||||||
void get_value_uint(Track *, int, Glib::ValueBase &) const;
|
void get_value_uint(Track *, int, Glib::ValueBase &) const;
|
||||||
|
@ -44,8 +44,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int stamp;
|
int stamp;
|
||||||
Playqueue *queue;
|
Queue *queue;
|
||||||
PlayqueueModel(Playqueue *);
|
QueueModel(Queue *);
|
||||||
|
|
||||||
void on_row_inserted(unsigned int);
|
void on_row_inserted(unsigned int);
|
||||||
void on_row_deleted(unsigned int);
|
void on_row_deleted(unsigned int);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#ifndef OCARINA_PLAYLIST_H
|
#ifndef OCARINA_PLAYLIST_H
|
||||||
#define OCARINA_PLAYLIST_H
|
#define OCARINA_PLAYLIST_H
|
||||||
|
|
||||||
#include <playqueue.h>
|
#include <queue.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -18,7 +18,7 @@ namespace playlist
|
||||||
void del(const std::string &, unsigned int);
|
void del(const std::string &, unsigned int);
|
||||||
void select(const std::string &);
|
void select(const std::string &);
|
||||||
const std::set<unsigned int> &get_tracks(const std::string &);
|
const std::set<unsigned int> &get_tracks(const std::string &);
|
||||||
Playqueue *get_pq();
|
Queue *get_pq();
|
||||||
|
|
||||||
#ifdef CONFIG_TEST
|
#ifdef CONFIG_TEST
|
||||||
void clear();
|
void clear();
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2013 (c) Anna Schumaker.
|
* Copyright 2013 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#ifndef OCARINA_PLAYQUEUE_H
|
#ifndef OCARINA_QUEUE_H
|
||||||
#define OCARINA_PLAYQUEUE_H
|
#define OCARINA_QUEUE_H
|
||||||
|
|
||||||
#include <file.h>
|
#include <file.h>
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
enum playqueue_flags {
|
enum queue_flags {
|
||||||
PQ_ENABLED = (1 << 0),
|
Q_ENABLED = (1 << 0),
|
||||||
PQ_RANDOM = (1 << 1),
|
Q_RANDOM = (1 << 1),
|
||||||
PQ_REPEAT = (1 << 2),
|
Q_REPEAT = (1 << 2),
|
||||||
PQ_NEVER_SORT = (1 << 3),
|
Q_NEVER_SORT = (1 << 3),
|
||||||
PQ_DISABLE_CHANGED_SIZE = (1 << 31),
|
Q_DISABLE_CHANGED_SIZE = (1 << 31),
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sort_info {
|
struct sort_info {
|
||||||
|
@ -22,7 +22,7 @@ struct sort_info {
|
||||||
bool ascending;
|
bool ascending;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Playqueue {
|
class Queue {
|
||||||
private:
|
private:
|
||||||
std :: vector <unsigned int> tracks;
|
std :: vector <unsigned int> tracks;
|
||||||
std :: list <sort_info> sort_order;
|
std :: list <sort_info> sort_order;
|
||||||
|
@ -34,14 +34,14 @@ private:
|
||||||
void _add_sort(sort_t, bool);
|
void _add_sort(sort_t, bool);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Playqueue();
|
Queue();
|
||||||
Playqueue(playqueue_flags);
|
Queue(queue_flags);
|
||||||
~Playqueue();
|
~Queue();
|
||||||
void write(File &);
|
void write(File &);
|
||||||
void read(File &);
|
void read(File &);
|
||||||
|
|
||||||
void set_flag(playqueue_flags);
|
void set_flag(queue_flags);
|
||||||
void unset_flag(playqueue_flags);
|
void unset_flag(queue_flags);
|
||||||
const unsigned int get_flags();
|
const unsigned int get_flags();
|
||||||
unsigned int get_length();
|
unsigned int get_length();
|
||||||
std::string get_length_str();
|
std::string get_length_str();
|
||||||
|
@ -67,4 +67,4 @@ public:
|
||||||
#endif /* CONFIG_TEST */
|
#endif /* CONFIG_TEST */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* OCARINA_PLAYQUEUE_H */
|
#endif /* OCARINA_QUEUE_H */
|
|
@ -5,7 +5,7 @@
|
||||||
#define OCARINA_TABS_H
|
#define OCARINA_TABS_H
|
||||||
|
|
||||||
#include <ocarina.h>
|
#include <ocarina.h>
|
||||||
#include <playqueue.h>
|
#include <queue.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
class Tab {
|
class Tab {
|
||||||
|
@ -15,8 +15,8 @@ private:
|
||||||
std::string tab_sorting_title;
|
std::string tab_sorting_title;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Playqueue *tab_pq;
|
Queue *tab_pq;
|
||||||
Glib::RefPtr<PlayqueueModel> tab_model;
|
Glib::RefPtr<QueueModel> tab_model;
|
||||||
Glib::RefPtr<Gtk::TreeModelFilter> tab_filter;
|
Glib::RefPtr<Gtk::TreeModelFilter> tab_filter;
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,13 +40,13 @@ protected:
|
||||||
*/
|
*/
|
||||||
void tab_init_random();
|
void tab_init_random();
|
||||||
void tab_init_repeat();
|
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();
|
void tab_dec_sort_count();
|
||||||
virtual void tab_set_size();
|
virtual void tab_set_size();
|
||||||
void tab_unmap();
|
void tab_unmap();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Tab(Playqueue *);
|
Tab(Queue *);
|
||||||
virtual ~Tab();
|
virtual ~Tab();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +59,7 @@ public:
|
||||||
void tab_display_sorting();
|
void tab_display_sorting();
|
||||||
void tab_focus_search();
|
void tab_focus_search();
|
||||||
void tab_selected_ids(std::vector<unsigned int> &);
|
void tab_selected_ids(std::vector<unsigned int> &);
|
||||||
void tab_queue_add(Playqueue *);
|
void tab_queue_add(Queue *);
|
||||||
bool tab_queue_selected(bool);
|
bool tab_queue_selected(bool);
|
||||||
bool tab_add_to_queue(unsigned int);
|
bool tab_add_to_queue(unsigned int);
|
||||||
bool tab_add_to_playlist(const std::string &);
|
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 tab_focus_search();
|
||||||
void init_tabs();
|
void init_tabs();
|
||||||
void post_init_tabs();
|
void post_init_tabs();
|
||||||
|
|
|
@ -19,7 +19,7 @@ static bool o_pause_enabled = false;
|
||||||
static unsigned int o_pause_count = 0;
|
static unsigned int o_pause_count = 0;
|
||||||
static bool o_should_pause = false;
|
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 File f_cur_track("cur_track", FILE_TYPE_DATA);
|
||||||
|
|
||||||
static void parse_error(GstMessage *error)
|
static void parse_error(GstMessage *error)
|
||||||
|
@ -117,9 +117,9 @@ void audio :: init(int *argc, char ***argv)
|
||||||
{
|
{
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
|
||||||
o_recently_played.set_flag(PQ_REPEAT);
|
o_recently_played.set_flag(Q_REPEAT);
|
||||||
o_recently_played.set_flag(PQ_NEVER_SORT);
|
o_recently_played.set_flag(Q_NEVER_SORT);
|
||||||
o_recently_played.set_flag(PQ_DISABLE_CHANGED_SIZE);
|
o_recently_played.set_flag(Q_DISABLE_CHANGED_SIZE);
|
||||||
gst_init(argc, argv);
|
gst_init(argc, argv);
|
||||||
|
|
||||||
ocarina_player = gst_element_factory_make("playbin", "ocarina_player");
|
ocarina_player = gst_element_factory_make("playbin", "ocarina_player");
|
||||||
|
@ -251,7 +251,7 @@ unsigned int audio :: current_trackid()
|
||||||
return cur_trackid;
|
return cur_trackid;
|
||||||
}
|
}
|
||||||
|
|
||||||
Playqueue *audio :: get_recent_pq()
|
Queue *audio :: get_recent_pq()
|
||||||
{
|
{
|
||||||
return &o_recently_played;
|
return &o_recently_played;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ static void no_op() {}
|
||||||
static void no_op(unsigned int) {}
|
static void no_op(unsigned int) {}
|
||||||
static void no_op(bool, unsigned int) {}
|
static void no_op(bool, unsigned int) {}
|
||||||
static void no_op(unsigned int id, Library *path) {}
|
static void no_op(unsigned int id, Library *path) {}
|
||||||
static void no_op(Playqueue *, unsigned int) {}
|
static void no_op(Queue *, unsigned int) {}
|
||||||
static void no_op(Playqueue *) {}
|
static void no_op(Queue *) {}
|
||||||
static void no_op(Track *) {}
|
static void no_op(Track *) {}
|
||||||
|
|
||||||
|
|
||||||
|
|
50
lib/deck.cpp
50
lib/deck.cpp
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
static std::list<Playqueue> playqueue_deck;
|
static std::list<Queue> playqueue_deck;
|
||||||
static Playqueue library_playqueue(PQ_ENABLED);
|
static Queue library_playqueue(Q_ENABLED);
|
||||||
static File deck_file("deck", FILE_TYPE_DATA);
|
static File deck_file("deck", FILE_TYPE_DATA);
|
||||||
|
|
||||||
static void add_library_track(unsigned int id)
|
static void add_library_track(unsigned int id)
|
||||||
|
@ -30,8 +30,8 @@ static void change_library_track(unsigned int id)
|
||||||
|
|
||||||
void deck :: init()
|
void deck :: init()
|
||||||
{
|
{
|
||||||
library_playqueue.set_flag(PQ_REPEAT);
|
library_playqueue.set_flag(Q_REPEAT);
|
||||||
library_playqueue.set_flag(PQ_DISABLE_CHANGED_SIZE);
|
library_playqueue.set_flag(Q_DISABLE_CHANGED_SIZE);
|
||||||
library_playqueue.add_sort(SORT_ARTIST);
|
library_playqueue.add_sort(SORT_ARTIST);
|
||||||
library_playqueue.add_sort(SORT_YEAR);
|
library_playqueue.add_sort(SORT_YEAR);
|
||||||
library_playqueue.add_sort(SORT_TRACK);
|
library_playqueue.add_sort(SORT_TRACK);
|
||||||
|
@ -51,7 +51,7 @@ void deck :: read()
|
||||||
int random;
|
int random;
|
||||||
unsigned int field;
|
unsigned int field;
|
||||||
bool ascending;
|
bool ascending;
|
||||||
std::list<Playqueue>::iterator it;
|
std::list<Queue>::iterator it;
|
||||||
|
|
||||||
if (!deck_file.exists())
|
if (!deck_file.exists())
|
||||||
return;
|
return;
|
||||||
|
@ -69,7 +69,7 @@ void deck :: read()
|
||||||
|
|
||||||
deck_file >> num;
|
deck_file >> num;
|
||||||
if (random)
|
if (random)
|
||||||
library_playqueue.set_flag(PQ_RANDOM);
|
library_playqueue.set_flag(Q_RANDOM);
|
||||||
|
|
||||||
playqueue_deck.resize(num);
|
playqueue_deck.resize(num);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ void deck :: read()
|
||||||
|
|
||||||
void deck :: write()
|
void deck :: write()
|
||||||
{
|
{
|
||||||
std::list<Playqueue>::iterator it;
|
std::list<Queue>::iterator it;
|
||||||
std::list<sort_info>::iterator st;
|
std::list<sort_info>::iterator st;
|
||||||
std::list<sort_info> sort_order;
|
std::list<sort_info> sort_order;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ void deck :: write()
|
||||||
|
|
||||||
/* Save library playqueue */
|
/* Save library playqueue */
|
||||||
sort_order = library_playqueue.get_sort_order();
|
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() << " ";
|
deck_file << sort_order.size() << " ";
|
||||||
for (st = sort_order.begin(); st != sort_order.end(); st++)
|
for (st = sort_order.begin(); st != sort_order.end(); st++)
|
||||||
deck_file << st->field << " " << st->ascending << " ";
|
deck_file << st->field << " " << st->ascending << " ";
|
||||||
|
@ -105,20 +105,20 @@ void deck :: write()
|
||||||
deck_file.close();
|
deck_file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Playqueue *deck :: create(bool random)
|
Queue *deck :: create(bool random)
|
||||||
{
|
{
|
||||||
Playqueue *pq;
|
Queue *pq;
|
||||||
playqueue_deck.push_back(Playqueue(PQ_ENABLED));
|
playqueue_deck.push_back(Queue(Q_ENABLED));
|
||||||
pq = &playqueue_deck.back();
|
pq = &playqueue_deck.back();
|
||||||
if (random == true)
|
if (random == true)
|
||||||
pq->set_flag(PQ_RANDOM);
|
pq->set_flag(Q_RANDOM);
|
||||||
get_callbacks()->on_pq_created(pq, playqueue_deck.size() - 1);
|
get_callbacks()->on_pq_created(pq, playqueue_deck.size() - 1);
|
||||||
return pq;
|
return pq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deck :: remove(unsigned int id)
|
void deck :: remove(unsigned int id)
|
||||||
{
|
{
|
||||||
std::list<Playqueue>::iterator it = playqueue_deck.begin();
|
std::list<Queue>::iterator it = playqueue_deck.begin();
|
||||||
for (unsigned int i = 0; i < id; i++)
|
for (unsigned int i = 0; i < id; i++)
|
||||||
it++;
|
it++;
|
||||||
get_callbacks()->on_pq_removed(&(*it));
|
get_callbacks()->on_pq_removed(&(*it));
|
||||||
|
@ -126,9 +126,9 @@ void deck :: remove(unsigned int id)
|
||||||
write();
|
write();
|
||||||
}
|
}
|
||||||
|
|
||||||
Playqueue *deck :: get(unsigned int id)
|
Queue *deck :: get(unsigned int id)
|
||||||
{
|
{
|
||||||
std::list<Playqueue>::iterator it = playqueue_deck.begin();
|
std::list<Queue>::iterator it = playqueue_deck.begin();
|
||||||
for (unsigned int i = 0; i < id; i++)
|
for (unsigned int i = 0; i < id; i++)
|
||||||
it++;
|
it++;
|
||||||
return &(*it);
|
return &(*it);
|
||||||
|
@ -141,8 +141,8 @@ unsigned int deck :: size()
|
||||||
|
|
||||||
void deck :: move(unsigned int old_pos, unsigned int new_pos)
|
void deck :: move(unsigned int old_pos, unsigned int new_pos)
|
||||||
{
|
{
|
||||||
std::list<Playqueue>::iterator it_old = playqueue_deck.begin();
|
std::list<Queue>::iterator it_old = playqueue_deck.begin();
|
||||||
std::list<Playqueue>::iterator it_new = playqueue_deck.begin();
|
std::list<Queue>::iterator it_new = playqueue_deck.begin();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < playqueue_deck.size(); i++) {
|
for (unsigned int i = 0; i < playqueue_deck.size(); i++) {
|
||||||
if (i < old_pos)
|
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);
|
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;
|
unsigned int old_pos = 0;
|
||||||
std::list<Playqueue>::iterator it_old = playqueue_deck.begin();
|
std::list<Queue>::iterator it_old = playqueue_deck.begin();
|
||||||
std::list<Playqueue>::iterator it_new = playqueue_deck.begin();
|
std::list<Queue>::iterator it_new = playqueue_deck.begin();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < playqueue_deck.size(); i++) {
|
for (unsigned int i = 0; i < playqueue_deck.size(); i++) {
|
||||||
if (&(*it_old) != pq) {
|
if (&(*it_old) != pq) {
|
||||||
|
@ -181,10 +181,10 @@ void deck :: move(Playqueue *pq, unsigned int new_pos)
|
||||||
unsigned int deck :: next()
|
unsigned int deck :: next()
|
||||||
{
|
{
|
||||||
unsigned int id = 0;
|
unsigned int id = 0;
|
||||||
std::list<Playqueue>::iterator it;
|
std::list<Queue>::iterator it;
|
||||||
|
|
||||||
for (it = playqueue_deck.begin(); it != playqueue_deck.end(); 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) {
|
if (it->size() == 0) {
|
||||||
playqueue_deck.erase(it);
|
playqueue_deck.erase(it);
|
||||||
get_callbacks()->on_pq_removed(&(*it));
|
get_callbacks()->on_pq_removed(&(*it));
|
||||||
|
@ -203,7 +203,7 @@ unsigned int deck :: next()
|
||||||
return library_playqueue.next();
|
return library_playqueue.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
Playqueue *deck :: get_library_pq()
|
Queue *deck :: get_library_pq()
|
||||||
{
|
{
|
||||||
return &library_playqueue;
|
return &library_playqueue;
|
||||||
}
|
}
|
||||||
|
@ -221,10 +221,10 @@ void deck :: reset()
|
||||||
void deck :: print_info()
|
void deck :: print_info()
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
std::list<Playqueue>::iterator it;
|
std::list<Queue>::iterator it;
|
||||||
|
|
||||||
for (it = playqueue_deck.begin(); it != playqueue_deck.end(); 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, it->size(), it->get_flags());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
static std::set<unsigned int> empty_set;
|
static std::set<unsigned int> empty_set;
|
||||||
static Index playlist_db("playlist.db", false);
|
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 std::string cur_pq;
|
||||||
|
|
||||||
static void import_ban_track(unsigned int track_id)
|
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_ARTIST);
|
||||||
playlist_pq.add_sort(SORT_YEAR);
|
playlist_pq.add_sort(SORT_YEAR);
|
||||||
playlist_pq.add_sort(SORT_TRACK);
|
playlist_pq.add_sort(SORT_TRACK);
|
||||||
playlist_pq.set_flag(PQ_REPEAT);
|
playlist_pq.set_flag(Q_REPEAT);
|
||||||
playlist_pq.set_flag(PQ_NEVER_SORT);
|
playlist_pq.set_flag(Q_NEVER_SORT);
|
||||||
|
|
||||||
get_callbacks()->on_library_import_ban = import_ban_track;
|
get_callbacks()->on_library_import_ban = import_ban_track;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ const std::set<unsigned int> &playlist :: get_tracks(const std::string &name)
|
||||||
throw -E_EXIST;
|
throw -E_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
Playqueue *playlist :: get_pq()
|
Queue *playlist :: get_pq()
|
||||||
{
|
{
|
||||||
return &playlist_pq;
|
return &playlist_pq;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
#include <callback.h>
|
#include <callback.h>
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
#include <playqueue.h>
|
#include <queue.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -13,28 +13,28 @@
|
||||||
#define O_HOURS (60 * O_MINUTES)
|
#define O_HOURS (60 * O_MINUTES)
|
||||||
#define O_DAYS (24 * O_HOURS)
|
#define O_DAYS (24 * O_HOURS)
|
||||||
|
|
||||||
Playqueue :: Playqueue()
|
Queue :: Queue()
|
||||||
: flags(0), cur(-1), length(0)
|
: flags(0), cur(-1), length(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Playqueue :: Playqueue(playqueue_flags f)
|
Queue :: Queue(queue_flags f)
|
||||||
: flags(f), cur(-1), length(0)
|
: flags(f), cur(-1), length(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Playqueue :: ~Playqueue()
|
Queue :: ~Queue()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playqueue :: write(File &f)
|
void Queue :: write(File &f)
|
||||||
{
|
{
|
||||||
f << flags << " " << tracks.size();
|
f << flags << " " << tracks.size();
|
||||||
for (unsigned int i = 0; i < tracks.size(); i++)
|
for (unsigned int i = 0; i < tracks.size(); i++)
|
||||||
f << " " << tracks[i];
|
f << " " << tracks[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playqueue :: read(File &f)
|
void Queue :: read(File &f)
|
||||||
{
|
{
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
f >> flags >> n;
|
f >> flags >> n;
|
||||||
|
@ -43,24 +43,24 @@ void Playqueue :: read(File &f)
|
||||||
f >> tracks[i];
|
f >> tracks[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playqueue :: set_flag(playqueue_flags f)
|
void Queue :: set_flag(queue_flags f)
|
||||||
{
|
{
|
||||||
flags |= f;
|
flags |= f;
|
||||||
get_callbacks()->on_queue_changed();
|
get_callbacks()->on_queue_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playqueue :: unset_flag(playqueue_flags f)
|
void Queue :: unset_flag(queue_flags f)
|
||||||
{
|
{
|
||||||
flags &= ~f;
|
flags &= ~f;
|
||||||
get_callbacks()->on_queue_changed();
|
get_callbacks()->on_queue_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int Playqueue :: get_flags()
|
const unsigned int Queue :: get_flags()
|
||||||
{
|
{
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Playqueue :: get_length()
|
unsigned int Queue :: get_length()
|
||||||
{
|
{
|
||||||
return 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;
|
std::stringstream ss;
|
||||||
unsigned int len = length;
|
unsigned int len = length;
|
||||||
|
@ -127,7 +127,7 @@ static bool track_less_than(Track *lhs, Track *rhs, std::list<sort_info> &order)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Playqueue :: find_sorted_id(Track *rhs)
|
unsigned int Queue :: find_sorted_id(Track *rhs)
|
||||||
{
|
{
|
||||||
Track *lhs;
|
Track *lhs;
|
||||||
unsigned int begin = 0, end = (tracks.size() - 1), mid;
|
unsigned int begin = 0, end = (tracks.size() - 1), mid;
|
||||||
|
@ -154,7 +154,7 @@ unsigned int Playqueue :: find_sorted_id(Track *rhs)
|
||||||
return begin;
|
return begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Playqueue :: add(unsigned int track_id)
|
unsigned int Queue :: add(unsigned int track_id)
|
||||||
{
|
{
|
||||||
unsigned int id = tracks.size();
|
unsigned int id = tracks.size();
|
||||||
Track *track = tagdb :: lookup(track_id);
|
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);
|
tracks.insert(tracks.begin() + id, track_id);
|
||||||
length += track->length;
|
length += track->length;
|
||||||
get_callbacks()->on_queue_track_add(this, id);
|
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();
|
get_callbacks()->on_queue_changed();
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Playqueue :: add_front(unsigned int track_id)
|
unsigned int Queue :: add_front(unsigned int track_id)
|
||||||
{
|
{
|
||||||
Track *track;
|
Track *track;
|
||||||
tracks.insert(tracks.begin(), track_id);
|
tracks.insert(tracks.begin(), track_id);
|
||||||
|
@ -178,12 +178,12 @@ unsigned int Playqueue :: add_front(unsigned int track_id)
|
||||||
track = tagdb :: lookup(track_id);
|
track = tagdb :: lookup(track_id);
|
||||||
length += track->length;
|
length += track->length;
|
||||||
get_callbacks()->on_queue_track_add(this, 0);
|
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();
|
get_callbacks()->on_queue_changed();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playqueue :: del(unsigned int plist_id)
|
void Queue :: del(unsigned int plist_id)
|
||||||
{
|
{
|
||||||
Track *track;
|
Track *track;
|
||||||
unsigned int track_id = tracks[plist_id];
|
unsigned int track_id = tracks[plist_id];
|
||||||
|
@ -192,11 +192,11 @@ void Playqueue :: del(unsigned int plist_id)
|
||||||
track = tagdb :: lookup(track_id);
|
track = tagdb :: lookup(track_id);
|
||||||
length -= track->length;
|
length -= track->length;
|
||||||
get_callbacks()->on_queue_track_del(this, plist_id);
|
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();
|
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;
|
unsigned int i = 0;
|
||||||
while (i < tracks.size()) {
|
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++) {
|
for (unsigned int i = 0; i < tracks.size(); i++) {
|
||||||
if (tracks[i] == track_id)
|
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();
|
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;
|
struct sort_info info;
|
||||||
std::list<sort_info>::iterator it;
|
std::list<sort_info>::iterator it;
|
||||||
|
@ -255,9 +255,9 @@ void Playqueue :: _add_sort(sort_t field, bool ascending)
|
||||||
sort_order.erase(sort_order.begin());
|
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;
|
return;
|
||||||
|
|
||||||
_add_sort(field, ascending);
|
_add_sort(field, ascending);
|
||||||
|
@ -268,31 +268,31 @@ void Playqueue :: add_sort(sort_t field, bool ascending)
|
||||||
get_callbacks()->on_queue_changed();
|
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;
|
return;
|
||||||
if (sort_order.front().field != field)
|
if (sort_order.front().field != field)
|
||||||
sort_order.clear();
|
sort_order.clear();
|
||||||
add_sort(field, ascending);
|
add_sort(field, ascending);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playqueue :: force_clear_sort()
|
void Queue :: force_clear_sort()
|
||||||
{
|
{
|
||||||
sort_order.clear();
|
sort_order.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<sort_info> &Playqueue :: get_sort_order()
|
std::list<sort_info> &Queue :: get_sort_order()
|
||||||
{
|
{
|
||||||
return sort_order;
|
return sort_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Playqueue :: operator[](unsigned int i)
|
unsigned int Queue :: operator[](unsigned int i)
|
||||||
{
|
{
|
||||||
return tracks[i];
|
return tracks[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Playqueue :: next()
|
unsigned int Queue :: next()
|
||||||
{
|
{
|
||||||
unsigned int res;
|
unsigned int res;
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ unsigned int Playqueue :: next()
|
||||||
throw -E_EXIST;
|
throw -E_EXIST;
|
||||||
else if (tracks.size() == 1)
|
else if (tracks.size() == 1)
|
||||||
cur = 0;
|
cur = 0;
|
||||||
else if (flags & PQ_RANDOM)
|
else if (flags & Q_RANDOM)
|
||||||
cur += rand() % (tracks.size() / 2) + 1;
|
cur += rand() % (tracks.size() / 2) + 1;
|
||||||
else
|
else
|
||||||
cur++;
|
cur++;
|
||||||
|
@ -309,29 +309,29 @@ unsigned int Playqueue :: next()
|
||||||
cur -= tracks.size();
|
cur -= tracks.size();
|
||||||
|
|
||||||
res = tracks[cur];
|
res = tracks[cur];
|
||||||
if (!(flags & PQ_REPEAT)) {
|
if (!(flags & Q_REPEAT)) {
|
||||||
del(cur);
|
del(cur);
|
||||||
cur--;
|
cur--;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playqueue :: set_cur(unsigned int c)
|
void Queue :: set_cur(unsigned int c)
|
||||||
{
|
{
|
||||||
cur = c;
|
cur = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Playqueue :: path_selected(unsigned int id)
|
void Queue :: path_selected(unsigned int id)
|
||||||
{
|
{
|
||||||
cur = id;
|
cur = id;
|
||||||
if (!(flags &PQ_REPEAT)) {
|
if (!(flags &Q_REPEAT)) {
|
||||||
del(cur);
|
del(cur);
|
||||||
cur--;
|
cur--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_TEST
|
#ifdef CONFIG_TEST
|
||||||
void Playqueue :: reset()
|
void Queue :: reset()
|
||||||
{
|
{
|
||||||
tracks.clear();
|
tracks.clear();
|
||||||
set_cur(0);
|
set_cur(0);
|
Loading…
Reference in New Issue
Block a user