Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#16 sorting patch for Krusader 1.90

krusader_kde3-cvs
open
nobody
5
2008-11-01
2008-11-01
Jacek Jaworski
No

Hi

Thanks to Krusader Krew for program that I use every day!

1. Motivations for this path

In my opinion main annoying thing in Krusader is crazy sorting.

I have directories like: !-download, !-movies, !-documents, !-music,
!-programing, !-install, !-sources and others beginning with "!-".
Aditionaly I have directories names have my national letters.
It is impossible to have these personal directories at the beginning
in the home directory. I use prefix "!-" and I expect that these
directories will appear before any others (it's rational because "!"
character is first printable ASCI character). This problem doesn't
exist under Windows (ie. Total Commader sorts it as I expect), and
it was big suprise when I encounter it under Linux.

This problem is not limited to Krusader, but probably every Linux
file managers have broken sorting. There are two reasons for this:
a) crazy sorting in libc (strcoll() and wcscoll()) - those functions
skips nonalfanumeric characters (who discover such idea???).
b) some simple work around in Krusader (favouritism directories
beginning with "." (dot)) - this is not enough!
Maybe you want always leap over "hidden" directories before you can
reach your "personal" directories, but it is unfriendly and
annoying. More complex solution is needed. I propose fallback to
basics, and sort characters below 128 code by simple compare, and
use QString::localeAwareCompare() when Unicode character is
encounter. But maybe you have good pretext to keep alive "crazy"
sorting. So I think that old sorting method should be an option -
optional sorting methods are already in Total Commader (although it
always have good sorting, and default is sorting whose I propose).

2. New features

a) I wrote 5 different sorting methods which are selectable in
Konfigurator window (in Krusader options window->icon "look and
feel"->tab "panel"->"sorting method" combobox). 4 of them are
inspired by Total Commander, and fifth method is old Krusader
sorting method (added for completnes). There are following sorting
methods:
- Alphabetical - ascii characters are compare by their values, when
unicode character is encounter QString::localeAwareCompare() is
called. It's similar to Total Commander "Alphabetical, considering
accents" algorithm.
- Alphabetical and numbers - same as "Alphabetical" with added
recognizing numbers and properly compare them (in ex. 5 is before
10) - it sorts my /usr/bin/ directory 3 times faster than below
"Krusader" algorithm, and need only 122% time of simplest "Character
code" algorithm. It's similar to Total Commander "Natural sorting:
alphabetical and numbers" algorithm, but improved: numbers are not
before any other characters - it's obvious as they aren't at the
beginning ascii table. This sorting method I propose as default.
- Character code - it sort only by compare characters values, not
care of alphabetical order nor numbers nor special characters. It's
similar to Total Commander "Strictly by numeric character code"
algorithm, but better: unicode characters are in correct order (probably due to better unicode table under Linux).
- Character code and numbers - same as "Character code" with added
recognizing numbers. It's similar to Total Commander "Natural
sorting: by character code and numbers" algorithm.
- Krusader - similar (or identical) to original Krusader sorting
algorithm - it favourite directories with "." (dot) at the
beginning, skips non alphanumeric characters when compare. This
algorithm doesn't exist in Total Comander (for good luck!). I doubt
that someone want use it, but maybe someone want try it and compare
it with others.

b) correct directory sorting by extension - it wasn't sort
directories by extension at all.

c) extendend header in brief view - now header has 5 sections (Name, Extension, Size, Date, Permissions) instead just Name. This feature is inspired by Total Commander. As I am big fan "brief view mode", so I very often used this smart and handy feature. At last it can be one of Krusader 's assets.

3. Fixed things

a) when sorting column is other than "name" and values are same then
it sorts by name. I think that it will look better.

b) replace (in many files) "extention" with "extension".

c) default sorting was descending in krdetailedview.cpp and krbriefview.cpp - now default is ascending

4. Issues
Not detected.

This is patch for Krusader 1.90, because I use it. Sorry by inconvinience, but Krusader 2.00 is in to early stage for every day use, but my main intention is enjoy with results of my work. I use "diff -ur" because I am not sure what diff options are preferred by Krusader Krew. To apply this patch execute: "patch -p2 -d ./krusader-1.90.0 < krusadersorting.patch".

regards
Jacek Jaworski

Discussion

  • Jacek Jaworski
    Jacek Jaworski
    2008-11-01

    sorting patch for Krusader 1.90

     
    Attachments