From d2f62276de27c1e10713e2a4357d5ce407a4542e Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Fri, 17 May 2024 16:19:20 +0200 Subject: [PATCH] _selected_tags(): make it a generator --- picard/ui/metadatabox.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/picard/ui/metadatabox.py b/picard/ui/metadatabox.py index 6845f09e7ed..85af6934db2 100644 --- a/picard/ui/metadatabox.py +++ b/picard/ui/metadatabox.py @@ -362,7 +362,7 @@ def _get_editor_value(editor): def contextMenuEvent(self, event): menu = QtWidgets.QMenu(self) if self.objects: - tags = self._selected_tags() + tags = list(self._selected_tags()) single_tag = len(tags) == 1 if single_tag: selected_tag = tags[0] @@ -461,7 +461,7 @@ def _edit_tag(self, tag): EditTagDialog(self.parent, tag).exec() def _edit_selected_tag(self): - tags = self._selected_tags(filter_func=self._tag_is_editable) + tags = list(self._selected_tags(filter_func=self._tag_is_editable)) if len(tags) == 1: self._edit_tag(tags[0]) @@ -500,11 +500,10 @@ def _tag_is_editable(self, tag): return self.tag_diff.status[tag] & TagStatus.READONLY == 0 def _selected_tags(self, filter_func=None): - tags = set(self.tag_diff.tag_names[item.row()] - for item in self.selectedItems()) - if filter_func: - tags = filter(filter_func, tags) - return list(tags) + for tag in set(self.tag_diff.tag_names[item.row()] + for item in self.selectedItems()): + if filter_func is None or filter_func(tag): + yield tag def _update_selection(self): files = set()