[gtkmm-documentation] exampletreemodel: Adapt to changed TreeModel API.



commit 02ddad297d35643aafd7723d2c3bdcfec40051ce
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 17 16:19:05 2017 +0100

    exampletreemodel: Adapt to changed TreeModel API.
    
    Using a const_iterator.

 .../others/treemodelcustom/exampletreemodel.cc     |   16 ++++++++--------
 examples/others/treemodelcustom/exampletreemodel.h |   12 ++++++------
 2 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/examples/others/treemodelcustom/exampletreemodel.cc 
b/examples/others/treemodelcustom/exampletreemodel.cc
index 6ab9273..7f6d1be 100644
--- a/examples/others/treemodelcustom/exampletreemodel.cc
+++ b/examples/others/treemodelcustom/exampletreemodel.cc
@@ -110,7 +110,7 @@ GType ExampleTreeModel::get_column_type_vfunc(int index) const
     return 0;
 }
 
-void ExampleTreeModel::get_value_vfunc(const TreeModel::iterator& iter, int column, Glib::ValueBase& value) 
const
+void ExampleTreeModel::get_value_vfunc(const TreeModel::const_iterator& iter, int column, Glib::ValueBase& 
value) const
 {
   if(check_treeiter_validity(iter))
   {
@@ -124,10 +124,10 @@ void ExampleTreeModel::get_value_vfunc(const TreeModel::iterator& iter, int colu
       //Glib::Value< Glib::ustring > value_specific;
       //value_specific.init( Glib::Value< Glib::ustring >::value_type() ); //TODO: Is there any way to avoid 
this step?
 
-      typeListOfRows::const_iterator dataRowIter = get_data_row_iter_from_tree_row_iter(iter);
+      auto dataRowIter = get_data_row_iter_from_tree_row_iter(iter);
       if(dataRowIter != m_rows.end())
       {
-        const typeRow& dataRow = *dataRowIter;
+        const auto& dataRow = *dataRowIter;
 
         Glib::ustring result = dataRow[column];
 
@@ -175,12 +175,12 @@ bool ExampleTreeModel::iter_children_vfunc(const iterator& parent, iterator& ite
   return iter_nth_child_vfunc(parent, 0, iter);
 }
 
-bool ExampleTreeModel::iter_has_child_vfunc(const iterator& iter) const
+bool ExampleTreeModel::iter_has_child_vfunc(const const_iterator& iter) const
 {
   return (iter_n_children_vfunc(iter) > 0);
 }
 
-int ExampleTreeModel::iter_n_children_vfunc(const iterator& iter) const
+int ExampleTreeModel::iter_n_children_vfunc(const const_iterator& iter) const
 {
   if(!check_treeiter_validity(iter))
     return 0;
@@ -242,7 +242,7 @@ bool ExampleTreeModel::iter_parent_vfunc(const iterator& child, iterator& iter)
   return false; //There are no children, so no parents.
 }
 
-Gtk::TreeModel::Path ExampleTreeModel::get_path_vfunc(const iterator& /* iter */) const
+Gtk::TreeModel::Path ExampleTreeModel::get_path_vfunc(const const_iterator& /* iter */) const
 {
    //TODO:
    return Path();
@@ -303,7 +303,7 @@ ExampleTreeModel::typeListOfRows::iterator ExampleTreeModel::get_data_row_iter_f
     return m_rows.begin() + row_index; //TODO: Performance.
 }
 
-ExampleTreeModel::typeListOfRows::const_iterator 
ExampleTreeModel::get_data_row_iter_from_tree_row_iter(const iterator& iter) const
+ExampleTreeModel::typeListOfRows::const_iterator 
ExampleTreeModel::get_data_row_iter_from_tree_row_iter(const const_iterator& iter) const
 {
   //Don't call this on an invalid iter.
   const auto pItem = (const GlueItem*)iter.gobj()->user_data;
@@ -315,7 +315,7 @@ ExampleTreeModel::typeListOfRows::const_iterator ExampleTreeModel::get_data_row_
     return m_rows.begin() + row_index; //TODO: Performance.
 }
 
-bool ExampleTreeModel::check_treeiter_validity(const iterator& iter) const
+bool ExampleTreeModel::check_treeiter_validity(const const_iterator& iter) const
 {
   // Anything that modifies the model's structure should change the model's stamp,
   // so that old iters are ignored.
diff --git a/examples/others/treemodelcustom/exampletreemodel.h 
b/examples/others/treemodelcustom/exampletreemodel.h
index 92c43c5..46f3bc3 100644
--- a/examples/others/treemodelcustom/exampletreemodel.h
+++ b/examples/others/treemodelcustom/exampletreemodel.h
@@ -41,19 +41,19 @@ protected:
    Gtk::TreeModelFlags get_flags_vfunc() const override;
    int get_n_columns_vfunc() const override;
    GType get_column_type_vfunc(int index) const override;
-   void get_value_vfunc(const TreeModel::iterator& iter, int column, Glib::ValueBase& value) const override;
+   void get_value_vfunc(const TreeModel::const_iterator& iter, int column, Glib::ValueBase& value) const 
override;
 
    bool iter_next_vfunc(const iterator& iter, iterator& iter_next) const override;
 
    //TODO: Make sure that we make all of these const when we have made them all const in the TreeModel:
    bool iter_children_vfunc(const iterator& parent, iterator& iter) const override;
-   bool iter_has_child_vfunc(const iterator& iter) const override;
-   int iter_n_children_vfunc(const iterator& iter) const override;
+   bool iter_has_child_vfunc(const const_iterator& iter) const override;
+   int iter_n_children_vfunc(const const_iterator& iter) const override;
    int iter_n_root_children_vfunc() const override;
    bool iter_nth_child_vfunc(const iterator& parent, int n, iterator& iter) const override;
    bool iter_nth_root_child_vfunc(int n, iterator& iter) const override;
    bool iter_parent_vfunc(const iterator& child, iterator& iter) const override;
-   Path get_path_vfunc(const iterator& iter) const override;
+   Path get_path_vfunc(const const_iterator& iter) const override;
    bool get_iter_vfunc(const Path& path, iterator& iter) const override;
 
 private:
@@ -94,8 +94,8 @@ private:
    };
 
    typeListOfRows::iterator get_data_row_iter_from_tree_row_iter(const iterator& iter);
-   typeListOfRows::const_iterator get_data_row_iter_from_tree_row_iter(const iterator& iter) const;
-   bool check_treeiter_validity(const iterator& iter) const;
+   typeListOfRows::const_iterator get_data_row_iter_from_tree_row_iter(const const_iterator& iter) const;
+   bool check_treeiter_validity(const const_iterator& iter) const;
    void remember_glue_item(GlueItem* item) const;
 
    //The data:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]