Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gtk::TreeModelFilter Class Reference

A GtkTreeModelFilter C++ wrapper class. More...

`#include <xfc/gtk/treemodelfilter.hh>`

Inheritance diagram for Xfc::Gtk::TreeModelFilter:

List of all members.

## Public Types

- typedef sigc::slot< bool,
  const TreeModel &, const
  TreeIter & > VisibleSlot
    Signature of the callback slot which decides whether the row indicated by TreeIter is visible.
- typedef sigc::slot< void,
  const TreeModel &, const
  TreeIter &, G::Value &, int > ModifySlot
    Signature of the callback slot which calculates display values from raw values in the model.

## Public Member Functions

Constructors

- TreeModelFilter (TreeModel &child_model, const TreePath *root=0)
    Constructs a new TreeModelFilter, with child_model as the child_model and root as the virtual root.
- virtual ~TreeModelFilter ()
    Destructor.

Accessors

- GtkTreeModelFilter * gtk_tree_model_filter () const
    Get a pointer to the GtkTreeModelFilter structure.
- operator GtkTreeModelFilter * () const
    Conversion operator; safely converts a TreeModelFilter to a GtkTreeModelFilter pointer.
- TreeModel * get_model () const
    Gets a pointer to the child model of the filter.

Methods

- void set_visible_func (const VisibleSlot &slot)
    Sets the visible function used when filtering the filter to be slot.
- void set_modify_func (int n_columns, const GType types[], const ModifySlot &slot)
    With the n_columns and types parameters, you give an array of column types for this model (which will be exposed to the parent model/view).
- void set_visible_column (int column)
    Sets column of the filter's child model to be the column where the filter should look for visibility information.
- TreeIter convert_child_iter_to_iter (const TreeIter &child_iter)
    Returns a TreeIter that points to the row in the TreeModelFilter that corresponds to the row pointed at by child_iter.
- TreeIter convert_iter_to_child_iter (const TreeIter &filter_iter)
    Returns a TreeIter that points to the row on the child model that corresponds to the row pointed to by filter_iter.
- Pointer< TreePath > convert_child_path_to_path (const TreePath &child_path)
    Converts child_path to a path relative to the TreeModelFilter.
- Pointer< TreePath > convert_path_to_child_path (const TreePath &filter_path)
    Converts filter_path to a path in the child model of the TreeModelFilter.
- void refilter ()
    Emits a "row_changed" for each row in the child model, which causes the filter to re-evaluate whether a row is visible or not.
- void clear_cache ()
    This method should almost never be called.

## Protected Member Functions

Constructors

- TreeModelFilter (GtkTreeModelFilter *filter, bool owns_reference=true)
    Construct a new TreeModelFilter from an existing GtkTreeModelFilter.

## Detailed Description

A GtkTreeModelFilter C++ wrapper class.

A TreeModelFilter is a tree model which wraps another tree model, and can do the following things:

- Filter specific rows, based on data from a "visible column", a column storing booleans indicating whether the row should be filtered or not, or based on the return value of a "visible function", which gets a model, iter and user_data and returns a boolean indicating whether the row should be filtered or not.
- Modify the "appearance" of the model, using a modify function. This is extremely powerful and allows for just changing some values and also for creating a completely different model based on the given child model.
- Set a different root node, also known as a "virtual root". You can pass in a Gtk::TreePath indicating the root node for the filter at construction time.

Note: dynamically allocated objects must either be unreferenced or assigned to a smart pointer. Stack objects are automatically unreferenced when they go out of scope.

## Member Typedef Documentation

typedef sigc::slot<void, const TreeModel&, const TreeIter&, G::Value&, int> Xfc::Gtk::TreeModelFilter::ModifySlot

| Signature of the callback slot which calculates display values from raw values in the model. Example: Method signature for ModifySlot.
                 void method(const TreeModel& model, const TreeIter& iter, G::Value& value, int column);
                 // model: The Gtk::TreeModelFilter.
                 // iter: A Gtk::TreeIter pointing to the row whose display values are determined.
                 // value: A G::Value already initialized with the correct type for the specifed column.
                 // column: The column whose display value is determined.
The slot must fill the G::Value with the display value for the specified column in the row indicated by TreeIter. Since this slot is called for each data access, it's not a particularly efficient operation.

typedef sigc::slot<bool, const TreeModel&, const TreeIter&> Xfc::Gtk::TreeModelFilter::VisibleSlot

| Signature of the callback slot which decides whether the row indicated by TreeIter is visible. Example: Method signature for VisibleSlot.
                 bool method(const TreeModel& model, const TreeIter& iter);
                 // model: The Gtk::TreeModelFilter.
                 // iter: A Gtk::TreeIter pointing to the row whose visibility is determined.
                 // return: Whether the row indicated by iter is visible.

## Constructor & Destructor Documentation

Xfc::Gtk::TreeModelFilter::TreeModelFilter | ( | GtkTreeModelFilter * | filter,
|  | bool | owns_reference = `true`
| ) | `[explicit, protected]`

  | Construct a new TreeModelFilter from an existing GtkTreeModelFilter. Parameters:
  | filter | A pointer to a GtkTreeModelFilter.
  | owns_reference | Set false if the initial reference count is floating, set true if it's not.
The filter can be a newly created GtkTreeModelFilter or an existing GtkTreeModelFilter (see G::Object::Object).

Xfc::Gtk::TreeModelFilter::TreeModelFilter | ( | TreeModel & | child_model,
|  | const TreePath * | root = `0`
| ) |

  | Constructs a new TreeModelFilter, with child_model as the child_model and root as the virtual root. Parameters:
  | child_model | A Gtk::TreeModel.
  | root | A Gtk::TreePath or null.
TreeModelFilter is created with a reference count of 1 that the caller owns.

## Member Function Documentation

void Xfc::Gtk::TreeModelFilter::clear_cache | ( |  | ) |

| This method should almost never be called. It clears the filter of any cached iterators that haven't been reffed with ref_node(). This might be useful if the child model being filtered is static (and doesn't change often) and there has been a lot of unreffed access to nodes. As a side effect of this function, all unreffed iters will become invalid.

TreeIter Xfc::Gtk::TreeModelFilter::convert_child_iter_to_iter | ( | const TreeIter & | child_iter | ) |

  | Returns a TreeIter that points to the row in the TreeModelFilter that corresponds to the row pointed at by child_iter. Parameters:
  | child_iter | A valid TreeIter pointing to a row on the child model.
Returns: A TreeIter pointing to the row in the model being filtered.

Pointer<TreePath> Xfc::Gtk::TreeModelFilter::convert_child_path_to_path | ( | const TreePath & | child_path | ) |

  | Converts child_path to a path relative to the TreeModelFilter. Parameters:
  | child_path | A TreePath to convert.
Returns: A newly allocated TreePath, or null. The returned path will point to the same row in the filtered model. If child_path isn't a valid path on the child model, then null is returned.

TreeIter Xfc::Gtk::TreeModelFilter::convert_iter_to_child_iter | ( | const TreeIter & | filter_iter | ) |

  | Returns a TreeIter that points to the row on the child model that corresponds to the row pointed to by filter_iter. Parameters:
  | filter_iter | A valid TreeIter pointing to a row in the TreeModelFilter.
Returns: A TreeIter pointing to the row in the child model.

Pointer<TreePath> Xfc::Gtk::TreeModelFilter::convert_path_to_child_path | ( | const TreePath & | filter_path | ) |

  | Converts filter_path to a path in the child model of the TreeModelFilter. Parameters:
  | filter_path | A TreePath to convert.
Returns: A newly allocated TreePath, or null. The returned path will point to the same row in the filtered model. If child_path isn't a valid path in the child model, then null is returned.

TreeModel* Xfc::Gtk::TreeModelFilter::get_model | ( |  | ) | const

| Gets a pointer to the child model of the filter. Returns: The child model of the filter.

void Xfc::Gtk::TreeModelFilter::set_modify_func | ( | int | n_columns,
|  | const GType | types[],
|  | const ModifySlot & | slot
| ) |

  | With the n_columns and types parameters, you give an array of column types for this model (which will be exposed to the parent model/view). Parameters:
  | n_columns | The number of columns in the filter model.
  | types | The GTypes of the columns.
  | slot | A Gtk::TreeModelFilter::ModifySlot, the modify callack function.
The modify slot will get called for each data access, the goal of the modify slot is to return the data which should be displayed at the location specified using the parameters of the modify slot.

void Xfc::Gtk::TreeModelFilter::set_visible_column | ( | int | column | ) |

  | Sets column of the filter's child model to be the column where the filter should look for visibility information. Parameters:
  | column | An integer which is the column containing the visible information.
The columns should be a column of type G_TYPE_BOOLEAN, where true means that a row is visible, and false if not.

void Xfc::Gtk::TreeModelFilter::set_visible_func | ( | const VisibleSlot & | slot | ) |

  | Sets the visible function used when filtering the filter to be slot. Parameters:
  | slot | A Gtk::TreeModelFilter::VisibleSlot, the visible callack function.
The visible slot should return true if the given row should be visible and false otherwise.

The documentation for this class was generated from the following file:

- treemodelfilter.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3