mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
added get_selected_instances method to be able use it in multiple places
This commit is contained in:
parent
9f4a2630b8
commit
1290312f4e
1 changed files with 17 additions and 10 deletions
|
|
@ -183,6 +183,21 @@ class PublisherWindow(QtWidgets.QWidget):
|
|||
def set_context_label(self, label):
|
||||
self.context_label.setText(label)
|
||||
|
||||
def get_selected_instances(self):
|
||||
instances = []
|
||||
instances_by_id = {}
|
||||
for instance in self.controller.instances:
|
||||
instance_id = instance.data["uuid"]
|
||||
instances_by_id[instance_id] = instance
|
||||
|
||||
for index in self.subset_view.selectionModel().selectedIndexes():
|
||||
instance_id = index.data(QtCore.Qt.UserRole)
|
||||
instance = instances_by_id.get(instance_id)
|
||||
if instance:
|
||||
instances.append(instance)
|
||||
|
||||
return instances
|
||||
|
||||
def _on_reset_clicked(self):
|
||||
self.reset()
|
||||
|
||||
|
|
@ -236,17 +251,9 @@ class PublisherWindow(QtWidgets.QWidget):
|
|||
self._refresh_instances()
|
||||
|
||||
def _on_subset_change(self, *_args):
|
||||
instances = []
|
||||
instances_by_id = {}
|
||||
for instance in self.controller.instances:
|
||||
instance_id = instance.data["uuid"]
|
||||
instances_by_id[instance_id] = instance
|
||||
instances = self.get_selected_instances()
|
||||
|
||||
for index in self.subset_view.selectionModel().selectedIndexes():
|
||||
instance_id = index.data(QtCore.Qt.UserRole)
|
||||
instance = instances_by_id.get(instance_id)
|
||||
if instance:
|
||||
instances.append(instance)
|
||||
self.delete_btn.setEnabled(len(instances) >= 0)
|
||||
|
||||
self.subset_attributes_widget.set_current_instances(instances)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue