SliceListModel#

class SliceListModel(**properties: Any)#

Superclasses: Object

Implemented Interfaces: ListModel, 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#

class SliceListModel
classmethod new(model: ListModel | None, offset: int, size: int) SliceListModel#

Creates a new slice model.

It presents the slice from offset to offset + size of the given model.

Parameters:
  • model – The model to use

  • offset – the offset of the slice

  • size – maximum size of the slice

Methods#

class SliceListModel
get_model() ListModel | None#

Gets the model that is currently being used or None if none.

get_offset() int#

Gets the offset set via set_offset().

get_size() int#

Gets the size set via set_size().

set_model(model: ListModel | None = None) None#

Sets the model to show a slice of.

The model’s item type must conform to self’s item type.

Parameters:

model – The model to be sliced

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.

Parameters:

offset – the new offset to use

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.

Parameters:

size – the maximum size

Properties#

class SliceListModel
props.item_type: type#

The type of the None singleton.

Added in version 4.8.

props.model: ListModel#

The type of the None singleton.

props.n_items: int#

The type of the None singleton.

Added in version 4.8.

props.offset: int#

The type of the None singleton.

props.size: int#

The type of the None singleton.