Gtk.FilterListModel¶
- Subclasses:
None
Methods¶
- Inherited:
GObject.Object (37), Gio.ListModel (4), Gtk.SectionModel (2)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r |
|||
r/w/en |
|||
r |
|||
r/en |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gtk.FilterListModel(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
GtkFilterListModel
is a list model that filters the elements of the underlying model according to aGtkFilter
.It hides some elements from the other model according to criteria given by a
GtkFilter
.The model can be set up to do incremental filtering, so that filtering long lists doesn’t block the UI. See [method`Gtk`.FilterListModel.set_incremental] for details.
GtkFilterListModel
passes through sections from the underlying model.- classmethod new(model, filter)[source]¶
- Parameters:
model (
Gio.ListModel
orNone
) – the model to sortfilter (
Gtk.Filter
orNone
) – filter
- Returns:
a new
GtkFilterListModel
- Return type:
Creates a new
GtkFilterListModel
that will filter model using the given filter.
- get_filter()[source]¶
- Returns:
The filter currently in use
- Return type:
Gtk.Filter
orNone
Gets the
GtkFilter
currently set on self.
- get_incremental()[source]¶
-
Returns whether incremental filtering is enabled.
See [method`Gtk`.FilterListModel.set_incremental].
- get_model()[source]¶
- Returns:
The model that gets filtered
- Return type:
Gets the model currently filtered or
None
if none.
- get_pending()[source]¶
- Returns:
The number of items not yet filtered
- Return type:
Returns the number of items that have not been filtered yet.
You can use this value to check if self is busy filtering by comparing the return value to 0 or you can compute the percentage of the filter remaining by dividing the return value by the total number of items in the underlying model:
``c pending = gtk_filter_list_model_get_pending (self); model = gtk_filter_list_model_get_model (self); percentage = pending / (double) g_list_model_get_n_items (model); ``
If no filter operation is ongoing - in particular when [property`Gtk`.FilterListModel:incremental] is
False
- this function returns 0.
- set_filter(filter)[source]¶
- Parameters:
filter (
Gtk.Filter
orNone
) – filter to use
Sets the filter used to filter items.
- set_incremental(incremental)[source]¶
-
Sets the filter model to do an incremental sort.
When incremental filtering is enabled, the
GtkFilterListModel
will not run filters immediately, but will instead queue an idle handler that incrementally filters the items and adds them to the list. This of course means that items are not instantly added to the list, but only appear incrementally.When your filter blocks the UI while filtering, you might consider turning this on. Depending on your model and filters, this may become interesting around 10,000 to 100,000 items.
By default, incremental filtering is disabled.
See [method`Gtk`.FilterListModel.get_pending] for progress information about an ongoing incremental filtering operation.
- set_model(model)[source]¶
- Parameters:
model (
Gio.ListModel
orNone
) – The model to be filtered
Sets the model to be filtered.
Note that GTK makes no effort to ensure that model conforms to the item type of self. It assumes that the caller knows what they are doing and have set up an appropriate filter to ensure that item types match.
Property Details¶
- Gtk.FilterListModel.props.filter¶
- Name:
filter
- Type:
- Default Value:
- Flags:
The filter for this model.
- Gtk.FilterListModel.props.incremental¶
- Name:
incremental
- Type:
- Default Value:
- Flags:
If the model should filter items incrementally.
- Gtk.FilterListModel.props.item_type¶
- Name:
item-type
- Type:
- Default Value:
<GType GObject>
- Flags:
The type of items. See [method`Gio`.ListModel.get_item_type].
New in version 4.8.
- Gtk.FilterListModel.props.model¶
- Name:
model
- Type:
- Default Value:
- Flags:
The model being filtered.
- Gtk.FilterListModel.props.n_items¶
-
The number of items. See [method`Gio`.ListModel.get_n_items].
New in version 4.8.
- Gtk.FilterListModel.props.pending¶
- Name:
pending
- Type:
- Default Value:
0
- Flags:
Number of items not yet filtered.