Bug 283409 - Dolphin does not remember the order of the selection
Summary: Dolphin does not remember the order of the selection
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: general (show other bugs)
Version: 1.99
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
: 293672 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-05 18:30 UTC by LuRan
Modified: 2013-12-06 00:31 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.13.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description LuRan 2011-10-05 18:30:13 UTC
Version:           unspecified (using Devel) 
OS:                Linux

In 4.7, when open multiple files in dolphin, dolphin will feed the filenames to the target program in the order of selection. For example, if I selected movie3.mp4, movie2.mp4, then movie1.mp4, and open them in mplayer, mplayer will play movie3 first then movie2 and in the end movie1. The new dolphin in the master branch does not seem to have this feature, the files are opened in some random order, starting from movie2 and then movie1 and movie3.

Reproducible: Always

Steps to Reproduce:
Select a few files in some specific order in dolphin and open them in the corresponding program.

Actual Results:  
The files are opened in a different order.

Expected Results:  
The files should be opened in the order I select them.
Comment 1 Frank Reininghaus 2011-10-13 19:09:58 UTC
Thanks for the report!

How do you select the items and open them? I tried (in the 4.7 branch) Control-clicking HTML files and then opening Firefox from the context menu, but the order in which the files are opened seems random to me.

In any case, even if the feature does exist in Dolphin in KDE 4.7, which is based on Qt's itemviews, it would be rather complicated to add this feature (remembering the order in which items are clicked) to Dolphin's new lightweight model/view-framework.

However, I agree that the order should not be random. This would be easy to do by sorting the list of selected indices in DolphinView::selectedItems().

@Peter: What do you think?
Comment 2 Peter Penz 2011-10-13 19:20:56 UTC
> @Peter: What do you think?

I agree that the order should not be random, personally I'd be in favor to just sort them corresponding to their current visual order in the view and not to the selection order. I quite often e.g. select pictures in a rather random order but want them to be inserted in e.g. KMail by their names and not by the order I've selected them. @LuRan: Would this be acceptable for you or do you explicitly want the selection order? My main concern with the selection-order is that when using the rubberband this gets a quite confusing as nobody will notice how the order of the selection has been done.
Comment 3 LuRan 2011-10-14 01:55:44 UTC
@Frank: I have a desktop file executing mplayer %U, and when I open some media files with it the files are played in selection order.
@Peter: I agree this behavior is bizarre in icon mode, actually it is how i discovered this feature, in detail mode it is quite neat though. Maybe a option in configuration?

Anyway if it is too hard to bring this (maybe unintended) feature in a clean way, I guess I can settle with sorting the item with name or the current visual order.
Comment 4 Frank Reininghaus 2011-10-16 18:40:51 UTC
Thanks for the quick reply!

From an implementation point of view, it's *much* easier to sort the items the same way they are sorted in the view. I'll commit a two-line change that does this in a minute. I've verified that it works when dropping attachments in KMail, and I'm pretty sure that it should also work in other situations where the selected items are used in some way. Feel free to check this yourself in the use case you described and leave a note here and reopen the report if it does not work as expected. Thanks.
Comment 5 Frank Reininghaus 2011-10-16 18:41:30 UTC
Git commit a415c9d686fa2cbd8cb63427edad29a55fe15fa7 by Frank Reininghaus.
Committed on 16/10/2011 at 20:39.
Pushed by freininghaus into branch 'master'.

Sort the items in DolphinView::selectedItems()

Before this commit, the order of the items in the list returned by
DolphinView::selectedItems() was random. Now the items are sorted like
they are sorted in the view.
BUG: 283409

M  +3    -0    dolphin/src/views/dolphinview.cpp

http://commits.kde.org/kde-baseapps/a415c9d686fa2cbd8cb63427edad29a55fe15fa7
Comment 6 Frank Reininghaus 2011-10-16 18:47:00 UTC
Git commit f24849a5d90745d49ac6e544e402264a523ad724 by Frank Reininghaus.
Committed on 16/10/2011 at 20:45.
Pushed by freininghaus into branch 'master'.

Sort the items in DolphinView::selectedItems(), part 2

I forgot this change in the last commit.
CCBUG:283409

M  +1    -1    dolphin/src/views/dolphinview.cpp

http://commits.kde.org/kde-baseapps/f24849a5d90745d49ac6e544e402264a523ad724
Comment 7 Frank Reininghaus 2011-10-16 19:23:53 UTC
Hm, I'm not quite sure if my commits really fixed the issue completely. I tried dragging and dropping files to KMail before my commits and found that the items were in random order. Now they are sorted by name in ascending order, like in Dolphin. However, I tried to sort by name in descending order now, but the dropped items in KMail are still in ascending order.

Maybe I overlooked something, or maybe there's some additional source of randomness somewhere in the process. I'll try to look into this further (not today, however, because I don't have the time right now).
Comment 8 Frank Reininghaus 2012-02-21 20:46:05 UTC
I've just noticed that my commits did not really fix the cause of the problem because DolphinView::selectedItems() is not used to determine the items that should be opened in an external application or dragged and dropped (sorting has been removed from that function in the meantime for other reasons, but this does not matter because it is not called in any context where sorting is needed as far as I can say).

To fix this properly, I think we have to do the following things:

1. To sort the items that should be opened: Sort the indexes in
void DolphinView::slotItemsActivated(const QSet<int>& indexes)
before the itemActivated() signal is emitted for each of them.

2. To sort items before a drag-and-drop operation: either
a) Sort the items in KItemListController::startDragging(), and make KItemModelBase::createMimeData() take a QList instead of a QSet, or
b) Sort the items in KFileItemModel::createMimeData().
I would prefer the first approach, because this would solve the issue also for potential other subclasses of KItemModelBase.
Comment 9 Peter Penz 2012-02-22 09:17:53 UTC
I'm fine with 1. + 2-a.

I just thought whether in the longterm it might be easier for us to use QList in the selection-manager instead of QSet but I'm not sure yet whether this will result in some performance penalties. However I'd say if at all then this (-> QList for selection-manager) is something for Dolphin 2.1 and should not be done for the 4.8.x releases.
Comment 10 Frank Reininghaus 2012-06-13 10:41:22 UTC
*** Bug 293672 has been marked as a duplicate of this bug. ***
Comment 11 Jeroen van Meeuwen (Kolab Systems) 2012-08-24 16:19:51 UTC
Resetting assignee to default as per bug #305719
Comment 12 Frank Reininghaus 2013-09-25 16:11:05 UTC
Just for the record: another reason why it does not work fully as expected in the drag&drop case is that KFileItemModel::createMimeData(const QSet<int>& indexes) uses KDirModel::simplifiedUrlList(mostLocalUrls) to remove child URLs, and that this function sorts the "mostLocalUrls" internally.
Comment 13 Frank Reininghaus 2013-12-06 00:28:11 UTC
In Dolphin 4.12, opening multiple selected files in an external program will open them in the same order as they appear in the view. This is a result of the commit

http://quickgit.kde.org/?p=kde-baseapps.git&a=commit&h=5c5d87fec44e7c5934e4b24060200173153f0ff4

When dragging selected items and dropping them in an external application, the order of the files will still be "sort by name in ascending order", no matter what the order in the view is. This will be fixed with my next commit, which will be part of Dolphin 4.13 (or whatever the next release will be called).
Comment 14 Frank Reininghaus 2013-12-06 00:31:41 UTC
Git commit c1ff5204efc8f38530c7906668f1f1645ac07cb6 by Frank Reininghaus.
Committed on 06/12/2013 at 00:11.
Pushed by freininghaus into branch 'master'.

Make KFileItemModel::createMimeData() faster

Moreover, this commit ensures that the order of the URLs in the
QMimeData object is the same as the order of the items in the view.

Selecting many items and copying them to the clipboard could take quite
a bit of time. This is because we used
KDirModel::simplifiedUrlList(urls) to remove child items from the list
of URLs, and this function sorts the URLs internally to make it easier
to find out which of them are child URLs.

However, since commit 5c5d87fec44e7c5934e4b24060200173153f0ff4, the
selected indices are already stored in ascending order, and this makes
it easy to detect if an item is a child of the last item that has been
added to the QMimeData.
REVIEW: 113515
FIXED-IN: 4.13.0

M  +15   -4    dolphin/src/kitemviews/kfileitemmodel.cpp

http://commits.kde.org/kde-baseapps/c1ff5204efc8f38530c7906668f1f1645ac07cb6