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

Per crate sorting #2046

Closed
wants to merge 45 commits into from
Closed

Per crate sorting #2046

wants to merge 45 commits into from

Conversation

ywwg
Copy link
Member

@ywwg ywwg commented Mar 3, 2019

https://bugs.launchpad.net/mixxx/+bug/1818342

Implements a method to save columns and sort order on a per-crate basis. This change introduces a new signal, unshowTrackModel, that is called by library features before they do work in preparation to do a showtrackmodel. This gives the table view a chance to save state before everything changes.

It's been a while since I've done QT signal/slot stuff, comments welcome!

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

I think this is still work in progress, right.
Please add the [WIP] prefix to the PR title.

I am a worrying about all the additional emit calls required. How do we make sure that we don't forget one?

It would be great if we can find a single place deeper in the call stack where it can be called. Did you already had a look for it?

Alternative we may introduce a wrapper that wraps storing and changing to a new model.

Do we need to consider two or more sittings for a single model? This might be relevant if we are able to show the same model side by side in two pane view.

src/widget/wtracktableview.cpp Show resolved Hide resolved
src/library/crate/cratefeature.cpp Outdated Show resolved Hide resolved
@ywwg ywwg changed the title Per crate sorting [WIP] Per crate sorting Mar 5, 2019
@ywwg
Copy link
Member Author

ywwg commented Apr 10, 2019

thanks for these notes. I'll look again for a better place to send the signal from, but I couldn't find it. I left a long comment in the bug explaining why some obvious simpler options didn't work.

@ywwg
Copy link
Member Author

ywwg commented Apr 13, 2019

I am a worrying about all the additional emit calls required. How do we make sure that we don't forget one?

The method I used was to find all subclasses of LibraryFeature and instrument the activate* methods. The activate functions are called directly (for example, in SidebarModel::doubleClicked) so there's no existing signal I can hook in to.

One possibility might be to have libraryfeature define a base version of Activate from which children inherit, but we'd still have to make sure that the children properly call the base class version before doing their own work.

Another possibility would be to have the callers of the Activate functions also call saveHeaderState, but they don't own the header and this would also be easy to mess up if someone adds a new way to activate a crate and they forget to emit the signal.

If there's somewhere else these could go I am all ears ;)

@ywwg ywwg force-pushed the per-crate-sorting branch from 605e07c to 060da9a Compare April 13, 2019 17:59
@ywwg
Copy link
Member Author

ywwg commented Dec 8, 2019

I finally realized we only need to explicitly save the view state when we are activating a crate, not any of the other ones. So I can remove the signal emits from all the other places in the code. I added comments to explain.

@Holzhaus
Copy link
Member

Holzhaus commented Mar 5, 2020

Btw, the Serato feature has been merged. You can test it with the sample files I provided here: #2480 (comment)

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

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

pre-commit fails due to eol warning

I haven't tested yet.

void WTrackTableView::saveViewState() {
// We save the header state when a track model requests it.
WTrackTableViewHeader* pHeader =
dynamic_cast<WTrackTableViewHeader*>(horizontalHeader());
Copy link
Contributor

Choose a reason for hiding this comment

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

qobject_cast?

@@ -266,12 +275,26 @@ void WTrackTableView::loadTrackModel(QAbstractItemModel *model) {
* there's no need to exchange the headers
* this will cause a small GUI freeze
*/
WTrackTableViewHeader* oldHeader =
Copy link
Contributor

Choose a reason for hiding this comment

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

qobject_cast?

@@ -298,6 +298,8 @@ void CrateFeature::activateChild(const QModelIndex& index) {
VERIFY_OR_DEBUG_ASSERT(crateId.isValid()) {
return;
}
// We need to save the header state now, before we activate a new crate and change track IDs.
emit(saveViewState());
Copy link
Contributor

Choose a reason for hiding this comment

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

emit() is deprecated and will trigger a clazy warning (see also below)

@github-actions github-actions bot added the ui label Oct 22, 2020
@Be-ing Be-ing changed the base branch from master to main October 23, 2020 23:27
@poelzi
Copy link
Contributor

poelzi commented Dec 30, 2020

This patch is very similar to #3063 in case of implemented code. I can add the sorting column there as well, that way all subsystems will remember sorting per view

@ywwg
Copy link
Member Author

ywwg commented Dec 31, 2020

that would be really great -- my patch is sort of abandonned because I could never do tests with serato / rekordbox

poelzi added a commit to poelzi/mixxx that referenced this pull request Jan 2, 2021
Use the model settings to store and restore table header state
for each crate/playlist/etc.
Reimplementation of mixxxdj#2046
@poelzi
Copy link
Contributor

poelzi commented Jan 2, 2021

@ywwg done. Wanna give it a try ?

@github-actions
Copy link

github-actions bot commented Apr 3, 2021

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the stale Stale issues that haven't been updated for a long time. label Apr 3, 2021
@ronso0 ronso0 marked this pull request as draft April 3, 2021 14:34
@ronso0
Copy link
Member

ronso0 commented Apr 3, 2021

superseded by #3063

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library stale Stale issues that haven't been updated for a long time. ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants