[gtkmm] Gtk::TreeModelFilter, TreeModelSort: More use of const_iterator
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gtk::TreeModelFilter, TreeModelSort: More use of const_iterator
- Date: Sun, 8 Jan 2017 14:53:06 +0000 (UTC)
commit 9df1c5f51633e6fb7305689b7e90f260e19656be
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Sun Jan 8 15:46:20 2017 +0100
Gtk::TreeModelFilter, TreeModelSort: More use of const_iterator
Make real const and non-const versions of convert_child_iter_to_iter()
and convert_iter_to_child_iter(). Use const_iterator in the const versions.
Bug #134520
In the previous commit message, "You can use select(*iter)" should be
"You can use select(row.get_iter())".
gtk/src/treemodelfilter.ccg | 32 +++++++++++++++++++++++++++-----
gtk/src/treemodelfilter.hg | 26 ++++++++++++++++++++------
gtk/src/treemodelsort.ccg | 32 +++++++++++++++++++++++++++-----
gtk/src/treemodelsort.hg | 18 ++++++++++++++++--
4 files changed, 90 insertions(+), 18 deletions(-)
---
diff --git a/gtk/src/treemodelfilter.ccg b/gtk/src/treemodelfilter.ccg
index 3c7a073..e83f1c2 100644
--- a/gtk/src/treemodelfilter.ccg
+++ b/gtk/src/treemodelfilter.ccg
@@ -73,7 +73,7 @@ static void SignalProxy_Modify_gtk_callback_destroy(void* data)
}
-typedef Gtk::TreeModel::Path Path; //So that the generated method implemenations can use this a return type.
+using Path = Gtk::TreeModel::Path; //So that the generated method implementations can use this as a return
type.
namespace Gtk
{
@@ -103,9 +103,19 @@ void TreeModelFilter::set_visible_func(const SlotVisible& slot)
}
-TreeModel::iterator TreeModelFilter::convert_child_iter_to_iter(const iterator& child_iter) const
+TreeModel::iterator TreeModelFilter::convert_child_iter_to_iter(const iterator& child_iter)
{
- iterator filter_iter(const_cast<TreeModelFilter*>(this));
+ iterator filter_iter(this);
+
+ gtk_tree_model_filter_convert_child_iter_to_iter(gobj(), filter_iter.gobj(),
+ const_cast<GtkTreeIter*>(child_iter.gobj()));
+
+ return filter_iter;
+}
+
+TreeModel::const_iterator TreeModelFilter::convert_child_iter_to_iter(const const_iterator& child_iter) const
+{
+ const_iterator filter_iter(const_cast<TreeModelFilter*>(this));
gtk_tree_model_filter_convert_child_iter_to_iter(
const_cast<GtkTreeModelFilter*>(gobj()), filter_iter.gobj(),
@@ -114,12 +124,24 @@ TreeModel::iterator TreeModelFilter::convert_child_iter_to_iter(const iterator&
return filter_iter;
}
-TreeModel::iterator TreeModelFilter::convert_iter_to_child_iter(const iterator& filter_iter) const
+TreeModel::iterator TreeModelFilter::convert_iter_to_child_iter(const iterator& filter_iter)
{
- const auto child_model = gtk_tree_model_filter_get_model(const_cast<GtkTreeModelFilter*>(gobj()));
+ const auto child_model = gtk_tree_model_filter_get_model(gobj());
iterator child_iter(dynamic_cast<TreeModel*>(Glib::wrap_auto((GObject*)child_model, false)));
+ gtk_tree_model_filter_convert_iter_to_child_iter(gobj(), child_iter.gobj(),
+ const_cast<GtkTreeIter*>(filter_iter.gobj()));
+
+ return child_iter;
+}
+
+TreeModel::const_iterator TreeModelFilter::convert_iter_to_child_iter(const const_iterator& filter_iter)
const
+{
+ const auto child_model = gtk_tree_model_filter_get_model(const_cast<GtkTreeModelFilter*>(gobj()));
+
+ const_iterator child_iter(dynamic_cast<TreeModel*>(Glib::wrap_auto((GObject*)child_model, false)));
+
gtk_tree_model_filter_convert_iter_to_child_iter(
const_cast<GtkTreeModelFilter*>(gobj()), child_iter.gobj(),
const_cast<GtkTreeIter*>(filter_iter.gobj()));
diff --git a/gtk/src/treemodelfilter.hg b/gtk/src/treemodelfilter.hg
index 6757b55..f523452 100644
--- a/gtk/src/treemodelfilter.hg
+++ b/gtk/src/treemodelfilter.hg
@@ -103,20 +103,34 @@ public:
_WRAP_METHOD(Glib::RefPtr<TreeModel> get_model(), gtk_tree_model_filter_get_model, refreturn)
_WRAP_METHOD(Glib::RefPtr<const TreeModel> get_model() const, gtk_tree_model_filter_get_model, refreturn,
constversion)
- /** Gets an iterator that points to the sorted row that corresponds to the child row pointed at by
child_iter.
+ /** Gets an iterator that points to the filtered row that corresponds to the child row pointed at by
child_iter.
*
* @param child_iter A valid iterator pointing to a row on the child model.
- * @result A valid iterator that points to the row in this sorted model.
+ * @result A valid iterator that points to the row in this filtered model.
*/
- iterator convert_child_iter_to_iter(const iterator& child_iter) const;
+ iterator convert_child_iter_to_iter(const iterator& child_iter);
+
+ /** Gets an iterator that points to the filtered row that corresponds to the child row pointed at by
child_iter.
+ *
+ * @param child_iter A valid iterator pointing to a row on the child model.
+ * @result A valid iterator that points to the row in this filtered model.
+ */
+ const_iterator convert_child_iter_to_iter(const const_iterator& child_iter) const;
_IGNORE(gtk_tree_model_filter_convert_child_iter_to_iter)
- /** Gets an iterator that points to the child row that corresponds to the sorted row pointed at by
sorted_iter.
+ /** Gets an iterator that points to the child row that corresponds to the filtered row pointed at by
sorted_iter.
+ *
+ * @param filter_iter A valid iterator pointing to a row on the filtered model.
+ * @result A valid iterator that points to the row in the child model.
+ */
+ iterator convert_iter_to_child_iter(const iterator& filter_iter);
+
+ /** Gets an iterator that points to the child row that corresponds to the filtered row pointed at by
sorted_iter.
*
- * @param filter_iter A valid iterator pointing to a row on the sorted model.
+ * @param filter_iter A valid iterator pointing to a row on the filtered model.
* @result A valid iterator that points to the row in the child model.
*/
- iterator convert_iter_to_child_iter(const iterator& filter_iter) const;
+ const_iterator convert_iter_to_child_iter(const const_iterator& filter_iter) const;
_IGNORE(gtk_tree_model_filter_convert_iter_to_child_iter)
_WRAP_METHOD(Path convert_child_path_to_path(const Path& child_path) const,
gtk_tree_model_filter_convert_child_path_to_path)
diff --git a/gtk/src/treemodelsort.ccg b/gtk/src/treemodelsort.ccg
index e892c7c..4e77d83 100644
--- a/gtk/src/treemodelsort.ccg
+++ b/gtk/src/treemodelsort.ccg
@@ -18,14 +18,24 @@
#include <gtk/gtk.h>
-typedef Gtk::TreeModel::Path Path; //So that the generated method implemenations can use this a return type.
+using Path = Gtk::TreeModel::Path; //So that the generated method implementations can use this as a return
type.
namespace Gtk
{
-TreeModel::iterator TreeModelSort::convert_child_iter_to_iter(const iterator& child_iter) const
+TreeModel::iterator TreeModelSort::convert_child_iter_to_iter(const iterator& child_iter)
{
- iterator sorted_iter(const_cast<TreeModelSort*>(this));
+ iterator sorted_iter(this);
+
+ gtk_tree_model_sort_convert_child_iter_to_iter(gobj(), sorted_iter.gobj(),
+ const_cast<GtkTreeIter*>(child_iter.gobj()));
+
+ return sorted_iter;
+}
+
+TreeModel::const_iterator TreeModelSort::convert_child_iter_to_iter(const const_iterator& child_iter) const
+{
+ const_iterator sorted_iter(const_cast<TreeModelSort*>(this));
gtk_tree_model_sort_convert_child_iter_to_iter(
const_cast<GtkTreeModelSort*>(gobj()), sorted_iter.gobj(),
@@ -34,12 +44,24 @@ TreeModel::iterator TreeModelSort::convert_child_iter_to_iter(const iterator& ch
return sorted_iter;
}
-TreeModel::iterator TreeModelSort::convert_iter_to_child_iter(const iterator& sorted_iter) const
+TreeModel::iterator TreeModelSort::convert_iter_to_child_iter(const iterator& sorted_iter)
{
- const auto child_model = gtk_tree_model_sort_get_model(const_cast<GtkTreeModelSort*>(gobj()));
+ const auto child_model = gtk_tree_model_sort_get_model(gobj());
iterator child_iter(dynamic_cast<TreeModel*>(Glib::wrap_auto((GObject*) child_model, false)));
+ gtk_tree_model_sort_convert_iter_to_child_iter(gobj(), child_iter.gobj(),
+ const_cast<GtkTreeIter*>(sorted_iter.gobj()));
+
+ return child_iter;
+}
+
+TreeModel::const_iterator TreeModelSort::convert_iter_to_child_iter(const const_iterator& sorted_iter) const
+{
+ const auto child_model = gtk_tree_model_sort_get_model(const_cast<GtkTreeModelSort*>(gobj()));
+
+ const_iterator child_iter(dynamic_cast<TreeModel*>(Glib::wrap_auto((GObject*) child_model, false)));
+
gtk_tree_model_sort_convert_iter_to_child_iter(
const_cast<GtkTreeModelSort*>(gobj()), child_iter.gobj(),
const_cast<GtkTreeIter*>(sorted_iter.gobj()));
diff --git a/gtk/src/treemodelsort.hg b/gtk/src/treemodelsort.hg
index 87042d5..5ec12e8 100644
--- a/gtk/src/treemodelsort.hg
+++ b/gtk/src/treemodelsort.hg
@@ -70,7 +70,14 @@ public:
* @param child_iter A valid iterator pointing to a row on the child model.
* @result A valid iterator that points to the row in this sorted model.
*/
- iterator convert_child_iter_to_iter(const iterator& child_iter) const;
+ iterator convert_child_iter_to_iter(const iterator& child_iter);
+
+ /** Gets an iterator that points to the sorted row that corresponds to the child row pointed at by
child_iter.
+ *
+ * @param child_iter A valid iterator pointing to a row on the child model.
+ * @result A valid iterator that points to the row in this sorted model.
+ */
+ const_iterator convert_child_iter_to_iter(const const_iterator& child_iter) const;
_IGNORE(gtk_tree_model_sort_convert_child_iter_to_iter)
_WRAP_METHOD(Path convert_path_to_child_path(const Path& sorted_path) const,
gtk_tree_model_sort_convert_path_to_child_path)
@@ -80,7 +87,14 @@ public:
* @param sorted_iter A valid iterator pointing to a row on the sorted model.
* @result A valid iterator that points to the row in the child model.
*/
- iterator convert_iter_to_child_iter(const iterator& sorted_iter) const;
+ iterator convert_iter_to_child_iter(const iterator& sorted_iter);
+
+ /** Gets an iterator that points to the child row that corresponds to the sorted row pointed at by
sorted_iter.
+ *
+ * @param sorted_iter A valid iterator pointing to a row on the sorted model.
+ * @result A valid iterator that points to the row in the child model.
+ */
+ const_iterator convert_iter_to_child_iter(const const_iterator& sorted_iter) const;
_IGNORE(gtk_tree_model_sort_convert_iter_to_child_iter)
_WRAP_METHOD(void reset_default_sort_func(), gtk_tree_model_sort_reset_default_sort_func)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]