Make KFileItemModel::createMimeData() faster, and ensure that the order of the URLs in the QMimeData object is the same as the order of the items in the view

Review Request #113515 - Created Oct. 30, 2013 and submitted

Frank Reininghaus
Note that the debugging output in DolphinView in this patch is not meant to be pushed to master, it's only there to make the effects of this patch easier to see.

Selecting many items and copying them to the clipboard can take quite a bit of time, and the URLs in the clipboard are always sorted by name in ascending order, no matter how the files are sorted in the view. This is because we use 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.

We can fix this quite easily now, because the selected indexes are now always stored in the view 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.
The URLs in the QMimeData now appear in the same order as in the view.

For benchmarking purposes, I pressed Ctrl+A and Ctrl+C in some folders on my hard drive and measured the time required to create the mime data with the DolphinView part of this patch (which is not meant to be pushed to master):

/usr/include/ (374 items): 27 ms (master) -> 9 ms (patched)

/usr/lib64 (3375 items): 210 ms -> 88 ms

/usr/ in Details View, with /usr/bin/ (3541 items) and /usr/lib64/ expanded: 1258 ms -> 0 ms

So the savings are particularly large when expanded folders are involved, but even in the other cases, this patch saves quite a bit of time.


  • 1
  • 0
  • 0
  • 1
Description From Last Updated
Remove this line Emmanuel Pescosta Emmanuel Pescosta
Emmanuel Pescosta
Emmanuel Pescosta
Commit Hook
Frank Reininghaus
Review request changed

Status: Closed (submitted)