don't change active state of mandatory instances

This commit is contained in:
Jakub Trllo 2025-07-03 10:20:03 +02:00
parent 9f69202538
commit 39d011b89f

View file

@ -152,6 +152,8 @@ class InstanceListItemWidget(QtWidgets.QWidget):
self._has_valid_context = None
self._checkbox_enabled = not instance.is_mandatory
self._set_valid_property(context_info.is_valid)
def mouseDoubleClickEvent(self, event):
@ -185,6 +187,10 @@ class InstanceListItemWidget(QtWidgets.QWidget):
self._active_checkbox.setChecked(new_value)
self._active_checkbox.blockSignals(False)
def is_checkbox_enabled(self) -> bool:
"""Checkbox can be changed by user."""
return self._checkbox_enabled
def update_instance(self, instance, context_info):
"""Update instance object."""
# Check product name
@ -206,6 +212,7 @@ class InstanceListItemWidget(QtWidgets.QWidget):
self._active_checkbox.setEnabled(enabled)
def _set_is_mandatory(self, is_mandatory: bool) -> None:
self._checkbox_enabled = not is_mandatory
self._active_checkbox.setVisible(not is_mandatory)
@ -954,11 +961,17 @@ class InstanceListView(AbstractInstanceView):
return
active_by_id = {}
all_changed = True
for row in range(group_item.rowCount()):
item = group_item.child(row)
instance_id = item.data(INSTANCE_ID_ROLE)
if instance_id is not None:
widget = self._widgets_by_id.get(instance_id)
if widget is None:
continue
if widget.is_checkbox_enabled():
active_by_id[instance_id] = active
else:
all_changed = False
self._controller.set_instances_active_state(active_by_id)
@ -968,6 +981,10 @@ class InstanceListView(AbstractInstanceView):
if not self._instance_view.isExpanded(proxy_index):
self._instance_view.expand(proxy_index)
if not all_changed:
# If not all instances were changed, update group checkstate
self._update_group_checkstate(group_name)
def has_items(self):
if self._convertor_group_widget is not None:
return True