[Patch]Iconview:save descending + directories first; sort by type improvement

David Faure dfaure at trolltech.com
Sat Aug 23 16:13:34 BST 2003


On Saturday 23 August 2003 02:04, Anna Nymos wrote:
> The attached patch for konqueror iconview does the following:
> - Save whether the items should be sorted ascending or descending
> - Save whether directories should be sorted first (fixes http://bugs.kde.org/show_bug.cgi?id=62803)
> Both is saved without user interaction the way it is also done with the sort criterion (using KonqPropsView).
> - When sorting by filetype, always sort by name within one filetype (fixes http://bugs.kde.org/show_bug.cgi?id=58884)
> 
> Is it OK to commit this patch? I hopefully didn't break binary compatibility this time...

Excellent, many thanks.

The only nitpick is the order of the data members (in the Private class)
   bool caseInsensitiveSort:1;
    QString sortcriterion;
+   bool dirsfirst:1;
+   bool descending:1;
 };

The two bools should go before the QString, so that the existing bitfield 
can be extended with two new bits (otherwise it starts another bitfield,
which defeats the point of using ":1" :)

> - When sorting by filetype, always sort by name within one filetype (fixes http://bugs.kde.org/show_bug.cgi?id=58884)

Hmm, 
-            case Type: key = item->item()->mimetype(); break; // ### slows down listing :-(
+            case Type: key = item->item()->mimetype()+item->text().lower(); break; // ### slows down listing :-(
I'm not sure this fix is 100% correct....
If file "y" is x-tar and file "a" is x-targz, then "y" should be before "a", but the keys will
be x-tary and x-targza so "y" will be after "a". This will show up as a bug if you
also have a file "b" that is x-tar, because then the order will be
"b" (x-tar), "a" (x-targz), "y" (x-tar), so the two x-tar files are not grouped together.
(Phew, it wasn't easy to find a working testcase :)

Not sure how to fix this properly though. At least using a separator that is low
in the ascii table might help (might even be '\008' or so). Then I can't find
a case that wouldn't be sorted correctly, since it ensures any x-tar file
is sorted before any x-tar<something> file.

Feel free to commit.

-- 
David FAURE, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kfm-devel mailing list