:right-sidebar: True SectionModel =================================================================== .. currentmodule:: gi.repository.Gtk .. versionadded:: 4.12 .. class:: SectionModel(*args, **kwargs) :no-contents-entry: Implementations: :class:`~gi.repository.Gtk.FilterListModel`, :class:`~gi.repository.Gtk.FlattenListModel`, :class:`~gi.repository.Gtk.MapListModel`, :class:`~gi.repository.Gtk.MultiSelection`, :class:`~gi.repository.Gtk.NoSelection`, :class:`~gi.repository.Gtk.SingleSelection`, :class:`~gi.repository.Gtk.SliceListModel`, :class:`~gi.repository.Gtk.SortListModel` ``GtkSectionModel`` is an interface that adds support for sections to list models. A ``GtkSectionModel`` groups successive items into so-called sections. List widgets like ``GtkListView`` and ``GtkGridView`` then allow displaying section headers for these sections by installing a header factory. Many GTK list models support sections inherently, or they pass through the sections of a model they are wrapping. When the section groupings of a model change, the model will emit the :obj:`~gi.repository.Gtk.SectionModel.signals.sections_changed` signal by calling the :obj:`~gi.repository.Gtk.SectionModel.sections_changed` function. All sections in the given range then need to be queried again. The :obj:`~gi.repository.Gio.ListModel.signals.items_changed` signal has the same effect, all sections in that range are invalidated, too. Methods ------- .. rst-class:: interim-class .. class:: SectionModel :no-index: .. method:: get_section(position: int) -> ~typing.Tuple[int, int] 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. .. versionadded:: 4.12 :param position: the position of the item to query .. method:: sections_changed(position: int, n_items: int) -> None This function emits the :obj:`~gi.repository.Gtk.SectionModel.signals.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 :obj:`~gi.repository.Gio.ListModel.signals.items_changed` implies the effect of the :obj:`~gi.repository.Gtk.SectionModel.signals.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 :obj:`~gi.repository.Gio.ListModel.signals.items_changed` instead of emitting two signals. .. versionadded:: 4.12 :param position: the first changed item :param n_items: the number of changed items Signals ------- .. rst-class:: interim-class .. class:: SectionModel.signals :no-index: .. method:: sections_changed(position: int, n_items: int) -> None The type of the None singleton. .. versionadded:: 4.12 :param position: The first item that may have changed :param n_items: number of items with changes Virtual Methods --------------- .. rst-class:: interim-class .. class:: SectionModel :no-index: .. method:: do_get_section(position: int) -> ~typing.Tuple[int, int] 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. .. versionadded:: 4.12 :param position: the position of the item to query