equal
deleted
inserted
replaced
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 #include <qregexp.h> |
18 #include <hbtextitem.h> |
19 #include <hbtextitem.h> |
19 #include <hbiconitem.h> |
20 #include <hbiconitem.h> |
20 #include <hbframeitem.h> |
21 #include <hbframeitem.h> |
21 #include <hbframebackground.h> |
22 #include <hbframebackground.h> |
22 #include <hbextendedlocale.h> |
23 #include <hbextendedlocale.h> |
23 #include <hbcolorscheme.h> |
24 #include <hbcolorscheme.h> |
24 #include <nmmessageenvelope.h> |
25 #include <nmmessageenvelope.h> |
25 #include <nmicons.h> |
26 #include <nmicons.h> |
|
27 #include <hbstringutil.h> |
26 #include "nmhswidgetlistviewitem.h" |
28 #include "nmhswidgetlistviewitem.h" |
27 |
29 |
28 /*! |
30 /*! |
29 \class NmHsWidgetListViewItem |
31 \class NmHsWidgetListViewItem |
30 \brief Mail widget list view item inherited from HbListViewItem |
32 \brief Mail widget list view item inherited from HbListViewItem |
146 NM_FUNCTION; |
148 NM_FUNCTION; |
147 // Member variables are created in previous function. |
149 // Member variables are created in previous function. |
148 // Sender. |
150 // Sender. |
149 QString senderDisplayName = envelope.sender().displayName(); |
151 QString senderDisplayName = envelope.sender().displayName(); |
150 if (!senderDisplayName.isNull() && !senderDisplayName.isEmpty()) { |
152 if (!senderDisplayName.isNull() && !senderDisplayName.isEmpty()) { |
151 mSender->setText(senderDisplayName); |
153 mSender->setText(cleanupDisplayName(senderDisplayName)); |
152 } |
154 } |
153 else { |
155 else { |
154 mSender->setText(envelope.sender().address()); |
156 mSender->setText(envelope.sender().address()); |
155 } |
157 } |
156 |
158 |
160 QDate sentLocalDate = localTime.date(); |
162 QDate sentLocalDate = localTime.date(); |
161 QDate currentdate = QDate::currentDate(); |
163 QDate currentdate = QDate::currentDate(); |
162 if (sentLocalDate == currentdate) { |
164 if (sentLocalDate == currentdate) { |
163 QString shortTimeSpec = r_qtn_time_usual; |
165 QString shortTimeSpec = r_qtn_time_usual; |
164 QTime time = localTime.time(); |
166 QTime time = localTime.time(); |
165 mTime->setText(locale.format(time, shortTimeSpec)); |
167 mTime->setText(HbStringUtil::convertDigits(locale.format(time, shortTimeSpec))); |
166 } else { |
168 } else { |
167 QString shortDateSpec = r_qtn_date_without_year; |
169 QString shortDateSpec = r_qtn_date_without_year; |
168 mTime->setText(locale.format(sentLocalDate, shortDateSpec)); |
170 mTime->setText(HbStringUtil::convertDigits(locale.format(sentLocalDate, shortDateSpec))); |
169 } |
171 } |
170 // Subject. |
172 // Subject. |
171 QString subjectText = envelope.subject(); |
173 QString subjectText = envelope.subject(); |
172 if (subjectText.length()) { |
174 if (subjectText.length()) { |
173 mSubject->setText(subjectText); |
175 mSubject->setText(subjectText); |
308 |
310 |
309 mTime->setFontSpec(fontSpec); |
311 mTime->setFontSpec(fontSpec); |
310 mTime->setTextColor(colorRole); |
312 mTime->setTextColor(colorRole); |
311 } |
313 } |
312 } |
314 } |
|
315 |
|
316 /*! |
|
317 Cleans up display name by stripping extra characters from the beginning and end of the string. |
|
318 */ |
|
319 QString NmHsWidgetListViewItem::cleanupDisplayName( const QString &displayName ) |
|
320 { |
|
321 NM_FUNCTION; |
|
322 |
|
323 // find the first and last position that is NOT one of the characters below |
|
324 QRegExp rx("[^\\s\"<>]"); |
|
325 int firstPos = std::max(rx.indexIn(displayName), 0); |
|
326 int lastPos = rx.lastIndexIn(displayName); |
|
327 |
|
328 if (lastPos < 0) { |
|
329 lastPos = displayName.length() - 1; |
|
330 } |
|
331 |
|
332 return displayName.mid(firstPos, lastPos - firstPos + 1); |
|
333 } |