Bug 180404 - Preserve CollectionBrowser ordering when adding to playlist
Summary: Preserve CollectionBrowser ordering when adding to playlist
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Playlist (show other bugs)
Version: 2.3-GIT
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
: 180745 498394 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-01-12 01:04 UTC by Matt Hubert
Modified: 2025-02-10 13:30 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Hubert 2009-01-12 01:04:02 UTC
Version:           2.0.1 (using 4.1.3 (KDE 4.1.3), Kubuntu packages)
Compiler:          cc
OS:                Linux (i686) release 2.6.27-9-generic

If your collection is sorted Genre / Artist / Year - Album, for instance, if you drag an artist into the playlist, it should enter your playlist in the same order displayed in the collection. Currently, it queues it up in alphabetical order. If you have your playlist sorted in descending order, it still queues it in ascending alphabetical order.

Also, even if it was supposed to sort them alphabetically, it does not ignore "The" when queuing artists or albums (as oppose to the collection).
Comment 1 Seb Ruiz 2009-01-14 23:59:43 UTC
I think this is a good improvement
Comment 2 Seb Ruiz 2009-01-14 23:59:49 UTC
*** Bug 180745 has been marked as a duplicate of this bug. ***
Comment 3 Scott Ortell 2009-01-15 00:11:39 UTC
Albums should be loaded in "Ascending" order in the playlist when loaded concurrently with other albums by the same artist.
In other words, as per amarok 1.4.x they would be listed chronologically.
In amarok 1.4.x, the albums were listed in descending order but loaded into the playlist in ascending order. 
This still seems to me to be the most logical approach.
Comment 4 Matt Hubert 2009-01-15 00:58:55 UTC
(In reply to comment #3)
> In other words, as per amarok 1.4.x they would be listed chronologically.
> In amarok 1.4.x, the albums were listed in descending order but loaded into the
> playlist in ascending order. 
> This still seems to me to be the most logical approach.

So even if they are listed descending in the collection, they should be ascending in the playlist? That was indeed the functionality of 1.4.x, and I always considered that broken. If somebody has their collection sorted a certain way, I would assume that is the way in which they want to listen to their music.

Now, there is of course the fact that the CollectionBrowser can't even sort by ascending chronological even if you wanted to. (Which could one day be fixed by 163781.)
Comment 5 Myriam Schweingruber 2010-01-08 20:40:08 UTC
Changing version.
Comment 6 Simeon 2011-12-20 15:36:16 UTC
This wish has been granted.This report should be removed.
Comment 7 Scott Ortell 2011-12-20 19:46:57 UTC
Could you be more specific? 
Is it fixed in svn?
I am using 2.5 and this has not changed at all
Right clicking on an artist in my Collection Browser and choosing Replace Playlist loads them in alphabetic order, which really makes no sense at all since that is effectively random when you consider artists generally dont title their albums in alphabetic order.
The bug was for albums not loading using the CollectionBrowser ordering pattern.
Comment 8 Myriam Schweingruber 2011-12-20 23:52:12 UTC
(In reply to comment #6)
> This wish has been granted.This report should be removed.

So sorry, please disregard this message, there was a misunderstanding with the
Google Code-In student.
Comment 9 Tuomas Nurmi 2025-01-11 21:37:58 UTC
*** Bug 498394 has been marked as a duplicate of this bug. ***
Comment 10 Tuomas Nurmi 2025-01-11 21:43:22 UTC
Both "Add to playlist" and dragging items from collections (codepaths at CollectionTreeItemModelBase::mimeData( const QList<CollectionTreeItem*> &items ) and CollectionTreeView::playChildTracksSlot( Meta::TrackList list ) ) seem to use use
    std::stable_sort( tracks.begin(), tracks.end(), Meta::Track::lessThan );
to sort the tracks to be added. Meta::Track::lessThan compares first disc and track number if same album, then artist name alphabetically, then album name alphabetically. So instead of using that lessThan, some different comparison function that checks the current collection tree ordering would be required. Maybe I'll try implementing (sooner or later).
Comment 11 Bug Janitor Service 2025-01-25 21:27:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/multimedia/amarok/-/merge_requests/139
Comment 12 Tuomas Nurmi 2025-01-25 21:29:25 UTC
Testable code available at https://invent.kde.org/multimedia/amarok/-/merge_requests/139 - touches multiple things, so I'll keep it in branch for some time in case anyone should try out it from there already. Then maybe merge, and have in git master for a long enough time before next release to hopefully uncover any potential issues.
Comment 13 Tuomas Nurmi 2025-01-28 16:57:17 UTC
Git commit 5fce61ded823dcfdec3ed945fabb2c1a34146f50 by Tuomas Nurmi.
Committed on 28/01/2025 at 16:57.
Pushed by nurmi into branch 'master'.

Try to preserve collection browser order when adding tracks to playlist

Boilerplate in previous commit, actual sorting implementation in this one.
Tries to emulate all the things that currently affect sorting in collection
browser. Should handle most of them, but some corner cases remain. At least
in cases where track has multiple labels, the sorting is not necessarily
preserved, and this cannot be reasonably fixed. Some other fixable corner
cases might be still uncovered, though.

M  +4    -0    ChangeLog
M  +8    -0    src/browsers/CollectionSortFilterProxyModel.cpp
M  +1    -0    src/browsers/CollectionSortFilterProxyModel.h
M  +53   -1    src/browsers/CollectionTreeItemModelBase.cpp

https://invent.kde.org/multimedia/amarok/-/commit/5fce61ded823dcfdec3ed945fabb2c1a34146f50
Comment 14 Tuomas Nurmi 2025-01-28 18:12:13 UTC
Ok, noticed a bug in some cases after merging the code. Reverting drag-and-drop order preservation for now, will work out a better solution there. Right click -> add to playlist sorting works correctly, still.
Comment 15 Tuomas Nurmi 2025-01-28 21:00:43 UTC
Git commit 1c40077feee3d9b60ab450da383a175aed2b1ffe by Tuomas Nurmi.
Committed on 28/01/2025 at 19:48.
Pushed by nurmi into branch 'master'.

Preserve track ordering also when drag-dropping from collection browser

To achieve this, currentOrderTrackLessThan needs to be propagated quite a bit further
so it can be used it when processing dropped track list in PlaylistModel.cpp.

Maybe not the cleanest possible solution, but the required changes are not that
extensive, except for testplaylistmodels, during whose compilation a bunch of related
source files needed to be included.

M  +8    -1    src/browsers/CollectionTreeItemModelBase.cpp
M  +8    -0    src/browsers/CollectionTreeView.cpp
M  +3    -0    src/browsers/CollectionTreeView.h
M  +9    -1    src/playlist/PlaylistModel.cpp
M  +13   -0    tests/playlist/CMakeLists.txt

https://invent.kde.org/multimedia/amarok/-/commit/1c40077feee3d9b60ab450da383a175aed2b1ffe
Comment 16 robert marshall 2025-02-10 13:30:09 UTC
Looks good to me - thanks very much!