[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: Sorting date and other column types in {K,Q}ListViews
From: Carsten Pfeiffer <carpdjih () cetus ! zrz ! tu-berlin ! de>
Date: 2001-12-29 15:57:06
[Download RAW message or body]
On Sat, Dec 29, 2001 at 03:31:32PM +0000, shaheed wrote:
> Now, this function is clearly common for several types of data, for example:
>
> - for filenames, where one might want directories sorted ahead of regular
> files
>
> - for dates, one wants to sort on the actual date, not its textual
> representation
>
> and is needed in several places like Konqueror and Cervisia. At the moment,
> this is done by different kinds of inconsistent hacks.
>
> What is the best way to tackle this? Perhaps there should be a standard
> {K,Q}ListViewItem's subclasses for storing certain data types?
The same is in kfile btw. Usually you reimplement key() in your item-class
and return a suitable QString there. To calculate them, there is
static QString sortingKey( const QString& value, bool isDir, int sortSpec);
static QString sortingKey( KIO::filesize_t value, bool isDir,int sortSpec);
in KFileItem. sortSpec can be an ORed combination of QDir::SortSpec items. You
have to use the filesize_t method for dates as well due to ambiguity with time_t.
Cheers
Carsten Pfeiffer
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic