:right-sidebar: True SliceListModel =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: SliceListModel(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gio.ListModel`, :class:`~gi.repository.Gtk.SectionModel` ``GtkSliceListModel`` is a list model that presents a slice of another model. This is useful when implementing paging by setting the size to the number of elements per page and updating the offset whenever a different page is opened. ``GtkSliceListModel`` passes through sections from the underlying model. Constructors ------------ .. rst-class:: interim-class .. class:: SliceListModel :no-index: .. classmethod:: new(model: ~gi.repository.Gio.ListModel | None, offset: int, size: int) -> ~gi.repository.Gtk.SliceListModel Creates a new slice model. It presents the slice from ``offset`` to offset + ``size`` of the given ``model``\. :param model: The model to use :param offset: the offset of the slice :param size: maximum size of the slice Methods ------- .. rst-class:: interim-class .. class:: SliceListModel :no-index: .. method:: get_model() -> ~gi.repository.Gio.ListModel | None Gets the model that is currently being used or :const:`None` if none. .. method:: get_offset() -> int Gets the offset set via :func:`~gi.repository.Gtk.SliceListModel.set_offset`. .. method:: get_size() -> int Gets the size set via :func:`~gi.repository.Gtk.SliceListModel.set_size`. .. method:: set_model(model: ~gi.repository.Gio.ListModel | None = None) -> None Sets the model to show a slice of. The model's item type must conform to ``self``\'s item type. :param model: The model to be sliced .. method:: set_offset(offset: int) -> None Sets the offset into the original model for this slice. If the offset is too large for the sliced model, ``self`` will end up empty. :param offset: the new offset to use .. method:: set_size(size: int) -> None Sets the maximum size. ``self`` will never have more items than ``size``\. It can however have fewer items if the offset is too large or the model sliced from doesn't have enough items. :param size: the maximum size Properties ---------- .. rst-class:: interim-class .. class:: SliceListModel :no-index: .. attribute:: props.item_type :type: ~gobject.GType The type of the None singleton. .. versionadded:: 4.8 .. attribute:: props.model :type: ~gi.repository.Gio.ListModel The type of the None singleton. .. attribute:: props.n_items :type: int The type of the None singleton. .. versionadded:: 4.8 .. attribute:: props.offset :type: int The type of the None singleton. .. attribute:: props.size :type: int The type of the None singleton.