messagingapp/msgui/conversationview/src/msgconversationwidget.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
    22 #include <HbIconItem>
    22 #include <HbIconItem>
    23 #include <QPainter>
    23 #include <QPainter>
    24 #include <QPixmap>
    24 #include <QPixmap>
    25 #include <QImageReader>
    25 #include <QImageReader>
    26 #include <QDir>
    26 #include <QDir>
       
    27 #include <HbEffect>
    27 #include "debugtraces.h"
    28 #include "debugtraces.h"
    28 
    29 
    29 #include "convergedmessage.h"
    30 #include "convergedmessage.h"
    30 
    31 
    31 #define DEBUG_PAINT 0
       
    32 
       
    33 const int MAX_SIZE(200);
    32 const int MAX_SIZE(200);
    34 
    33 
    35 // Icons
    34 // Icons
    36 const QString MSG_FORWARD_ICON(":/icons/qtg_mono_forward.svg");
    35 const QString MSG_HIGH_PRIORITY_ICON("qtg_small_priority_high");
    37 
    36 const QString MSG_LOW_PRIORITY_ICON("qtg_small_priority_low");
    38 const QString MSG_HIGH_PRIORITY_ICON(":/icons/qtg_small_priority_high.svg");
    37 const QString MSG_ATTACH_ICON("qtg_small_attachment");
    39 const QString MSG_LOW_PRIORITY_ICON(":/icons/qtg_small_priority_low.svg");
    38 const QString MSG_AUDIO_ICON("qtg_large_music_player");
    40 
    39 const QString MSG_VIDEO_ICON("qtg_large_video_player");
    41 const QString MSG_ATTACH_ICON(":/icons/qtg_small_attachment.svg");
    40 const QString MSG_AUDIO_PLAY_ICON("qtg_large_music_player");
    42 
       
    43 const QString MSG_AUDIO_ICON(":/icons/qtg_large_music_player.png");
       
    44 const QString MSG_VIDEO_ICON(":/icons/video_icon.png");
       
    45 const QString MSG_AUDIO_PLAY_ICON(":/icons/qtg_large_music_player.png");
       
    46 
    41 
    47 
    42 
    48 // Frames
    43 // Frames
    49 const QString IN_CHAT_FRAME(":/bubble/qtg_fr_convlist_received_normal");
    44 const QString CV_RECEIVED_NORMAL_FR("qtg_fr_convlist_received_normal");
    50 const QString IN_CHAT_FRAME_PRESSED(":/bubble/qtg_fr_convlist_received_pressed");
    45 const QString CV_RECEIVED_PRESSED_FR("qtg_fr_convlist_received_pressed");
    51 const QString OUT_CHAT_FRAME(":/bubble/qtg_fr_convlist_sent_normal");
    46 const QString CV_RECEIVED_HIGHLIGHT_FR("qtg_fr_convlist_received_highlight");
    52 const QString OUT_CHAT_FRAME_PRESSED(":/bubble/qtg_fr_convlist_sent_pressed");
    47 const QString CV_SENT_NORMAL_FR("qtg_fr_convlist_sent_normal");
    53 const QString IN_CHAT_FRAME_UNREAD(":/bubble/qtg_fr_convlist_received_highlight");
    48 const QString CV_SENT_PRESSED_FR("qtg_fr_convlist_sent_pressed");
    54 const QString NEW_ITEM_FRAME(":/new_item/qtg_fr_list_new_item");
    49 const QString CV_SENT_HIGHLIGHT_FR("qtg_fr_convlist_sent_highlight");
    55 const QString SENDING_CHAT_FRAME(":/bubble/qtg_fr_convlist_sent_highlight");
    50 const QString NEW_ITEM_FRAME("qtg_fr_list_new_item");
    56 
       
    57 #define PLUGINPATH "conversationviewplugin.dll"
       
    58 
    51 
    59 //---------------------------------------------------------------
    52 //---------------------------------------------------------------
    60 // MsgConversationWidget::MsgConversationWidget
    53 // MsgConversationWidget::MsgConversationWidget
    61 // @see header file
    54 // @see header file
    62 //---------------------------------------------------------------
    55 //---------------------------------------------------------------
    68         mHasVideo(false),
    61         mHasVideo(false),
    69         mIsPlayable(false),
    62         mIsPlayable(false),
    70         mIncoming(false),
    63         mIncoming(false),
    71         mUnread(false),
    64         mUnread(false),
    72         mIsMMS(false),
    65         mIsMMS(false),
       
    66         mIsMMSNotification(false),
    73         mPriority(0),
    67         mPriority(0),
    74         mSendingState(0),
    68         mSendingState(0),
       
    69         mNotificationState(0),
    75         mNewFrameItem(NULL),
    70         mNewFrameItem(NULL),
    76         mBubbleFrameItem(NULL),
    71         mBubbleFrameItem(NULL),
    77         mSubjectTextItem(NULL),
    72         mSubjectTextItem(NULL),
    78         mBodyTextItem(NULL),
    73         mBodyTextItem(NULL),
    79         mTimeStampTextItem(NULL),
    74         mTimeStampTextItem(NULL),
   107     // Common to SMS/MMS
   102     // Common to SMS/MMS
   108 
   103 
   109     mBubbleFrameItem = new HbFrameItem(this);
   104     mBubbleFrameItem = new HbFrameItem(this);
   110     // ZValue is set to make the bubble to be rendered in behind text items.
   105     // ZValue is set to make the bubble to be rendered in behind text items.
   111     mBubbleFrameItem->setZValue(-1.0);
   106     mBubbleFrameItem->setZValue(-1.0);
       
   107     mBubbleFrameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   112     HbStyle::setItemName(mBubbleFrameItem, "bubble");
   108     HbStyle::setItemName(mBubbleFrameItem, "bubble");
   113 
   109 
   114     mBodyTextItem = new HbTextItem(this);
   110     mBodyTextItem = new HbTextItem(this);
   115     mBodyTextItem->setTextWrapping(Hb::TextWordWrap);
   111     mBodyTextItem->setTextWrapping(Hb::TextWordWrap);
   116     HbStyle::setItemName(mBodyTextItem, "bodyText");
   112     HbStyle::setItemName(mBodyTextItem, "bodyText");
   287 
   283 
   288 //---------------------------------------------------------------
   284 //---------------------------------------------------------------
   289 // MsgConversationWidget::displayAudioIcon
   285 // MsgConversationWidget::displayAudioIcon
   290 // @see header file
   286 // @see header file
   291 //---------------------------------------------------------------
   287 //---------------------------------------------------------------
   292 void MsgConversationWidget::displayAudioIcon()
   288 void MsgConversationWidget::displayAudioIcon(const QString &iconPath)
   293 {
   289 {
   294     if (hasAudio())
   290     if (hasAudio())
   295     {
   291     {
   296         if (hasImage())
   292         if (hasImage())
   297         {
   293         {
   298             if (!mPlayIconItem)
   294             if (!mPlayIconItem)
   299             {
   295             {
   300                 mPlayIconItem = new HbIconItem(this);
   296                 mPlayIconItem = new HbIconItem(this);
   301                 HbStyle::setItemName(mPlayIconItem, "playIcon");
   297                 HbStyle::setItemName(mPlayIconItem, "playIcon");
   302             }
   298             }
   303             mPlayIconItem->setIconName(MSG_AUDIO_PLAY_ICON);
   299             mPlayIconItem->setIconName(iconPath.isEmpty() ? MSG_AUDIO_PLAY_ICON : iconPath);
   304         }
   300         }
   305         else
   301         else
   306         {
   302         {
   307             if (!mAudioIconItem)
   303             if (!mAudioIconItem)
   308             {
   304             {
   309                 mAudioIconItem = new HbIconItem(this);
   305                 mAudioIconItem = new HbIconItem(this);
   310                 HbStyle::setItemName(mAudioIconItem, "audioIcon");
   306                 HbStyle::setItemName(mAudioIconItem, "audioIcon");
   311             }
   307             }
   312             mAudioIconItem->setIconName(MSG_AUDIO_ICON);
   308             mAudioIconItem->setIconName(iconPath.isEmpty() ? MSG_AUDIO_PLAY_ICON : iconPath);
   313         }
   309         }
   314     }
   310     }
   315 }
   311 }
   316 
   312 
   317 //---------------------------------------------------------------
   313 //---------------------------------------------------------------
   413 {
   409 {
   414     return mIsMMS;
   410     return mIsMMS;
   415 }
   411 }
   416 
   412 
   417 //---------------------------------------------------------------
   413 //---------------------------------------------------------------
       
   414 // MsgConversationWidget::setMMSNotification
       
   415 // @see header file
       
   416 //---------------------------------------------------------------
       
   417 void MsgConversationWidget::setMMSNotification(bool isMMSNotification)
       
   418 {
       
   419     mIsMMSNotification = isMMSNotification;
       
   420 }
       
   421 
       
   422 //---------------------------------------------------------------
       
   423 // MsgConversationWidget::isMMS
       
   424 // @see header file
       
   425 //---------------------------------------------------------------
       
   426 bool MsgConversationWidget::isMMSNotification()
       
   427 {
       
   428     return mIsMMSNotification;
       
   429 }
       
   430 
       
   431 //---------------------------------------------------------------
   418 // MsgConversationWidget::setSendingState
   432 // MsgConversationWidget::setSendingState
   419 // @see header file
   433 // @see header file
   420 //---------------------------------------------------------------
   434 //---------------------------------------------------------------
   421 void MsgConversationWidget::setSendingState(int state)
   435 void MsgConversationWidget::setSendingState(int state)
   422 {
   436 {
   460 {
   474 {
   461     return mSendingState;
   475     return mSendingState;
   462 }
   476 }
   463 
   477 
   464 //---------------------------------------------------------------
   478 //---------------------------------------------------------------
       
   479 // MsgConversationWidget::setNotificationState
       
   480 // @see header file
       
   481 //---------------------------------------------------------------
       
   482 void MsgConversationWidget::setNotificationState(int state)
       
   483 {
       
   484     switch (state)
       
   485     {
       
   486         case ConvergedMessage::NotifFailed:
       
   487         {
       
   488             mNotificationState = NotifFailed;
       
   489             break;
       
   490         }
       
   491         case ConvergedMessage::NotifReadyForFetching:
       
   492         {
       
   493             mNotificationState = NotifReadyForFetching;
       
   494             break;
       
   495         }
       
   496         case ConvergedMessage::NotifRetrieving:
       
   497         case ConvergedMessage::NotifWaiting:
       
   498         {
       
   499             mNotificationState = NotifRetrieving;
       
   500             break;
       
   501         }
       
   502         case ConvergedMessage::NotifExpired:
       
   503         {
       
   504             mNotificationState = NotifExpired;
       
   505             break;
       
   506         }
       
   507         default:
       
   508         {
       
   509             mNotificationState = NotifUnknown;
       
   510             break;
       
   511         }
       
   512     }
       
   513 }
       
   514 
       
   515 //---------------------------------------------------------------
       
   516 // MsgConversationWidget::notificationState
       
   517 // @see header file
       
   518 //---------------------------------------------------------------
       
   519 int MsgConversationWidget::notificationState()
       
   520 {
       
   521     return mNotificationState;
       
   522 }
       
   523 
       
   524 //---------------------------------------------------------------
   465 // MsgConversationWidget::setTimeStamp
   525 // MsgConversationWidget::setTimeStamp
   466 // @see header file
   526 // @see header file
   467 //---------------------------------------------------------------
   527 //---------------------------------------------------------------
   468 void MsgConversationWidget::setTimeStamp(const QString &timeStamp)
   528 void MsgConversationWidget::setTimeStamp(const QString &timeStamp)
   469 {
   529 {
   491 // MsgConversationWidget::drawBubbleFrame
   551 // MsgConversationWidget::drawBubbleFrame
   492 // @see header file
   552 // @see header file
   493 //---------------------------------------------------------------
   553 //---------------------------------------------------------------
   494 void MsgConversationWidget::drawBubbleFrame()
   554 void MsgConversationWidget::drawBubbleFrame()
   495 {
   555 {
   496     mBubbleFrameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   497     mBubbleFrameItem->frameDrawer().setFillWholeRect(true);
       
   498 
       
   499     if(isIncoming())
   556     if(isIncoming())
   500     {
   557     {
   501         mBubbleFrameItem->frameDrawer().setFrameGraphicsName(IN_CHAT_FRAME);
   558         if (mIsMMSNotification && (mNotificationState == NotifUnknown
       
   559                 || mNotificationState == NotifRetrieving ))
       
   560         {
       
   561             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(
       
   562                 CV_RECEIVED_HIGHLIGHT_FR);
       
   563             //Inactive state bubble  
       
   564         }
       
   565         else
       
   566         {
       
   567             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_RECEIVED_NORMAL_FR);
       
   568         }
   502     }
   569     }
   503     else
   570     else
   504     {
   571     {
   505         if(mSendingState == Sending || mSendingState == Pending || mSendingState == Unknown)
   572         if(mSendingState == Sending || mSendingState == Pending || 
   506         {
   573            mSendingState == Unknown || mSendingState == Failed)
   507             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(SENDING_CHAT_FRAME);
   574         {
       
   575             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_SENT_HIGHLIGHT_FR);
   508         }
   576         }
   509         else
   577         else
   510         {
   578         {
   511             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(OUT_CHAT_FRAME);
   579             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_SENT_NORMAL_FR);
   512         }
   580         }
       
   581     }
       
   582 }
       
   583 
       
   584 //---------------------------------------------------------------
       
   585 // MsgConversationWidget::drawPressedBubbleFrame
       
   586 // @see header file
       
   587 //---------------------------------------------------------------
       
   588 void MsgConversationWidget::drawPressedBubbleFrame()
       
   589 {
       
   590     if(isIncoming())
       
   591     {
       
   592         mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_RECEIVED_PRESSED_FR);
       
   593     }
       
   594     else
       
   595     {
       
   596         mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_SENT_PRESSED_FR);
       
   597     }
       
   598 }
       
   599 
       
   600 //---------------------------------------------------------------
       
   601 // MsgConversationWidget::pressStateChanged
       
   602 // @see header file
       
   603 //---------------------------------------------------------------
       
   604 void MsgConversationWidget::pressStateChanged(bool pressed, bool animate)
       
   605 {
       
   606     Q_UNUSED(animate)
       
   607 
       
   608     if (mBubbleFrameItem) {
       
   609         (pressed) ? drawPressedBubbleFrame() : drawBubbleFrame();
   513     }
   610     }
   514 }
   611 }
   515 
   612 
   516 // EOF
   613 // EOF