2 /* $Id: treemodelsort.ccg,v 1.2 2003/11/04 18:11:36 murrayc Exp $ */
4 /* Copyright 1998-2002 The gtkmm Development Team
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <gtk/gtktreemodelsort.h>
24 typedef Gtk::TreeModel::Path Path; //So that the generated method implemenations can use this a return type.
29 TreeModel::iterator TreeModelSort::convert_child_iter_to_iter(const iterator& child_iter) const
31 TreeIter sorted_iter (const_cast<TreeModelSort*>(this));
33 gtk_tree_model_sort_convert_child_iter_to_iter(
34 const_cast<GtkTreeModelSort*>(gobj()), sorted_iter.gobj(),
35 const_cast<GtkTreeIter*>(child_iter.gobj()));
40 TreeModel::iterator TreeModelSort::convert_iter_to_child_iter(const iterator& sorted_iter) const
42 GtkTreeModel *const child_model = gtk_tree_model_sort_get_model(const_cast<GtkTreeModelSort*>(gobj()));
44 TreeIter child_iter (dynamic_cast<TreeModel*>(Glib::wrap_auto((GObject*) child_model, false)));
46 gtk_tree_model_sort_convert_iter_to_child_iter(
47 const_cast<GtkTreeModelSort*>(gobj()), child_iter.gobj(),
48 const_cast<GtkTreeIter*>(sorted_iter.gobj()));
53 void TreeModelSort::set_value_impl(const iterator& row, int column, const Glib::ValueBase& value)
55 // Avoid two extra ref/unref cycles -- we don't store the child
56 // model pointer anywhere, so it's OK to do this _internally_.
58 TreeModel *const child_model = dynamic_cast<TreeModel*>(
59 Glib::wrap_auto((GObject*) gtk_tree_model_sort_get_model(gobj()), false));
61 TreeIter child_iter (child_model);
63 gtk_tree_model_sort_convert_iter_to_child_iter(
64 gobj(), child_iter.gobj(), const_cast<GtkTreeIter*>(row.gobj()));
66 child_model->set_value_impl(child_iter, column, value);