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 {
private:
int _stamp;
Queue *_queue;
void increment_stamp();
bool check_iter_validity(const Gtk::TreeIter &) const;
protected:
/* Inherited from Gtk::TreeModel */
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;
void get_value_vfunc(const Gtk::TreeIter &, int, Glib::ValueBase &) const;
bool iter_next_vfunc(const Gtk::TreeIter &, Gtk::TreeIter &) const;
int iter_n_root_children_vfunc() const;
bool iter_nth_root_child_vfunc(int, Gtk::TreeIter &) const;
void get_value_vfunc(const Gtk::TreeIter &, int, Glib::ValueBase &) const;
bool iter_next_vfunc(const Gtk::TreeIter &, Gtk::TreeIter &) const;
int iter_n_root_children_vfunc() const;
bool iter_nth_root_child_vfunc(int, 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:
int stamp;
Queue *queue;
QueueModel(Queue *);
void on_row_inserted(unsigned int);

View File

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