Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Qt.ListModel.ListModel Class Reference
Inheritance diagram for UM.Qt.ListModel.ListModel:
UM.Qt.Bindings.OutputDevicesModel.OutputDevicesModel UM.Qt.Bindings.ProjectOutputDevicesModel.ProjectOutputDevicesModel UM.Qt.Bindings.StageModel.StageModel UM.Settings.Models.ContainerStacksModel.ContainerStacksModel UM.Settings.Models.DefinitionContainersModel.DefinitionContainersModel UM.Settings.Models.InstanceContainersModel.InstanceContainersModel

Public Member Functions

None __init__ (self, parent=None)
int count (self)
int rowCount (self, parent=None)
 addRoleName (self, int role, str name)
 roleNames (self)
 data (self, index, role)
Dict[str, Any] getItem (self, int index)
List[Dict[str, Any]] items (self)
None setItems (self, List[Dict[str, Any]] items)
 appendItem (self, Dict[str, Any] item)
None insertItem (self, int index, Dict[str, Any] item)
None removeItem (self, int index)
None clear (self)
None setProperty (self, int index, str property, Any value)
None sort (self, Callable[[Any], float] fun, Optional[str] key=None, reverse=False)
int find (self, str key, Any value)

Static Public Attributes

 itemsChanged = pyqtSignal()

Protected Attributes

list _items = []
dict _role_names = {}

Detailed Description

Convenience base class for models of a list of items.

This class represents a list of dictionary objects that
can be exposed to QML. It is intended primarily as a read-only
convenience class but supports removing elements so can also be
used for limited writing.

Member Function Documentation

◆ appendItem()

UM.Qt.ListModel.ListModel.appendItem ( self,
Dict[str, Any] item )
Add an item to the list.

:param item: The item to add.

◆ clear()

None UM.Qt.ListModel.ListModel.clear ( self)
Clear the list.

◆ data()

UM.Qt.ListModel.ListModel.data ( self,
index,
role )
Reimplemented from QAbstractListModel

◆ find()

int UM.Qt.ListModel.ListModel.find ( self,
str key,
Any value )
Find a entry by key value pair

:param key:
:param value:
:return: index of setting if found, None otherwise

◆ getItem()

Dict[str, Any] UM.Qt.ListModel.ListModel.getItem ( self,
int index )
Get an item from the list

◆ insertItem()

None UM.Qt.ListModel.ListModel.insertItem ( self,
int index,
Dict[str, Any] item )
Insert an item into the list at an index.

:param index: The index where to insert.
:param item: The item to add.

◆ items()

List[Dict[str, Any]] UM.Qt.ListModel.ListModel.items ( self)
The list of items in this model.

◆ removeItem()

None UM.Qt.ListModel.ListModel.removeItem ( self,
int index )
Remove an item from the list.

:param index: The index of the item to remove.

◆ rowCount()

int UM.Qt.ListModel.ListModel.rowCount ( self,
parent = None )
This function is necessary because it is abstract in QAbstractListModel.

Under the hood, Qt will call this function when it needs to know how
many items are in the model.
This pyqtSlot will not be linked to the itemsChanged signal, so please
use the normal count() function instead.

◆ setItems()

None UM.Qt.ListModel.ListModel.setItems ( self,
List[Dict[str, Any]] items )
Replace all items at once.
:param items: The new list of items.

◆ sort()

None UM.Qt.ListModel.ListModel.sort ( self,
Callable[[Any], float] fun,
Optional[str] key = None,
reverse = False )
Sort the list.

:param fun: The callable to use for determining the sort key.
:param key: Use the sorting function on the underlying data
:param reverse: reverse the sorted results

The documentation for this class was generated from the following file:
  • UM/Qt/ListModel.py