gtkmm 4.12.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gtk::SectionModel Class Reference

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

#include <gtkmm/sectionmodel.h>

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

Public Member Functions

 SectionModel (SectionModel && src) noexcept
 
SectionModeloperator= (SectionModel && src) noexcept
 
 ~SectionModel () noexcept override
 
GtkSectionModel * gobj ()
 Provides access to the underlying C GObject. More...
 
const GtkSectionModel * gobj () const
 Provides access to the underlying C GObject. More...
 
std::pair< guint, guint > get_section (guint position) const
 Query the section that covers the given position. More...
 
void sections_changed (guint position, guint n_items)
 
Glib::SignalProxy< void(guint, guint)> signal_sections_changed ()
 

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

 SectionModel ()
 You should derive from this class to use it. More...
 
virtual void get_section_vfunc (guint position, guint & out_start, guint & out_end)
 Return the section that covers the given position. More...
 

Related Functions

(Note that these are not member functions.)

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

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
positionThe 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 
)

◆ 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
positionThe first item that may have changed.
n_itemsNumber of items with changes.

Friends And Related Function Documentation

◆ wrap()

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