39 const QString MSG_OUTBOX_ICON("qtg_small_outbox"); |
40 const QString MSG_OUTBOX_ICON("qtg_small_outbox"); |
40 const QString MSG_FAIL_ICON("qtg_small_fail"); |
41 const QString MSG_FAIL_ICON("qtg_small_fail"); |
41 const QString ANIMATION_FILE(":/qtg_anim_loading.axml"); |
42 const QString ANIMATION_FILE(":/qtg_anim_loading.axml"); |
42 const QString ANIMATION_ICON_NAME("qtg_anim_loading"); |
43 const QString ANIMATION_ICON_NAME("qtg_anim_loading"); |
43 const QString VCARD_ICON("qtg_large_mycard"); |
44 const QString VCARD_ICON("qtg_large_mycard"); |
|
45 const QString IMAGE_ICON("qtg_small_image"); |
|
46 const QString CORRUPTED_ICON("qtg_small_corrupted"); |
|
47 const QString MSG_VIDEO_ICON("qtg_small_video"); |
44 |
48 |
45 // LOCALIZATION |
49 // LOCALIZATION |
46 #define LOC_RINGING_TONE hbTrId("txt_messaging_dpopinfo_ringing_tone") |
50 #define LOC_RINGING_TONE hbTrId("txt_messaging_dpopinfo_ringing_tone") |
47 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_list_business_card") |
51 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_list_business_card") |
48 #define LOC_CALENDAR_EVENT hbTrId("txt_messaging_list_calendar_event") |
52 #define LOC_CALENDAR_EVENT hbTrId("txt_messaging_list_calendar_event") |
53 // MsgConversationViewItem::MsgConversationViewItem |
57 // MsgConversationViewItem::MsgConversationViewItem |
54 // Constructor |
58 // Constructor |
55 //--------------------------------------------------------------- |
59 //--------------------------------------------------------------- |
56 MsgConversationViewItem::MsgConversationViewItem(QGraphicsItem* parent) : |
60 MsgConversationViewItem::MsgConversationViewItem(QGraphicsItem* parent) : |
57 HbListViewItem(parent), mIncoming(false), mConversation(0), |
61 HbListViewItem(parent), mIncoming(false), mConversation(0), |
58 mMessageStateIconItem(0) |
62 mIncomingMsgStateIconItem(0), mOutgoingMsgStateIconItem(0) |
59 { |
63 { |
60 } |
64 } |
61 |
65 |
62 //--------------------------------------------------------------- |
66 //--------------------------------------------------------------- |
63 // MsgConversationViewItem::MsgConversationViewItem |
67 // MsgConversationViewItem::MsgConversationViewItem |
70 //--------------------------------------------------------------- |
74 //--------------------------------------------------------------- |
71 // MsgConversationViewItem::createItem |
75 // MsgConversationViewItem::createItem |
72 // Create a new decorator item. |
76 // Create a new decorator item. |
73 //--------------------------------------------------------------- |
77 //--------------------------------------------------------------- |
74 MsgConversationViewItem* MsgConversationViewItem::createItem() |
78 MsgConversationViewItem* MsgConversationViewItem::createItem() |
75 { |
79 { |
76 return new MsgConversationViewItem(*this); |
80 MsgConversationViewItem *item = new MsgConversationViewItem(*this); |
77 } |
81 item->init(); |
|
82 return item; |
|
83 } |
78 |
84 |
79 //--------------------------------------------------------------- |
85 //--------------------------------------------------------------- |
80 // MsgConversationViewItem::updateChildItems |
86 // MsgConversationViewItem::updateChildItems |
81 // |
87 // |
82 //--------------------------------------------------------------- |
88 //--------------------------------------------------------------- |
83 void MsgConversationViewItem::updateChildItems() |
89 void MsgConversationViewItem::updateChildItems() |
84 { |
90 { |
85 |
|
86 if (!mMessageStateIconItem) |
|
87 { |
|
88 mMessageStateIconItem = new HbIconItem(this); |
|
89 HbStyle::setItemName(mMessageStateIconItem, "msgStateIcon"); |
|
90 } |
|
91 |
|
92 QModelIndex index = modelIndex(); |
91 QModelIndex index = modelIndex(); |
93 |
92 |
94 #ifdef _DEBUG_TRACES_ |
93 #ifdef _DEBUG_TRACES_ |
95 qCritical() << "START MsgConversationViewItem::updateChildItems: " |
94 qCritical() << "START MsgConversationViewItem::updateChildItems: " |
96 << index.data(ConvergedMsgId).toInt(); |
95 << index.data(ConvergedMsgId).toInt(); |
134 |
133 |
135 //--------------------------------------------------------------- |
134 //--------------------------------------------------------------- |
136 // MsgConversationViewItem::updateSmsTypeItem |
135 // MsgConversationViewItem::updateSmsTypeItem |
137 // @see header file |
136 // @see header file |
138 //--------------------------------------------------------------- |
137 //--------------------------------------------------------------- |
139 void MsgConversationViewItem::updateSmsTypeItem(const QModelIndex& index, int messageSubType) |
138 void MsgConversationViewItem::updateSmsTypeItem(const QModelIndex& index, |
140 { |
139 int messageSubType) |
141 |
140 { |
142 if (!mConversation) |
141 |
143 { |
|
144 mConversation = new MsgConversationWidget(this); |
|
145 HbStyle::setItemName(mConversation, "msgconvwidget"); |
|
146 } |
|
147 mIncoming = false; |
142 mIncoming = false; |
148 mConversation->resetProperties(); |
143 mConversation->resetProperties(); |
149 |
144 |
150 int direction = index.data(Direction).toInt(); |
145 int direction = index.data(Direction).toInt(); |
151 |
146 |
152 if (direction == ConvergedMessage::Incoming) |
147 if (direction == ConvergedMessage::Incoming) |
153 { |
148 { |
154 setIncoming(true); |
149 setIncoming(true); |
155 mConversation->setIncoming(true); |
150 mConversation->setIncoming(true); |
156 |
151 |
157 mMessageStateIconItem->setVisible(false); |
152 mIncomingMsgStateIconItem->setVisible(false); |
158 } |
153 } |
159 else if (direction == ConvergedMessage::Outgoing) |
154 else if (direction == ConvergedMessage::Outgoing) |
160 { |
155 { |
161 setIncoming(false); |
156 setIncoming(false); |
162 mConversation->setIncoming(false); |
157 mConversation->setIncoming(false); |
163 |
158 |
293 |
288 |
294 // Now set the media contents |
289 // Now set the media contents |
295 |
290 |
296 //preview image |
291 //preview image |
297 bool hasImage = (msgProperty & EPreviewImage) ? true : false; |
292 bool hasImage = (msgProperty & EPreviewImage) ? true : false; |
298 |
|
299 if (hasImage) |
293 if (hasImage) |
300 { |
294 { |
301 int msgId = index.data(ConvergedMsgId).toInt(); |
|
302 mConversation->setPreviewIconPath(previewPath, msgId); |
|
303 mConversation->setImage(true); |
295 mConversation->setImage(true); |
304 } |
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 } |
305 |
313 |
306 bool hasVideo = (msgProperty & EPreviewVideo) ? true : false; |
314 bool hasVideo = (msgProperty & EPreviewVideo) ? true : false; |
307 |
|
308 if (hasVideo) |
315 if (hasVideo) |
309 { |
316 { |
310 mConversation->setVideo(true); |
317 mConversation->setVideo(true); |
311 } |
318 HbIcon videoPreviewIcon; |
312 |
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 } |
313 bool hasAudio = (msgProperty & EPreviewAudio) ? true : false; |
333 bool hasAudio = (msgProperty & EPreviewAudio) ? true : false; |
314 if (hasAudio) |
334 if (hasAudio) |
315 { |
335 { |
316 mConversation->setAudio(true); |
336 mConversation->setAudio(true); |
317 } |
337 if (msgProperty & EPreviewProtectedAudio) |
318 |
338 { |
319 mConversation->displayAudioIcon(); |
339 mConversation->displayAudioIcon(); |
|
340 } |
|
341 else if (msgProperty & EPreviewCorruptedAudio) |
|
342 { |
|
343 mConversation->displayAudioIcon(CORRUPTED_ICON); |
|
344 } |
|
345 else |
|
346 { |
|
347 mConversation->displayAudioIcon(); |
|
348 } |
|
349 } |
320 |
350 |
321 int priority = index.data(MessagePriority).toInt(); |
351 int priority = index.data(MessagePriority).toInt(); |
322 mConversation->setPriority(priority); |
352 mConversation->setPriority(priority); |
323 mConversation->setSubject(subject); |
353 mConversation->setSubject(subject); |
324 mConversation->setBodyText(bodyText); |
354 mConversation->setBodyText(bodyText); |
329 { |
359 { |
330 mConversation->setImage(false); |
360 mConversation->setImage(false); |
331 mConversation->setAudio(true); |
361 mConversation->setAudio(true); |
332 mConversation->displayAudioIcon(); |
362 mConversation->displayAudioIcon(); |
333 mConversation->setSubject(LOC_RINGING_TONE); |
363 mConversation->setSubject(LOC_RINGING_TONE); |
|
364 mConversation->setBodyText(bodyText); |
334 } |
365 } |
335 else if (messageSubType == ConvergedMessage::VCard) |
366 else if (messageSubType == ConvergedMessage::VCard) |
336 { |
367 { |
337 mConversation->setImage(false); |
368 mConversation->setImage(false); |
338 mConversation->setAudio(true); |
369 mConversation->setAudio(true); |
378 // MsgConversationViewItem::containsPoint |
409 // MsgConversationViewItem::containsPoint |
379 // |
410 // |
380 //--------------------------------------------------------------- |
411 //--------------------------------------------------------------- |
381 bool MsgConversationViewItem::containsPoint(const QPointF& point) |
412 bool MsgConversationViewItem::containsPoint(const QPointF& point) |
382 { |
413 { |
383 return mConversation->boundingRect(). |
414 return mConversation->boundingRect(). contains(mConversation->mapFromScene( |
384 contains(mConversation->mapFromScene(point)); |
415 point)); |
385 } |
416 } |
386 |
417 |
387 //--------------------------------------------------------------- |
418 //--------------------------------------------------------------- |
388 // MsgConversationViewItem::setIncoming |
419 // MsgConversationViewItem::setIncoming |
389 // @see header file |
420 // @see header file |
390 //--------------------------------------------------------------- |
421 //--------------------------------------------------------------- |
391 void MsgConversationViewItem::setIncoming(bool incoming) |
422 void MsgConversationViewItem::setIncoming(bool incoming) |
392 { |
423 { |
393 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 } |
394 } |
442 } |
395 |
443 |
396 //--------------------------------------------------------------- |
444 //--------------------------------------------------------------- |
397 // MsgConversationViewItem::isIncoming |
445 // MsgConversationViewItem::isIncoming |
398 // @see header file |
446 // @see header file |
406 // MsgConversationViewItem::setMessageStateIcon |
454 // MsgConversationViewItem::setMessageStateIcon |
407 // @see header file |
455 // @see header file |
408 //--------------------------------------------------------------- |
456 //--------------------------------------------------------------- |
409 void MsgConversationViewItem::setMessageStateIcon(int messageState) |
457 void MsgConversationViewItem::setMessageStateIcon(int messageState) |
410 { |
458 { |
411 HbIconAnimator& iconAnimator = mMessageStateIconItem->animator(); |
459 HbIconAnimator& iconAnimator = mOutgoingMsgStateIconItem->animator(); |
412 HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global(); |
460 HbIconAnimationManager* iconAnimationManager = |
|
461 HbIconAnimationManager::global(); |
413 switch (messageState) |
462 switch (messageState) |
414 { |
463 { |
415 case ConvergedMessage::Waiting: |
464 case ConvergedMessage::Waiting: |
416 case ConvergedMessage::Scheduled: |
465 case ConvergedMessage::Scheduled: |
417 case ConvergedMessage::Sending: |
466 case ConvergedMessage::Sending: |
418 { |
467 { |
419 bool defined = iconAnimationManager->addDefinitionFile(ANIMATION_FILE); |
468 bool defined = iconAnimationManager->addDefinitionFile( |
420 HbIcon animIcon; |
469 ANIMATION_FILE); |
|
470 HbIcon animIcon; |
421 animIcon.setIconName(ANIMATION_ICON_NAME); |
471 animIcon.setIconName(ANIMATION_ICON_NAME); |
422 QSizeF size = mMessageStateIconItem->size(); |
472 QSizeF size = mOutgoingMsgStateIconItem->size(); |
423 mMessageStateIconItem->setIcon(animIcon); |
473 mOutgoingMsgStateIconItem->setIcon(animIcon); |
424 mMessageStateIconItem->setVisible(true); |
474 mOutgoingMsgStateIconItem->setVisible(true); |
425 iconAnimator.startAnimation(); |
475 iconAnimator.startAnimation(); |
426 repolish(); |
|
427 break; |
476 break; |
428 } |
477 } |
429 case ConvergedMessage::Suspended: |
478 case ConvergedMessage::Suspended: |
430 { |
479 { |
431 iconAnimator.stopAnimation(); |
480 iconAnimator.stopAnimation(); |
432 mMessageStateIconItem->setIcon(MSG_OUTBOX_ICON); |
481 mOutgoingMsgStateIconItem->setIcon(MSG_OUTBOX_ICON); |
433 mMessageStateIconItem->setVisible(true); |
482 mOutgoingMsgStateIconItem->setVisible(true); |
434 break; |
483 break; |
435 |
484 |
436 } |
485 } |
437 case ConvergedMessage::Resend: |
486 case ConvergedMessage::Resend: |
438 { |
487 { |
439 iconAnimator.stopAnimation(); |
488 iconAnimator.stopAnimation(); |
440 mMessageStateIconItem->setIcon(MSG_OUTBOX_ICON); |
489 mOutgoingMsgStateIconItem->setIcon(MSG_OUTBOX_ICON); |
441 mMessageStateIconItem->setVisible(true); |
490 mOutgoingMsgStateIconItem->setVisible(true); |
442 break; |
491 break; |
443 } |
492 } |
444 case ConvergedMessage::Failed: |
493 case ConvergedMessage::Failed: |
445 { |
494 { |
446 iconAnimator.stopAnimation(); |
495 iconAnimator.stopAnimation(); |
447 mMessageStateIconItem->setIcon(MSG_FAIL_ICON); |
496 mOutgoingMsgStateIconItem->setIcon(MSG_FAIL_ICON); |
448 mMessageStateIconItem->setVisible(true); |
497 mOutgoingMsgStateIconItem->setVisible(true); |
449 break; |
498 break; |
450 } |
499 } |
451 case ConvergedMessage::Unknown: |
500 case ConvergedMessage::Unknown: |
452 default: |
501 default: |
453 { |
502 { |
454 iconAnimator.stopAnimation(); |
503 iconAnimator.stopAnimation(); |
455 mMessageStateIconItem->setVisible(false); |
504 mOutgoingMsgStateIconItem->setVisible(false); |
456 break; |
505 break; |
457 } |
506 } |
458 } |
507 } |
459 } |
508 } |
460 |
509 |
463 // @see header file |
512 // @see header file |
464 //--------------------------------------------------------------- |
513 //--------------------------------------------------------------- |
465 |
514 |
466 void MsgConversationViewItem::setNotificationStateIcon(int notificationState) |
515 void MsgConversationViewItem::setNotificationStateIcon(int notificationState) |
467 { |
516 { |
468 HbIconAnimator& iconAnimator = mMessageStateIconItem->animator(); |
517 HbIconAnimator& iconAnimator = mIncomingMsgStateIconItem->animator(); |
469 HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global(); |
518 HbIconAnimationManager* iconAnimationManager = |
|
519 HbIconAnimationManager::global(); |
470 switch (notificationState) |
520 switch (notificationState) |
471 { |
521 { |
472 case ConvergedMessage::NotifRetrieving: |
522 case ConvergedMessage::NotifRetrieving: |
473 case ConvergedMessage::NotifWaiting: |
523 case ConvergedMessage::NotifWaiting: |
474 { |
524 { |
475 //TODO: Temp icon until official icons are received |
525 //TODO: Temp icon until official icons are received |
476 bool defined = iconAnimationManager->addDefinitionFile(ANIMATION_FILE); |
526 bool defined = iconAnimationManager->addDefinitionFile( |
|
527 ANIMATION_FILE); |
477 HbIcon animIcon; |
528 HbIcon animIcon; |
478 animIcon.setIconName(ANIMATION_ICON_NAME); |
529 animIcon.setIconName(ANIMATION_ICON_NAME); |
479 QSizeF size = mMessageStateIconItem->size(); |
530 QSizeF size = mIncomingMsgStateIconItem->size(); |
480 mMessageStateIconItem->setIcon(animIcon); |
531 mIncomingMsgStateIconItem->setIcon(animIcon); |
481 mMessageStateIconItem->setVisible(true); |
532 mIncomingMsgStateIconItem->setVisible(true); |
482 iconAnimator.startAnimation(); |
533 iconAnimator.startAnimation(); |
483 repolish(); |
|
484 break; |
534 break; |
485 } |
535 } |
486 default: |
536 default: |
487 { |
537 { |
488 iconAnimator.stopAnimation(); |
538 iconAnimator.stopAnimation(); |
489 mMessageStateIconItem->setVisible(false); |
539 mIncomingMsgStateIconItem->setVisible(false); |
490 break; |
540 break; |
491 } |
541 } |
492 } |
542 } |
493 } |
543 } |
494 |
544 |
499 void MsgConversationViewItem::pressStateChanged (bool pressed, bool animate) |
549 void MsgConversationViewItem::pressStateChanged (bool pressed, bool animate) |
500 { |
550 { |
501 mConversation->pressStateChanged(pressed, animate); |
551 mConversation->pressStateChanged(pressed, animate); |
502 } |
552 } |
503 |
553 |
|
554 //--------------------------------------------------------------- |
|
555 // MsgConversationViewItem::init |
|
556 // @see header file |
|
557 //--------------------------------------------------------------- |
|
558 void MsgConversationViewItem::init() |
|
559 { |
|
560 mConversation = new MsgConversationWidget(this); |
|
561 HbStyle::setItemName(mConversation, "msgconvwidget"); |
|
562 |
|
563 mIncomingMsgStateIconItem = new HbIconItem(this); |
|
564 HbStyle::setItemName(mIncomingMsgStateIconItem, "msgStateIconIncoming"); |
|
565 |
|
566 mOutgoingMsgStateIconItem = new HbIconItem(this); |
|
567 HbStyle::setItemName(mOutgoingMsgStateIconItem, "msgStateIconOutgoing"); |
|
568 |
|
569 HbMainWindow *mainWindow = hbInstance->allMainWindows()[0]; |
|
570 |
|
571 connect(mainWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, |
|
572 SLOT(orientationchanged(Qt::Orientation)), Qt::UniqueConnection); |
|
573 |
|
574 // Force polish to get all the sub-item properties right. |
|
575 polishEvent(); |
|
576 } |
|
577 |
|
578 //--------------------------------------------------------------- |
|
579 // MsgConversationViewItem::orientationchanged |
|
580 // @see header file |
|
581 //--------------------------------------------------------------- |
|
582 void MsgConversationViewItem::orientationchanged(Qt::Orientation orientation) |
|
583 { |
|
584 QDEBUG_WRITE("MsgConversationViewItem:orientationchanged start.") |
|
585 |
|
586 repolish(); |
|
587 |
|
588 QDEBUG_WRITE("MsgConversationViewItem:orientationchanged end.") |
|
589 } |
|
590 |
504 // EOF |
591 // EOF |