132 } |
131 } |
133 painter->restore(); |
132 painter->restore(); |
134 } |
133 } |
135 } |
134 } |
136 |
135 |
137 /*! |
136 |
138 Setter for message object |
137 /*! |
|
138 Sets the message and updates the UI according to the given message data. |
|
139 |
|
140 \param message The message to set. |
139 */ |
141 */ |
140 void NmViewerHeader::setMessage(NmMessage* message) |
142 void NmViewerHeader::setMessage(NmMessage* message) |
141 { |
143 { |
142 NM_FUNCTION; |
144 NM_FUNCTION; |
143 |
145 |
144 mMessage=message; |
146 mMessage = message; |
145 setHeaderData(); |
147 setHeaderData(); |
146 } |
148 } |
147 |
149 |
148 |
150 |
149 /*! |
151 /*! |
150 Function updates data in already created objects. New message pointer |
152 Updates data in already created objects. The given message pointer comes |
151 comes from viewer view, ownership is not transferred. |
153 from the viewer view and the ownership of the instance is not transferred. |
152 This function gets called when message body is fetched and |
154 This method gets called when the message body is fetched and recipient |
153 to/cc/bcc data needs to be updated |
155 (to/cc/bcc) data needs to be updated. |
|
156 |
|
157 Note that if the message has been changed, this method should not be called |
|
158 since this method _only_ updates the recipient data! If the message has been |
|
159 changed, call setMessage() instead. |
|
160 |
|
161 \param message The message data. |
154 */ |
162 */ |
155 void NmViewerHeader::updateMessageData(NmMessage* message) |
163 void NmViewerHeader::updateMessageData(NmMessage* message) |
156 { |
164 { |
157 NM_FUNCTION; |
165 NM_FUNCTION; |
158 |
166 |
159 if (message){ |
167 if (message) { |
160 mMessage=message; |
168 mMessage = message; |
161 // Set recipients to text edit field as html |
169 |
162 NmAddress sender = mMessage->envelope().sender(); |
170 // Set recipients to the text edit field as html. |
163 if (mRecipientsBox){ |
171 NmAddress sender = mMessage->envelope().sender(); |
164 mRecipientsBox->setHtml(formatRecipientList(addressToDisplay(sender), |
172 |
|
173 if (mRecipientsBox) { |
|
174 mRecipientsBox->setHtml( |
|
175 formatRecipientList(addressToDisplay(sender), |
165 mMessage->envelope().toRecipients(), |
176 mMessage->envelope().toRecipients(), |
166 mMessage->envelope().ccRecipients())); |
177 mMessage->envelope().ccRecipients())); |
167 } |
178 } |
168 } |
179 } |
169 } |
180 } |
170 |
181 |
171 /*! |
182 |
172 Function sets data to header area based on message data |
183 /*! |
|
184 Sets the data of the header area based on message data. |
173 */ |
185 */ |
174 void NmViewerHeader::setHeaderData() |
186 void NmViewerHeader::setHeaderData() |
175 { |
187 { |
176 NM_FUNCTION; |
188 NM_FUNCTION; |
177 |
189 |
178 if (mMessage) { |
190 if (mMessage) { |
179 // Background is all white always, so force text color to black |
191 // Background is all white always, so force text color to black. |
180 QColor textColor(Qt::black); |
192 QColor textColor(Qt::black); |
|
193 |
|
194 // Get the message envelope. |
181 const NmMessageEnvelope &envelope = mMessage->envelope(); |
195 const NmMessageEnvelope &envelope = mMessage->envelope(); |
|
196 |
|
197 // Set the sender. |
182 const QString dispName = envelope.sender().displayName(); |
198 const QString dispName = envelope.sender().displayName(); |
183 if (dispName.length()>0){ |
199 |
|
200 if (dispName.length()) { |
184 mSenderName = NmUtilities::cleanupDisplayName(dispName); |
201 mSenderName = NmUtilities::cleanupDisplayName(dispName); |
185 } |
202 } |
186 else { |
203 else { |
|
204 // Use the address instead. |
187 mSenderName = envelope.sender().address(); |
205 mSenderName = envelope.sender().address(); |
188 } |
206 } |
|
207 |
189 if (mHeaderBox) { |
208 if (mHeaderBox) { |
190 mHeaderBox->setHeading(mSenderName); |
209 mHeaderBox->setHeading(mSenderName); |
191 } |
210 } |
192 // Set subject text |
211 |
|
212 // Set the subject text. |
193 if (mSubject){ |
213 if (mSubject){ |
194 QString subjectText = envelope.subject(); |
214 QString subjectText = envelope.subject(); |
195 if (subjectText.length()){ |
215 |
|
216 if (subjectText.length()) { |
196 mSubject->setText(subjectText); |
217 mSubject->setText(subjectText); |
197 } |
218 } |
198 else{ |
219 else{ |
199 mSubject->setText(hbTrId("txt_mail_dblist_val_no_subject")); |
220 mSubject->setText(hbTrId("txt_mail_dblist_val_no_subject")); |
200 } |
221 } |
201 mSubject->setTextColor(textColor); |
222 |
202 } |
223 mSubject->setTextColor(textColor); |
203 if (mSent){ |
224 } |
|
225 |
|
226 if (mSent) { |
204 HbExtendedLocale locale = HbExtendedLocale::system(); |
227 HbExtendedLocale locale = HbExtendedLocale::system(); |
205 QDateTime localTime = envelope.sentTime().addSecs(locale.universalTimeOffset()); |
228 QDateTime localTime = |
|
229 envelope.sentTime().addSecs(locale.universalTimeOffset()); |
206 QTime time = localTime.time(); |
230 QTime time = localTime.time(); |
207 QDate sentLocalDate = localTime.date(); |
231 QDate sentLocalDate = localTime.date(); |
208 QString shortDateSpec = r_qtn_date_without_year; |
232 QString shortDateSpec = r_qtn_date_without_year; |
209 QString shortTimeSpec = r_qtn_time_usual; |
233 QString shortTimeSpec = r_qtn_time_usual; |
210 QString text = locale.format(sentLocalDate, shortDateSpec); |
234 QString text = locale.format(sentLocalDate, shortDateSpec); |
211 text += " "; |
235 text += " "; |
212 text += locale.format(time, shortTimeSpec); |
236 text += locale.format(time, shortTimeSpec); |
213 mSent->setText(text); |
237 mSent->setText(HbStringUtil::convertDigits(text)); |
214 mSent->setTextColor(textColor); |
238 mSent->setTextColor(textColor); |
215 } |
239 } |
216 if (mPrioIcon){ |
240 |
217 switch (envelope.priority()){ |
241 if (mPrioIcon) { |
218 case NmMessagePriorityLow: |
242 switch (envelope.priority()) { |
|
243 case NmMessagePriorityLow: { |
219 mPrioIcon->setObjectName("ViewerHeaderPriorityLow"); |
244 mPrioIcon->setObjectName("ViewerHeaderPriorityLow"); |
220 mPrioIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconPriorityLow)); |
245 mPrioIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconPriorityLow)); |
221 mPrioIcon->show(); |
246 mPrioIcon->show(); |
222 break; |
247 break; |
223 case NmMessagePriorityHigh: |
248 } |
|
249 case NmMessagePriorityHigh: { |
224 mPrioIcon->setObjectName("ViewerHeaderPriorityHigh"); |
250 mPrioIcon->setObjectName("ViewerHeaderPriorityHigh"); |
225 mPrioIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconPriorityHigh)); |
251 mPrioIcon->setIcon(NmIcons::getIcon(NmIcons::NmIconPriorityHigh)); |
226 mPrioIcon->show(); |
252 mPrioIcon->show(); |
227 break; |
253 break; |
|
254 } |
228 case NmMessagePriorityNormal: |
255 case NmMessagePriorityNormal: |
229 default: |
256 default: { |
230 // Normal priority has no icon so hide the label hide. |
257 // Normal priority has no icon so hide the label hide. |
231 mPrioIcon->setObjectName("ViewerHeaderPriorityNormal"); |
258 mPrioIcon->setObjectName("ViewerHeaderPriorityNormal"); |
232 break; |
259 break; |
233 } |
260 } |
234 } |
261 } |
235 } |
262 } |
|
263 } |
|
264 |
236 createExpandableHeader(); |
265 createExpandableHeader(); |
237 } |
266 } |
238 |
267 |
239 |
268 |
240 /*! |
269 /*! |
255 { |
284 { |
256 NM_FUNCTION; |
285 NM_FUNCTION; |
257 |
286 |
258 if (mHeaderBox) { // Initialize recipient box |
287 if (mHeaderBox) { // Initialize recipient box |
259 if (!mRecipientsBox) { |
288 if (!mRecipientsBox) { |
260 mRecipientsBox = new HbLabel(); |
289 mRecipientsBox = new HbTextEdit(); |
261 HbStyle::setItemName(mRecipientsBox, "recipients"); |
290 mRecipientsBox->setReadOnly(true); |
|
291 mRecipientsBox->document()-> |
|
292 defaultTextOption().setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); |
|
293 mRecipientsBox->setObjectName("toField"); |
|
294 mRecipientsBox->setBackgroundItem(NULL); |
262 mRecipientsBox->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
295 mRecipientsBox->setFontSpec(HbFontSpec(HbFontSpec::Secondary)); |
263 mRecipientsBox->setTextWrapping((Hb::TextWrapping)NmTextWrapWordOrAnywhere); |
296 connect(mRecipientsBox, SIGNAL(anchorTapped(const QString &)), |
|
297 this, SLOT(anchorTapped(const QString &))); |
264 } |
298 } |
265 if (mMessage) { |
299 if (mMessage) { |
266 // Set recipients to text edit field as html |
300 // Set recipients to text edit field as html |
267 NmAddress sender = mMessage->envelope().sender(); |
301 NmAddress sender = mMessage->envelope().sender(); |
268 mRecipientsBox->setHtml(formatRecipientList(addressToDisplay(sender), |
302 mRecipientsBox->setHtml(formatRecipientList(addressToDisplay(sender), |