class GenericTreeModel(GObject.GObject, Gtk.TreeModel): (source)
Known subclasses: zim.plugins.pageindex.PageTreeStoreBase
A base implementation of a Gtk.TreeModel for python.
The GenericTreeModel eases implementing the Gtk.TreeModel interface in Python. The class can be subclassed to provide a TreeModel implementation which works directly with Python objects instead of iterators.
All of the on_* methods should be overridden by subclasses to provide the underlying implementation a way to access custom model data. For the purposes of this API, all custom model data supplied or handed back through the overridable API will use the argument names: node, parent, and child in regards to user data python objects.
The create_tree_iter, set_user_data, invalidate_iters, iter_is_valid methods are available to help manage Gtk.TreeIter objects and their Python object references.
GenericTreeModel manages a pool of user data nodes that have been used with iters. This pool stores a references to user data nodes as a dictionary value with the key being the integer id of the data. This id is what the Gtk.TreeIter objects use to reference data in the pool. References will be removed from the pool when the model is deleted or explicitly by using the optional "node" argument to the "row_deleted" method when notifying the model of row deletion.
Method | __init__ |
Initialize. Make sure to call this from derived classes if overridden. |
Method | create_tree_iter |
Create a Gtk.TreeIter instance with the given user_data specific for this model. |
Method | do_get_column_type |
Internal method. |
Method | do_get_flags |
Internal method. |
Method | do_get_iter |
Internal method. |
Method | do_get_n_columns |
Internal method. |
Method | do_get_path |
Internal method. |
Method | do_get_value |
Internal method. |
Method | do_iter_children |
Internal method. |
Method | do_iter_has_child |
Internal method. |
Method | do_iter_n_children |
Internal method. |
Method | do_iter_next |
Internal method. |
Method | do_iter_nth_child |
Internal method. |
Method | do_iter_parent |
Internal method. |
Method | do_ref_node |
Undocumented |
Method | do_unref_node |
Undocumented |
Method | get_user_data |
Get the user_data associated with the given TreeIter. |
Method | invalidate_iter |
Clear user data and its reference from the iter and this model. |
Method | invalidate_iters |
This method invalidates all TreeIter objects associated with this custom tree model and frees their locally pooled references. |
Method | iter_depth_first |
Depth-first iteration of the entire TreeModel yielding the python nodes. |
Method | iter_is_valid |
:Returns: True if the gtk.TreeIter specified by iter is valid for the custom tree model. |
Method | on_get_column_type |
Overridable. |
Method | on_get_flags |
Overridable. |
Method | on_get_iter |
Overridable. |
Method | on_get_n_columns |
Overridable. |
Method | on_get_path |
Overridable. |
Method | on_get_value |
Overridable. |
Method | on_iter_children |
Overridable. |
Method | on_iter_has_child |
Overridable. |
Method | on_iter_n_children |
Overridable. |
Method | on_iter_next |
Overridable. |
Method | on_iter_nth_child |
Overridable. |
Method | on_iter_parent |
Overridable. |
Method | on_ref_node |
Undocumented |
Method | on_unref_node |
Undocumented |
Method | row_deleted |
Notify the model a row has been deleted. |
Method | set_user_data |
Applies user_data and stamp to the given iter. |
Class Variable | leak_references |
Undocumented |
Instance Variable | stamp |
Undocumented |
Method | _create_tree_iter |
Internal creation of a (bool, TreeIter) pair for returning directly back to the view interfacing with this model. |
Instance Variable | _held_refs |
Undocumented |
zim.plugins.pageindex.PageTreeStoreBase
Create a Gtk.TreeIter instance with the given user_data specific for this model.
Use this method to create Gtk.TreeIter instance instead of directly calling Gtk.Treeiter(), this will ensure proper reference managment of wrapped used_data.
Get the user_data associated with the given TreeIter.
GenericTreeModel stores arbitrary Python objects mapped to instances of Gtk.TreeIter. This method allows to retrieve the Python object held by the given iterator.
Applies user_data and stamp to the given iter.
If the models "leak_references" property is set, a reference to the user_data is stored with the model to ensure we don't run into bad memory problems with the TreeIter.