Skip to content

Gtk.FlattenListModel

class — extends GObject.Object, Gio.ListModel, SectionModel

A list model that concatenates other list models.

GtkFlattenListModel takes a list model containing list models, and flattens it into a single model. Each list model becomes a section in the single model.

Constructors

new

@classmethod
def new(cls, model: Gio.ListModel | None = ...) -> FlattenListModel

Creates a new GtkFlattenListModel that flattens list.

Parameters:

  • model — the model to be flattened

Methods

get_model

def get_model(self) -> Gio.ListModel | None

Gets the model set via FlattenListModel.set_model.

get_model_for_item

def get_model_for_item(self, position: int) -> Gio.ListModel | None

Returns the model containing the item at the given position.

Parameters:

  • position — a position

set_model

def set_model(self, model: Gio.ListModel | None = ...) -> None

Sets a new model to be flattened.

Parameters:

  • model — the new model

Properties

item_type

item_type: type | GObject.Type  # read-only

The type of items. See Gio.ListModel.get_item_type.

model

model: Gio.ListModel  # read/write

The model being flattened.

n_items

n_items: int  # read-only

The number of items. See Gio.ListModel.get_n_items.