Bug 404749

Summary: Feature request : Separate items by pick and color labels
Product: [Applications] digikam Reporter: K D Murray <foss>
Component: Albums-SortAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: caulier.gilles, metzpinguin
Priority: NOR    
Version First Reported In: 6.1.0   
Target Milestone: ---   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 9.0.0
Sentry Crash Report:

Description K D Murray 2019-02-23 21:17:58 UTC
SUMMARY

The main album view can be separated into categories through View -> Separate Items -> thing to separate on.


Currently, one can separate by Album or Image format. I'd love it if I could separate by pick rating, such that accepted images are grouped together.


I have experience in C++ programming, including some with Qt, but not the KDE frameworks or digikam. If someone could guide me on where this feature would need to be implemented, I'm happy to provide a patch.
Comment 1 caulier.gilles 2019-02-24 08:33:26 UTC
I Murray,

Thank for your proposal to help us in digiKam project.

Don't be afraid. even if digiKam is stamped as KDE familly application, we drop 85 % of KDE dependencies with new 6.0.0. The goal is to create a pure Qt application in the future, with KDE support as optional. Marble application do it very well.

So a Qt skill is simply enough here.

1/ First, you need to checkout digiKam code. We work currently to "dplugins" branch from git repository, not master.

https://cgit.kde.org/digikam.git/log/?h=development/dplugins


2/ Configure, resolve dependencies, and compile digiKam. Look this documentation for details :

https://www.digikam.org/api/index.html#externaldeps

3/ When application is compiled and installed, you are ready to play with code. The feature that you request in this file is to implement a sort of item by Color Labels or Pick Labels. The sort by Rating is already implemented. The list of options are hosted to MainView/View/Sort Items/... menu entry.

All these menu options are implemented here : 

https://cgit.kde.org/digikam.git/tree/core/app/main/digikamapp_setup.cpp?h=development/dplugins#n523

4/ To route these actions, all are managed by a QSignalMapper which finally call this slot :

https://cgit.kde.org/digikam.git/tree/core/app/views/stack/itemiconview.cpp?h=development/dplugins#n1999

The sort roles is passed by the QSignalMapper map, and it will setup the iconview kind of sort.

The ApplicationSettings call is to remmember the kind of sort between sessions.

This line is the core call to setup the model depending of sort :

d->iconView->imageFilterModel()->setSortRole((ItemSortSettings::SortRole) sortRole);

After to setup the model, a signal is emitted to update the icon view contents. It pass through ApplicationSettings.


5/ Icon view instance is a complex set of derived classes.

The high level is this one :

https://cgit.kde.org/digikam.git/tree/core/app/items/views/digikamitemview.cpp?h=development/dplugins#n79

derived from :

https://cgit.kde.org/digikam.git/tree/core/app/items/views/itemcategorizedview.cpp?h=development/dplugins#n112

derived from :

https://cgit.kde.org/digikam.git/tree/core/libs/widgets/itemview/itemviewcategorized.cpp?h=development/dplugins#n116

derived from :

https://cgit.kde.org/digikam.git/tree/core/libs/widgets/itemview/dcategorizedview.cpp?h=development/dplugins#n53

From this level of classes, this important stuff is the image filter model to setup with role.

This one is returned from 

https://cgit.kde.org/digikam.git/tree/core/app/items/views/itemcategorizedview.cpp?h=development/dplugins#n210

And ItemFilterModel is defined in database models collection and method to set sort rule is implemented here :

https://cgit.kde.org/digikam.git/tree/core/libs/database/models/itemfiltermodel.cpp?h=development/dplugins#n812

...which set the role in sort settings class :

https://cgit.kde.org/digikam.git/tree/core/libs/database/models/itemsortsettings.cpp?h=development/dplugins#n88

6/ the sort mechanism is of course depend of database contents and the models classes must be patched to drive new king of sort. If you look into the model settings class 

There are 2 classes :

https://cgit.kde.org/digikam.git/tree/core/libs/database/models/itemfiltersettings.cpp?h=development/dplugins#n376

... Which is used to filter icon-view item with the right sidebar tab named "Filters". This one already support Pick and Color labels.

https://cgit.kde.org/digikam.git/tree/core/libs/database/models/itemsortsettings.cpp?h=development/dplugins#n255

... used to sort items by criteria from View menu. Pick and color labels rules are not implemented here. 

VoilĂ  for a first start...

Gilles Caulier
Comment 2 caulier.gilles 2020-08-01 15:45:17 UTC
Murray: Ping ???
Comment 3 caulier.gilles 2025-11-30 13:09:46 UTC
Git commit a2a3426e073d77cd25542ba50505a2da3959bf38 by Gilles Caulier.
Committed on 30/11/2025 at 13:09.
Pushed by cgilles into branch 'master'.

Add support of Icon-View sort items by pick labels.

M  +1    -0    NEWS
M  +7    -1    core/app/main/digikamapp_setup.cpp
M  +12   -0    core/libs/database/models/itemsortsettings.cpp
M  +1    -0    core/libs/database/models/itemsortsettings.h

https://invent.kde.org/graphics/digikam/-/commit/a2a3426e073d77cd25542ba50505a2da3959bf38
Comment 4 caulier.gilles 2025-11-30 13:22:00 UTC
Git commit 4a0f3a63a8c3c25dafe171752a10a0b41b039465 by Gilles Caulier.
Committed on 30/11/2025 at 13:21.
Pushed by cgilles into branch 'master'.

Add support of Icon-View sort items by color labels.

M  +4    -0    core/app/main/digikamapp_setup.cpp
M  +12   -0    core/libs/database/models/itemsortsettings.cpp
M  +1    -0    core/libs/database/models/itemsortsettings.h

https://invent.kde.org/graphics/digikam/-/commit/4a0f3a63a8c3c25dafe171752a10a0b41b039465
Comment 5 caulier.gilles 2025-11-30 13:29:31 UTC
Git commit 5cf3253d983992b11718e84185b86452157f2507 by Gilles Caulier.
Committed on 30/11/2025 at 13:29.
Pushed by cgilles into branch 'master'.

Add support of Import Icon-View sort items by pick and color labels.

M  +15   -6    core/utilities/import/main/importui.cpp
M  +10   -0    core/utilities/import/models/camitemsortsettings.cpp
M  +3    -1    core/utilities/import/models/camitemsortsettings.h

https://invent.kde.org/graphics/digikam/-/commit/5cf3253d983992b11718e84185b86452157f2507
Comment 6 caulier.gilles 2025-11-30 14:02:38 UTC
Maik,

The item sort by pick and color labels are implemented for the album icon-view and the import icon-view.

It still one point where sort by rating is supported by not pick and color labels: the plugin interface:

Look here :

https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/database/utils/ifaces/dbinfoiface.cpp?ref_type=heads#L113

In fact this call this method core DB interface :

https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/database/coredb/coredb.cpp?ref_type=heads#L3979

If we would to imitate ByItemRating sorting here for pick and color labels, the way is completely different as pick and color are tags not imageinformation properties:

https://invent.kde.org/graphics/digikam/-/blob/master/core/data/database/dbconfig.xml.cmake.in?ref_type=heads#L378

Q1 : we really need to add support of pick and color label sorting in plugin interface ?
Q2 : if yes, it's already implemented somewhere in the DB interface ?

Gilles
Comment 7 Maik Qualmann 2025-11-30 15:47:43 UTC
Hi Gilles,

I don't think an implementation is necessary anymore. We should remove it completely. If I understand correctly, DBInfoIface::Private::imagesFromPAlbum() is only used by DBInfoIface::allAlbumItems() and DBInfoIface::albumItems(), and this is used by the Media Server Tool.

All other plugins either use the current selection or the currentAlbumItems() function, which uses the Album Manager via the current view.

The problem with the database sorting is that it doesn't necessarily correspond to the actual sorting in the current view. We sort using a QCollator, possibly "Natural," taking versioning into account, etc. The sort direction is also not applied.

Maik
Comment 8 caulier.gilles 2025-11-30 16:35:29 UTC
Interresing. Thanks Maik. So i can close this file now...