gtkmm 4.19.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gtk::TreeListModel Class Reference

A list model that can create child models on demand. More...

#include <gtkmm/treelistmodel.h>

Inheritance diagram for Gtk::TreeListModel:
Inheritance graph
[legend]

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 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 sigc::notifiable
typedef internal::func_destroy_notify func_destroy_notify
 

Public Member Functions

 TreeListModel (TreeListModel &&src) noexcept
 
TreeListModeloperator= (TreeListModel &&src) noexcept
 
 ~TreeListModel () noexcept override
 
GtkTreeListModelgobj ()
 Provides access to the underlying C GObject.
 
const GtkTreeListModelgobj () const
 Provides access to the underlying C GObject.
 
GtkTreeListModelgobj_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::ListModelget_model ()
 Gets the root model that self was created with.
 
Glib::RefPtr< const Gio::ListModelget_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< TreeListRowget_child_row (guint position)
 Gets the row item corresponding to the child at index position for self's root model.
 
Glib::RefPtr< const TreeListRowget_child_row (guint position) const
 Gets the row item corresponding to the child at index position for self's root model.
 
Glib::RefPtr< TreeListRowget_row (guint position)
 Gets the row object for the given row.
 
Glib::RefPtr< const TreeListRowget_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.
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
voidget_data (const QueryQuark &key)
 
void set_data (const Quark &key, void *data)
 
void set_data_with_c_callback (const Quark &key, void *data, GDestroyNotify notify)
 
void set_data (const Quark &key, void *data, DestroyNotify notify)
 
void remove_data (const QueryQuark &quark)
 
voidsteal_data (const QueryQuark &quark)
 
Glib::RefPtr< Glib::Objectwrap (GObject *object, bool take_copy=false)
 
- 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
 
GObjectgobj ()
 
const GObjectgobj () const
 
GObjectgobj_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
 
- Public Member Functions inherited from Gio::ListModel
 ListModel (ListModel &&src) noexcept
 
ListModeloperator= (ListModel &&src) noexcept
 
 ~ListModel () noexcept override
 
GListModelgobj ()
 
const GListModelgobj () const
 
GType get_item_type () const
 
guint get_n_items () const
 
Glib::RefPtr< Glib::ObjectBaseget_object (guint position)
 
Glib::RefPtr< const Glib::ObjectBaseget_object (guint position) const
 
Glib::RefPtr< T_itemget_typed_object (guint position)
 
Glib::RefPtr< const T_itemget_typed_object (guint position) const
 
Glib::SignalProxy< void(guint, guint, guint)> signal_items_changed ()
 
- 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
 
GObjectgobj ()
 
const GObjectgobj () const
 

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< TreeListModelcreate (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.
 
- Static Public Member Functions inherited from Gio::ListModel
static void add_interface (GType gtype_implementer)
 
static GType get_type ()
 

Protected Member Functions

 TreeListModel (const Glib::RefPtr< Gio::ListModel > &root, const SlotCreateModel &slot_create, bool passthrough=false, bool autoexpand=false)
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- 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)
 
- Protected Member Functions inherited from Gio::ListModel
 ListModel ()
 
void items_changed (guint position, guint removed, guint added)
 
virtual GType get_item_type_vfunc ()
 
virtual guint get_n_items_vfunc ()
 
virtual gpointer get_item_vfunc (guint position)
 
Glib::RefPtr< Gio::ListModelwrap (GListModel *object, bool take_copy=false)
 

Related Symbols

(Note that these are not member symbols.)

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

Detailed Description

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.

See also
Gio::ListModel
Since gtkmm 3.98:

Member Typedef Documentation

◆ SlotCreateModel

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.

Parameters
itemThe item that is being expanded.
Returns
The model tracking the children of item or nullptr if item can never have children.

Constructor & Destructor Documentation

◆ TreeListModel() [1/2]

Gtk::TreeListModel::TreeListModel ( TreeListModel &&  src)
noexcept

◆ ~TreeListModel()

Gtk::TreeListModel::~TreeListModel ( )
overridenoexcept

◆ TreeListModel() [2/2]

Gtk::TreeListModel::TreeListModel ( const Glib::RefPtr< Gio::ListModel > &  root,
const SlotCreateModel slot_create,
bool  passthrough = false,
bool  autoexpand = false 
)
protected

Member Function Documentation

◆ create()

static Glib::RefPtr< TreeListModel > Gtk::TreeListModel::create ( const Glib::RefPtr< Gio::ListModel > &  root,
const SlotCreateModel slot_create,
bool  passthrough = false,
bool  autoexpand = false 
)
static

Creates a new empty Gtk::TreeListModel displaying root with all rows collapsed.

Parameters
rootThe Gio::ListModel to use as root.
slot_createSlot to call to create the Gio::ListModel for the children of an item.
passthroughtrue to pass through items from the models.
autoexpandtrue to set the autoexpand property and expand the root model.

◆ get_autoexpand()

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().

Returns
true if the model is set to autoexpand.

◆ get_child_row() [1/2]

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().

Parameters
positionPosition of the child to get.
Returns
The child in position.

◆ get_child_row() [2/2]

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().

Parameters
positionPosition of the child to get.
Returns
The child in position.

◆ get_model() [1/2]

Glib::RefPtr< Gio::ListModel > Gtk::TreeListModel::get_model ( )

Gets the root model that self was created with.

Returns
The root model.

◆ get_model() [2/2]

Glib::RefPtr< const Gio::ListModel > Gtk::TreeListModel::get_model ( ) const

Gets the root model that self was created with.

Returns
The root model.

◆ get_passthrough()

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::TreeListRows.

Returns
true if the model is passing through original row items.

◆ get_row() [1/2]

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().

Parameters
positionThe position of the row to fetch.
Returns
The row item.

◆ get_row() [2/2]

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().

Parameters
positionThe position of the row to fetch.
Returns
The row item.

◆ get_type()

static GType Gtk::TreeListModel::get_type ( )
static

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

◆ gobj() [1/2]

GtkTreeListModel * Gtk::TreeListModel::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkTreeListModel * Gtk::TreeListModel::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

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.

◆ operator=()

TreeListModel & Gtk::TreeListModel::operator= ( TreeListModel &&  src)
noexcept

◆ property_autoexpand() [1/2]

Glib::PropertyProxy< bool > Gtk::TreeListModel::property_autoexpand ( )

If all rows should be expanded by default.

Default value: false

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

◆ property_autoexpand() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::TreeListModel::property_autoexpand ( ) const

If all rows should be expanded by default.

Default value: false

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

◆ property_item_type()

Glib::PropertyProxy_ReadOnly< GType > Gtk::TreeListModel::property_item_type ( ) const

The type of items.

See Gio::ListModel::get_item_type().

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

◆ property_model()

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::ListModel > > Gtk::TreeListModel::property_model ( ) const

The root model displayed.

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

◆ property_n_items()

Glib::PropertyProxy_ReadOnly< unsigned int > Gtk::TreeListModel::property_n_items ( ) const

The number of items.

See Gio::ListModel::get_n_items().

Since gtkmm 4.8:

Default value: 0

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

◆ property_passthrough()

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

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

◆ set_autoexpand()

void Gtk::TreeListModel::set_autoexpand ( bool  autoexpand = true)

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().

Parameters
autoexpandtrue to make the model autoexpand its rows.

Friends And Related Symbol Documentation

◆ wrap()

Glib::RefPtr< Gtk::TreeListModel > wrap ( GtkTreeListModel 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.