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 | |||
@@ -12,56 +12,60 @@ MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | |||
12 | void MailListViewItem::showEntry() | 12 | void MailListViewItem::showEntry() |
13 | { | 13 | { |
14 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { | 14 | if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { |
15 | setPixmap( 0, SmallIcon ( "kmmsgreplied") ); | 15 | setPixmap( 0, SmallIcon ( "kmmsgreplied") ); |
16 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { | 16 | } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { |
17 | /* I think it looks nicer if there are not such a log of icons but only on mails | 17 | /* I think it looks nicer if there are not such a log of icons but only on mails |
18 | replied or new - Alwin*/ | 18 | replied or new - Alwin*/ |
19 | //setPixmap( 0,SmallIcon ("kmmsgunseen") ); | 19 | //setPixmap( 0,SmallIcon ("kmmsgunseen") ); |
20 | } else { | 20 | } else { |
21 | setPixmap( 0,SmallIcon ( "kmmsgnew") ); | 21 | setPixmap( 0,SmallIcon ( "kmmsgnew") ); |
22 | } | 22 | } |
23 | double s = mail_data->Msgsize(); | 23 | double s = mail_data->Msgsize(); |
24 | int w; | 24 | int w = 0; |
25 | w=0; | 25 | s/=1024; |
26 | 26 | if (s>999.0) { | |
27 | while (s>1024) { | 27 | s/=1024.0; |
28 | s/=1024; | ||
29 | ++w; | 28 | ++w; |
30 | if (w>=2) break; | ||
31 | } | 29 | } |
32 | 30 | QString fsort; | |
33 | QString q=""; | 31 | fsort.sprintf( "%.2f", s ); |
34 | QString fsize=""; | 32 | QString fsize = QString::number( s, 'f', 2 ); |
35 | switch(w) { | 33 | // 1.23 |
36 | case 1: | 34 | // 11.23 |
37 | q="k"; | 35 | // 111.23 |
36 | // 999.23 maxlen | ||
37 | switch(fsize.length() ) { | ||
38 | case 4: | ||
39 | fsort = "00" + fsize ; | ||
38 | break; | 40 | break; |
39 | case 2: | 41 | case 5: |
40 | q="M"; | 42 | fsort = "0" + fsize ; |
41 | break; | 43 | break; |
42 | default: | 44 | default: |
43 | break; | 45 | fsort = fsize ; |
46 | break; | ||
47 | |||
44 | } | 48 | } |
45 | 49 | if ( w == 0 ) { | |
46 | { | 50 | setText(3, fsize + "kB" ); |
47 | QTextOStream o(&fsize); | 51 | mKeyMap.insert(3, "k" + fsort); |
48 | if (w>0) o.precision(2); else o.precision(0); | 52 | //setText(3, "kB" + fsort ); // test only |
49 | o.setf(QTextStream::fixed); | 53 | } else { |
50 | o << s << " " << q << "Byte"; | 54 | //setText(3, fsize + "MB"); |
55 | mKeyMap.insert(4, "M" +fsort ); | ||
51 | } | 56 | } |
52 | |||
53 | setText(1,mail_data->getSubject()); | 57 | setText(1,mail_data->getSubject()); |
54 | setText(2,mail_data->getFrom()); | 58 | setText(2,mail_data->getFrom()); |
55 | setText(3,fsize); | 59 | |
56 | QString date = mail_data->getDate(); | 60 | QString date = mail_data->getDate(); |
57 | 61 | ||
58 | int kom = date.find( ",")+2; | 62 | int kom = date.find( ",")+2; |
59 | if ( kom == 1 ) | 63 | if ( kom == 1 ) |
60 | kom = 0; | 64 | kom = 0; |
61 | if ( date.mid(kom,1) == " ") | 65 | if ( date.mid(kom,1) == " ") |
62 | ++kom; | 66 | ++kom; |
63 | if ( date.mid(kom+1,1) == " " ) | 67 | if ( date.mid(kom+1,1) == " " ) |
64 | date = "0" + date.mid( kom ); | 68 | date = "0" + date.mid( kom ); |
65 | else if ( kom ) | 69 | else if ( kom ) |
66 | date = date.mid( kom ); | 70 | date = date.mid( kom ); |
67 | if ( kom || date.mid(2,1 ) == " ") { | 71 | if ( kom || date.mid(2,1 ) == " ") { |
@@ -82,34 +86,57 @@ void MailListViewItem::showEntry() | |||
82 | else if ( mon == "Jul" ) | 86 | else if ( mon == "Jul" ) |
83 | so = "07"; | 87 | so = "07"; |
84 | else if ( mon == "Aug" ) | 88 | else if ( mon == "Aug" ) |
85 | so = "08"; | 89 | so = "08"; |
86 | else if ( mon == "Sep" ) | 90 | else if ( mon == "Sep" ) |
87 | so = "09"; | 91 | so = "09"; |
88 | else if ( mon == "Oct" ) | 92 | else if ( mon == "Oct" ) |
89 | so = "10"; | 93 | so = "10"; |
90 | else if ( mon == "Nov" ) | 94 | else if ( mon == "Nov" ) |
91 | so = "11"; | 95 | so = "11"; |
92 | else if ( mon == "Dec" ) | 96 | else if ( mon == "Dec" ) |
93 | so = "12"; | 97 | so = "12"; |
94 | date = date.mid(7,4)+"-"+so+"-"+date.left(2)+" "+date.mid(12,14); | 98 | date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); |
95 | } | 99 | } |
96 | // if ( date.left(1) != "1" || date.left(1) != "2" ) | 100 | // if ( date.left(1) != "1" || date.left(1) != "2" ) |
97 | // date = date.mid(5); | 101 | // date = date.mid(5); |
98 | setText(4,date); | 102 | mKeyMap.insert(4,date); |
103 | setText(4,mail_data->getDate()); | ||
99 | } | 104 | } |
100 | 105 | ||
101 | void MailListViewItem::storeData(const RecMailP&data) | 106 | void MailListViewItem::storeData(const RecMailP&data) |
102 | { | 107 | { |
103 | mail_data = data; | 108 | mail_data = data; |
104 | } | 109 | } |
110 | void MailListViewItem::setSortKey(int column,const QString &key) | ||
111 | { | ||
112 | mKeyMap.insert(column,key); | ||
113 | } | ||
114 | QString MailListViewItem::key(int column, bool) const | ||
115 | { | ||
116 | // to make is fast, we use here special cases | ||
117 | if ( column == 3 || column == 4 ) { | ||
118 | return *mKeyMap.find(column); | ||
119 | } | ||
120 | if ( column == 1 ) { | ||
121 | if ( text(1).left(4).lower() == "re: " ) | ||
122 | return text(1).mid(4); | ||
123 | |||
124 | } | ||
125 | return text(column); | ||
126 | /* | ||
127 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | ||
128 | if (it == mKeyMap.end()) return text(column); | ||
129 | else return *it; | ||
130 | */ | ||
131 | } | ||
105 | 132 | ||
106 | const RecMailP& MailListViewItem::data()const | 133 | const RecMailP& MailListViewItem::data()const |
107 | { | 134 | { |
108 | return mail_data; | 135 | return mail_data; |
109 | } | 136 | } |
110 | 137 | ||
111 | MAILLIB::ATYPE MailListViewItem::wrapperType() | 138 | MAILLIB::ATYPE MailListViewItem::wrapperType() |
112 | { | 139 | { |
113 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; | 140 | if (!mail_data->Wrapper()) return MAILLIB::A_UNDEFINED; |
114 | return mail_data->Wrapper()->getType(); | 141 | return mail_data->Wrapper()->getType(); |
115 | } | 142 | } |