Move code from _update_imagelist_state() to metadataitem_update_metadata_images()

This commit is contained in:
Laurent Monin
2024-05-22 22:18:13 +02:00
parent 2aa4e12525
commit 84f4ca3f48

View File

@@ -238,10 +238,24 @@ class MetadataItem(Item):
return changed
def _update_imagelist_state(self, state):
def metadataitem_update_metadata_images(self):
"""Update the metadata images of the current object based on its children.
Based on the type of the current object, this will update `self.metadata.images` to
represent the metadata images of all children (`Track` or `File` objects).
This method will iterate over all children and completely rebuild
`self.metadata.images`. Whenever possible the more specific functions
`add_metadata_images` or `remove_metadata_images` should be used.
Returns:
bool: True, if images where changed, False otherwise
"""
from picard.track import Track
from picard.util.imagelist import ImageList
state = self._get_imagelist_state()
changed = False
for src_obj in state.sources:
state.process_images(src_obj, Track)
@@ -260,21 +274,6 @@ class MetadataItem(Item):
return changed
def metadataitem_update_metadata_images(self):
"""Update the metadata images of the current object based on its children.
Based on the type of the current object, this will update `self.metadata.images` to
represent the metadata images of all children (`Track` or `File` objects).
This method will iterate over all children and completely rebuild
`self.metadata.images`. Whenever possible the more specific functions
`add_metadata_images` or `remove_metadata_images` should be used.
Returns:
bool: True, if images where changed, False otherwise
"""
return self._update_imagelist_state(self._get_imagelist_state())
class FileListItem(MetadataItem):