19 |
19 |
20 // SYSTEM INCLUDES |
20 // SYSTEM INCLUDES |
21 #include <QDateTime> |
21 #include <QDateTime> |
22 #include "debugtraces.h" |
22 #include "debugtraces.h" |
23 #include <QDir> |
23 #include <QDir> |
|
24 #include <QChar> |
24 #include <HbTextItem> |
25 #include <HbTextItem> |
25 #include <HbIconItem> |
26 #include <HbIconItem> |
|
27 #include <HbIconAnimationManager> |
|
28 #include <HbIconAnimator> |
26 |
29 |
27 // USER INCLUDES |
30 // USER INCLUDES |
28 #include "msgconversationwidget.h" |
31 #include "msgconversationwidget.h" |
29 #include "msgviewdefines.h" |
32 #include "msgviewdefines.h" |
30 #include "msgviewutils.h" |
33 #include "msgviewutils.h" |
31 #include "convergedmessage.h" |
34 #include "convergedmessage.h" |
32 #include "conversationsenginedefines.h" |
35 #include "conversationsenginedefines.h" |
33 |
36 |
34 // LOCAL CONSTANTS |
37 // LOCAL CONSTANTS |
35 |
38 const QString MSG_OUTBOX_ICON("qtg_small_outbox"); |
36 const QString MSG_FAIL_ICON(":/icons/qtg_small_fail.png"); |
39 const QString MSG_FAIL_ICON("qtg_small_fail"); |
37 |
40 const QString ANIMATION_FILE(":/qtg_anim_loading.axml"); |
|
41 const QString ANIMATION_ICON_NAME("qtg_anim_loading"); |
|
42 const QString VCARD_ICON("qtg_large_mycard"); |
|
43 |
|
44 // LOCALIZATION |
38 #define LOC_RINGING_TONE hbTrId("txt_messaging_dpopinfo_ringing_tone") |
45 #define LOC_RINGING_TONE hbTrId("txt_messaging_dpopinfo_ringing_tone") |
39 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_list_business_card") |
46 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_list_business_card") |
40 #define LOC_CALENDER_EVENT hbTrId("txt_messaging_list_calendar_event") |
47 #define LOC_CALENDAR_EVENT hbTrId("txt_messaging_list_calendar_event") |
41 #define LOC_UNSUPPORTED_MESSAGE hbTrId("txt_messaging_list_listview_unsupported_message_type") |
48 #define LOC_UNSUPPORTED_MSG_TYPE hbTrId("txt_messaging_list_listview_unsupported_message_type") |
|
49 #define LOC_RESEND_AT hbTrId("Resend at ") |
42 |
50 |
43 //--------------------------------------------------------------- |
51 //--------------------------------------------------------------- |
44 // MsgConversationViewItem::MsgConversationViewItem |
52 // MsgConversationViewItem::MsgConversationViewItem |
45 // Constructor |
53 // Constructor |
46 //--------------------------------------------------------------- |
54 //--------------------------------------------------------------- |
84 #ifdef _DEBUG_TRACES_ |
92 #ifdef _DEBUG_TRACES_ |
85 qCritical() << "START MsgConversationViewItem::updateChildItems: " |
93 qCritical() << "START MsgConversationViewItem::updateChildItems: " |
86 << index.data(ConvergedMsgId).toInt(); |
94 << index.data(ConvergedMsgId).toInt(); |
87 #endif |
95 #endif |
88 |
96 |
|
97 // Create items common to each type of message |
|
98 |
|
99 QString bodyText = index.data(BodyText).toString(); |
|
100 int messageType = index.data(MessageType).toInt(); |
|
101 int messageSubType = index.data(MessageSubType).toInt(); |
|
102 |
89 // Set message properties common to SMS/MMS/IM etc.. |
103 // Set message properties common to SMS/MMS/IM etc.. |
90 |
104 |
91 int direction = index.data(Direction).toInt(); |
105 int direction = index.data(Direction).toInt(); |
92 |
106 |
93 if ( (direction == ConvergedMessage::Incoming) || |
107 if ( direction == ConvergedMessage::Incoming) |
94 (direction == ConvergedMessage::Missed)) |
|
95 { |
108 { |
96 setIncoming(true); |
109 setIncoming(true); |
97 mConversation->setIncoming(true); |
110 mConversation->setIncoming(true); |
|
111 |
|
112 if(messageType == ConvergedMessage::MmsNotification) |
|
113 { |
|
114 mConversation->setMMSNotification(true); |
|
115 int notificationState = index.data(NotificationStatus).toInt(); |
|
116 mConversation->setNotificationState(notificationState); |
|
117 setNotificationStateIcon(notificationState); |
|
118 } |
|
119 else |
|
120 { |
|
121 mMessageStateIconItem->setVisible(false); |
|
122 } |
98 } |
123 } |
99 else if (direction == ConvergedMessage::Outgoing) |
124 else if (direction == ConvergedMessage::Outgoing) |
100 { |
125 { |
101 setIncoming(false); |
126 setIncoming(false); |
102 mConversation->setIncoming(false); |
127 mConversation->setIncoming(false); |
112 mConversation->drawBubbleFrame(); |
137 mConversation->drawBubbleFrame(); |
113 mConversation->drawNewItemFrame(); |
138 mConversation->drawNewItemFrame(); |
114 |
139 |
115 QDateTime dateTime; |
140 QDateTime dateTime; |
116 dateTime.setTime_t(index.data(TimeStamp).toUInt()); |
141 dateTime.setTime_t(index.data(TimeStamp).toUInt()); |
|
142 QString resendStateNote((index.data(SendingState).toInt() == ConvergedMessage::Resend)? LOC_RESEND_AT : ""); |
117 if (dateTime.date() == QDateTime::currentDateTime().date()) |
143 if (dateTime.date() == QDateTime::currentDateTime().date()) |
118 { |
144 { |
119 mConversation->setTimeStamp(dateTime.toString(TIME_FORMAT)); |
145 |
|
146 mConversation->setTimeStamp(resendStateNote + dateTime.toString(TIME_FORMAT)); |
120 } |
147 } |
121 else |
148 else |
122 { |
149 { |
123 mConversation->setTimeStamp(dateTime.toString(DATE_FORMAT)); |
150 mConversation->setTimeStamp(resendStateNote + dateTime.toString(DATE_FORMAT)); |
124 } |
151 } |
125 |
|
126 // Create items common to each type of message |
|
127 |
|
128 QString bodyText = index.data(BodyText).toString(); |
|
129 int messageType = index.data(MessageType).toInt(); |
|
130 |
152 |
131 QDEBUG_WRITE_FORMAT("MsgConversationViewItem::updateChildItems msg type value",messageType) |
153 QDEBUG_WRITE_FORMAT("MsgConversationViewItem::updateChildItems msg type value",messageType) |
132 |
154 |
133 if (messageType == ConvergedMessage::Sms || |
155 if (messageType == ConvergedMessage::Sms || |
134 messageType == ConvergedMessage::IM) |
156 messageType == ConvergedMessage::IM) |
135 { |
157 { |
136 QDEBUG_WRITE("MsgConversationViewItem::updateChildItems SMS block") |
|
137 mConversation->setMMS(false); |
158 mConversation->setMMS(false); |
|
159 bodyText.replace(QChar::ParagraphSeparator, QChar::LineSeparator); |
|
160 bodyText.replace('\r', QChar::LineSeparator); |
138 mConversation->setBodyText(bodyText); |
161 mConversation->setBodyText(bodyText); |
139 } |
162 } |
140 else if (messageType == ConvergedMessage::Mms) |
163 else if (messageType == ConvergedMessage::Mms) |
141 { |
164 { |
142 QDEBUG_WRITE("MsgConversationViewItem::updateChildItems MMS block") |
|
143 |
|
144 mConversation->setMMS(true); |
165 mConversation->setMMS(true); |
145 QString attachments = index.data(Attachments).toString(); |
166 QString attachments = index.data(Attachments).toString(); |
146 QString subject = index.data(Subject).toString(); |
167 QString subject = index.data(Subject).toString(); |
147 |
168 |
148 bool hasAttachments = (index.data(MessageProperty).toInt() |
169 bool hasAttachments = (index.data(MessageProperty).toInt() |
149 & ConvergedMessage::Attachment) ? true : false; |
170 & ConvergedMessage::Attachment) ? true : false; |
150 |
171 |
151 if (hasAttachments) |
172 if (hasAttachments) |
152 { |
173 { |
153 mConversation->setAttachment(); |
174 mConversation->setAttachment(); |
154 } |
175 } |
190 mConversation->displayAudioIcon(); |
211 mConversation->displayAudioIcon(); |
191 |
212 |
192 int priority = index.data(MessagePriority).toInt(); |
213 int priority = index.data(MessagePriority).toInt(); |
193 mConversation->setPriority(priority); |
214 mConversation->setPriority(priority); |
194 mConversation->setSubject(subject); |
215 mConversation->setSubject(subject); |
|
216 mConversation->setBodyText(bodyText); |
|
217 } // END of ConvergedMessage::Mms |
|
218 else if (messageType == ConvergedMessage::BioMsg) |
|
219 { |
|
220 if (messageSubType == ConvergedMessage::RingingTone) |
|
221 { |
|
222 mConversation->setMMS(true); |
|
223 mConversation->setImage(false); |
|
224 mConversation->setAudio(true); |
|
225 mConversation->displayAudioIcon(); |
|
226 mConversation->setSubject(LOC_RINGING_TONE); |
|
227 } |
|
228 else if (messageSubType == ConvergedMessage::VCard) |
|
229 { |
|
230 mConversation->setMMS(true); |
|
231 mConversation->setImage(false); |
|
232 mConversation->setAudio(true); |
|
233 mConversation->displayAudioIcon(VCARD_ICON); |
|
234 mConversation->setSubject(LOC_BUSINESS_CARD); |
|
235 mConversation->setBodyText(bodyText); |
|
236 } |
|
237 else |
|
238 { |
|
239 mConversation->setMMS(false); |
|
240 mConversation->setBodyText(LOC_UNSUPPORTED_MSG_TYPE); |
|
241 } |
|
242 } |
|
243 else if (messageType == ConvergedMessage::BT) |
|
244 { |
|
245 mConversation->setMMS(true); |
|
246 QString deviceName = index.data(ConversationAddress).toString(); |
|
247 mConversation->setSubject(deviceName); |
|
248 QString blueToothBody; |
|
249 if (messageSubType == ConvergedMessage::VCard) |
|
250 { |
|
251 mConversation->setImage(false); |
|
252 mConversation->setAudio(true); |
|
253 mConversation->displayAudioIcon(VCARD_ICON); |
|
254 blueToothBody.append(LOC_BUSINESS_CARD); |
|
255 blueToothBody.append(QChar::LineSeparator); |
|
256 blueToothBody.append(bodyText); |
|
257 } |
|
258 else |
|
259 { |
|
260 blueToothBody.append(bodyText); |
|
261 } |
|
262 mConversation->setBodyText(blueToothBody); |
|
263 } |
|
264 else if(messageType == ConvergedMessage::MmsNotification) |
|
265 { |
|
266 mConversation->setMMS(true); |
|
267 |
|
268 QString subject = index.data(Subject).toString(); |
|
269 int priority = index.data(MessagePriority).toInt(); |
|
270 mConversation->setPriority(priority); |
|
271 mConversation->setSubject(subject); |
195 mConversation->setBodyText(bodyText); |
272 mConversation->setBodyText(bodyText); |
196 |
273 } |
197 } // END of ConvergedMessage::Mms |
|
198 else if (messageType == ConvergedMessage::RingingTone) |
|
199 { |
|
200 QDEBUG_WRITE("MsgConversationViewItem::updateChildItems Ringing Tone block") |
|
201 mConversation->setMMS(true); |
|
202 mConversation->setImage(false); |
|
203 mConversation->setAudio(true); |
|
204 mConversation->displayAudioIcon(); |
|
205 mConversation->setSubject(LOC_RINGING_TONE); |
|
206 } |
|
207 /// for all the biotype messages |
|
208 else if (messageType == ConvergedMessage::VCard) |
|
209 { |
|
210 mConversation->setMMS(false); |
|
211 mConversation->setBodyText(LOC_BUSINESS_CARD); |
|
212 } |
|
213 /// for all the biotype messages |
|
214 else if (messageType == ConvergedMessage::VCal) |
|
215 { |
|
216 mConversation->setMMS(false); |
|
217 mConversation->setBodyText(LOC_CALENDER_EVENT); |
|
218 } |
|
219 /// for all the biotype messages |
|
220 else if (messageType == ConvergedMessage::BioMsg) |
|
221 { |
|
222 mConversation->setMMS(false); |
|
223 mConversation->setBodyText(LOC_UNSUPPORTED_MESSAGE); |
|
224 } |
|
225 |
|
226 |
274 |
227 #ifdef _DEBUG_TRACES_ |
275 #ifdef _DEBUG_TRACES_ |
228 qCritical() << "END MsgConversationViewItem::updateChildItems: " |
276 qCritical() << "END MsgConversationViewItem::updateChildItems: " |
229 << index.data(ConvergedMsgId).toInt(); |
277 << index.data(ConvergedMsgId).toInt(); |
230 #endif |
278 #endif |
259 { |
307 { |
260 return mIncoming; |
308 return mIncoming; |
261 } |
309 } |
262 |
310 |
263 //--------------------------------------------------------------- |
311 //--------------------------------------------------------------- |
264 // MsgConversationViewItem::setIncoming |
312 // MsgConversationViewItem::setMessageStateIcon |
265 // @see header file |
313 // @see header file |
266 //--------------------------------------------------------------- |
314 //--------------------------------------------------------------- |
267 void MsgConversationViewItem::setMessageStateIcon(int messageState) |
315 void MsgConversationViewItem::setMessageStateIcon(int messageState) |
268 { |
316 { |
|
317 HbIconAnimator& iconAnimator = mMessageStateIconItem->animator(); |
|
318 HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global(); |
269 switch (messageState) |
319 switch (messageState) |
270 { |
320 { |
|
321 |
|
322 case ConvergedMessage::Waiting: |
|
323 case ConvergedMessage::Scheduled: |
|
324 case ConvergedMessage::Sending: |
|
325 { |
|
326 bool defined = iconAnimationManager->addDefinitionFile(ANIMATION_FILE); |
|
327 HbIcon animIcon; |
|
328 animIcon.setIconName(ANIMATION_ICON_NAME); |
|
329 QSizeF size = mMessageStateIconItem->size(); |
|
330 mMessageStateIconItem->setIcon(animIcon); |
|
331 mMessageStateIconItem->setVisible(true); |
|
332 iconAnimator.startAnimation(); |
|
333 repolish(); |
|
334 break; |
|
335 } |
271 case ConvergedMessage::Suspended: |
336 case ConvergedMessage::Suspended: |
|
337 { |
|
338 iconAnimator.stopAnimation(); |
|
339 mMessageStateIconItem->setIcon(MSG_OUTBOX_ICON); |
|
340 mMessageStateIconItem->setVisible(true); |
|
341 break; |
|
342 |
|
343 } |
272 case ConvergedMessage::Resend: |
344 case ConvergedMessage::Resend: |
273 { |
345 { |
274 //TODO: Temp icon until official icons are received |
346 iconAnimator.stopAnimation(); |
|
347 mMessageStateIconItem->setIcon(MSG_OUTBOX_ICON); |
|
348 mMessageStateIconItem->setVisible(true); |
|
349 break; |
|
350 } |
|
351 case ConvergedMessage::Failed: |
|
352 { |
|
353 iconAnimator.stopAnimation(); |
275 mMessageStateIconItem->setIcon(MSG_FAIL_ICON); |
354 mMessageStateIconItem->setIcon(MSG_FAIL_ICON); |
276 mMessageStateIconItem->setVisible(true); |
355 mMessageStateIconItem->setVisible(true); |
277 break; |
356 break; |
278 } |
357 } |
279 case ConvergedMessage::Failed: |
358 case ConvergedMessage::Unknown: |
280 { |
359 default: |
|
360 { |
|
361 iconAnimator.stopAnimation(); |
|
362 mMessageStateIconItem->setVisible(false); |
|
363 break; |
|
364 } |
|
365 } |
|
366 } |
|
367 |
|
368 //--------------------------------------------------------------- |
|
369 // MsgConversationViewItem::setNotificationStateIcon |
|
370 // @see header file |
|
371 //--------------------------------------------------------------- |
|
372 |
|
373 void MsgConversationViewItem::setNotificationStateIcon(int notificationState) |
|
374 { |
|
375 HbIconAnimator& iconAnimator = mMessageStateIconItem->animator(); |
|
376 HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global(); |
|
377 switch (notificationState) |
|
378 { |
|
379 |
|
380 case ConvergedMessage::NotifRetrieving: |
|
381 case ConvergedMessage::NotifWaiting: |
|
382 { |
281 //TODO: Temp icon until official icons are received |
383 //TODO: Temp icon until official icons are received |
282 mMessageStateIconItem->setIcon(MSG_FAIL_ICON); |
384 bool defined = iconAnimationManager->addDefinitionFile(ANIMATION_FILE); |
|
385 HbIcon animIcon; |
|
386 animIcon.setIconName(ANIMATION_ICON_NAME); |
|
387 QSizeF size = mMessageStateIconItem->size(); |
|
388 mMessageStateIconItem->setIcon(animIcon); |
283 mMessageStateIconItem->setVisible(true); |
389 mMessageStateIconItem->setVisible(true); |
284 break; |
390 iconAnimator.startAnimation(); |
285 } |
391 repolish(); |
|
392 break; |
|
393 } |
286 default: |
394 default: |
287 { |
395 { |
|
396 iconAnimator.stopAnimation(); |
288 mMessageStateIconItem->setVisible(false); |
397 mMessageStateIconItem->setVisible(false); |
289 break; |
398 break; |
290 } |
399 } |
291 } |
400 } |
292 } |
401 } |
293 |
402 |
|
403 //--------------------------------------------------------------- |
|
404 // MsgConversationViewItem::pressStateChanged |
|
405 // @see header file |
|
406 //--------------------------------------------------------------- |
|
407 void MsgConversationViewItem::pressStateChanged (bool pressed, bool animate) |
|
408 { |
|
409 mConversation->pressStateChanged(pressed, animate); |
|
410 } |
|
411 |
294 // EOF |
412 // EOF |