author | alwin <alwin> | 2004-02-22 23:56:05 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-22 23:56:05 (UTC) |
commit | eba25a5ebeca30b7124e7fae80685dbd1c9a985d (patch) (unidiff) | |
tree | d62dd266e9b57f3eae34612f5d0fc4cf0b625c20 /noncore/net/mailit/emaillistitem.cpp | |
parent | 666a49773d06ac94c19996d763854725c2f7a578 (diff) | |
download | opie-eba25a5ebeca30b7124e7fae80685dbd1c9a985d.zip opie-eba25a5ebeca30b7124e7fae80685dbd1c9a985d.tar.gz opie-eba25a5ebeca30b7124e7fae80685dbd1c9a985d.tar.bz2 |
moved mailit into unsupported area 'cause replaced by opiemail3
Diffstat (limited to 'noncore/net/mailit/emaillistitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mailit/emaillistitem.cpp | 158 |
1 files changed, 0 insertions, 158 deletions
diff --git a/noncore/net/mailit/emaillistitem.cpp b/noncore/net/mailit/emaillistitem.cpp deleted file mode 100644 index a25f93a..0000000 --- a/noncore/net/mailit/emaillistitem.cpp +++ b/dev/null | |||
@@ -1,158 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qt Palmtop Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include <qstring.h> | ||
21 | #include <qpe/resource.h> | ||
22 | #include "emaillistitem.h" | ||
23 | |||
24 | EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) | ||
25 | : QListViewItem(parent) | ||
26 | { | ||
27 | QString temp; | ||
28 | |||
29 | mail = mailIn; | ||
30 | |||
31 | if (inbox) { | ||
32 | setText(0, mail.from); | ||
33 | } else { | ||
34 | QStringList::Iterator it = mail.recipients.begin(); | ||
35 | temp = *it; | ||
36 | if (mail.recipients.count() > 1) | ||
37 | temp += "..."; | ||
38 | setText(0, temp); | ||
39 | } | ||
40 | setText(1, mail.subject); | ||
41 | // setText(2,mail.date); | ||
42 | setText(2,dateFromULCString(mail.date)); | ||
43 | |||
44 | if (mailIn.files.count()>0) | ||
45 | { | ||
46 | setPixmap(0, Resource::loadPixmap("mailit/attach")); | ||
47 | } | ||
48 | |||
49 | selected = FALSE; | ||
50 | } | ||
51 | |||
52 | Email* EmailListItem::getMail() | ||
53 | { | ||
54 | return &mail; | ||
55 | } | ||
56 | |||
57 | void EmailListItem::setMail(Email newMail) | ||
58 | { | ||
59 | mail = newMail; | ||
60 | repaint(); | ||
61 | } | ||
62 | |||
63 | void EmailListItem::setItemSelected(bool enable) | ||
64 | { | ||
65 | selected = enable; | ||
66 | setSelected(enable); | ||
67 | repaint(); | ||
68 | } | ||
69 | |||
70 | bool EmailListItem::isItemSelected() | ||
71 | { | ||
72 | return selected; | ||
73 | } | ||
74 | |||
75 | void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, | ||
76 | int column, int width, int alignment ) | ||
77 | { | ||
78 | |||
79 | QColorGroup _cg( cg ); | ||
80 | QColor c = _cg.text(); | ||
81 | |||
82 | if ( (! mail.read) && (mail.received) ) | ||
83 | _cg.setColor( QColorGroup::Text, Qt::blue); | ||
84 | if (!mail.downloaded) | ||
85 | _cg.setColor( QColorGroup::Text, Qt::red); | ||
86 | |||
87 | /* if (selected) { | ||
88 | _cg.setColor(QColorGroup::Base, Qt::blue); | ||
89 | _cg.setColor(QColorGroup::Text, Qt::yellow); | ||
90 | if (isSelected()) { | ||
91 | _cg.setColor(QColorGroup::HighlightedText, Qt::yellow); | ||
92 | } else { | ||
93 | _cg.setColor(QColorGroup::Highlight, Qt::blue); | ||
94 | } | ||
95 | } | ||
96 | */ | ||
97 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | ||
98 | |||
99 | _cg.setColor( QColorGroup::Text, c ); | ||
100 | } | ||
101 | |||
102 | /* | ||
103 | * Converts an E-Mail date (ULC) RFC 2822 conform to a QDateTime. | ||
104 | * Returning a QString with formatting of "YYYY-MM-DD HH:MM:SS" | ||
105 | * (zodiac: This method was tested with more than 300 inbox mails, | ||
106 | * it didn't slow down the loading of mail-it.) | ||
107 | */ | ||
108 | QString EmailListItem::dateFromULCString( QString ulcDate ) | ||
109 | { | ||
110 | QString sTemp, sTime; | ||
111 | int iPos, iDay, iMon=1, iYear; | ||
112 | |||
113 | iPos=ulcDate.find(','); | ||
114 | if (iPos) { // it has a day-of-week | ||
115 | ulcDate=ulcDate.remove(0,++iPos); //.stripWhiteSpace(); | ||
116 | } | ||
117 | |||
118 | QStringList dateEntries = QStringList::split(" ",ulcDate,FALSE); | ||
119 | QStringList::Iterator iter = dateEntries.begin(); | ||
120 | |||
121 | // Get day as DD | ||
122 | iDay = (*iter++).toInt(); | ||
123 | |||
124 | // Get month as string Mmm | ||
125 | sTemp = (*iter++); | ||
126 | if (sTemp =="Jan") {iMon=1;} else | ||
127 | if (sTemp =="Feb") {iMon=2;} else | ||
128 | if (sTemp =="Mar") {iMon=3;} else | ||
129 | if (sTemp =="Apr") {iMon=4;} else | ||
130 | if (sTemp =="May") {iMon=5;} else | ||
131 | if (sTemp =="Jun") {iMon=6;} else | ||
132 | if (sTemp =="Jul") {iMon=7;} else | ||
133 | if (sTemp =="Aug") {iMon=8;} else | ||
134 | if (sTemp =="Sep") {iMon=9;} else | ||
135 | if (sTemp =="Oct") {iMon=10;} else | ||
136 | if (sTemp =="Nov") {iMon=11;} else | ||
137 | if (sTemp =="Dec") {iMon=12;} | ||
138 | |||
139 | // Get year as YYYY or YY | ||
140 | iYear = (*iter++).toInt(); | ||
141 | |||
142 | QDate date = QDate(iYear, iMon, iDay); | ||
143 | |||
144 | // Convert timestring into a QTime | ||
145 | QStringList timeEntries = QStringList::split(":",(*iter++),FALSE); | ||
146 | QStringList::Iterator iterTime = timeEntries.begin(); | ||
147 | iYear=(*iterTime++).toInt(); // var reuse.. *cough* | ||
148 | iMon=(*iterTime++).toInt(); | ||
149 | iDay=(*iterTime++).toInt(); | ||
150 | QTime time = QTime(iYear,iMon,iDay); | ||
151 | |||
152 | return QString::number(date.year())+"-" | ||
153 | +QString::number(date.month()).rightJustify(2,'0')+"-" | ||
154 | +QString::number(date.day()).rightJustify(2,'0')+" " | ||
155 | +time.toString(); | ||
156 | } | ||
157 | |||
158 | |||