Skip to content

Commit

Permalink
_selected_tags(): make it a generator
Browse files Browse the repository at this point in the history
  • Loading branch information
zas committed May 17, 2024
1 parent c8a295c commit d2f6227
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions picard/ui/metadatabox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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])

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit d2f6227

Please sign in to comment.