gtkmm 2.24.4

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gtk::TreeModelSort Class Reference
TreeView Classes

A wrapper which makes an underlying Gtk::TreeModel sortable. More...

Inheritance diagram for Gtk::TreeModelSort:
[legend]
Collaboration diagram for Gtk::TreeModelSort:
[legend]

## Public Member Functions
| TreeModelSort (TreeModelSort&& src) noexcept
TreeModelSort& | operator= (TreeModelSort&& src) noexcept
| ~TreeModelSort () noexceptoverride
GtkTreeModelSort* | gobj ()
| Provides access to the underlying C GObject. More...
const GtkTreeModelSort* | gobj () const
| Provides access to the underlying C GObject. More...
GtkTreeModelSort* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
Glib::RefPtr< TreeModel > | get_model ()
| Returns the model the Gtk::TreeModelSort is sorting. More...
Glib::RefPtr< const TreeModel > | get_model () const
| Returns the model the Gtk::TreeModelSort is sorting. More...
Path | convert_child_path_to_path (const Path& child_path) const
| Converts child_path to a path relative to tree_model_sort. More...
iterator | convert_child_iter_to_iter (const iterator& child_iter) const
| Gets an iterator that points to the sorted row that corresponds to the child row pointed at by child_iter. More...
Path | convert_path_to_child_path (const Path& sorted_path) const
| Converts sorted_path to a path on the child model of tree_model_sort. More...
iterator | convert_iter_to_child_iter (const iterator& sorted_iter) const
| Gets an iterator that points to the child row that corresponds to the sorted row pointed at by sorted_iter. More...
void | reset_default_sort_func ()
| This resets the default sort function to be in the 'unsorted' state. More...
void | clear_cache ()
| This function should almost never be called. More...
bool | iter_is_valid (const iterator& iter) const
| <warning> This function is slow. More...
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< TreeModel > > | property_model () const
| The model for the TreeModelSort to sort. More...
Public Member Functions inherited from Glib::Object
| Object (const Object &)=delete
Object & | operator= (const Object &)=delete
| Object (Object &&src) noexcept
Object & | operator= (Object &&src) noexcept
void * | get_data (const QueryQuark &key)
void | set_data (const Quark &key, void *data)
void | set_data (const Quark &key, void *data, DestroyNotify notify)
void | remove_data (const QueryQuark &quark)
void * | steal_data (const QueryQuark &quark)
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
void | set_property (const Glib::ustring &property_name, const PropertyType &value)
void | get_property (const Glib::ustring &property_name, PropertyType &value) const
void | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void > &slot)
void | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void > &&slot)
sigc::connection | connect_property_changed_with_return (const Glib::ustring &property_name, const sigc::slot< void > &slot)
sigc::connection | connect_property_changed_with_return (const Glib::ustring &property_name, sigc::slot< void > &&slot)
void | freeze_notify ()
void | thaw_notify ()
virtual void | reference () const
virtual void | unreference () const
GObject * | gobj ()
const GObject * | gobj () const
GObject * | gobj_copy () const
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const
Public Member Functions inherited from Gtk::TreeModel
| TreeModel (TreeModel&& src) noexcept
TreeModel& | operator= (TreeModel&& src) noexcept
| ~TreeModel () noexceptoverride
GtkTreeModel* | gobj ()
| Provides access to the underlying C GObject. More...
const GtkTreeModel* | gobj () const
| Provides access to the underlying C GObject. More...
iterator | get_iter (const Path& path)
| Returns a valid iterator pointing to path. More...
iterator | get_iter (const Glib::ustring& path_string)
| Returns a valid iterator pointing to path_string. More...
Children | children ()
| This returns an STL-like container API, for iterating over the rows. More...
Children | children () const
| This returns an STL-like container API, for iterating over the rows. More...
void | foreach_iter (const SlotForeachIter& slot)
| Calls a callback slot on each node in the model in a depth-first fashion. More...
void | foreach_path (const SlotForeachPath& slot)
| Calls a callback slot on each node in the model in a depth-first fashion. More...
void | foreach (const SlotForeachPathAndIter& slot)
| Calls a callback slot on each node in the model in a depth-first fashion. More...
TreeModelFlags | get_flags () const
| Returns a set of flags supported by this interface. More...
int | get_n_columns () const
| Returns the number of columns supported by tree_model. More...
GType | get_column_type (int index) const
| Returns the type of the column. More...
TreeModel::Path | get_path (const iterator& iter) const
| Returns a Gtk::TreePath referenced by iter. More...
void | row_changed (const Path& path, const iterator& iter)
| Emits the "row-changed" signal on tree_model. More...
void | row_inserted (const Path& path, const iterator& iter)
| Emits the "row-inserted" signal on tree_model. More...
void | row_has_child_toggled (const Path& path, const iterator& iter)
| Emits the "row-has-child-toggled" signal on tree_model. More...
void | row_deleted (const Path& path)
| Emits the "row-deleted" signal on tree_model. More...
void | rows_reordered (const Path& path, const iterator& iter, const Glib::ArrayHandle< int >& new_order)
| Emits the "rows_reordered" signal on the tree model. More...
void | rows_reordered (const Path& path, const Glib::ArrayHandle< int >& new_order)
| Emits the "rows_reordered" signal on the tree model. More...
void | rows_reordered (const Path& path, const iterator& iter, int* new_order)
| Emits the "rows-reordered" signal on tree_model. More...
Glib::ustring | get_string (const iterator& iter) const
| Generates a string representation of the iter. More...
Glib::SignalProxy< void, const TreeModel::Path&, const TreeModel::iterator& > | signal_row_changed ()
Glib::SignalProxy< void, const TreeModel::Path&, const TreeModel::iterator& > | signal_row_inserted ()
Glib::SignalProxy< void, const TreeModel::Path&, const TreeModel::iterator& > | signal_row_has_child_toggled ()
Glib::SignalProxy< void, const TreeModel::Path& > | signal_row_deleted ()
Glib::SignalProxy< void, const TreeModel::Path&, const TreeModel::iterator&, int* > | signal_rows_reordered ()
Public Member Functions inherited from Glib::Interface
| Interface ()
| Interface (Interface &&src) noexcept
Interface & | operator= (Interface &&src) noexcept
| Interface (const Glib::Interface_Class &interface_class)
| Interface (GObject *castitem)
| ~Interface () noexceptoverride
| Interface (const Interface &)=delete
Interface & | operator= (const Interface &)=delete
GObject * | gobj ()
const GObject * | gobj () const
Public Member Functions inherited from Gtk::TreeSortable
| TreeSortable (TreeSortable&& src) noexcept
TreeSortable& | operator= (TreeSortable&& src) noexcept
| ~TreeSortable () noexceptoverride
GtkTreeSortable* | gobj ()
| Provides access to the underlying C GObject. More...
const GtkTreeSortable* | gobj () const
| Provides access to the underlying C GObject. More...
bool | get_sort_column_id (int& sort_column_id, SortType& order) const
| Fills in sort_column_id and order with the current sort column and the order. More...
void | set_sort_column (const TreeModelColumnBase& sort_column_id, SortType order)
| Sets the current sort column to be sort_column_id. More...
void | set_sort_column (int sort_column_id, SortType order)
| Sets the current sort column to be sort_column_id. More...
void | set_sort_column_id (const TreeModelColumnBase& sort_column_id, SortType order)
void | set_sort_column_id (int sort_column_id, SortType order)
void | set_sort_func (const TreeModelColumnBase& sort_column, const SlotCompare& slot)
| Sets the comparison function used when sorting a certain column. More...
void | set_sort_func (int sort_column_id, const SlotCompare& slot)
| Sets the comparison function used when sorting a certain column. More...
void | set_default_sort_func (const SlotCompare& slot)
| Sets the default comparison function used when sorting. More...
void | unset_default_sort_func ()
| Sets the default comparison function used when sorting. More...
bool | has_default_sort_func () const
| Returns `true` if the model has a default sort function. More...
void | sort_column_changed ()
| Emits a Gtk::TreeSortable::signal_sort_column_changed() signal on sortable. More...
Glib::SignalProxy< void > | signal_sort_column_changed ()

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static Glib::RefPtr< TreeModelSort > | create (const Glib::RefPtr< TreeModel >& model)
Static Public Member Functions inherited from Gtk::TreeModel
static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
Static Public Member Functions inherited from Gtk::TreeSortable
static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## Protected Member Functions
| TreeModelSort (const Glib::RefPtr< TreeModel >& model)
virtual void | set_value_impl (const iterator& row, int column, const Glib::ValueBase& value)
| Override and implement this in a derived TreeModel class, so that Row::operator() and Row::set_value() work. More...
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams &construct_params)
| Object (GObject *castitem)
| ~Object () noexceptoverride
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| ObjectBase (const char *custom_type_name)
| ObjectBase (const std::type_info &custom_type_info)
| ObjectBase (ObjectBase &&src) noexcept
ObjectBase & | operator= (ObjectBase &&src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject *castitem)
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
Protected Member Functions inherited from Gtk::TreeModel
| TreeModel ()
| You should derive from this class to use it. More...
virtual TreeModelFlags | get_flags_vfunc () const
virtual int | get_n_columns_vfunc () const
virtual GType | get_column_type_vfunc (int index) const
virtual bool | iter_next_vfunc (const iterator& iter, iterator& iter_next) const
| Override and implement this in a derived TreeModel class. More...
virtual bool | get_iter_vfunc (const Path& path, iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual bool | iter_children_vfunc (const iterator& parent, iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual bool | iter_parent_vfunc (const iterator& child, iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual bool | iter_nth_child_vfunc (const iterator& parent, int n, iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual bool | iter_nth_root_child_vfunc (int n, iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual bool | iter_has_child_vfunc (const iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual int | iter_n_children_vfunc (const iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual int | iter_n_root_children_vfunc () const
| Override and implement this in a derived TreeModel class. More...
virtual void | ref_node_vfunc (const iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual void | unref_node_vfunc (const iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual TreeModel::Path | get_path_vfunc (const iterator& iter) const
| Override and implement this in a derived TreeModel class. More...
virtual void | get_value_vfunc (const iterator& iter, int column, Glib::ValueBase& value) const
| Override and implement this in a derived TreeModel class. More...
virtual void | get_value_impl (const iterator& row, int column, Glib::ValueBase& value) const
virtual void | on_row_changed (const TreeModel::Path& path, const TreeModel::iterator& iter)
| This is a default handler for the signal signal_row_changed(). More...
virtual void | on_row_inserted (const TreeModel::Path& path, const TreeModel::iterator& iter)
| This is a default handler for the signal signal_row_inserted(). More...
virtual void | on_row_has_child_toggled (const TreeModel::Path& path, const TreeModel::iterator& iter)
| This is a default handler for the signal signal_row_has_child_toggled(). More...
virtual void | on_row_deleted (const TreeModel::Path& path)
| This is a default handler for the signal signal_row_deleted(). More...
virtual void | on_rows_reordered (const TreeModel::Path& path, const TreeModel::iterator& iter, int* new_order)
| This is a default handler for the signal signal_rows_reordered(). More...
Protected Member Functions inherited from Gtk::TreeSortable
| TreeSortable ()
| You should derive from this class to use it. More...
virtual bool | get_sort_column_id_vfunc (int* sort_column_id, SortType* order) const
virtual void | set_sort_column_id_vfunc (int sort_column_id, SortType order)
virtual void | set_sort_func_vfunc (int sort_column_id, GtkTreeIterCompareFunc func, void* data, GDestroyNotify destroy)
virtual void | set_default_sort_func_vfunc (GtkTreeIterCompareFunc func, void* data, GDestroyNotify destroy)
virtual bool | has_default_sort_func_vfunc () const
virtual void | sort_column_changed_vfunc () const
virtual void | on_sort_column_changed ()
| This is a default handler for the signal signal_sort_column_changed(). More...

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gtk::TreeModelSort > | wrap (GtkTreeModelSort* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Gtk::TreeModel
Glib::RefPtr< Gtk::TreeModel > | wrap (GtkTreeModel* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Gtk::TreeSortable
Glib::RefPtr< Gtk::TreeSortable > | wrap (GtkTreeSortable* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Additional Inherited Members
Public Types inherited from Glib::Object
typedef void(*)(gpointer data | DestroyNotify)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify
Public Types inherited from Gtk::TreeModel
typedef TreeModelColumnRecord | ColumnRecord
typedef TreeNodeChildren | Children
typedef Children::iterator | iterator
typedef Children::reverse_iterator | reverse_iterator
typedef Children::const_iterator | const_iterator
typedef Children::const_reverse_iterator | const_reverse_iterator
typedef TreeRow | Row
typedef TreePath | Path
typedef TreeRowReference | RowReference
typedef sigc::slot< bool, const TreeModel::iterator& > | SlotForeachIter
| For example, void on_foreach(const Gtk::TreeModel::iterator& iter);. More...
typedef sigc::slot< bool, const TreeModel::Path& > | SlotForeachPath
| For example, void on_foreach(const Gtk::TreeModel::Path& path);. More...
typedef sigc::slot< bool, const TreeModel::Path&, const TreeModel::iterator& > | SlotForeachPathAndIter
| For example, void on_foreach(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter);. More...
Public Types inherited from Gtk::TreeSortable
enum | { DEFAULT_SORT_COLUMN_ID = -1, DEFAULT_UNSORTED_COLUMN_ID = -2 }
typedef sigc::slot< int, const Gtk::TreeModel::iterator&, const Gtk::TreeModel::iterator& > | SlotCompare
| This callback should return -1 if a compares before b, 0 if they compare equal, 1 if a compares after b. More...

## Detailed Description

A wrapper which makes an underlying Gtk::TreeModel sortable.

The TreeModelSort is a model which implements the TreeSortable interface. It does not hold any data itself, but rather is created with a child model and proxies its data. It has identical column types to this child model, and the changes in the child are propagated. The primary purpose of this model is to provide a way to sort a different model without modifying it. Note that the sort function used by TreeModelSort is not guaranteed to be stable.

For instance, you might create two TreeView widgets each with a view of the same data. If the model is wrapped by a TreeModelSort then the two TreeViews can each sort their view of the data without affecting the other. By contrast, if we simply put the same model in each widget, then sorting the first would sort the second.

## Constructor & Destructor Documentation

Gtk::TreeModelSort::TreeModelSort | ( | TreeModelSort&& | src | ) |
| noexcept

Gtk::TreeModelSort::~TreeModelSort | ( |  | ) |
| override noexcept

Gtk::TreeModelSort::TreeModelSort | ( | const Glib::RefPtr< TreeModel >& | model | ) |
| explicit protected

## Member Function Documentation

void Gtk::TreeModelSort::clear_cache | ( |  | ) |

This function should almost never be called.

It clears the tree_model_sort of any cached iterators that haven't been reffed with ref_node(). This might be useful if the child model being sorted 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 be invalid.

iterator Gtk::TreeModelSort::convert_child_iter_to_iter | ( | const iterator& | child_iter | ) | const

Gets an iterator that points to the sorted row that corresponds to the child row pointed at by child_iter.

Parameters

  child_iter | A valid iterator pointing to a row on the child model.

Returns
  A valid iterator that points to the row in this sorted model.

Path Gtk::TreeModelSort::convert_child_path_to_path | ( | const Path& | child_path | ) | const

Converts child_path to a path relative to tree_model_sort.

That is, child_path points to a path in the child model. The returned path will point to the same row in the sorted model. If child_path isn't a valid path on the child model, then `nullptr` is returned.

Parameters

  child_path | A Gtk::TreePath to convert.

Returns
  A newly allocated Gtk::TreePath, or `nullptr`.

iterator Gtk::TreeModelSort::convert_iter_to_child_iter | ( | const iterator& | sorted_iter | ) | const

Gets an iterator that points to the child row that corresponds to the sorted row pointed at by sorted_iter.

Parameters

  sorted_iter | A valid iterator pointing to a row on the sorted model.

Returns
  A valid iterator that points to the row in the child model.

Path Gtk::TreeModelSort::convert_path_to_child_path | ( | const Path& | sorted_path | ) | const

Converts sorted_path to a path on the child model of tree_model_sort.

That is, sorted_path points to a location in tree_model_sort. The returned path will point to the same location in the model not being sorted. If sorted_path does not point to a location in the child model, `nullptr` is returned.

Parameters

  sorted_path | A Gtk::TreePath to convert.

Returns
  A newly allocated Gtk::TreePath, or `nullptr`.

static Glib::RefPtr<TreeModelSort> Gtk::TreeModelSort::create | ( | const Glib::RefPtr< TreeModel >& | model | ) |
| static

Glib::RefPtr<TreeModel> Gtk::TreeModelSort::get_model | ( |  | ) |

Returns the model the Gtk::TreeModelSort is sorting.

Returns
  The "child model" being sorted.

Glib::RefPtr<const TreeModel> Gtk::TreeModelSort::get_model | ( |  | ) | const

Returns the model the Gtk::TreeModelSort is sorting.

Returns
  The "child model" being sorted.

static GType Gtk::TreeModelSort::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

GtkTreeModelSort* Gtk::TreeModelSort::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

const GtkTreeModelSort* Gtk::TreeModelSort::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

GtkTreeModelSort* Gtk::TreeModelSort::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gtk::TreeModelSort::iter_is_valid | ( | const iterator& | iter | ) | const
| virtual

<warning> This function is slow.

Only use it for debugging and/or testing purposes. </warning>

Checks if the given iter is a valid iter for this Gtk::TreeModelSort.

Since gtkmm 2.2:

Parameters

  iter | A Gtk::TreeIter.

Returns
  `true` if the iter is valid, `false` if the iter is invalid.

Reimplemented from Gtk::TreeModel.

TreeModelSort& Gtk::TreeModelSort::operator= | ( | TreeModelSort&& | src | ) |
| noexcept

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TreeModel> > Gtk::TreeModelSort::property_model | ( |  | ) | const

The model for the TreeModelSort to sort.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

void Gtk::TreeModelSort::reset_default_sort_func | ( |  | ) |

This resets the default sort function to be in the 'unsorted' state.

That is, it is in the same order as the child model. It will re-sort the model to be in the same order as the child model only if the Gtk::TreeModelSort is in 'unsorted' state.

virtual void Gtk::TreeModelSort::set_value_impl | ( | const iterator& | row,
|  | int | column,
|  | const Glib::ValueBase & | value
| ) |  |
| protected virtual

Override and implement this in a derived TreeModel class, so that Row::operator() and Row::set_value() work.

You can probably just implement this by calling set_value_vfunc(). Your implementation of set_value_impl() should also call row_changed() after changing the value.

Reimplemented from Gtk::TreeModel.

## Friends And Related Function Documentation

Glib::RefPtr< Gtk::TreeModelSort > wrap | ( | GtkTreeModelSort * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.

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

- gtkmm/treemodelsort.h