Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image list cleanup #2488

Merged
merged 43 commits into from
May 26, 2024
Merged

Image list cleanup #2488

merged 43 commits into from
May 26, 2024

Conversation

zas
Copy link
Collaborator

@zas zas commented May 22, 2024

Summary

  • This is a…
    • Bug fix
    • Feature addition
    • Refactoring
    • Minor / simple change (like a typo)
    • Other
  • Describe this change in 1-2 sentences:

Problem

  • JIRA ticket (optional): PICARD-XXX

Solution

Action

Additional actions required:

  • Update Picard documentation (please include a reference to this PR)
  • Other (please specify below)

@zas zas force-pushed the image_list_cleanup branch 4 times, most recently from 42e08b2 to a2c1ea5 Compare May 22, 2024 21:13
zas added 20 commits May 23, 2024 10:05
- classes defined here are mainly used at top level
- they aren't specific to UI, as they are used to define important classes like Cluster, Album, etc...
- there's not even any Qt import in there
It defines:
- metadata & orig_metadata properties
- metadata_images_changed signal
- move methods related to metadata from FileListItem to it
- it doesn't belong here anyway
- it depends on an object passed as obj -> self
- transitional: local imports
…item_update_metadata_images()

The long name is to avoid conflicts with existing update_metadata_images() in Album/Cluster
Called from MetadataItem._get_imagelist_state()
Then pass them to ImageListState() constructor
Those don't change, and are only set to True for Album & FileItem
…ources using it

It is much cleaner.
The new method is named `children_metadata_items()`
Compatibility preserved defining matching `@property`, that's transitional
@zas zas requested a review from phw May 23, 2024 13:00
@zas zas marked this pull request as ready for review May 23, 2024 13:00
@phw
Copy link
Member

phw commented May 25, 2024

@zas I started reviewing, but I'm not through it yet. But so far this looks really good.

About the issue with Item: I actially suspect that initial intention was indeed that Item is more UI related. But it didn't turn out this way. For the UI part there are the TreeItem classes.

The Item class gained stuff over the years. And this shows another oddity: I don't think the DataObj class has any reason to exist. It looks like this was kind of the non-UI base class. But I think the stuff there should actually be put into Item or your MetadataItem class. That way we also avoid the awkward multiple inheritance for many of the classes, without clear distinction what does what.

We can do this in a separate refactoring, but here is my short comment on the DataObj members:

class DataObject(LockableObject):

    def __init__(self, obj_id):
        super().__init__()
        self.id = obj_id  # Probably best placed in MetadataItem
        self.item = None  # I think this should go to Item, likely with a different name (ui_item ?)
        self._genres = Counter() # -> MetadataItem

    @property
    def genres(self): # -> MetadataItem
        ...

    def add_genre(self, name, count): # -> MetadataItem
        ...

    @staticmethod
    def set_genre_inc_params(inc, config=None): # -> MetadataItem
        ...

@zas
Copy link
Collaborator Author

zas commented May 25, 2024

I don't think the DataObj class has any reason to exist.

I agree, let's first merge this and then we can fix that. This PR is big enough.

Copy link
Member

@phw phw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great move. While reviewing the commits I had a couple of comments, but they were all addressed later on.

I'd be in favor of avoiding inline declaration. I think it harms readability. Also the type is recreated on every function call, which seems wasteful.

Apart from that LGTM.

picard/item.py Show resolved Hide resolved
@zas zas merged commit 5f21a6b into metabrainz:master May 26, 2024
45 checks passed
@zas zas deleted the image_list_cleanup branch May 26, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants