-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
… an a wron application layer anyway.
…tAndEnsureTrackIds()
We shouldn't rush these changes into the current release. |
There was a problem hiding this 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.
Yes, don't delay 2.2.2 |
src/library/trackcollection.h
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()
src/library/trackcollection.cpp
Outdated
@@ -87,6 +87,13 @@ void TrackCollection::relocateDirectory(QString oldDir, QString newDir) { | |||
GlobalTrackCacheLocker().relocateCachedTracks(&m_trackDao); | |||
} | |||
|
|||
QList<TrackId> TrackCollection::getAndEnsureTrackIds( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Done. |
src/library/dao/trackdao.h
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping
There was a problem hiding this comment.
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
src/library/autodj/autodjfeature.cpp
Outdated
m_pTrackCollection->unhideTracks(trackIds); | ||
} else { | ||
trackIds = m_pTrackCollection->getTrackDAO().addMultipleTracks(files, true); | ||
if (!files.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEmpty()
src/library/autodj/autodjfeature.cpp
Outdated
options |= TrackDAO::ResolveTrackIdOption::AddMissing; | ||
} | ||
QList<TrackId> trackIds = m_pTrackCollection->resolveTrackIds(files, options); | ||
if (!trackIds.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEmpty()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
src/library/crate/cratefeature.cpp
Outdated
if (!trackIds.at(trackIdIndex).isValid()) { | ||
trackIds.removeAt(trackIdIndex--); | ||
} | ||
if (!files.size()) { |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEmpty()
There was a problem hiding this comment.
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.h
Outdated
@@ -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); |
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEmpty()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
src/library/playlistfeature.cpp
Outdated
// playlist. | ||
// Adds track, does not insert duplicates, handles unremoving logic. | ||
trackIds = m_pTrackCollection->getTrackDAO().addMultipleTracks(files, true); | ||
if (!files.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEmpty()
src/library/dao/trackdao.h
Outdated
@@ -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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
Done, hopefully :-) |
@uklotzde ping. Do the latest changes address all your concerns? |
@daschuer Please replace the remaining !size() with isEmpty(). |
Done. |
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. |
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.