1 /* $Id: treemodelsort.hg,v 1.5 2006/04/12 11:11:25 murrayc Exp $ */
3 /* Copyright(C) 1998-2002 The gtkmm Development Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or(at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 _PINCLUDE(glibmm/private/object_p.h)
23 #include <gtkmm/treeiter.h>
24 #include <gtkmm/treemodel.h>
25 #include <gtkmm/treesortable.h>
26 // We couldn't include it in treemodel.h, but doing it here makes it easier for people.
27 #include <gtkmm/treepath.h>
33 /** A wrapper which makes an underlying Gtk::TreeModel sortable.
35 * The TreeModelSort is a model which implements the TreeSortable interface.
36 * It does not hold any data itself, but rather is created with
37 * a child model and proxies its data. It has identical column types to
38 * this child model, and the changes in the child are propagated. The
39 * primary purpose of this model is to provide a way to sort a different
40 * model without modifying it. Note that the sort function used by
41 * TreeModelSort is not guaranteed to be stable.
43 * For instance, you might create two TreeView widgets each with a
44 * view of the same data. If the model is wrapped by a
45 * TreeModelSort then the two TreeViews can each sort their
46 * view of the data without affecting the other. By contrast, if we
47 * simply put the same model in each widget, then sorting the first would
52 class TreeModelSort : public Glib::Object, public TreeModel, public TreeSortable
54 _CLASS_GOBJECT(TreeModelSort, GtkTreeModelSort, GTK_TREE_MODEL_SORT, Glib::Object, GObject)
55 _IMPLEMENTS_INTERFACE(TreeModel)
56 _IMPLEMENTS_INTERFACE(TreeSortable)
59 _WRAP_CTOR(TreeModelSort(const Glib::RefPtr<TreeModel>& model), gtk_tree_model_sort_new_with_model)
62 _WRAP_CREATE(const Glib::RefPtr<TreeModel>& model)
64 _WRAP_METHOD(Glib::RefPtr<TreeModel> get_model(), gtk_tree_model_sort_get_model, refreturn)
65 _WRAP_METHOD(Glib::RefPtr<const TreeModel> get_model() const, gtk_tree_model_sort_get_model, refreturn, constversion)
67 _WRAP_METHOD(Path convert_child_path_to_path(const Path& child_path) const, gtk_tree_model_sort_convert_child_path_to_path)
69 /** Gets an iterator that points to the sorted row that corresponds to the child row pointed at by child_iter.
71 * @param child_iter A valid iterator pointing to a row on the child model.
72 * @result A valid iterator that points to the row in this sorted model.
74 iterator convert_child_iter_to_iter(const iterator& child_iter) const;
76 _WRAP_METHOD(Path convert_path_to_child_path(const Path& sorted_path) const, gtk_tree_model_sort_convert_path_to_child_path)
78 /** Gets an iterator that points to the child row that corresponds to the sorted row pointed at by sorted_iter.
80 * @param sorted_iter A valid iterator pointing to a row on the sorted model.
81 * @result A valid iterator that points to the row in the child model.
83 iterator convert_iter_to_child_iter(const iterator& sorted_iter) const;
85 _WRAP_METHOD(void reset_default_sort_func(), gtk_tree_model_sort_reset_default_sort_func)
86 _WRAP_METHOD(void clear_cache(), gtk_tree_model_sort_clear_cache)
88 _WRAP_METHOD(bool iter_is_valid(const iterator& iter) const, gtk_tree_model_sort_iter_is_valid)
91 virtual void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value);