author | zautrix <zautrix> | 2004-07-04 12:40:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-04 12:40:46 (UTC) |
commit | deb87bff56cd9cbb41e352c2ccfa97be142d6e48 (patch) (side-by-side diff) | |
tree | d711d6085e4143e1731da440732e823e69c092a3 /kmicromail/mailistviewitem.cpp | |
parent | 4a947dbc08cc7640dda4f8a89ddb3c80ecc5f9ea (diff) | |
download | kdepimpi-deb87bff56cd9cbb41e352c2ccfa97be142d6e48.zip kdepimpi-deb87bff56cd9cbb41e352c2ccfa97be142d6e48.tar.gz kdepimpi-deb87bff56cd9cbb41e352c2ccfa97be142d6e48.tar.bz2 |
Make sorting in KM working
Diffstat (limited to 'kmicromail/mailistviewitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/mailistviewitem.cpp | 77 |
1 files changed, 52 insertions, 25 deletions
diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp index b9b4cd9..1ca0ada 100644 --- a/kmicromail/mailistviewitem.cpp +++ b/kmicromail/mailistviewitem.cpp @@ -21,38 +21,42 @@ void MailListViewItem::showEntry() setPixmap( 0,SmallIcon ( "kmmsgnew") ); } double s = mail_data->Msgsize(); - int w; - w=0; - - while (s>1024) { - s/=1024; + int w = 0; + s/=1024; + if (s>999.0) { + s/=1024.0; ++w; - if (w>=2) break; } - - QString q=""; - QString fsize=""; - switch(w) { - case 1: - q="k"; + QString fsort; + fsort.sprintf( "%.2f", s ); + QString fsize = QString::number( s, 'f', 2 ); + // 1.23 + // 11.23 + // 111.23 + // 999.23 maxlen + switch(fsize.length() ) { + case 4: + fsort = "00" + fsize ; break; - case 2: - q="M"; + case 5: + fsort = "0" + fsize ; break; default: - break; + fsort = fsize ; + break; + } - - { - QTextOStream o(&fsize); - if (w>0) o.precision(2); else o.precision(0); - o.setf(QTextStream::fixed); - o << s << " " << q << "Byte"; + if ( w == 0 ) { + setText(3, fsize + "kB" ); + mKeyMap.insert(3, "k" + fsort); + //setText(3, "kB" + fsort ); // test only + } else { + //setText(3, fsize + "MB"); + mKeyMap.insert(4, "M" +fsort ); } - setText(1,mail_data->getSubject()); setText(2,mail_data->getFrom()); - setText(3,fsize); + QString date = mail_data->getDate(); int kom = date.find( ",")+2; @@ -91,17 +95,40 @@ void MailListViewItem::showEntry() so = "11"; else if ( mon == "Dec" ) so = "12"; - date = date.mid(7,4)+"-"+so+"-"+date.left(2)+" "+date.mid(12,14); + date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); } // if ( date.left(1) != "1" || date.left(1) != "2" ) // date = date.mid(5); - setText(4,date); + mKeyMap.insert(4,date); + setText(4,mail_data->getDate()); } void MailListViewItem::storeData(const RecMailP&data) { mail_data = data; } +void MailListViewItem::setSortKey(int column,const QString &key) +{ + mKeyMap.insert(column,key); +} +QString MailListViewItem::key(int column, bool) const +{ + // to make is fast, we use here special cases + if ( column == 3 || column == 4 ) { + return *mKeyMap.find(column); + } + if ( column == 1 ) { + if ( text(1).left(4).lower() == "re: " ) + return text(1).mid(4); + + } + return text(column); + /* + QMap<int,QString>::ConstIterator it = mKeyMap.find(column); + if (it == mKeyMap.end()) return text(column); + else return *it; + */ +} const RecMailP& MailListViewItem::data()const { |