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

Fix the track order during drag and drop Lp1829601 #2237

Merged
merged 13 commits into from Oct 22, 2019

Conversation

daschuer
Copy link
Member

This fixes the original issue described in https://bugs.launchpad.net/mixxx/+bug/1829601
And introduces some de-duplication and some view update issues.

This can be merged after 2.2.2 if its too late to merge before.

@uklotzde
Copy link
Contributor

We shouldn't rush these changes into the current release.

@uklotzde uklotzde added this to the 2.2.x milestone Aug 13, 2019
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.

On hold until version 2.2.2 has been tagged.

@daschuer
Copy link
Member Author

Yes, don't delay 2.2.2

@daschuer daschuer modified the milestones: 2.2.x, 2.2.3 Aug 15, 2019
@@ -66,6 +66,10 @@ class TrackCollection : public QObject,

void relocateDirectory(QString oldDir, QString newDir);

// This function returns a track ID of all file in the list not already visible,
// it adds and unhides the tracks as well.
QList<TrackId> getAndEnsureTrackIds(const QList<QFileInfo>& files, bool addMissingTracks);
Copy link
Contributor

@uklotzde uklotzde Aug 15, 2019

Choose a reason for hiding this comment

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

The name of this function has to be improved if you need to add detailed comments upon every usage. Also the name "get" doesn't fit if it is not read-only or idempotent.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually the third name of this function. A strong hint that it does to much at once. :-/
Unfortunately this is required for a quick execution.
I was lately fine with this name, but I am happy to change it.

Ideas:
createOrGetTrackIds()
addMissingTracksAndGetAllTrackIds()

@@ -87,6 +87,13 @@ void TrackCollection::relocateDirectory(QString oldDir, QString newDir) {
GlobalTrackCacheLocker().relocateCachedTracks(&m_trackDao);
}

QList<TrackId> TrackCollection::getAndEnsureTrackIds(
Copy link
Contributor

Choose a reason for hiding this comment

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

The function getTrackIds() has already a name that doesn't fit.

Since it is a lookup and mapping "resolveTrackIds()" comes into my mind. But I didn't check how to combine it with the 2 options addMissingTracks and unhideHiddenTracks.

Copy link
Contributor

Choose a reason for hiding this comment

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

The boolean parameter should be replace by an enum that represents a bitmask with the options ADD_MISSING_TRACKS and UNHIDE_HIDDEN_TRACKS.

The function name should contain the word "File", because we are going from files to ids.

But I'm still searching for the right verb that characterizes this operation in a single word. It's difficult, because the operation is so manifold. How about emplaceTrackFiles()? @Be-ing Any suggestions from a native speaker?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe "resolveTrackIds()" it reads well in combination with the descriptive enum parameter.
I will try that.

@daschuer
Copy link
Member Author

Done.

@@ -40,7 +48,7 @@ class TrackDAO : public QObject, public virtual DAO, public virtual GlobalTrackC
void finish();

TrackId getTrackId(const QString& absoluteFilePath);
QList<TrackId> getTrackIds(const QList<QFileInfo>& files, bool addMissingTracks);
QList<TrackId> resolveTrackIds(const QList<QFileInfo>& files, ResolveTrackIdOptions options);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add the default option = ResolveTrackIdOption::ResolveOnly? Would make sense here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping

Copy link
Contributor

Choose a reason for hiding this comment

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

It is not obvious that options contains a mask of flags. Maybe a renaming could help (.h/.cpp)?
ResolveTrackIdOptions options -> ResolveTrackIdFlags flags

m_pTrackCollection->unhideTracks(trackIds);
} else {
trackIds = m_pTrackCollection->getTrackDAO().addMultipleTracks(files, true);
if (!files.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

isEmpty()

options |= TrackDAO::ResolveTrackIdOption::AddMissing;
}
QList<TrackId> trackIds = m_pTrackCollection->resolveTrackIds(files, options);
if (!trackIds.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

isEmpty()

Copy link
Contributor

Choose a reason for hiding this comment

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

ping

if (!trackIds.at(trackIdIndex).isValid()) {
trackIds.removeAt(trackIdIndex--);
}
if (!files.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

isEmpty()

options |= TrackDAO::ResolveTrackIdOption::AddMissing;
}
QList<TrackId> trackIds = m_pTrackCollection->resolveTrackIds(files, options);
if (!trackIds.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

isEmpty()

Copy link
Contributor

Choose a reason for hiding this comment

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

ping

src/library/dao/trackdao.cpp Show resolved Hide resolved
@@ -40,7 +48,7 @@ class TrackDAO : public QObject, public virtual DAO, public virtual GlobalTrackC
void finish();

TrackId getTrackId(const QString& absoluteFilePath);
QList<TrackId> getTrackIds(const QList<QFileInfo>& files, bool addMissingTracks);
QList<TrackId> resolveTrackIds(const QList<QFileInfo>& files, ResolveTrackIdOptions options);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ping

options |= TrackDAO::ResolveTrackIdOption::AddMissing;
}
QList<TrackId> trackIds = m_pTrackCollection->resolveTrackIds(files, options);
if (!trackIds.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

isEmpty()

Copy link
Contributor

Choose a reason for hiding this comment

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

ping

// playlist.
// Adds track, does not insert duplicates, handles unremoving logic.
trackIds = m_pTrackCollection->getTrackDAO().addMultipleTracks(files, true);
if (!files.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

isEmpty()

@@ -40,7 +48,7 @@ class TrackDAO : public QObject, public virtual DAO, public virtual GlobalTrackC
void finish();

TrackId getTrackId(const QString& absoluteFilePath);
QList<TrackId> getTrackIds(const QList<QFileInfo>& files, bool addMissingTracks);
QList<TrackId> resolveTrackIds(const QList<QFileInfo>& files, ResolveTrackIdOptions options);
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not obvious that options contains a mask of flags. Maybe a renaming could help (.h/.cpp)?
ResolveTrackIdOptions options -> ResolveTrackIdFlags flags

@@ -138,26 +138,26 @@ void AutoDJFeature::activate() {
}

bool AutoDJFeature::dropAccept(QList<QUrl> urls, QObject* pSource) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The dropAccept()/dropAcceptChild() contain a lot of duplicated code (AutoDJ/Crates/Playlist). Is It possible to extract this code into a function?

@daschuer
Copy link
Member Author

Done, hopefully :-)

@Be-ing
Copy link
Member

Be-ing commented Sep 29, 2019

@uklotzde ping. Do the latest changes address all your concerns?

@uklotzde
Copy link
Contributor

uklotzde commented Oct 3, 2019

@daschuer Please replace the remaining !size() with isEmpty().

@daschuer
Copy link
Member Author

daschuer commented Oct 3, 2019

Done.

@uklotzde
Copy link
Contributor

Some minor code style issues are still waiting to be fixed. The bug is fixed, though. LGTM.

I'll merge this now to finally close the PR and avoid that more merge conflicts with master appear! Resolving the merge conflicts is already tedious, just managed it for testing.

@uklotzde uklotzde merged commit cb9abf2 into mixxxdj:2.2 Oct 22, 2019
@daschuer daschuer deleted the lp1829601 branch September 26, 2021 17:37
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.

None yet

3 participants