92 #ifdef _DEBUG_TRACES_ |
93 #ifdef _DEBUG_TRACES_ |
93 qCritical() << "START MsgConversationViewItem::updateChildItems: " |
94 qCritical() << "START MsgConversationViewItem::updateChildItems: " |
94 << index.data(ConvergedMsgId).toInt(); |
95 << index.data(ConvergedMsgId).toInt(); |
95 #endif |
96 #endif |
96 |
97 |
97 // Create items common to each type of message |
|
98 |
|
99 QString bodyText = index.data(BodyText).toString(); |
|
100 int messageType = index.data(MessageType).toInt(); |
98 int messageType = index.data(MessageType).toInt(); |
101 int messageSubType = index.data(MessageSubType).toInt(); |
99 int messageSubType = index.data(MessageSubType).toInt(); |
102 |
100 |
103 // Set message properties common to SMS/MMS/IM etc.. |
101 |
104 |
102 if (messageType == ConvergedMessage::Sms) |
|
103 { |
|
104 updateSmsTypeItem(index); |
|
105 } |
|
106 else if (messageType == ConvergedMessage::Mms || messageType |
|
107 == ConvergedMessage::MmsNotification || messageType |
|
108 == ConvergedMessage::BT) |
|
109 { |
|
110 updateMmsTypeItem(index, messageType, messageSubType); |
|
111 } |
|
112 else if (messageType == ConvergedMessage::BioMsg) |
|
113 { |
|
114 if (messageSubType == ConvergedMessage::VCard || messageSubType |
|
115 == ConvergedMessage::RingingTone) |
|
116 { |
|
117 updateMmsTypeItem(index, messageType, messageSubType); |
|
118 } |
|
119 else |
|
120 { |
|
121 updateSmsTypeItem(index, messageSubType); |
|
122 } |
|
123 } |
|
124 |
|
125 #ifdef _DEBUG_TRACES_ |
|
126 qCritical() << "END MsgConversationViewItem::updateChildItems: " |
|
127 << index.data(ConvergedMsgId).toInt(); |
|
128 #endif |
|
129 |
|
130 repolish(); |
|
131 HbListViewItem::updateChildItems(); |
|
132 } |
|
133 |
|
134 //--------------------------------------------------------------- |
|
135 // MsgConversationViewItem::updateSmsTypeItem |
|
136 // @see header file |
|
137 //--------------------------------------------------------------- |
|
138 void MsgConversationViewItem::updateSmsTypeItem(const QModelIndex& index, |
|
139 int messageSubType) |
|
140 { |
|
141 |
|
142 mIncoming = false; |
|
143 mConversation->resetProperties(); |
|
144 |
105 int direction = index.data(Direction).toInt(); |
145 int direction = index.data(Direction).toInt(); |
106 |
146 |
107 if ( direction == ConvergedMessage::Incoming) |
147 if (direction == ConvergedMessage::Incoming) |
108 { |
148 { |
109 setIncoming(true); |
149 setIncoming(true); |
110 mConversation->setIncoming(true); |
150 mConversation->setIncoming(true); |
111 |
151 |
112 if(messageType == ConvergedMessage::MmsNotification) |
152 mIncomingMsgStateIconItem->setVisible(false); |
113 { |
153 } |
|
154 else if (direction == ConvergedMessage::Outgoing) |
|
155 { |
|
156 setIncoming(false); |
|
157 mConversation->setIncoming(false); |
|
158 |
|
159 int sendingState = index.data(SendingState).toInt(); |
|
160 mConversation->setSendingState(sendingState); |
|
161 setMessageStateIcon(sendingState); |
|
162 } |
|
163 |
|
164 bool unreadStatus = index.data(UnReadStatus).toBool(); |
|
165 mConversation->setUnread(unreadStatus); |
|
166 |
|
167 mConversation->drawBubbleFrame(); |
|
168 mConversation->drawNewItemFrame(); |
|
169 |
|
170 QDateTime dateTime; |
|
171 dateTime.setTime_t(index.data(TimeStamp).toUInt()); |
|
172 QString resendStateNote((index.data(SendingState).toInt() |
|
173 == ConvergedMessage::Resend) ? LOC_RESEND_AT : ""); |
|
174 if (dateTime.date() == QDateTime::currentDateTime().date()) |
|
175 { |
|
176 |
|
177 mConversation->setTimeStamp(resendStateNote + dateTime.toString( |
|
178 TIME_FORMAT)); |
|
179 } |
|
180 else |
|
181 { |
|
182 mConversation->setTimeStamp(resendStateNote + dateTime.toString( |
|
183 DATE_FORMAT)); |
|
184 } |
|
185 |
|
186 if (messageSubType == ConvergedMessage::VCal) |
|
187 { |
|
188 mConversation->setSubject(LOC_UNSUPPORTED_MSG_TYPE); |
|
189 } |
|
190 else |
|
191 { |
|
192 QString bodyText = index.data(BodyText).toString(); |
|
193 bodyText.replace(QChar::ParagraphSeparator, QChar::LineSeparator); |
|
194 bodyText.replace('\r', QChar::LineSeparator); |
|
195 mConversation->setSubject(bodyText); |
|
196 } |
|
197 |
|
198 //repolish |
|
199 mConversation->repolishWidget(); |
|
200 } |
|
201 |
|
202 //--------------------------------------------------------------- |
|
203 // MsgConversationViewItem::updateMmsTypeItem |
|
204 // @see header file |
|
205 //--------------------------------------------------------------- |
|
206 void MsgConversationViewItem::updateMmsTypeItem(const QModelIndex& index, |
|
207 int messageType, int messageSubType) |
|
208 { |
|
209 // create widget |
|
210 if (!mConversation) |
|
211 { |
|
212 mConversation = new MsgConversationWidget(this); |
|
213 HbStyle::setItemName(mConversation, "msgconvwidget"); |
|
214 } |
|
215 mIncoming = false; |
|
216 mConversation->resetProperties(); |
|
217 |
|
218 mConversation->setMMS(true); |
|
219 int direction = index.data(Direction).toInt(); |
|
220 QString bodyText = index.data(BodyText).toString(); |
|
221 |
|
222 if (direction == ConvergedMessage::Incoming) |
|
223 { |
|
224 setIncoming(true); |
|
225 mConversation->setIncoming(true); |
|
226 |
|
227 if (messageType == ConvergedMessage::MmsNotification) |
|
228 { |
114 mConversation->setMMSNotification(true); |
229 mConversation->setMMSNotification(true); |
115 int notificationState = index.data(NotificationStatus).toInt(); |
230 int notificationState = index.data(NotificationStatus).toInt(); |
116 mConversation->setNotificationState(notificationState); |
231 mConversation->setNotificationState(notificationState); |
117 setNotificationStateIcon(notificationState); |
232 setNotificationStateIcon(notificationState); |
118 } |
233 } |
119 else |
234 else |
120 { |
235 { |
121 mMessageStateIconItem->setVisible(false); |
236 mIncomingMsgStateIconItem->setVisible(false); |
122 } |
237 } |
123 } |
238 } |
124 else if (direction == ConvergedMessage::Outgoing) |
239 else if (direction == ConvergedMessage::Outgoing) |
125 { |
240 { |
126 setIncoming(false); |
241 setIncoming(false); |
127 mConversation->setIncoming(false); |
242 mConversation->setIncoming(false); |
128 |
243 |
129 int sendingState = index.data(SendingState).toInt(); |
244 int sendingState = index.data(SendingState).toInt(); |
130 mConversation->setSendingState(sendingState); |
245 mConversation->setSendingState(sendingState); |
131 setMessageStateIcon(sendingState); |
246 setMessageStateIcon(sendingState); |
132 } |
247 } |
133 |
248 |
134 bool unreadStatus = index.data(UnReadStatus).toBool(); |
249 bool unreadStatus = index.data(UnReadStatus).toBool(); |
135 mConversation->setUnread(unreadStatus); |
250 mConversation->setUnread(unreadStatus); |
136 // Create items common to SMS/MMS/IM etc... |
251 |
137 mConversation->drawBubbleFrame(); |
252 mConversation->drawBubbleFrame(); |
138 mConversation->drawNewItemFrame(); |
253 mConversation->drawNewItemFrame(); |
139 |
254 |
140 QDateTime dateTime; |
255 QDateTime dateTime; |
141 dateTime.setTime_t(index.data(TimeStamp).toUInt()); |
256 dateTime.setTime_t(index.data(TimeStamp).toUInt()); |
142 QString resendStateNote((index.data(SendingState).toInt() == ConvergedMessage::Resend)? LOC_RESEND_AT : ""); |
257 QString resendStateNote((index.data(SendingState).toInt() |
|
258 == ConvergedMessage::Resend) ? LOC_RESEND_AT : ""); |
143 if (dateTime.date() == QDateTime::currentDateTime().date()) |
259 if (dateTime.date() == QDateTime::currentDateTime().date()) |
144 { |
260 { |
145 |
261 |
146 mConversation->setTimeStamp(resendStateNote + dateTime.toString(TIME_FORMAT)); |
262 mConversation->setTimeStamp(resendStateNote + dateTime.toString( |
147 } |
263 TIME_FORMAT)); |
|
264 } |
148 else |
265 else |
149 { |
266 { |
150 mConversation->setTimeStamp(resendStateNote + dateTime.toString(DATE_FORMAT)); |
267 mConversation->setTimeStamp(resendStateNote + dateTime.toString( |
151 } |
268 DATE_FORMAT)); |
152 |
269 } |
153 QDEBUG_WRITE_FORMAT("MsgConversationViewItem::updateChildItems msg type value",messageType) |
270 |
154 |
271 if (messageType == ConvergedMessage::Mms) |
155 if (messageType == ConvergedMessage::Sms || |
272 { |
156 messageType == ConvergedMessage::IM) |
273 //preview path |
157 { |
274 QString previewPath = index.data(Attachments).toString(); |
158 mConversation->setMMS(false); |
|
159 bodyText.replace(QChar::ParagraphSeparator, QChar::LineSeparator); |
|
160 bodyText.replace('\r', QChar::LineSeparator); |
|
161 mConversation->setBodyText(bodyText); |
|
162 } |
|
163 else if (messageType == ConvergedMessage::Mms) |
|
164 { |
|
165 mConversation->setMMS(true); |
|
166 QString attachments = index.data(Attachments).toString(); |
|
167 QString subject = index.data(Subject).toString(); |
275 QString subject = index.data(Subject).toString(); |
168 |
276 |
169 bool hasAttachments = (index.data(MessageProperty).toInt() |
277 int msgProperty = index.data(MessageProperty).toInt(); |
170 & ConvergedMessage::Attachment) ? true : false; |
278 bool hasAttachments = (msgProperty & EPreviewAttachment) ? true : false; |
171 |
279 |
172 if (hasAttachments) |
280 if (hasAttachments) |
173 { |
281 { |
174 mConversation->setAttachment(); |
282 mConversation->setAttachment(); |
175 } |
283 } |
176 else |
284 else |
177 { |
285 { |
178 mConversation->setAttachment(false); |
286 mConversation->setAttachment(false); |
179 } |
287 } |
180 QStringList mediaFiles = attachments.split('|', |
288 |
181 QString::SkipEmptyParts); |
|
182 //Can be used for preview icon |
|
183 QStringList imageFiles; |
|
184 |
|
185 MsgViewUtils viewUtils; |
|
186 |
|
187 for (int i = 0; i < mediaFiles.size(); ++i) |
|
188 { |
|
189 QString type = viewUtils.mimeTypeL(QDir::toNativeSeparators( |
|
190 mediaFiles.at(i))); |
|
191 |
|
192 if (type.contains("image")) |
|
193 { |
|
194 imageFiles << mediaFiles.at(i); |
|
195 mConversation->setImage(true); |
|
196 } |
|
197 else if (type.contains("video")) |
|
198 { |
|
199 mConversation->setVideo(false); |
|
200 } |
|
201 else if (type.contains("audio")) |
|
202 { |
|
203 mConversation->setAudio(true); |
|
204 } |
|
205 } |
|
206 // Now set the media contents |
289 // Now set the media contents |
207 if (!imageFiles.isEmpty()) |
290 |
208 { |
291 //preview image |
209 mConversation->setPreviewIconPath(imageFiles.at(0)); |
292 bool hasImage = (msgProperty & EPreviewImage) ? true : false; |
210 } |
293 if (hasImage) |
211 mConversation->displayAudioIcon(); |
294 { |
|
295 mConversation->setImage(true); |
|
296 HbIcon previewIcon; |
|
297 if (msgProperty & EPreviewProtectedImage) |
|
298 { |
|
299 previewIcon = HbIcon(IMAGE_ICON); |
|
300 } |
|
301 else if (msgProperty & EPreviewCorruptedImage) |
|
302 { |
|
303 // TODO: Change to official icon. |
|
304 previewIcon = HbIcon(CORRUPTED_ICON); |
|
305 } |
|
306 else |
|
307 { |
|
308 QVariant previewData = index.data(PreviewIcon); |
|
309 previewIcon = qvariant_cast<HbIcon> (previewData); |
|
310 } |
|
311 mConversation->setPreviewIcon(previewIcon); |
|
312 } |
|
313 |
|
314 bool hasVideo = (msgProperty & EPreviewVideo) ? true : false; |
|
315 if (hasVideo) |
|
316 { |
|
317 mConversation->setVideo(true); |
|
318 HbIcon videoPreviewIcon; |
|
319 if (msgProperty & EPreviewProtectedVideo) |
|
320 { |
|
321 videoPreviewIcon = HbIcon(MSG_VIDEO_ICON); |
|
322 } |
|
323 else if (msgProperty & EPreviewCorruptedVideo) |
|
324 { |
|
325 videoPreviewIcon = HbIcon(CORRUPTED_ICON); |
|
326 } |
|
327 else |
|
328 { |
|
329 videoPreviewIcon = HbIcon(MSG_VIDEO_ICON); |
|
330 } |
|
331 mConversation->setPreviewIcon(videoPreviewIcon); |
|
332 } |
|
333 bool hasAudio = (msgProperty & EPreviewAudio) ? true : false; |
|
334 if (hasAudio) |
|
335 { |
|
336 mConversation->setAudio(true); |
|
337 if (msgProperty & EPreviewProtectedAudio) |
|
338 { |
|
339 mConversation->displayAudioIcon(); |
|
340 } |
|
341 else if (msgProperty & EPreviewCorruptedAudio) |
|
342 { |
|
343 mConversation->displayAudioIcon(CORRUPTED_ICON); |
|
344 } |
|
345 else |
|
346 { |
|
347 mConversation->displayAudioIcon(); |
|
348 } |
|
349 } |
212 |
350 |
213 int priority = index.data(MessagePriority).toInt(); |
351 int priority = index.data(MessagePriority).toInt(); |
214 mConversation->setPriority(priority); |
352 mConversation->setPriority(priority); |
215 mConversation->setSubject(subject); |
353 mConversation->setSubject(subject); |
216 mConversation->setBodyText(bodyText); |
354 mConversation->setBodyText(bodyText); |
217 } // END of ConvergedMessage::Mms |
355 } |
218 else if (messageType == ConvergedMessage::BioMsg) |
356 else if (messageType == ConvergedMessage::BioMsg) |
219 { |
357 { |
220 if (messageSubType == ConvergedMessage::RingingTone) |
358 if (messageSubType == ConvergedMessage::RingingTone) |
221 { |
359 { |
222 mConversation->setMMS(true); |
|
223 mConversation->setImage(false); |
360 mConversation->setImage(false); |
224 mConversation->setAudio(true); |
361 mConversation->setAudio(true); |
225 mConversation->displayAudioIcon(); |
362 mConversation->displayAudioIcon(); |
226 mConversation->setSubject(LOC_RINGING_TONE); |
363 mConversation->setSubject(LOC_RINGING_TONE); |
227 } |
364 mConversation->setBodyText(bodyText); |
|
365 } |
228 else if (messageSubType == ConvergedMessage::VCard) |
366 else if (messageSubType == ConvergedMessage::VCard) |
229 { |
367 { |
230 mConversation->setMMS(true); |
|
231 mConversation->setImage(false); |
368 mConversation->setImage(false); |
232 mConversation->setAudio(true); |
369 mConversation->setAudio(true); |
233 mConversation->displayAudioIcon(VCARD_ICON); |
370 mConversation->displayAudioIcon(VCARD_ICON); |
234 mConversation->setSubject(LOC_BUSINESS_CARD); |
371 mConversation->setSubject(LOC_BUSINESS_CARD); |
235 mConversation->setBodyText(bodyText); |
372 mConversation->setBodyText(bodyText); |
236 } |
373 } |
237 else |
374 } |
238 { |
|
239 mConversation->setMMS(false); |
|
240 mConversation->setBodyText(LOC_UNSUPPORTED_MSG_TYPE); |
|
241 } |
|
242 } |
|
243 else if (messageType == ConvergedMessage::BT) |
375 else if (messageType == ConvergedMessage::BT) |
244 { |
376 { |
245 mConversation->setMMS(true); |
|
246 QString deviceName = index.data(ConversationAddress).toString(); |
377 QString deviceName = index.data(ConversationAddress).toString(); |
247 mConversation->setSubject(deviceName); |
378 mConversation->setSubject(deviceName); |
248 QString blueToothBody; |
379 QString blueToothBody; |
249 if (messageSubType == ConvergedMessage::VCard) |
380 if (messageSubType == ConvergedMessage::VCard) |
250 { |
381 { |
251 mConversation->setImage(false); |
382 mConversation->setImage(false); |
252 mConversation->setAudio(true); |
383 mConversation->setAudio(true); |
253 mConversation->displayAudioIcon(VCARD_ICON); |
384 mConversation->displayAudioIcon(VCARD_ICON); |
254 blueToothBody.append(LOC_BUSINESS_CARD); |
385 blueToothBody.append(LOC_BUSINESS_CARD); |
255 blueToothBody.append(QChar::LineSeparator); |
386 blueToothBody.append(QChar::LineSeparator); |
256 blueToothBody.append(bodyText); |
387 blueToothBody.append(bodyText); |
257 } |
388 } |
258 else |
389 else |
259 { |
390 { |
260 blueToothBody.append(bodyText); |
391 blueToothBody.append(bodyText); |
261 } |
392 } |
262 mConversation->setBodyText(blueToothBody); |
393 mConversation->setBodyText(blueToothBody); |
263 } |
394 } |
264 else if(messageType == ConvergedMessage::MmsNotification) |
395 else if (messageType == ConvergedMessage::MmsNotification) |
265 { |
396 { |
266 mConversation->setMMS(true); |
|
267 |
|
268 QString subject = index.data(Subject).toString(); |
397 QString subject = index.data(Subject).toString(); |
269 int priority = index.data(MessagePriority).toInt(); |
398 int priority = index.data(MessagePriority).toInt(); |
270 mConversation->setPriority(priority); |
399 mConversation->setPriority(priority); |
271 mConversation->setSubject(subject); |
400 mConversation->setSubject(subject); |
272 mConversation->setBodyText(bodyText); |
401 mConversation->setBodyText(bodyText); |
273 } |
402 } |
274 |
403 |
275 #ifdef _DEBUG_TRACES_ |
404 //repolish widget |
276 qCritical() << "END MsgConversationViewItem::updateChildItems: " |
405 mConversation->repolishWidget(); |
277 << index.data(ConvergedMsgId).toInt(); |
406 } |
278 #endif |
|
279 |
|
280 HbListViewItem::updateChildItems(); |
|
281 } |
|
282 |
407 |
283 //--------------------------------------------------------------- |
408 //--------------------------------------------------------------- |
284 // MsgConversationViewItem::containsPoint |
409 // MsgConversationViewItem::containsPoint |
285 // |
410 // |
286 //--------------------------------------------------------------- |
411 //--------------------------------------------------------------- |
287 bool MsgConversationViewItem::containsPoint(const QPointF& point) |
412 bool MsgConversationViewItem::containsPoint(const QPointF& point) |
288 { |
413 { |
289 return mConversation->boundingRect(). |
414 return mConversation->boundingRect(). contains(mConversation->mapFromScene( |
290 contains(mConversation->mapFromScene(point)); |
415 point)); |
291 } |
416 } |
292 |
417 |
293 //--------------------------------------------------------------- |
418 //--------------------------------------------------------------- |
294 // MsgConversationViewItem::setIncoming |
419 // MsgConversationViewItem::setIncoming |
295 // @see header file |
420 // @see header file |
296 //--------------------------------------------------------------- |
421 //--------------------------------------------------------------- |
297 void MsgConversationViewItem::setIncoming(bool incoming) |
422 void MsgConversationViewItem::setIncoming(bool incoming) |
298 { |
423 { |
299 mIncoming = incoming; |
424 mIncoming = incoming; |
|
425 |
|
426 if (mIncoming) |
|
427 { |
|
428 HbStyle::setItemName(mOutgoingMsgStateIconItem, ""); |
|
429 mOutgoingMsgStateIconItem->setVisible(false); |
|
430 HbStyle::setItemName(mIncomingMsgStateIconItem, "msgStateIconIncoming"); |
|
431 mIncomingMsgStateIconItem->setIcon(HbIcon()); |
|
432 mIncomingMsgStateIconItem->setVisible(false); |
|
433 } |
|
434 else |
|
435 { |
|
436 HbStyle::setItemName(mIncomingMsgStateIconItem, ""); |
|
437 mIncomingMsgStateIconItem->setVisible(false); |
|
438 HbStyle::setItemName(mOutgoingMsgStateIconItem, "msgStateIconOutgoing"); |
|
439 mOutgoingMsgStateIconItem->setIcon(HbIcon()); |
|
440 mOutgoingMsgStateIconItem->setVisible(false); |
|
441 } |
300 } |
442 } |
301 |
443 |
302 //--------------------------------------------------------------- |
444 //--------------------------------------------------------------- |
303 // MsgConversationViewItem::isIncoming |
445 // MsgConversationViewItem::isIncoming |
304 // @see header file |
446 // @see header file |