From 09af8d81d2e6e4c7b8d052ff1fe22231d79a6e3e Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 29 Jun 2014 10:47:59 -0400 Subject: [PATCH] model: Move the custom TreeModel from gui/ to lib/ Signed-off-by: Anna Schumaker --- include/gui/ocarina.h | 40 ----------------------------------- include/gui/tabs.h | 1 + include/lib/model.h | 47 ++++++++++++++++++++++++++++++++++++++++++ {gui => lib}/model.cpp | 2 +- 4 files changed, 49 insertions(+), 41 deletions(-) create mode 100644 include/lib/model.h rename {gui => lib}/model.cpp (99%) diff --git a/include/gui/ocarina.h b/include/gui/ocarina.h index 7ab11762..174926ca 100644 --- a/include/gui/ocarina.h +++ b/include/gui/ocarina.h @@ -4,7 +4,6 @@ #ifndef OCARINA_H #define OCARINA_H -#include #include @@ -16,45 +15,6 @@ void collection_mgr_init(); Gtk::Window *ocarina_init(int *, char ***); -/* model.cpp */ -class QueueModel : public Gtk::TreeModel, public Glib::Object { -private: - void increment_stamp(); - void get_value_uint(Track *, int, Glib::ValueBase &) const; - void get_value_str(Track *, int, Glib::ValueBase &) const; - 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; - 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; - bool iter_children_vfunc(const Gtk::TreeIter &, Gtk::TreeIter &) const; - bool iter_has_child_vfunc(const Gtk::TreeIter &) const; - int iter_n_children_vfunc(const Gtk::TreeIter &) const; - int iter_n_root_children_vfunc() const; - bool iter_nth_child_vfunc(const Gtk::TreeIter &, int, Gtk::TreeIter &) const; - bool iter_nth_root_child_vfunc(int, Gtk::TreeIter &) const; - bool iter_parent_vfunc(const Gtk::TreeIter &, Gtk::TreeIter &) const; - Gtk::TreeModel::Path get_path_vfunc(const 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); - void on_row_deleted(unsigned int); - void on_row_changed(unsigned int); - void on_path_selected(const Gtk::TreePath &); - unsigned int iter_to_id(const Gtk::TreeIter &); - unsigned int path_to_id(const Gtk::TreePath &); -}; - - /* gui.cpp */ void enable_idle(); void connect_button(const std::string &, void (*func)()); diff --git a/include/gui/tabs.h b/include/gui/tabs.h index 3230f2bc..dd8287ea 100644 --- a/include/gui/tabs.h +++ b/include/gui/tabs.h @@ -5,6 +5,7 @@ #define OCARINA_TABS_H #include +#include #include #include #include diff --git a/include/lib/model.h b/include/lib/model.h new file mode 100644 index 00000000..7c7c6c15 --- /dev/null +++ b/include/lib/model.h @@ -0,0 +1,47 @@ +/* + * Copyright 2014 (c) Anna Schumaker. + */ +#ifndef OCARINA_LIB_MODEL_H +#define OCARINA_LIB_MODEL_H + +#include +#include + +class QueueModel : public Gtk::TreeModel, public Glib::Object { +private: + void increment_stamp(); + void get_value_uint(Track *, int, Glib::ValueBase &) const; + void get_value_str(Track *, int, Glib::ValueBase &) const; + 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; + 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; + bool iter_children_vfunc(const Gtk::TreeIter &, Gtk::TreeIter &) const; + bool iter_has_child_vfunc(const Gtk::TreeIter &) const; + int iter_n_children_vfunc(const Gtk::TreeIter &) const; + int iter_n_root_children_vfunc() const; + bool iter_nth_child_vfunc(const Gtk::TreeIter &, int, Gtk::TreeIter &) const; + bool iter_nth_root_child_vfunc(int, Gtk::TreeIter &) const; + bool iter_parent_vfunc(const Gtk::TreeIter &, Gtk::TreeIter &) const; + Gtk::TreeModel::Path get_path_vfunc(const 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); + void on_row_deleted(unsigned int); + void on_row_changed(unsigned int); + void on_path_selected(const Gtk::TreePath &); + unsigned int iter_to_id(const Gtk::TreeIter &); + unsigned int path_to_id(const Gtk::TreePath &); +}; + +#endif /* OCARINA_LIB_MODEL_H */ diff --git a/gui/model.cpp b/lib/model.cpp similarity index 99% rename from gui/model.cpp rename to lib/model.cpp index c9cda64d..ea1fedb5 100644 --- a/gui/model.cpp +++ b/lib/model.cpp @@ -5,7 +5,7 @@ * https://git.gnome.org/browse/gtkmm-documentation/tree/examples/others/treemodelcustom */ #include -#include +#include #include #include