Diffstat (limited to 'noncore/unsupported/mailit/emaillistitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mailit/emaillistitem.cpp | 73 |
1 files changed, 66 insertions, 7 deletions
diff --git a/noncore/unsupported/mailit/emaillistitem.cpp b/noncore/unsupported/mailit/emaillistitem.cpp index fc9f766..a25f93a 100644 --- a/noncore/unsupported/mailit/emaillistitem.cpp +++ b/noncore/unsupported/mailit/emaillistitem.cpp | |||
@@ -27,5 +27,5 @@ EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) | |||
27 | QString temp; | 27 | QString temp; |
28 | 28 | ||
29 | mail = mailIn; | 29 | mail = mailIn; |
30 | 30 | ||
31 | if (inbox) { | 31 | if (inbox) { |
@@ -40,4 +40,5 @@ EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) | |||
40 | setText(1, mail.subject); | 40 | setText(1, mail.subject); |
41 | setText(2,mail.date); | 41 | // setText(2,mail.date); |
42 | 42 | setText(2,dateFromULCString(mail.date)); | |
43 | |||
43 | if (mailIn.files.count()>0) | 44 | if (mailIn.files.count()>0) |
@@ -46,3 +47,3 @@ EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) | |||
46 | } | 47 | } |
47 | 48 | ||
48 | selected = FALSE; | 49 | selected = FALSE; |
@@ -84,3 +85,3 @@ void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, | |||
84 | _cg.setColor( QColorGroup::Text, Qt::red); | 85 | _cg.setColor( QColorGroup::Text, Qt::red); |
85 | 86 | ||
86 | /* if (selected) { | 87 | /* if (selected) { |
@@ -94,3 +95,3 @@ void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, | |||
94 | } | 95 | } |
95 | */ | 96 | */ |
96 | QListViewItem::paintCell( p, _cg, column, width, alignment ); | 97 | QListViewItem::paintCell( p, _cg, column, width, alignment ); |
@@ -99 +100,59 @@ void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, | |||
99 | } | 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 | |||