gtkmm 4.16.0
|
A list model that can create child models on demand. More...
#include <gtkmm/treelistmodel.h>
Public Types | |
using | SlotCreateModel = sigc::slot< Glib::RefPtr< Gio::ListModel >(const Glib::RefPtr< Glib::ObjectBase > &)> |
For instance: Glib::RefPtr<Gio::ListModel> create_func(const Glib::RefPtr<Glib::ObjectBase>& item);. | |
Public Member Functions | |
TreeListModel (TreeListModel &&src) noexcept | |
TreeListModel & | operator= (TreeListModel &&src) noexcept |
~TreeListModel () noexcept override | |
GtkTreeListModel * | gobj () |
Provides access to the underlying C GObject. | |
const GtkTreeListModel * | gobj () const |
Provides access to the underlying C GObject. | |
GtkTreeListModel * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
Glib::RefPtr< Gio::ListModel > | get_model () |
Gets the root model that self was created with. | |
Glib::RefPtr< const Gio::ListModel > | get_model () const |
Gets the root model that self was created with. | |
bool | get_passthrough () const |
Gets whether the model is passing through original row items. | |
void | set_autoexpand (bool autoexpand=true) |
Sets whether the model should autoexpand. | |
bool | get_autoexpand () const |
Gets whether the model is set to automatically expand new rows that get added. | |
Glib::RefPtr< TreeListRow > | get_child_row (guint position) |
Gets the row item corresponding to the child at index position for self's root model. | |
Glib::RefPtr< const TreeListRow > | get_child_row (guint position) const |
Gets the row item corresponding to the child at index position for self's root model. | |
Glib::RefPtr< TreeListRow > | get_row (guint position) |
Gets the row object for the given row. | |
Glib::RefPtr< const TreeListRow > | get_row (guint position) const |
Gets the row object for the given row. | |
Glib::PropertyProxy< bool > | property_autoexpand () |
If all rows should be expanded by default. | |
Glib::PropertyProxy_ReadOnly< bool > | property_autoexpand () const |
If all rows should be expanded by default. | |
Glib::PropertyProxy_ReadOnly< GType > | property_item_type () const |
The type of items. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::ListModel > > | property_model () const |
The root model displayed. | |
Glib::PropertyProxy_ReadOnly< unsigned int > | property_n_items () const |
The number of items. | |
Glib::PropertyProxy_ReadOnly< bool > | property_passthrough () const |
Gets whether the model is in passthrough mode. | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static Glib::RefPtr< TreeListModel > | create (const Glib::RefPtr< Gio::ListModel > &root, const SlotCreateModel &slot_create, bool passthrough=false, bool autoexpand=false) |
Creates a new empty Gtk::TreeListModel displaying root with all rows collapsed. | |
Protected Member Functions | |
TreeListModel (const Glib::RefPtr< Gio::ListModel > &root, const SlotCreateModel &slot_create, bool passthrough=false, bool autoexpand=false) | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::TreeListModel > | wrap (GtkTreeListModel *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
A list model that can create child models on demand.
Gtk::TreeListModel is a Gio::ListModel implementation that can expand rows by creating new child list models on demand.
using Gtk::TreeListModel::SlotCreateModel = sigc::slot<Glib::RefPtr<Gio::ListModel>(const Glib::RefPtr<Glib::ObjectBase>&)> |
For instance: Glib::RefPtr<Gio::ListModel> create_func(const Glib::RefPtr<Glib::ObjectBase>& item);.
Prototype of the function called to create new child models when Gtk::TreeListRow::set_expanded() is called.
This function can return nullptr
to indicate that item is guaranteed to be a leaf node and will never have children. If it does not have children but may get children later, it should return an empty model that is filled once children arrive.
item | The item that is being expanded. |
nullptr
if item can never have children.
|
noexcept |
|
overridenoexcept |
|
protected |
|
static |
Creates a new empty Gtk::TreeListModel displaying root with all rows collapsed.
root | The Gio::ListModel to use as root. |
slot_create | Slot to call to create the Gio::ListModel for the children of an item. |
passthrough | true to pass through items from the models. |
autoexpand | true to set the autoexpand property and expand the root model. |
bool Gtk::TreeListModel::get_autoexpand | ( | ) | const |
Gets whether the model is set to automatically expand new rows that get added.
This can be either rows added by changes to the underlying models or via Gtk::TreeListRow::set_expanded().
true
if the model is set to autoexpand. Glib::RefPtr< TreeListRow > Gtk::TreeListModel::get_child_row | ( | guint | position | ) |
Gets the row item corresponding to the child at index position for self's root model.
If position is greater than the number of children in the root model, nullptr
is returned.
Do not confuse this function with get_row().
position | Position of the child to get. |
Glib::RefPtr< const TreeListRow > Gtk::TreeListModel::get_child_row | ( | guint | position | ) | const |
Gets the row item corresponding to the child at index position for self's root model.
If position is greater than the number of children in the root model, nullptr
is returned.
Do not confuse this function with get_row().
position | Position of the child to get. |
Glib::RefPtr< Gio::ListModel > Gtk::TreeListModel::get_model | ( | ) |
Gets the root model that self was created with.
Glib::RefPtr< const Gio::ListModel > Gtk::TreeListModel::get_model | ( | ) | const |
Gets the root model that self was created with.
bool Gtk::TreeListModel::get_passthrough | ( | ) | const |
Gets whether the model is passing through original row items.
If this function returns false
, the Gio::ListModel
functions for self return custom Gtk::TreeListRow
objects. You need to call Gtk::TreeListRow::get_item() on these objects to get the original item.
If true
, the values of the child models are passed through in their original state. You then need to call get_row() to get the custom Gtk::TreeListRow
s.
true
if the model is passing through original row items. Glib::RefPtr< TreeListRow > Gtk::TreeListModel::get_row | ( | guint | position | ) |
Gets the row object for the given row.
If position is greater than the number of items in self, nullptr
is returned.
The row object can be used to expand and collapse rows as well as to inspect its position in the tree. See its documentation for details.
This row object is persistent and will refer to the current item as long as the row is present in self, independent of other rows being added or removed.
If self is set to not be passthrough, this function is equivalent to calling Glib::list_model_get_item().
Do not confuse this function with get_child_row().
position | The position of the row to fetch. |
Glib::RefPtr< const TreeListRow > Gtk::TreeListModel::get_row | ( | guint | position | ) | const |
Gets the row object for the given row.
If position is greater than the number of items in self, nullptr
is returned.
The row object can be used to expand and collapse rows as well as to inspect its position in the tree. See its documentation for details.
This row object is persistent and will refer to the current item as long as the row is present in self, independent of other rows being added or removed.
If self is set to not be passthrough, this function is equivalent to calling Glib::list_model_get_item().
Do not confuse this function with get_child_row().
position | The position of the row to fetch. |
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GtkTreeListModel * Gtk::TreeListModel::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
noexcept |
Glib::PropertyProxy< bool > Gtk::TreeListModel::property_autoexpand | ( | ) |
If all rows should be expanded by default.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::TreeListModel::property_autoexpand | ( | ) | const |
If all rows should be expanded by default.
Default value: false
Glib::PropertyProxy_ReadOnly< GType > Gtk::TreeListModel::property_item_type | ( | ) | const |
The type of items.
See Gio::ListModel::get_item_type().
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::ListModel > > Gtk::TreeListModel::property_model | ( | ) | const |
The root model displayed.
Glib::PropertyProxy_ReadOnly< unsigned int > Gtk::TreeListModel::property_n_items | ( | ) | const |
The number of items.
See Gio::ListModel::get_n_items().
Default value: 0
Glib::PropertyProxy_ReadOnly< bool > Gtk::TreeListModel::property_passthrough | ( | ) | const |
Gets whether the model is in passthrough mode.
If false
, the Gio::ListModel
functions for this object return custom Gtk::TreeListRow objects. If true
, the values of the child models are pass through unmodified.
Default value: false
Sets whether the model should autoexpand.
If set to true
, the model will recursively expand all rows that get added to the model. This can be either rows added by changes to the underlying models or via Gtk::TreeListRow::set_expanded().
autoexpand | true to make the model autoexpand its rows. |
|
related |
A Glib::wrap() method for this object.
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. |