gtkmm: Gtk::TreeModel Class Reference

This class defines a generic tree interface for use by the Gtk::TreeView widget. More...

#include <gtkmm/treemodel.h>

Inheritance diagram for Gtk::TreeModel:

Public Types

enum  Flags {

  Flags::ITERS_PERSIST = 1 << 0,

  Flags::LIST_ONLY = 1 << 1

}
 These flags indicate various properties of a Gtk::TreeModel. More...

 
typedef TreeModelColumnRecord ColumnRecord
 
typedef TreeNodeChildren Children
 
typedef TreeNodeConstChildren ConstChildren
 
typedef Children::iterator iterator
 
typedef ConstChildren::const_iterator const_iterator
 
typedef TreeConstRow ConstRow
 
typedef TreeRow Row
 
typedef TreePath Path
 
typedef TreeRowReference RowReference
 
typedef sigc::slot< bool(const TreeModel::iterator&)> SlotForeachIter
 The type of callback slot used by foreach_iter(). More...

 
typedef sigc::slot< bool(const TreeModel::Path&)> SlotForeachPath
 The type of callback slot used by foreach_path(). More...

 
typedef sigc::slot< bool(const TreeModel::Path&, const TreeModel::iterator&)> SlotForeachPathAndIter
 The type of callback slot used by foreach(). More...

 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 
- Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify func_destroy_notify
 

Public Member Functions

 TreeModel (TreeModel&& src) noexcept
 
TreeModeloperator= (TreeModel&& src) noexcept
 
 ~TreeModel () noexcept override
 
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...

 
const_iterator get_iter (const Path& path) const
 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...

 
const_iterator get_iter (const Glib::ustring& path_string) const
 Returns a valid iterator pointing to path_string. More...

 
Children children ()
 This returns an STL-like container API, for iterating over the rows. More...

 
const ConstChildren children () const
 This returns an STL-like container API, for iterating over the rows. More...

 
void foreach_iter (const SlotForeachIter& slot)
 Calls a callback of type SlotForeachIter on each node in the model in a depth-first fashion. More...

 
void foreach_path (const SlotForeachPath& slot)
 Calls a callback of type SlotForeachPath on each node in the model in a depth-first fashion. More...

 
void foreach (const SlotForeachPathAndIter& slot)
 Calls a callback of type SlotForeachPathAndIter on each node in the model in a depth-first fashion. More...

 
Flags 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 const_iterator& iter) const
 Returns a Gtk::TreePath referenced by iter. More...

 
void row_changed (const Path& path, const const_iterator& iter)
 Emits the Gtk::TreeModel::signal_row_changed() signal on tree_model. More...

 
void row_inserted (const Path& path, const const_iterator& iter)
 Emits the Gtk::TreeModel::signal_row_inserted() signal on tree_model. More...

 
void row_has_child_toggled (const Path& path, const const_iterator& iter)
 Emits the Gtk::TreeModel::signal_row_has_child_toggled() signal on tree_model. More...

 
void row_deleted (const Path& path)
 Emits the Gtk::TreeModel::signal_row_deleted() signal on tree_model. More...

 
void rows_reordered (const Path& path, const const_iterator& iter, const std::vector< int >& new_order)
 Emits the "rows_reordered" signal on the tree model. More...

 
void rows_reordered (const Path& path, const std::vector< int >& new_order)
 Emits the "rows_reordered" signal on the tree model. More...

 
void rows_reordered (const Path& path, const const_iterator& iter, int* new_order)
 Emits the Gtk::TreeModel::signal_rows_reordered() signal on tree_model. More...

 
Glib::ustring get_string (const 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
 
Interfaceoperator= (Interface &&src) noexcept
 
 Interface (const Glib::Interface_Class &interface_class)
 
 Interface (GObject *castitem)
 
 ~Interface () noexcept override
 
 Interface (const Interface &)=delete
 
Interfaceoperator= (const Interface &)=delete
 
GObject * gobj ()
 
const GObject * gobj () const
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (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
 
PropertyType get_property (const Glib::ustring &property_name) const
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
 
sigc::connection connect_property_changed (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) noexcept
 
 ~trackable ()
 
void add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src) noexcept
 
void remove_destroy_notify_callback (notifiable *data) const
 

Static Public Member Functions

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

 TreeModel ()
 You should derive from this class to use it. More...

 
virtual Flags 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 const_iterator& iter) const
 Override and implement this in a derived TreeModel class. More...

 
virtual int iter_n_children_vfunc (const 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 const_iterator& iter) const
 Override and implement this in a derived TreeModel class. More...

 
virtual void get_value_vfunc (const const_iterator& iter, int column, Glib::ValueBase& value) const
 Override and implement this in a derived TreeModel class. More...

 
virtual void set_value_impl (const iterator& iter, 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...

 
virtual void get_value_impl (const const_iterator& iter, 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 Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::TreeModelwrap (GtkTreeModel* object, bool take_copy=false)
 A Glib::wrap() method for this object. More...

 

Detailed Description

This class defines a generic tree interface for use by the Gtk::TreeView widget.

It is is designed to be usable with any appropriate data structure. The programmer just has to implement this interface on their own data type for it to be viewable by a Gtk::TreeView widget.

The model is represented as a hierarchical tree of strongly-typed, columned data. In other words, the model can be seen as a tree where every node has different values depending on which column is being queried. The type of data found in a column is determined by TreeModel::Column<> templates. The types are homogeneous per column across all nodes. It is important to note that this interface only provides a way of examining a model and observing changes. The implementation of each individual model decides how and if changes are made.

In order to make life simpler for programmers who do not need to write their own specialized model, two generic models are provided - the Gtk::TreeStore and the Gtk::ListStore. To use these, the developer simply pushes data into these models as necessary. These models provide the data structure as well as all appropriate tree interfaces. As a result, implementing drag and drop, sorting, and storing data is trivial. For the vast majority of trees and lists, these two models are sufficient.

Models are accessed on a node/column level of granularity. One can query for the value of a model at a certain node and a certain column on that node. There are two structures used to reference a particular node in a model. They are the Path and the iterator. Most of the interface consists of operations on an iterator.

A Gtk::TreeModel::Path is essentially a potential node. It is a location on a model that may or may not actually correspond to a node on a specific model.

By contrast, an Gtk::TreeModel::iterator is a reference to a specific node on a specific model. One can convert a path to an iterator by calling Gtk::TreeModel::get_iter(). These iterators are the primary way of accessing a model and are similar to the iterators used by Gtk::TextBuffer. The model interface defines a set of operations using them for navigating the model.

The RowReference is also useful, because it remains valid as long as there is an existing row pointed to by it's path. You can convert between RowReferences and iterators and Path s.

Member Typedef Documentation

typedef sigc::slot<bool(const TreeModel::iterator&)> Gtk::TreeModel::SlotForeachIter

The type of callback slot used by foreach_iter().

If the callback function returns true, then the tree ceases to be walked, and foreach_iter() returns.

For example: bool on_foreach_iter(const Gtk::TreeModel::iterator& iter);

typedef sigc::slot<bool(const TreeModel::Path&)> Gtk::TreeModel::SlotForeachPath

The type of callback slot used by foreach_path().

For example: bool on_foreach_path(const Gtk::TreeModel::Path& path);

If the callback function returns true, then the tree ceases to be walked, and foreach_path() returns.

The type of callback slot used by foreach().

For example: bool on_foreach(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter);

If the callback function returns true, then the tree ceases to be walked, and foreach() returns.

Constructor & Destructor Documentation

Gtk::TreeModel::TreeModel ( )
protected

You should derive from this class to use it.

Gtk::TreeModel::TreeModel ( TreeModel&&  src)
noexcept
Gtk::TreeModel::~TreeModel ( )
overridenoexcept

Member Function Documentation

static void Gtk::TreeModel::add_interface ( GType  gtype_implementer)
static
Children Gtk::TreeModel::children ( )

This returns an STL-like container API, for iterating over the rows.

const ConstChildren Gtk::TreeModel::children ( ) const

This returns an STL-like container API, for iterating over the rows.

void Gtk::TreeModel::foreach ( const SlotForeachPathAndIter slot)

Calls a callback of type SlotForeachPathAndIter on each node in the model in a depth-first fashion.

If the callback function returns true, then the tree ceases to be walked, and foreach() returns.

Parameters
slotThe function to call for each selected node.
void Gtk::TreeModel::foreach_iter ( const SlotForeachIter slot)

Calls a callback of type SlotForeachIter on each node in the model in a depth-first fashion.

If the callback function returns true, then the tree ceases to be walked, and foreach_iter() returns.

Parameters
slotThe function to call for each selected node.
void Gtk::TreeModel::foreach_path ( const SlotForeachPath slot)

Calls a callback of type SlotForeachPath on each node in the model in a depth-first fashion.

If the callback function returns true, then the tree ceases to be walked, and foreach_path() returns.

Parameters
slotThe function to call for each selected node.
GType Gtk::TreeModel::get_column_type ( int  index) const

Returns the type of the column.

Parameters
indexThe column index.
Returns
The type of the column.
virtual GType Gtk::TreeModel::get_column_type_vfunc ( int  index) const
protectedvirtual
Flags Gtk::TreeModel::get_flags ( ) const

Returns a set of flags supported by this interface.

The flags are a bitwise combination of Gtk::TreeModel::Flags. The flags supported should not change during the lifetime of the tree_model.

Returns
The flags supported by this interface.
virtual Flags Gtk::TreeModel::get_flags_vfunc ( ) const
protectedvirtual
iterator Gtk::TreeModel::get_iter ( const Path path)

Returns a valid iterator pointing to path.

Parameters
pathThe Gtk::TreeModel::Path.
Returns
A valid iterator pointing to the path, or an invalid iterator if that is not possible.
const_iterator Gtk::TreeModel::get_iter ( const Path path) const

Returns a valid iterator pointing to path.

Parameters
pathThe Gtk::TreeModel::Path.
Returns
A valid iterator pointing to the path, or an invalid iterator if that is not possible.
iterator Gtk::TreeModel::get_iter ( const Glib::ustring path_string)

Returns a valid iterator pointing to path_string.

Parameters
path_stringThe path, as a string representation.
Returns
A valid iterator pointing to the path, or an invalid iterator if that is not possible.
const_iterator Gtk::TreeModel::get_iter ( const Glib::ustring path_string) const

Returns a valid iterator pointing to path_string.

Parameters
path_stringThe path, as a string representation.
Returns
A valid iterator pointing to the path, or an invalid iterator if that is not possible.
virtual bool Gtk::TreeModel::get_iter_vfunc ( const Path path,
iterator iter 
) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Sets iter to a valid iterator pointing to path

Parameters
pathAn path to a node.
iterAn iterator that will be set to refer to a node to the path, or will be set as invalid.
Returns
true if the operation was possible.
int Gtk::TreeModel::get_n_columns ( ) const

Returns the number of columns supported by tree_model.

Returns
The number of columns.
virtual int Gtk::TreeModel::get_n_columns_vfunc ( ) const
protectedvirtual
TreeModel::Path Gtk::TreeModel::get_path ( const const_iterator iter) const

Returns a Gtk::TreePath referenced by iter.

Parameters
iterThe Gtk::TreeIter.
Returns
A Gtk::TreePath.
virtual TreeModel::Path Gtk::TreeModel::get_path_vfunc ( const const_iterator iter) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Returns a Path referenced by iter.

Parameters
iterThe iterator.
Returns
The path.
Glib::ustring Gtk::TreeModel::get_string ( const const_iterator iter) const

Generates a string representation of the iter.

This string is a “:” separated list of numbers. For example, “4:10:0:3” would be an acceptable return value for this string.

Parameters
iterAn Gtk::TreeIter.
Returns
The string.
static GType Gtk::TreeModel::get_type ( )
static

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

virtual void Gtk::TreeModel::get_value_impl ( const const_iterator iter,
int  column,
Glib::ValueBase value 
) const
protectedvirtual
virtual void Gtk::TreeModel::get_value_vfunc ( const const_iterator iter,
int  column,
Glib::ValueBase value 
) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Initializes and sets value to that at column.

Parameters
iterThe iterator.
columnThe column to lookup the value at.
valueAn empty Glib:Value to set.
GtkTreeModel* Gtk::TreeModel::gobj ( )
inline

Provides access to the underlying C GObject.

const GtkTreeModel* Gtk::TreeModel::gobj ( ) const
inline

Provides access to the underlying C GObject.

virtual bool Gtk::TreeModel::iter_children_vfunc ( const iterator parent,
iterator iter 
) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Sets iter to refer to the first child of parent. If parent has no children, false is returned and iter is set to be invalid.

Parameters
parentAn iterator.
iterAn iterator that will be set to refer to the firt child node, or will be set as invalid.
Returns
true if the operation was possible.
virtual bool Gtk::TreeModel::iter_has_child_vfunc ( const const_iterator iter) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Returns true if iter has children, false otherwise.

Parameters
iterThe iterator to test for children.
Returns
true if iter has children.
virtual int Gtk::TreeModel::iter_n_children_vfunc ( const const_iterator iter) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Returns the number of children that iter has. See also iter_n_root_children_vfunc().

Parameters
iterThe iterator to test for children.
Returns
The number of children of iter.
virtual int Gtk::TreeModel::iter_n_root_children_vfunc ( ) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Returns the number of toplevel nodes. See also iter_n_children().

Returns
The number of children at the root level.
virtual bool Gtk::TreeModel::iter_next_vfunc ( const iterator iter,
iterator iter_next 
) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Sets iter_next to refer to the node following iter it at the current level. If there is no next iter, false is returned and iter_next is set to be invalid.

Parameters
iterAn iterator.
iter_nextAn iterator that will be set to refer to the next node, or will be set as invalid.
Returns
true if the operation was possible.
virtual bool Gtk::TreeModel::iter_nth_child_vfunc ( const iterator parent,
int  n,
iterator iter 
) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Sets iter to be the child of parent using the given index. The first index is 0. If n is too big, or parent has no children, iter is set to an invalid iterator and false is returned. See also iter_nth_root_child_vfunc()

Parameters
parentAn iterator.
nThe index of the child node to which iter should be set.
iterAn iterator that will be set to refer to the nth node, or will be set as invalid.
Returns
true if the operation was possible.
virtual bool Gtk::TreeModel::iter_nth_root_child_vfunc ( int  n,
iterator iter 
) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Sets iter to be the child of at the root level using the given index. The first index is 0. If n is too big, or if there are no children, iter is set to an invalid iterator and false is returned. See also iter_nth_child_vfunc().

Parameters
nThe index of the child node to which iter should be set.
iterAn iterator that will be set to refer to the nth node, or will be set as invalid.
Returns
true if the operation was possible.
virtual bool Gtk::TreeModel::iter_parent_vfunc ( const iterator child,
iterator iter 
) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Sets iter to be the parent of child. If child is at the toplevel, and doesn't have a parent, then iter is set to an invalid iterator and false is returned.

Parameters
childAn iterator.
iterAn iterator that will be set to refer to the parent node, or will be set as invalid.
Returns
true if the operation was possible.
virtual void Gtk::TreeModel::on_row_changed ( const TreeModel::Path path,
const TreeModel::iterator iter 
)
protectedvirtual

This is a default handler for the signal signal_row_changed().

virtual void Gtk::TreeModel::on_row_deleted ( const TreeModel::Path path)
protectedvirtual

This is a default handler for the signal signal_row_deleted().

virtual void Gtk::TreeModel::on_row_has_child_toggled ( const TreeModel::Path path,
const TreeModel::iterator iter 
)
protectedvirtual

This is a default handler for the signal signal_row_has_child_toggled().

virtual void Gtk::TreeModel::on_row_inserted ( const TreeModel::Path path,
const TreeModel::iterator iter 
)
protectedvirtual

This is a default handler for the signal signal_row_inserted().

virtual void Gtk::TreeModel::on_rows_reordered ( const TreeModel::Path path,
const TreeModel::iterator iter,
int *  new_order 
)
protectedvirtual

This is a default handler for the signal signal_rows_reordered().

TreeModel& Gtk::TreeModel::operator= ( TreeModel&&  src)
noexcept
virtual void Gtk::TreeModel::ref_node_vfunc ( const iterator iter) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Lets the tree ref the node. This is an optional method for models to implement. To be more specific, models may ignore this call as it exists primarily for performance reasons.

This function is primarily meant as a way for views to let caching model know when nodes are being displayed (and hence, whether or not to cache that node.) For example, a file-system based model would not want to keep the entire file-hierarchy in memory, just the sections that are currently being displayed by every current view.

A model should be expected to be able to get an iter independent of its reffed state.

Parameters
iterthe iterator.
void Gtk::TreeModel::row_changed ( const Path path,
const const_iterator iter 
)

Emits the Gtk::TreeModel::signal_row_changed() signal on tree_model.

Parameters
pathA Gtk::TreePath-struct pointing to the changed row.
iterA valid Gtk::TreeIter-struct pointing to the changed row.
void Gtk::TreeModel::row_deleted ( const Path path)

Emits the Gtk::TreeModel::signal_row_deleted() signal on tree_model.

This should be called by models after a row has been removed. The location pointed to by path should be the location that the row previously was at. It may not be a valid location anymore.

Nodes that are deleted are not unreffed, this means that any outstanding references on the deleted node should not be released.

Parameters
pathA Gtk::TreePath-struct pointing to the previous location of the deleted row.
void Gtk::TreeModel::row_has_child_toggled ( const Path path,
const const_iterator iter 
)

Emits the Gtk::TreeModel::signal_row_has_child_toggled() signal on tree_model.

This should be called by models after the child state of a node changes.

Parameters
pathA Gtk::TreePath-struct pointing to the changed row.
iterA valid Gtk::TreeIter-struct pointing to the changed row.
void Gtk::TreeModel::row_inserted ( const Path path,
const const_iterator iter 
)

Emits the Gtk::TreeModel::signal_row_inserted() signal on tree_model.

Parameters
pathA Gtk::TreePath-struct pointing to the inserted row.
iterA valid Gtk::TreeIter-struct pointing to the inserted row.
void Gtk::TreeModel::rows_reordered ( const Path path,
const const_iterator iter,
const std::vector< int > &  new_order 
)

Emits the "rows_reordered" signal on the tree model.

This should be called by custom models when their rows have been reordered.

Parameters
pathA tree path pointing to the tree node whose children have been reordered.
iterA valid iterator pointing to the node whose children have been reordered. See also, rows_reordered(const Path& path, const std::vector<int>& new_order), if the path has a depth of 0.
new_orderAn array of integers mapping the current position of each child to its old position before the re-ordering, i.e. new_order<literal>[newpos] = oldpos.
void Gtk::TreeModel::rows_reordered ( const Path path,
const std::vector< int > &  new_order 
)

Emits the "rows_reordered" signal on the tree model.

This should be called by custom models when their rows have been reordered. This method overload is for nodes whose path has a depth of 0.

Since gtkmm 2.10:
Parameters
pathA tree path pointing to the tree node whose children have been reordered.
new_orderAn array of integers mapping the current position of each child to its old position before the re-ordering, i.e. new_order<literal>[newpos] = oldpos.
void Gtk::TreeModel::rows_reordered ( const Path path,
const const_iterator iter,
int *  new_order 
)

Emits the Gtk::TreeModel::signal_rows_reordered() signal on tree_model.

This should be called by models when their rows have been reordered.

Parameters
pathA Gtk::TreePath pointing to the tree node whose children have been reordered.
iterA valid Gtk::TreeIter pointing to the node whose children have been reordered, or nullptr if the depth of path is 0.
new_orderAn array of integers mapping the current position of each child to its old position before the re-ordering, i.e. new_order[newpos] = oldpos.
virtual void Gtk::TreeModel::set_value_impl ( const iterator iter,
int  column,
const Glib::ValueBase value 
)
protectedvirtual

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

Your implementation of set_value_impl() should call row_changed() after changing the value.

Reimplemented in Gtk::TreeModelFilter, Gtk::TreeStore, Gtk::TreeModelSort, and Gtk::ListStore.

Glib::SignalProxy<void(const TreeModel::Path&, const TreeModel::iterator&)> Gtk::TreeModel::signal_row_changed ( )
Slot Prototype:
void on_my_row_changed(const TreeModel::Path& path, const TreeModel::iterator& iter)

Flags: Run Last

This signal is emitted when a row in the model has changed.

Parameters
pathA Gtk::TreePath-struct identifying the changed row.
iterA valid Gtk::TreeIter-struct pointing to the changed row.
Glib::SignalProxy<void(const TreeModel::Path&)> Gtk::TreeModel::signal_row_deleted ( )
Slot Prototype:
void on_my_row_deleted(const TreeModel::Path& path)

Flags: Run First

This signal is emitted when a row has been deleted.

Note that no iterator is passed to the signal handler, since the row is already deleted.

This should be called by models after a row has been removed. The location pointed to by path should be the location that the row previously was at. It may not be a valid location anymore.

Parameters
pathA Gtk::TreePath-struct identifying the row.
Glib::SignalProxy<void(const TreeModel::Path&, const TreeModel::iterator&)> Gtk::TreeModel::signal_row_has_child_toggled ( )
Slot Prototype:
void on_my_row_has_child_toggled(const TreeModel::Path& path, const TreeModel::iterator& iter)

Flags: Run Last

This signal is emitted when a row has gotten the first child row or lost its last child row.

Parameters
pathA Gtk::TreePath-struct identifying the row.
iterA valid Gtk::TreeIter-struct pointing to the row.
Glib::SignalProxy<void(const TreeModel::Path&, const TreeModel::iterator&)> Gtk::TreeModel::signal_row_inserted ( )
Slot Prototype:
void on_my_row_inserted(const TreeModel::Path& path, const TreeModel::iterator& iter)

Flags: Run First

This signal is emitted when a new row has been inserted in the model.

Note that the row may still be empty at this point, since it is a common pattern to first insert an empty row, and then fill it with the desired values.

Parameters
pathA Gtk::TreePath-struct identifying the new row.
iterA valid Gtk::TreeIter-struct pointing to the new row.
Glib::SignalProxy<void(const TreeModel::Path&, const TreeModel::iterator&, int*)> Gtk::TreeModel::signal_rows_reordered ( )
Slot Prototype:
void on_my_rows_reordered(const TreeModel::Path& path, const TreeModel::iterator& iter, int* new_order)

Flags: Run First

This signal is emitted when the children of a node in the Gtk::TreeModel have been reordered.

Note that this signal is not emitted when rows are reordered by DND, since this is implemented by removing and then reinserting the row.

Parameters
pathA Gtk::TreePath-struct identifying the tree node whose children have been reordered.
iterA valid Gtk::TreeIter-struct pointing to the node whose children have been reordered, or nullptr if the depth of path is 0.
new_orderAn array of integers mapping the current position of each child to its old position before the re-ordering, i.e. new_order[newpos] = oldpos.
virtual void Gtk::TreeModel::unref_node_vfunc ( const iterator iter) const
protectedvirtual

Override and implement this in a derived TreeModel class.

Lets the tree unref the node. This is an optional method for models to implement. To be more specific, models may ignore this call as it exists primarily for performance reasons.

For more information on what this means, see unref_node_vfunc(). Please note that nodes that are deleted are not unreffed.

Parameters
iterthe iterator.

Friends And Related Function Documentation

Glib::RefPtr< Gtk::TreeModel > wrap ( GtkTreeModel *  object,
bool  take_copy = false 
)
related

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

Parameters
objectThe C instance.
take_copyFalse 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.