gtkmm: Gtk::SectionModel Class Reference

gtkmm 4.16.0

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gtk::SectionModel Class Reference
ListView Classes

Interface that adds support for section to list models. More...

`#include <gtkmm/sectionmodel.h>`

Inheritance diagram for Gtk::SectionModel:
[legend]

## Public Member Functions
| SectionModel (SectionModel && src) noexcept
SectionModel & | operator= (SectionModel && src) noexcept
| ~SectionModel () noexcept override
GtkSectionModel * | gobj ()
| Provides access to the underlying C GObject.
const GtkSectionModel * | gobj () const
| Provides access to the underlying C GObject.
std::pair< guint, guint > | get_section (guint position) const
| Query the section that covers the given position.
void | sections_changed (guint position, guint n_items)
| This function emits the signal_sections_changed() signal to notify about changes to sections.
Glib::SignalProxy< void(guint, guint)> | signal_sections_changed ()
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 () noexcept override
| Interface (const Interface &)=delete
Interface & | operator= (const Interface &)=delete
GObject * | gobj ()
const GObject * | gobj () const
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
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

## 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.

## Protected Member Functions
| SectionModel ()
| You should derive from this class to use it.
virtual void | get_section_vfunc (guint position, guint & out_start, guint & out_end)
| Return the section that covers the given position.
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)

## Related Symbols
(Note that these are not member symbols.)
Glib::RefPtr< Gtk::SectionModel > | wrap (GtkSectionModel * object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Interface that adds support for section to list models.

This support is then used by widgets using list models to be able to group their items into sections.

Many GTK list models support sections inherently, or they pass through the sections of a model they are wrapping.

A Gtk::SectionModel groups successive items into so-called sections. List widgets like Gtk::ListView then allow displaying section headers for these sections.

When the section groupings of a model changes, the model will emit signal_sections_changed() by calling the sections_changed() function. All sections in the given range now need to be queried again.
Gio::ListModel::signal_items_changed() has the same effect, all sections in that range are invalidated, too.

See also
  Gio::ListModel, Gtk::ListView

Since gtkmm 4.12

## Constructor & Destructor Documentation

## ◆ SectionModel() [1/2]

Gtk::SectionModel::SectionModel | ( |  | ) |
| protected

You should derive from this class to use it.

## ◆ SectionModel() [2/2]

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

## ◆ ~SectionModel()

Gtk::SectionModel::~SectionModel | ( |  | ) |
| overridenoexcept

## Member Function Documentation

## ◆ add_interface()

static void Gtk::SectionModel::add_interface | ( | GType | gtype_implementer | ) |
| static

## ◆ get_section()

std::pair< guint, guint > Gtk::SectionModel::get_section | ( | guint | position | ) | const

Query the section that covers the given position.

The number of items in the section can be computed by out_end - out_start.

If the position is larger than the number of items, a single range from n_items to G_MAXUINT will be returned.

Since gtkmm 4.12

Parameters

  position | The position of the item to query.

Returns
  {out_start, out_end} The position of the first item in the section, and the position of the first item not part of the section anymore.

## ◆ get_section_vfunc()

virtual void Gtk::SectionModel::get_section_vfunc | ( | guint | position,
|  | guint & | out_start,
|  | guint & | out_end )
| protectedvirtual

Return the section that covers the given position.

If the position is outside the number of items, returns a single range from n_items to G_MAXUINT.

## ◆ get_type()

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

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

## ◆ gobj() [1/2]

GtkSectionModel * Gtk::SectionModel::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GtkSectionModel * Gtk::SectionModel::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ operator=()

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

## ◆ sections_changed()

void Gtk::SectionModel::sections_changed | ( | guint | position,
|  | guint | n_items )

This function emits the signal_sections_changed() signal to notify about changes to sections.

It must cover all positions that used to be a section start or that are now a section start. It does not have to cover all positions for which the section has changed.

The Gio::ListModel::signal_items_changed() implies the effect of the signal_sections_changed() signal for all the items it covers.

It is recommended that when changes to the items cause section changes in a larger range, that the larger range is included in the emission of the Gio::ListModel::signal_items_changed() instead of emitting two signals.

Since gtkmm 4.12

Parameters

  position | The first changed item.
  n_items | The number of changed items.

## ◆ signal_sections_changed()

Glib::SignalProxy< void(guint, guint)> Gtk::SectionModel::signal_sections_changed | ( |  | ) |

Slot Prototype:
  `void on_my_sections_changed(guint position, guint n_items)`

Flags: Run Last

Emitted when the start-of-section state of some of the items in model changes.

Note that this signal does not specify the new section state of the items, they need to be queried manually. It is also not necessary for a model to change the section state of any of the items in the section model, though it would be rather useless to emit such a signal.

The Gio::ListModel::signal_items_changed() implies the effect of the signal_sections_changed() signal for all the items it covers.

Since gtkmm 4.12

Parameters

  position | The first item that may have changed.
  n_items | Number of items with changes.

## Friends And Related Symbol Documentation

## ◆ wrap()

Glib::RefPtr< Gtk::SectionModel > wrap | ( | GtkSectionModel * | 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.