Gio.ListStore¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
|||
r |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gio.ListStore(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
GListStore
is a simple implementation of [iface`Gio`.ListModel] that stores all items in memory.It provides insertions, deletions, and lookups in logarithmic time with a fast path for the common case of iterating the list linearly.
- classmethod new(item_type)[source]¶
- Parameters:
item_type (
GObject.GType
) – theGObject.GType
of items in the list- Returns:
a new
Gio.ListStore
- Return type:
Creates a new
Gio.ListStore
with items of type item_type. item_type must be a subclass ofGObject.Object
.New in version 2.44.
- append(item)[source]¶
- Parameters:
item (
GObject.Object
) – the new item
Appends item to self. item must be of type
Gio.ListStore
:item-type
.This function takes a ref on item.
Use
Gio.ListStore.splice
() to append multiple items at the same time efficiently.New in version 2.44.
- find(item)[source]¶
- Parameters:
item (
GObject.Object
) – an item- Returns:
Whether self contains item. If it was found, position will be set to the position where item occurred for the first time.
- position:
the first position of item, if it was found.
- Return type:
Looks up the given item in the list store by looping over the items until the first occurrence of item. If item was not found, then position will not be set, and this method will return
False
.If you need to compare the two items with a custom comparison function, use
Gio.ListStore.find_with_equal_func
() with a customGLib.EqualFunc
instead.New in version 2.64.
- find_with_equal_func(item, equal_func)[source]¶
- Parameters:
item (
GObject.Object
orNone
) – an itemequal_func (
GLib.EqualFunc
) – A custom equality check function
- Returns:
Whether self contains item. If it was found, position will be set to the position where item occurred for the first time.
- position:
the first position of item, if it was found.
- Return type:
Looks up the given item in the list store by looping over the items and comparing them with equal_func until the first occurrence of item which matches. If item was not found, then position will not be set, and this method will return
False
.item is always passed as second parameter to equal_func.
Since GLib 2.76 it is possible to pass
NULL
for item.New in version 2.64.
- find_with_equal_func_full(item, equal_func, *user_data)[source]¶
- Parameters:
item (
GObject.Object
orNone
) – an itemequal_func (
GLib.EqualFuncFull
) – A custom equality check function
- Returns:
Whether self contains item. If it was found, position will be set to the position where item occurred for the first time.
- position:
the first position of item, if it was found.
- Return type:
Like
Gio.ListStore.find_with_equal_func
() but with an additional user_data that is passed to equal_func.item is always passed as second parameter to equal_func.
Since GLib 2.76 it is possible to pass
NULL
for item.New in version 2.74.
- insert(position, item)[source]¶
- Parameters:
position (
int
) – the position at which to insert the new itemitem (
GObject.Object
) – the new item
Inserts item into self at position. item must be of type
Gio.ListStore
:item-type
or derived from it. position must be smaller than the length of the list, or equal to it to append.This function takes a ref on item.
Use
Gio.ListStore.splice
() to insert multiple items at the same time efficiently.New in version 2.44.
- insert_sorted(item, compare_func, *user_data)[source]¶
- Parameters:
item (
GObject.Object
) – the new itemcompare_func (
GLib.CompareDataFunc
) – pairwise comparison function for sorting
- Returns:
the position at which item was inserted
- Return type:
Inserts item into self at a position to be determined by the compare_func.
The list must already be sorted before calling this function or the result is undefined. Usually you would approach this by only ever inserting items by way of this function.
This function takes a ref on item.
New in version 2.44.
- remove(position)[source]¶
- Parameters:
position (
int
) – the position of the item that is to be removed
Removes the item from self that is at position. position must be smaller than the current length of the list.
Use
Gio.ListStore.splice
() to remove multiple items at the same time efficiently.New in version 2.44.
- sort(compare_func, *user_data)[source]¶
- Parameters:
compare_func (
GLib.CompareDataFunc
) – pairwise comparison function for sorting
Sort the items in self according to compare_func.
New in version 2.46.
- splice(position, n_removals, additions)[source]¶
- Parameters:
position (
int
) – the position at which to make the changen_removals (
int
) – the number of items to removeadditions ([
GObject.Object
]) – the items to add
Changes self by removing n_removals items and adding n_additions items to it. additions must contain n_additions items of type
Gio.ListStore
:item-type
.None
is not permitted.This function is more efficient than
Gio.ListStore.insert
() andGio.ListStore.remove
(), because it only emitsGio.ListModel
::items-changed
once for the change.This function takes a ref on each item in additions.
The parameters position and n_removals must be correct (ie: position + n_removals must be less than or equal to the length of the list at the time this function is called).
New in version 2.44.
Property Details¶
- Gio.ListStore.props.item_type¶
- Name:
item-type
- Type:
- Default Value:
<GType GObject>
- Flags:
The type of items contained in this list store. Items must be subclasses of
GObject.Object
.New in version 2.44.