lib: Make QueueModel variables private

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-01-13 20:33:52 -05:00
parent 4078f9a893
commit 9d84fdb8b7
2 changed files with 19 additions and 24 deletions

View File

@ -9,24 +9,25 @@
class QueueModel : public Gtk::TreeModel, public Glib::Object { class QueueModel : public Gtk::TreeModel, public Glib::Object {
private: private:
int _stamp;
Queue *_queue;
void increment_stamp(); void increment_stamp();
bool check_iter_validity(const Gtk::TreeIter &) const; bool check_iter_validity(const Gtk::TreeIter &) const;
protected: protected:
/* Inherited from Gtk::TreeModel */ /* Inherited from Gtk::TreeModel */
Gtk::TreeModelFlags get_flags_vfunc() const; Gtk::TreeModelFlags get_flags_vfunc() const;
int get_n_columns_vfunc() const; int get_n_columns_vfunc() const;
GType get_column_type_vfunc(int) const; GType get_column_type_vfunc(int) const;
void get_value_vfunc(const Gtk::TreeIter &, int, Glib::ValueBase &) const; void get_value_vfunc(const Gtk::TreeIter &, int, Glib::ValueBase &) const;
bool iter_next_vfunc(const Gtk::TreeIter &, Gtk::TreeIter &) const; bool iter_next_vfunc(const Gtk::TreeIter &, Gtk::TreeIter &) const;
int iter_n_root_children_vfunc() const; int iter_n_root_children_vfunc() const;
bool iter_nth_root_child_vfunc(int, Gtk::TreeIter &) const; bool iter_nth_root_child_vfunc(int, Gtk::TreeIter &) const;
Gtk::TreeModel::Path get_path_vfunc(const Gtk::TreeIter &) const; Gtk::TreeModel::Path get_path_vfunc(const Gtk::TreeIter &) const;
bool get_iter_vfunc(const Gtk::TreePath &, Gtk::TreeIter &) const; bool get_iter_vfunc(const Gtk::TreePath &, Gtk::TreeIter &) const;
public: public:
int stamp;
Queue *queue;
QueueModel(Queue *); QueueModel(Queue *);
void on_row_inserted(unsigned int); void on_row_inserted(unsigned int);

View File

@ -11,19 +11,19 @@
QueueModel::QueueModel(Queue *q) QueueModel::QueueModel(Queue *q)
: Glib::ObjectBase( typeid(QueueModel) ), : Glib::ObjectBase( typeid(QueueModel) ),
Glib::Object(), stamp(1), queue(q) Glib::Object(), _stamp(1), _queue(q)
{ {
} }
void QueueModel::increment_stamp() void QueueModel::increment_stamp()
{ {
if (++stamp == 0) if (++_stamp == 0)
++stamp; ++_stamp;
} }
bool QueueModel::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();
} }
void QueueModel::on_row_inserted(unsigned int row) void QueueModel::on_row_inserted(unsigned int row)
@ -47,7 +47,7 @@ void QueueModel::on_row_changed(unsigned int row)
void QueueModel::on_path_selected(const Gtk::TreePath &path) void QueueModel::on_path_selected(const Gtk::TreePath &path)
{ {
audio :: load_track(tags :: get_track(path_to_id(path))); audio :: load_track(tags :: get_track(path_to_id(path)));
queue->track_selected(path[0]); _queue->track_selected(path[0]);
audio :: play(); audio :: play();
} }
@ -58,17 +58,11 @@ unsigned int QueueModel :: iter_to_id(const Gtk::TreeIter &iter) const
unsigned int QueueModel::path_to_id(const Gtk::TreePath &path) const unsigned int QueueModel::path_to_id(const Gtk::TreePath &path) const
{ {
return queue->operator[](path[0])->index(); return _queue->operator[](path[0])->index();
} }
/*
*
* Function overrides begin here
*
*/
Gtk::TreeModelFlags QueueModel::get_flags_vfunc() const Gtk::TreeModelFlags QueueModel::get_flags_vfunc() const
{ {
return Gtk::TREE_MODEL_LIST_ONLY; return Gtk::TREE_MODEL_LIST_ONLY;
@ -106,7 +100,7 @@ void QueueModel::get_value_vfunc(const Gtk::TreeIter &iter, int column,
column > get_n_columns_vfunc()) column > get_n_columns_vfunc())
return; return;
track = queue->operator[](iter_to_id(iter)); track = _queue->operator[](iter_to_id(iter));
switch (column) { switch (column) {
case 0: case 0:
@ -143,16 +137,16 @@ bool QueueModel::iter_next_vfunc(const Gtk::TreeIter &iter,
int QueueModel::iter_n_root_children_vfunc() const int QueueModel::iter_n_root_children_vfunc() const
{ {
return queue->size(); return _queue->size();
} }
bool QueueModel::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())
return false; return false;
iter.set_stamp(stamp); iter.set_stamp(_stamp);
iter.gobj()->user_data = GUINT_TO_POINTER(n); iter.gobj()->user_data = GUINT_TO_POINTER(n);
return true; return true;
} }