[Digikam-users] More questions about sort order in folders

Arnd Baecker arnd.baecker at web.de
Tue Jul 8 18:38:32 BST 2008


Hi Chris,

On Tue, 8 Jul 2008, Chris G wrote:

> I have been looking at the code that Arnd pointed me at in reply to my
> previous E-Mail about this:-
>
>     > - I want "View-Sort Albums-By
>     > Date" to do *exactly* that.  I.e. I want the view option to simply
>     > change the sort order of my albums in the 'normal' view of my albums.
>     > Preserve all the hierarchy I have carefully created by sorting each level
>     > within that hiearchy by date.  This is surely quite simple
>
>     The relevant code is in
>       digikam/albumfolderview.cpp
>     namely void AlbumFolderView::resort() which in turn makes
>     use of AlbumFolderViewItem* AlbumFolderView::findParent(...)
>     with calls depending on the value of getAlbumSortOrder().
>
>
> So I have the 0.9.4rc2 version downloaded and compiling

Excellent!

> and I'm
> looking at albumfolderview.cpp.  Specifically I'm looking at
> findParentByFolder() which is called by findParent(...) when the album
> sort is set to "By Folder".
>
> Where does the actual sorting take place?  I.e. when it's set to sort
> "By Folder" who/what/where does the alphabetic sort take place?  I
> want to dive in and change the sort for "View-Sort Albums-By Folder"
> so that I can have the folder hierarchy with a different sort order.
>
> If I find I can change the code fairly easily to do what I want then I
> might even get clever and add the required extra menu items.  It needs
> really to be a sub-menu which appears when you select "View-Sort Albums-By
> Folder" to allow changing to different sort orders within the original
> albums/folders.

After a second look at the code, it seems that I was a bit too fast
with pointing my fingers at this bit of code...

If I understand things correctly,
the actual sorting is in the end done by QListView:
Namely, AlbumFolderView inherits from FolderView
which in turn inherits from QListView.

To sort according to something else, one may either
change the returned key for each item
http://doc.trolltech.com/3.3/qlistviewitem.html#key
or modify the compare function
http://doc.trolltech.com/3.3/qlistviewitem.html#compare

It seems that
int AlbumFolderViewItem::compare(QListViewItem *i, int col, bool
ascending)
does already something like this.
So maybe this, together with the corresponding QListViewItem
needs to be extended?

Gilles, does this sound like the right approach?

> (I am actually a C/C++ programmer, it's been my job since the early
> 1980s)

Oh, that's brilliant (then you do know C++ much better than me ;-)!
Help with the code is always very welcome and I am sure
that your expertise will be valuable.
Note that Gilles is always extremely helpful in explaining the
whereabouts in the code (either via the mailing list or via IRC).

Best, Arnd




More information about the Digikam-users mailing list