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

DlgTrackInfo: Use TrackRecord as model #3906

Merged
merged 16 commits into from
Jun 10, 2021
Merged

DlgTrackInfo: Use TrackRecord as model #3906

merged 16 commits into from
Jun 10, 2021

Conversation

uklotzde
Copy link
Contributor

@uklotzde uklotzde commented May 25, 2021

Save all edits temporarily in a local TrackRecord and replace them in the
Track object all at once on apply. This is required to keep the properties
in sync and valid while editing. Validation should not be done by the
dialog itself but by TrackRecord which serves as the model that contains
the domain logic.

This change becomes crucial when properties dependent on each other,
e.g. when storing genres both as multiple, custom tags and redundantly
formatted in a text property. Those properties need to be synchronized
mutually with each other.

The control and data flow is still far from perfect but it is hopefully a first
step in the right direction.

Should also fix https://bugs.launchpad.net/mixxx/+bug/1929311/comments/18

@uklotzde uklotzde added this to the 2.4.0 milestone May 25, 2021
Save all edits temporarily in a local TrackRecord and replace them in the
Track object all at once on apply. This is required to keep the properties
in sync and valid while editing. Validation should not be done by the
dialog itself but by TrackRecord which serves as the model that contains
the domain logic.

This change becomes crucial when properties dependent on each other,
e.g. when storing genres both as multiple, custom tags and redundantly
formatted in a text property. Those properties need to be synchronized
mutually with each other.
@uklotzde uklotzde marked this pull request as ready for review May 25, 2021 10:42
@Holzhaus
Copy link
Member

I suppose this conflicts a bit with #3924, right? Can we return a QFlags when replacing the trackrecord that reflects which values actually changed and then emit changed signals on the track?

Copy link
Member

@Holzhaus Holzhaus left a comment

Choose a reason for hiding this comment

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

The Track edit dialog acts weird with this PR. When hitting "Apply", values disappear:
Peek 2021-05-29 18-52

@uklotzde
Copy link
Contributor Author

uklotzde commented May 29, 2021

@Holzhaus Thanks for testing! Editing the genre field works differently with custom tags. I forgot to add the signal handler that is needed temporarily until custom tags are ready.

I also found another the other minor initialization bug in the opposite direction when populating fields. Rust would have saved me from making such an obvious mistake ;)

@uklotzde
Copy link
Contributor Author

I suppose this conflicts a bit with #3924, right? Can we return a QFlags when replacing the trackrecord that reflects which values actually changed and then emit changed signals on the track?

Unrelated. The flags would need to be passed internally to Track::emitMetadataChanged() within Track.

@Holzhaus
Copy link
Member

Holzhaus commented Jun 9, 2021

If I change the Genre, the key disappears:

Peek 2021-06-09 12-41

Copy link
Member

@Holzhaus Holzhaus left a comment

Choose a reason for hiding this comment

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

LGTM. Code changes seem sensible.

Comment on lines +484 to +486
// Special case handling for the comment field that is not
// updated by the editingFinished signal.
m_trackRecord.refMetadata().refTrackInfo().setComment(txtComment->toPlainText());
Copy link
Member

Choose a reason for hiding this comment

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

Why is it not updated by the editingFinished signal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has not changed. Because QPlainTextEdit only has a textChanged() but no editingFinished() signal?

Copy link
Member

Choose a reason for hiding this comment

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

OK, I was just wondering.

@uklotzde
Copy link
Contributor Author

uklotzde commented Jun 9, 2021

@Holzhaus I force pushed the last commit, which was not finished yet.

The changes not only fix the key text synchronization bug but also remove redundant code and improve the data binding with TrackRecord. Only done for the key field, yet. With the introduction of QML we need to rethink all data bindings anyway and come up with consistent patterns and naming.

@Holzhaus
Copy link
Member

Holzhaus commented Jun 9, 2021

With the introduction of QML we need to rethink all data bindings anyway and come up with consistent patterns and naming.

With our current QML implementation we can keep using legacy widgets such as the DlgTrackInfo side by side. In the long-term: Yes.

@uklotzde
Copy link
Contributor Author

uklotzde commented Jun 9, 2021

This was also a perfect example for marking a data type as [[nodiscard]].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants