/* Copyright (C) 1998-2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or(at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
#include
#include
// We couldn't include it in treemodel.h, but doing it here makes it easier for people.
#include
_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/object_p.h)
namespace Gtk
{
/**
* @ingroup TreeView
*
*/
class GTKMM_API TreeModelFilter :
public Glib::Object,
public TreeModel
{
_CLASS_GOBJECT(TreeModelFilter, GtkTreeModelFilter, GTK_TREE_MODEL_FILTER, Glib::Object, GObject, , , GTKMM_API)
_IMPLEMENTS_INTERFACE(TreeModel)
protected:
explicit TreeModelFilter(const Glib::RefPtr& child_model);
explicit TreeModelFilter(const Glib::RefPtr& child_model, const TreeModel::Path& virtual_root);
dnl // Don't _IGNORE(gtk_tree_model_filter_new). It's listed in gtk_methods.defs as
dnl // a method of GtkTreeModel. Ignoring it would make gmmproc think that this
dnl // file wraps GtkTreeModel, and it would list all GtkTreeModel methods as unwrapped.
public:
/** This creates a TreeModelFilter with @a child_model as the child model.
* You can use set_visible_func(), set_visible_column() and/or set_modify_func() to change the mapping of child
* model to parent model.
*/
_WRAP_CREATE(const Glib::RefPtr& child_model)
/** This creates a TreeModelFilter with @a child_model as the child model, and @a root as the virtual root.
* You can use set_visible_func(), set_visible_column() and/or set_modify_func() to change the mapping of child
* model to parent model.
*/
_WRAP_CREATE(const Glib::RefPtr& child_model, const TreeModel::Path& virtual_root)
/** For instance,
* bool on_visible(const TreeModel::const_iterator& iter);
* This should return true if the given row should be visible and false otherwise.
*/
typedef sigc::slot SlotVisible;
/** Sets the "visible" callback used when filtering the filter.
* The callback function should return true if the given row should be visible and false otherwise.
*
* @param slot A callback slot which determines whether the row should be visible.
*/
void set_visible_func(const SlotVisible& slot);
_IGNORE(gtk_tree_model_filter_set_visible_func)
//TODO: It would be nicer to use "const TreeModelColumnBase& column" instead of "int column",
//but how can we get the TreeModelColumnBase from the int in the SignalProxy?
//Maybe we could pass the ColumnsRecord to set_modify_func() and store it in the proxy? murrayc.
/** For instance,
* void on_modify(const Gtk::TreeModel::iterator& iter, Glib::ValueBase& value, int column);
*
* where iter is an iterator to a row in the child model,
* value is an output parameter in which you must store the value to be used in the parent model's row,
* column is the column in the parent row whose row value you must provide in the value output paramater.
*/
typedef sigc::slot SlotModify;
/** Specify columns that will be provided by this model, and a callback that will provide data for these
* columns based on data in the columns of the child model.
* The modify function will get called for each data access.
*
* @param columns Column types for this model (which will be exposed to the parent model/view).
* @param slot A callback which will be called for each data access.
*/
void set_modify_func(const TreeModelColumnRecord& columns, const SlotModify& slot);
_IGNORE(gtk_tree_model_filter_set_modify_func)
_WRAP_METHOD(void set_visible_column(const TreeModelColumnBase& column), gtk_tree_model_filter_set_visible_column)
_WRAP_METHOD(void set_visible_column(int column), gtk_tree_model_filter_set_visible_column)
_WRAP_METHOD(Glib::RefPtr get_model(), gtk_tree_model_filter_get_model, refreturn)
_WRAP_METHOD(Glib::RefPtr 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.
*
* @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;
_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.
*
* @param filter_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& 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)
_WRAP_METHOD(Path convert_path_to_child_path(const Path& filter_path) const, gtk_tree_model_filter_convert_path_to_child_path)
_WRAP_METHOD(void refilter(), gtk_tree_model_filter_refilter)
_WRAP_METHOD(void clear_cache(), gtk_tree_model_filter_clear_cache)
_WRAP_PROPERTY("child-model", Glib::RefPtr)
_WRAP_PROPERTY("virtual-root", TreeModel::Path)
protected:
void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value) override;
};
} // namespace Gtk