[Patch] Sort by time of modification in iconview + multicolumsnview
Carsten Pfeiffer
carpdjih at mailbox.tu-berlin.de
Fri Feb 14 01:18:59 GMT 2003
-----BEGIN PGP SIGNED MESSAGE-----
On Friday 14 February 2003 01:05, Anna Nymos wrote:
> Wouldn't using KFileView()::sortingKey() only increase the programming
> amount? You still have to create "any string that should be used as sort
> criterion"(first argument). In addition you have to find out, whether the
The string is simply the filename or whatever else one might want to use.
> file is a directory(second argument) and to OR together QDir::IgnoreCase,
> QDir::Reversed(doesn't even affect the resulting QString) and
> QDir::DirsFirst if they apply(third argument). So I can't see what this
Whether it's a file or directory should be known already (see
KFileItem::isDir()). The other arguments do affect the resulting QString
(otherwise they would not be there).
Or do you prefer everything being sorted strictly by modification time?
Directories and files all mixed together? I don't think we want that.
See the implementation:
QString KFileView::sortingKey( const QString& value, bool isDir, int sortSpec
)
{
bool reverse = sortSpec & QDir::Reversed;
bool dirsFirst = sortSpec & QDir::DirsFirst;
char start = (isDir && dirsFirst) ? (reverse ? '2' : '0') : '1';
QString result = (sortSpec & QDir::IgnoreCase) ? value.lower() : value;
return result.prepend( start );
}
> additional programming effort is good for. It would only be usefull if the
> third argument would also accept QDir::Name, QDir::Time and QDir::Size and
> make a sensible sort criterion out of it.
All three parameters together form the sort criterion. QDir::Name, Time and
Size are not useful here, because they only refer to a value out of several
(i.e. "sort by name and not by time or size"). We don't need that, as we just
pass the value we want to sort by as first parameter (i.e. the name, or date
or size (using the overloaded sortingKey() method for the latter)).
Cheers
Carsten Pfeiffer
-----BEGIN PGP SIGNATURE-----
iQEVAwUBPkxEA6WgYMJuwmZtAQE/TAf+NpkFrJXDREgR50x76YSchyWpnW50D/Fj
3X8noUqzPKArXIT/tbGGhwxTqaJ5WVGqan/RrSV0CiqfVvuhEYcRChe1sPWcdvDk
pIXQ2G0rnVW8EogSKjAYsOTlefYtw9k1ohnqssptNjQctCLt5nzzL/jb2WcuHsCq
5Tzxe8fOcep7nDscPOHzEyo8Ryv5sOLt85SpQPIANVfhAiuwOCWQ2KRJedoX6Gk2
1HhAOEpt4umvuYtR9LfnWesz5WHIhg1sZ2JwWeL48vMvvbDa8hUMae4VE9oPFmWN
ULDx7ofL8TPT7PgC8/twPuAJlAxBholkbkU9QlFOOJJSi7oZGwl1hg==
=Ccms
-----END PGP SIGNATURE-----
More information about the kfm-devel
mailing list