From 9d84fdb8b7e6b0a222ea9d8e609436c15a59f85f Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 13 Jan 2015 20:33:52 -0500 Subject: [PATCH] lib: Make QueueModel variables private Signed-off-by: Anna Schumaker --- include/lib/model.h | 17 +++++++++-------- lib/model.cpp | 26 ++++++++++---------------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/include/lib/model.h b/include/lib/model.h index 3a2a3c03..fbd243ed 100644 --- a/include/lib/model.h +++ b/include/lib/model.h @@ -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); diff --git a/lib/model.cpp b/lib/model.cpp index cd4abeae..2379be39 100644 --- a/lib/model.cpp +++ b/lib/model.cpp @@ -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; }