[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: KListView and sorting items
From: Giovanni Venturi <gventuri73 () tiscali ! it>
Date: 2005-10-16 18:16:34
Message-ID: 200510162016.38171.gventuri73 () tiscali ! it
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
Alle 09:43, domenica 16 ottobre 2005, André Wöbbeking ha scritto:
> Override QListViewItem::compare() to compare the data without conversion
> into QStrings. Also override QListViewItem::text() then the conversion
> is only necessary if the item is visible. For example
>
> class MyItem : public QListViewItem
> {
> public:
>
> virtual int compare(QListViewItem*, int, bool) const;
>
> virtual QString text(int) const;
> };
>
>
>
> Cheers,
> André
>
Mmm, I don't understand. I used compare() before your reply because the
sorting was done according the strings and I need according long:
int KSnifferViewItem::compare( QListViewItem *i, int col,
bool ascending ) const
{
int result;
switch (col)
{
case 0:
// frame number...
if (key(col, ascending).toLong() < i->key(col, ascending).toLong())
result = -1;
else if (key(col, ascending).toLong() > i->key(col, ascending).toLong())
result = 1;
else
result = 0;
break;
case 1:
// time...
if (key(col, ascending).toDouble() < i->key(col, ascending).toDouble())
result = -1;
else if (key(col, ascending).toDouble() > i->key(col,
ascending).toDouble())
result = 1;
else
result = 0;
break;
default:
result = QListViewItem::compare( i, col, ascending );
}
return result;
}
Maybe compare() I wrote has some statement that is not for the system
performance? Can someone reply me?
Redifine text? In which way? I don't understand.
Help me :-),
Giovanni
--
A KDE Italian translator and KSniffer core developer
Slackware GNU/Linux current version - kernel 2.6.13.2
[Attachment #5 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic