Debian Codegraph @

gtk/src/treemodelsort.ccg

raw
1 /* Copyright (C) 1998-2002 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <gtk/gtk.h>
18
19 typedef Gtk::TreeModel::Path Path; //So that the generated method implemenations can use this a return type.
20
21 namespace Gtk
22 {
23
24 TreeModel::iterator TreeModelSort::convert_child_iter_to_iter(const iterator& child_iter) const
25 {
26 TreeIter sorted_iter (const_cast<TreeModelSort*>(this));
27
28 gtk_tree_model_sort_convert_child_iter_to_iter(
29 const_cast<GtkTreeModelSort*>(gobj()), sorted_iter.gobj(),
30 const_cast<GtkTreeIter*>(child_iter.gobj()));
31
32 return sorted_iter;
33 }
34
35 TreeModel::iterator TreeModelSort::convert_iter_to_child_iter(const iterator& sorted_iter) const
36 {
37 const auto child_model = gtk_tree_model_sort_get_model(const_cast<GtkTreeModelSort*>(gobj()));
38
39 TreeIter child_iter (dynamic_cast<TreeModel*>(Glib::wrap_auto((GObject*) child_model, false)));
40
41 gtk_tree_model_sort_convert_iter_to_child_iter(
42 const_cast<GtkTreeModelSort*>(gobj()), child_iter.gobj(),
43 const_cast<GtkTreeIter*>(sorted_iter.gobj()));
44
45 return child_iter;
46 }
47
48 void TreeModelSort::set_value_impl(const iterator& row, int column, const Glib::ValueBase& value)
49 {
50 // Avoid two extra ref/unref cycles -- we don't store the child
51 // model pointer anywhere, so it's OK to do this _internally_.
52
53 const auto child_model = dynamic_cast<TreeModel*>(
54 Glib::wrap_auto((GObject*) gtk_tree_model_sort_get_model(gobj()), false));
55
56 TreeIter child_iter (child_model);
57
58 gtk_tree_model_sort_convert_iter_to_child_iter(
59 gobj(), child_iter.gobj(), const_cast<GtkTreeIter*>(row.gobj()));
60
61 child_model->set_value_impl(child_iter, column, value);
62 }
63
64 } // namespace Gtk