More questions about sort order in folders

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

More questions about sort order in folders

Chris Green
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 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.

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

--
Chris Green
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Arnd Baecker
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

_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Chris Green
On Tue, Jul 08, 2008 at 07:38:32PM +0200, Arnd Baecker wrote:

> >
> > 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?
>
OK, thanks, that looks more like the right[ish] place, I'll do some
digging around and see if I can understand it.

> 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 ;-)!

I work on Sun Solaris systems, mostly on legacy code written in C and
C++ but also some Java.  I'm only working part-time now as I approach
retirement (I'm 61).

> 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).
>
Thanks for the pointers, as I said I'll dig around a bit and probably
come back with more questions soon.

--
Chris Green
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Chris Green
On Wed, Jul 09, 2008 at 08:07:09PM +0100, Chris G wrote:

> On Tue, Jul 08, 2008 at 07:38:32PM +0200, Arnd Baecker wrote:
> >
> > 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?
> >
> OK, thanks, that looks more like the right[ish] place, I'll do some
> digging around and see if I can understand it.
>
... and after a bit of looking around and fiddling I have got things
to work the way I want!  :-)

Currently all I have done is to replace the alphabetical sort in "Sort
Albums - By Folder" with a sort by the date set in the album properties.
So now I can set the dates in album properties and I get the albums in
folder view in chronological order - whoopee!  :-)

Would you like this developed a little further so that one can switch
from alphabetical to chronological sorting?  Presumably the way to do
this would be to add an extra menu option so there is:-

    Sort Albums - By Folder Alphabetical
                  By Folder Chronological
                  By Collection
                  By Date

Another thing I would like to add is the ability to force a resort,
currently one has to switch to a different "Sort Albums" option and
back again to force a resort.

Is this change of general interest or shall I just keep it as a
private patch which I apply for my own use only?

--
Chris Green
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Bugzilla from daniel.svard@gmail.com

On Thu, Jul 10, 2008 at 6:32 AM, Chris G <[hidden email]> wrote:
... and after a bit of looking around and fiddling I have got things
to work the way I want!  :-)

Currently all I have done is to replace the alphabetical sort in "Sort
Albums - By Folder" with a sort by the date set in the album properties.
So now I can set the dates in album properties and I get the albums in
folder view in chronological order - whoopee!  :-)

Would you like this developed a little further so that one can switch
from alphabetical to chronological sorting?  Presumably the way to do
this would be to add an extra menu option so there is:-

   Sort Albums - By Folder Alphabetical
                 By Folder Chronological
                 By Collection
                 By Date

Another thing I would like to add is the ability to force a resort,
currently one has to switch to a different "Sort Albums" option and
back again to force a resort.

Is this change of general interest or shall I just keep it as a
private patch which I apply for my own use only?

Hi Chris,

I know at least I would enjoy this option for sorting my album list. It would probably help me with setting the date property on them properly too. Making it a menu choice would probably be a good idea as to not remove the alphabetical sort option.

So please, do share.

Regards,
Daniel Svärd

_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Arnd Baecker
In reply to this post by Chris Green
On Wed, 9 Jul 2008, Chris G wrote:

> On Wed, Jul 09, 2008 at 08:07:09PM +0100, Chris G wrote:
> > On Tue, Jul 08, 2008 at 07:38:32PM +0200, Arnd Baecker wrote:
> > >
> > > 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?
> > >
> > OK, thanks, that looks more like the right[ish] place, I'll do some
> > digging around and see if I can understand it.
> >
> ... and after a bit of looking around and fiddling I have got things
> to work the way I want!  :-)
>
> Currently all I have done is to replace the alphabetical sort in "Sort
> Albums - By Folder" with a sort by the date set in the album properties.
> So now I can set the dates in album properties and I get the albums in
> folder view in chronological order - whoopee!  :-)

That's excellent!

> Would you like this developed a little further so that one can switch
> from alphabetical to chronological sorting?  Presumably the way to do
> this would be to add an extra menu option so there is:-
>
>     Sort Albums - By Folder Alphabetical
>                   By Folder Chronological
>                   By Collection
>                   By Date

Sounds good to me.
Gilles, Marcel, what do you think?

> Another thing I would like to add is the ability to force a resort,
> currently one has to switch to a different "Sort Albums" option and
> back again to force a resort.

In which situation do you want to enforce a resort?

> Is this change of general interest or shall I just keep it as a
> private patch which I apply for my own use only?

As far as I can say this is clearly of general interest.

Could you attach your current patch at
https://bugs.kde.org/show_bug.cgi?id=156186
as it addresses the first part of the wish there?
At this point the patch need not be polished etc.,
but I (and others) can have a look at it.

Thanks a lot!

Best, Arnd

P.S. I think your patch would also solve
https://bugs.kde.org/show_bug.cgi?id=158868

Also we should keep in mind that there are some issues
related to computing the right date for an album:
- "Change date of album to exif date of first image"
  https://bugs.kde.org/show_bug.cgi?id=89364
- "Album date average incorrect"
  https://bugs.kde.org/show_bug.cgi?id=121460
  (We need to check whether this one is still happening in current svn...)
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Chris Green
On Thu, Jul 10, 2008 at 03:53:10AM +0200, Arnd Baecker wrote:

> On Wed, 9 Jul 2008, Chris G wrote:
>
> > On Wed, Jul 09, 2008 at 08:07:09PM +0100, Chris G wrote:
> > > On Tue, Jul 08, 2008 at 07:38:32PM +0200, Arnd Baecker wrote:
> > > >
> > > > 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?
> > > >
> > > OK, thanks, that looks more like the right[ish] place, I'll do some
> > > digging around and see if I can understand it.
> > >
> > ... and after a bit of looking around and fiddling I have got things
> > to work the way I want!  :-)
> >
> > Currently all I have done is to replace the alphabetical sort in "Sort
> > Albums - By Folder" with a sort by the date set in the album properties.
> > So now I can set the dates in album properties and I get the albums in
> > folder view in chronological order - whoopee!  :-)
>
> That's excellent!
>
> > Would you like this developed a little further so that one can switch
> > from alphabetical to chronological sorting?  Presumably the way to do
> > this would be to add an extra menu option so there is:-
> >
> >     Sort Albums - By Folder Alphabetical
> >                   By Folder Chronological
> >                   By Collection
> >                   By Date
>
> Sounds good to me.
> Gilles, Marcel, what do you think?
>
> > Another thing I would like to add is the ability to force a resort,
> > currently one has to switch to a different "Sort Albums" option and
> > back again to force a resort.
>
> In which situation do you want to enforce a resort?
>
It would be good to be able to just ask for a resort - menu option
maybe - so that after setting a whole lot of album dates one can
'resort' and see if you've got it right.

> > Is this change of general interest or shall I just keep it as a
> > private patch which I apply for my own use only?
>
> As far as I can say this is clearly of general interest.
>
> Could you attach your current patch at
> https://bugs.kde.org/show_bug.cgi?id=156186
> as it addresses the first part of the wish there?
> At this point the patch need not be polished etc.,
> but I (and others) can have a look at it.
>
OK, I'll try and do that this evening, I need to take advantage of the
weather today to go and clear the last of the ragwort (poisonous plant)
from our fields.

--
Chris Green
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Marcel Wiesweg

> > > Another thing I would like to add is the ability to force a resort,
> > > currently one has to switch to a different "Sort Albums" option and
> > > back again to force a resort.
> >
> > In which situation do you want to enforce a resort?
>
> It would be good to be able to just ask for a resort - menu option
> maybe - so that after setting a whole lot of album dates one can
> 'resort' and see if you've got it right.

I would expect that resorting works immediately - you change the date, the
album is resorted. It may be that we dont currently have the necessary
signals available.
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Chris Green
On Thu, Jul 10, 2008 at 09:57:37PM +0200, Marcel Wiesweg wrote:

>
> > > > Another thing I would like to add is the ability to force a resort,
> > > > currently one has to switch to a different "Sort Albums" option and
> > > > back again to force a resort.
> > >
> > > In which situation do you want to enforce a resort?
> >
> > It would be good to be able to just ask for a resort - menu option
> > maybe - so that after setting a whole lot of album dates one can
> > 'resort' and see if you've got it right.
>
> I would expect that resorting works immediately - you change the date, the
> album is resorted. It may be that we dont currently have the necessary
> signals available.

No, it's never been like that in the albums/folders.  For example if
you create new albums in an album then while you're doing it they just
appear in the order you create them.  It's only if you exit and
re-enter (or go to a different sort and back) that you get them in
alphabetical order rather then the order you created them.

--
Chris Green
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Chris Green
In reply to this post by Arnd Baecker
On Thu, Jul 10, 2008 at 03:53:10AM +0200, Arnd Baecker wrote:

> > Is this change of general interest or shall I just keep it as a
> > private patch which I apply for my own use only?
>
> As far as I can say this is clearly of general interest.
>
> Could you attach your current patch at
> https://bugs.kde.org/show_bug.cgi?id=156186
> as it addresses the first part of the wish there?
> At this point the patch need not be polished etc.,
> but I (and others) can have a look at it.
>
I have submitted my patch to bugzilla as above, I've just listed it
out as a comment rather than a patch/diff, hope that's OK.  For future
reference is there anywhere that gives a quick description of how to
submit a patch as an attachment?  (Remember I'm a died-in-the-wool
Solaris developer, not used to these new-fangled modern Linux systems!).

--
Chris Green
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Gilles Caulier-4
2008/7/10 Chris G <[hidden email]>:

> On Thu, Jul 10, 2008 at 03:53:10AM +0200, Arnd Baecker wrote:
>> > Is this change of general interest or shall I just keep it as a
>> > private patch which I apply for my own use only?
>>
>> As far as I can say this is clearly of general interest.
>>
>> Could you attach your current patch at
>> https://bugs.kde.org/show_bug.cgi?id=156186
>> as it addresses the first part of the wish there?
>> At this point the patch need not be polished etc.,
>> but I (and others) can have a look at it.
>>
> I have submitted my patch to bugzilla as above, I've just listed it
> out as a comment rather than a patch/diff, hope that's OK.  For future
> reference is there anywhere that gives a quick description of how to
> submit a patch as an attachment?  (Remember I'm a died-in-the-wool
> Solaris developer, not used to these new-fangled modern Linux systems!).
>

Look here :

http://www.digikam.org/drupal/contrib

Gilles Caulier
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Chris Green
On Thu, Jul 10, 2008 at 10:44:09PM +0200, Gilles Caulier wrote:

> 2008/7/10 Chris G <[hidden email]>:
> > On Thu, Jul 10, 2008 at 03:53:10AM +0200, Arnd Baecker wrote:
> >> > Is this change of general interest or shall I just keep it as a
> >> > private patch which I apply for my own use only?
> >>
> >> As far as I can say this is clearly of general interest.
> >>
> >> Could you attach your current patch at
> >> https://bugs.kde.org/show_bug.cgi?id=156186
> >> as it addresses the first part of the wish there?
> >> At this point the patch need not be polished etc.,
> >> but I (and others) can have a look at it.
> >>
> > I have submitted my patch to bugzilla as above, I've just listed it
> > out as a comment rather than a patch/diff, hope that's OK.  For future
> > reference is there anywhere that gives a quick description of how to
> > submit a patch as an attachment?  (Remember I'm a died-in-the-wool
> > Solaris developer, not used to these new-fangled modern Linux systems!).
> >
>
> Look here :
>
> http://www.digikam.org/drupal/contrib
>
Er, yes, but.........   :-)

I have a KDE bugzilla login and know how to use that.  What I don't
have a clue about is svn etc., I need a quick tutorial on that.  As I
said I'm a Solaris person, at work we use a combination of an
antiquated SCCS based code management system and Continuus (commercial).

If I just say (as it suggests at http://www.digikam.org/drupal/contrib)

    svn diff diff.patch

I just get an error

    svn: 'diff.patch' is not a working copy
    svn: Can't open file 'diff.patch/.svn/entries': No such file or directory

Which doesn't surprise me at all as I've not got the code using svn or
anything.

--
Chris Green
_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Arnd Baecker
In reply to this post by Chris Green
Hi Chris,

On Thu, 10 Jul 2008, Chris G wrote:

> On Thu, Jul 10, 2008 at 03:53:10AM +0200, Arnd Baecker wrote:
> > > Is this change of general interest or shall I just keep it as a
> > > private patch which I apply for my own use only?
> >
> > As far as I can say this is clearly of general interest.
> >
> > Could you attach your current patch at
> > https://bugs.kde.org/show_bug.cgi?id=156186
> > as it addresses the first part of the wish there?
> > At this point the patch need not be polished etc.,
> > but I (and others) can have a look at it.
> >
> I have submitted my patch to bugzilla as above, I've just listed it
> out as a comment rather than a patch/diff, hope that's OK.  For future
> reference is there anywhere that gives a quick description of how to
> submit a patch as an attachment?  (Remember I'm a died-in-the-wool
> Solaris developer, not used to these new-fangled modern Linux systems!).

;-)

Well, its still cooking with water, though sometimes
some weird modern spices are thrown to make things look shiny ...

To get a good diff there are two options:

a) # copy the un-modified file

   cp albumfolderview.cpp albumfolderview.cpp_orig
   # make your changes, compile, install and test

   # then do the diff:
   diff -u albumfolderview.cpp_orig albumfolderview.cpp  >  p156186v1.patch

b) much more convient and recommended is to use an svn check-out:
   See http://www.digikam.org/drupal/download?q=download/svn
   under "Install digiKam for KDE3 in your Home Directory"

   The advantage of that installation procedure is
   that it is completely independent from you system installation
   and can be "turned on/off" just by setting (or not setting)
   the corresponding environment variables.

   Note that in the past there were some problems
   when several exiv2 versions are installed; if we are lucky
   this has been solved yesterday by Gilles.

   To create a diff:
     svn diff >  p156186v1.patch

   To revert a patch:
     patch -R < p156186v1.patch

   I usually issue the svn diff command on the graphics level.
   (Not sure if this is optimal or not).

   Sometimes, when applying patches via
      patch -p0 < p156186v1.patch
   the additional "-p0" option is needed.

  Before updating from svn via
    svn up
  it is recommended to un-apply all patches, so that
    svn diff
  does not show any differences.
  Otherwise it might happen that there are conflicts, which one
  then has to correct by hand.
  I.e. I prefer to unapply all patches, do `svn up` and
  then apply the patches again. This seems somehow more controlled to me.

Finally, to upload the patch to the bug tracker (BKO),
just use the "Create a New Attachment" near the bottom of the page
(might be only visible if you are logged in).

Hope this helps, and don't hesitate to ask!

Best, Arnd

P.S.: And now I will try your patch ... ;-)

_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users
Reply | Threaded
Open this post in threaded view
|

Re: More questions about sort order in folders

Marcel Wiesweg
In reply to this post by Chris Green

> I have a KDE bugzilla login and know how to use that.  What I don't
> have a clue about is svn etc., I need a quick tutorial on that.  As I
> said I'm a Solaris person, at work we use a combination of an
> antiquated SCCS based code management system and Continuus (commercial).
>
> If I just say (as it suggests at http://www.digikam.org/drupal/contrib)
>
>     svn diff diff.patch
>
> I just get an error
>
>     svn: 'diff.patch' is not a working copy
>     svn: Can't open file 'diff.patch/.svn/entries': No such file or
> directory

With the line above, you tell svn to give you a diff for the file diff.patch
(which does not exist), like
svn diff digikam/digikamapp.cpp

What you want is

svn diff | less
svn diff > diff.patch

Svn has direct help:

svn help
svn help diff

>
> Which doesn't surprise me at all as I've not got the code using svn or
> anything.


_______________________________________________
Digikam-users mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-users