Bug 313880

Summary: "Sort items" choice not respected in the import Dialog box
Product: [Applications] digikam Reporter: Frédéric COIFFIER <frederic.coiffier>
Component: Import-SortAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles, Dieter, falolaf, mfraz74+kde, romain.pub, simon.eu, tpr, wazery
Priority: NOR    
Version: 3.3.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 4.0.0
Sentry Crash Report:

Description Frédéric COIFFIER 2013-01-25 12:30:48 UTC
Tested with Digikam 3.0.0_rc

With the import Dialog box (for SDCard for example), the photos aren't sorted accordingly to the "View > Sort items" choice.
By default, they are sorted "By name" even if "By date" is selected.
Selecting "By xxx" and next "By date" works. But the next time that the dialod box will be opened, photos will still be sorted by name.

Reproducible: Always

Steps to Reproduce:
1. Open the Import Dialog box and select "View > Sort items > By date"
2. Close the dialog box
3. Reopen the import dialog box

Actual Results:  
Photos are sorted by name whereas "By date" is still selected.

Expected Results:  
Photos should be sorted accordingly to the "Sort items" choice
Comment 1 Dieter Rethmeyer 2013-02-23 11:17:21 UTC
This happens as well with the release version 3.0.0. It seems that digikam only applies the changed sort order temporarily  - I expect digikam to save changes in the sort order in the import dialog permantently as it had been up to version 2.9 so I need not apply them each time I want to import photos.
Comment 2 falolaf 2013-03-08 09:32:56 UTC
The same happens with View->Item Sorting Order.
Comment 3 Romain Henriet 2013-05-18 07:45:33 UTC
I confirm this bug in Digikam 3.2.0.
Backward sort allows to quickly show last photos as their thumbnail is computed first. With forward sort, you have to wait for all the photos to be read before selecting the ones you have just taken (I don't always remember to format my card after importing photos).
Comment 4 falolaf 2013-08-19 10:33:21 UTC
Still present in 3.3.0!
Comment 5 Teemu Rytilahti 2013-12-02 16:35:57 UTC
*** Bug 325925 has been marked as a duplicate of this bug. ***
Comment 6 Teemu Rytilahti 2013-12-02 16:36:38 UTC
My comment from another bug, here for the reference:
I can confirm this. The settings are saved properly, but on load the change is not being propagated properly. The relevant code is in digikam/utilities/importui/main/importui.cpp's setupActions(). 

The naming of sorting functions/variables is a bit odd here, "Sorty by x" calls view's slotSortImages(), but the current item is read from ImportSettings::instance()->getImageSortOrder(). For ascending/descending the call goes to slotSortImagesOrder() and the value is read from getImageSorting(). Perhaps those are mixed or should there be separate calls for setting the values on load? I'd suggest renaming those variables nevertheless if possible. SortBy and SortOrder would be better names :-)
Comment 7 Islam Wazery 2014-01-03 20:51:02 UTC
I figured out what is the problem.  In ImportIconView.cpp ln:81 the Filter Model is provided with all the saved sorting, ordering and grouping settings which user last used. This code is well functioning but if it gets called in right time. This code is called mainly from SetupUserArea, in which called before the controller finished its work, so I think we need to have something reporting that controller finished listing all the items. I am now trying to implement that. 

Do you have any ideas for that Teemu?
Comment 8 Teemu Rytilahti 2014-01-03 22:04:35 UTC
Similar thoughs what I had. The information itself gets correctly to the models both ways (when being inserted, when selecting the action from the menu), but the sorting itself is not called when items are being inserted. 

Perhaps there's a missing call to some function or what not to request sorting the items after addition?

How the view is supposed to know from the model, that it should call for sorting?

In my opinion this wouldn't per se require us to know when the listing of all items is ready, though that can be used to avoid multiple updates.