-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Playlists: allow to adopt current order (sorted) as playlist order #15319
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
base: main
Are you sure you want to change the base?
Conversation
169868d
to
8686932
Compare
Haven't looked at this or tested, thank you for picking this up. I also tried to implement this a while ago but failed back then. |
|
||
//qDebug() << "Swapping tracks " << trackAPosition << " and " << trackBPosition; | ||
trackPositionIds.insert(trackAPosition, trackBId); | ||
trackPositionIds.insert(trackBPosition, trackAId); | ||
// qDebug() << "Swapping tracks " << trackAPosition << " and " << trackBPosition; |
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.
huh?
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.
hmm.. whoopsy?
for (auto oldIdAndPos : newOrder) { | ||
int oldPos = oldIdAndPos.second; | ||
const TrackId trackId = oldIdAndPos.first; |
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.
NIT: you should be able to use destructuring on a pair
for (auto oldIdAndPos : newOrder) { | |
int oldPos = oldIdAndPos.second; | |
const TrackId trackId = oldIdAndPos.first; | |
for (auto [trackId, oldPos] : newOrder) { |
// Print out any SQL error, if there was one. | ||
if (query.lastError().isValid()) { | ||
qDebug() << query.lastError(); | ||
} |
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.
dumb question: will this run if there was an error? Don't we just return then?
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.
Idk 🤷♂️
I adopted it from the other methods.
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.
right, but those don't return early for failed queries, right?
if (newOrder.isEmpty() || playlistId == kInvalidPlaylistId) { | ||
return; | ||
} |
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 also check that newOrder.size()
matches the playlist 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.
Hmmmaybe.. why not.
FWIWI also had in mind that we might use this for AutoDJ and then we'd need to exclude the first track which is already loaded as "next" (like in AutoDJ's own Shuffle function)
QList<std::pair<TrackId, int>> idPosList; | ||
int numOfTracks = rowCount(); |
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.
NIT:
QList<std::pair<TrackId, int>> idPosList; | |
int numOfTracks = rowCount(); | |
QList<std::pair<TrackId, int>> idPosList; | |
int numOfTracks = rowCount(); | |
idPosList.reserve(numOfTracks); |
cuz why not
pTrackModel->orderTracksByCurrPos(); | ||
// TODO should we resort by # ?? |
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.
can you elaborate?
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.
I wonder whether we should now sort by #, like is that what the user wants to see/use after adopting the order?
Probably yes, but my coffee break was over ; )
Also, if yes, PlaylistDAO::orderTracksByCurrPos
should return true on succes, and only then we re-sort (for good UX)
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.
yeah, I agree.
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.
I'll try to implement it.
(I think I recently looked at the Shuffle action for Tracks, Crates which is also in the header) |
Closes #15315
I decided for a separate function instead of doing multiple
moveTrack
.