mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 06:27:26 -06:00
Use ListModel.setItems() instead of appending one item at a time
setItems sets the items to a (presorted) list of items instead of adding items one by one and then sorting the list. This way if an update to the model causes a signal storm at least it happens only once for an update. Specifically this reduces switching to a dual extrusion printer by half. Contributes to CURA-2193
This commit is contained in:
parent
0e602b8d0b
commit
b343649131
3 changed files with 14 additions and 9 deletions
|
@ -31,7 +31,7 @@ class ContainerSettingsModel(ListModel):
|
|||
self._update()
|
||||
|
||||
def _update(self):
|
||||
self.clear()
|
||||
items = []
|
||||
|
||||
if len(self._container_ids) == 0:
|
||||
return
|
||||
|
@ -64,14 +64,15 @@ class ContainerSettingsModel(ListModel):
|
|||
else:
|
||||
values.append("")
|
||||
|
||||
self.appendItem({
|
||||
items.append({
|
||||
"key": key,
|
||||
"values": values,
|
||||
"label": definition.label,
|
||||
"unit": definition.unit,
|
||||
"category": category.label
|
||||
})
|
||||
self.sort(lambda k: (k["category"], k["key"]))
|
||||
items.sort(key = lambda k: (k["category"], k["key"]))
|
||||
self.setItems(items)
|
||||
|
||||
## Set the ids of the containers which have the settings this model should list.
|
||||
# Also makes sure the model updates when the containers have property changes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue