Debian Codegraph @

gtk/src/treemodelsort.hg

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 _DEFS(gtkmm,gtk)
18 _PINCLUDE(glibmm/private/object_p.h)
19
20 #include <gtkmm/treeiter.h>
21 #include <gtkmm/treemodel.h>
22 #include <gtkmm/treesortable.h>
23 // We couldn't include it in treemodel.h, but doing it here makes it easier for people.
24 #include <gtkmm/treepath.h>
25
26
27 namespace Gtk
28 {
29
30 /** A wrapper which makes an underlying Gtk::TreeModel sortable.
31 *
32 * The TreeModelSort is a model which implements the TreeSortable interface.
33 * It does not hold any data itself, but rather is created with
34 * a child model and proxies its data. It has identical column types to
35 * this child model, and the changes in the child are propagated. The
36 * primary purpose of this model is to provide a way to sort a different
37 * model without modifying it. Note that the sort function used by
38 * TreeModelSort is not guaranteed to be stable.
39 *
40 * For instance, you might create two TreeView widgets each with a
41 * view of the same data. If the model is wrapped by a
42 * TreeModelSort then the two TreeViews can each sort their
43 * view of the data without affecting the other. By contrast, if we
44 * simply put the same model in each widget, then sorting the first would
45 * sort the second.
46 *
47 * @ingroup TreeView
48 */
49 class GTKMM_API TreeModelSort : public Glib::Object, public TreeModel, public TreeSortable
50 {
51 _CLASS_GOBJECT(TreeModelSort, GtkTreeModelSort, GTK_TREE_MODEL_SORT, Glib::Object, GObject, , , GTKMM_API)
52 _IMPLEMENTS_INTERFACE(TreeModel)
53 _IMPLEMENTS_INTERFACE(TreeSortable)
54
55 protected:
56 _WRAP_CTOR(TreeModelSort(const Glib::RefPtr<TreeModel>& model), gtk_tree_model_sort_new_with_model)
57
58 public:
59 _WRAP_CREATE(const Glib::RefPtr<TreeModel>& model)
60
61 _WRAP_METHOD(Glib::RefPtr<TreeModel> get_model(), gtk_tree_model_sort_get_model, refreturn)
62 _WRAP_METHOD(Glib::RefPtr<const TreeModel> get_model() const, gtk_tree_model_sort_get_model, refreturn, constversion)
63
64 _WRAP_METHOD(Path convert_child_path_to_path(const Path& child_path) const, gtk_tree_model_sort_convert_child_path_to_path)
65
66 /** Gets an iterator that points to the sorted row that corresponds to the child row pointed at by child_iter.
67 *
68 * @param child_iter A valid iterator pointing to a row on the child model.
69 * @result A valid iterator that points to the row in this sorted model.
70 */
71 iterator convert_child_iter_to_iter(const iterator& child_iter) const;
72 _IGNORE(gtk_tree_model_sort_convert_child_iter_to_iter)
73
74 _WRAP_METHOD(Path convert_path_to_child_path(const Path& sorted_path) const, gtk_tree_model_sort_convert_path_to_child_path)
75
76 /** Gets an iterator that points to the child row that corresponds to the sorted row pointed at by sorted_iter.
77 *
78 * @param sorted_iter A valid iterator pointing to a row on the sorted model.
79 * @result A valid iterator that points to the row in the child model.
80 */
81 iterator convert_iter_to_child_iter(const iterator& sorted_iter) const;
82 _IGNORE(gtk_tree_model_sort_convert_iter_to_child_iter)
83
84 _WRAP_METHOD(void reset_default_sort_func(), gtk_tree_model_sort_reset_default_sort_func)
85 _WRAP_METHOD(void clear_cache(), gtk_tree_model_sort_clear_cache)
86
87 _WRAP_METHOD(bool iter_is_valid(const iterator& iter) const, gtk_tree_model_sort_iter_is_valid)
88
89 _WRAP_PROPERTY("model", Glib::RefPtr<TreeModel>)
90
91 protected:
92 void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value) override;
93 };
94
95 } // namespace Gtk