Uranium
Application Framework
UM.Qt.ListModel.ListModel Class Reference

Convenience base class for models of a list of items. More...

Inheritance diagram for UM.Qt.ListModel.ListModel:
UM.Qt.Bindings.OutputDevicesModel.OutputDevicesModel 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)
 
def addRoleName (self, int role, str name)
 
def roleNames (self)
 
def data (self, index, role)
 Reimplemented from QAbstractListModel.
 
Dict[str, Any] getItem (self, int index)
 
List[Dict[str, Any]] items (self)
 
None setItems (self, List[Dict[str, Any]] items)
 Replace all items at once. More...
 
def appendItem (self, Dict[str, Any] item)
 Add an item to the list. More...
 
None insertItem (self, int index, Dict[str, Any] item)
 Insert an item into the list at an index. More...
 
None removeItem (self, int index)
 Remove an item from the list. More...
 
None clear (self)
 Clear the list. More...
 
None setProperty (self, int index, str property, Any value)
 
None sort (self, Callable[[Any], float] fun)
 Sort the list. More...
 
int find (self, str key, Any value)
 

Static Public Attributes

 itemsChanged = pyqtSignal()
 
 int
 Get an item from the list.
 
 notify
 The list of items in this model. More...
 
 result
 This function is necessary because it is abstract in QAbstractListModel. More...
 
 str
 Find a entry by key value pair. More...
 
 QVariant
 

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()

def UM.Qt.ListModel.ListModel.appendItem (   self,
Dict[str, Any]  item 
)

Add an item to the list.

Parameters
itemThe item to add.

◆ clear()

None UM.Qt.ListModel.ListModel.clear (   self)

Clear 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.

Parameters
indexThe index where to insert.
itemThe item to add.

◆ removeItem()

None UM.Qt.ListModel.ListModel.removeItem (   self,
int  index 
)

Remove an item from the list.

Parameters
indexThe index of the item to remove.

◆ setItems()

None UM.Qt.ListModel.ListModel.setItems (   self,
List[Dict[str, Any]]  items 
)

Replace all items at once.

Parameters
itemsThe new list of items.

◆ sort()

None UM.Qt.ListModel.ListModel.sort (   self,
Callable[[Any], float]  fun 
)

Sort the list.

Parameters
funThe callable to use for determining the sort key.

Member Data Documentation

◆ notify

UM.Qt.ListModel.ListModel.notify
static

The list of items in this model.

◆ result

UM.Qt.ListModel.ListModel.result
static

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.

◆ str

UM.Qt.ListModel.ListModel.str
static

Find a entry by key value pair.

Parameters
key
value
Returns
index of setting if found, None otherwise

The documentation for this class was generated from the following file: