messagingapp/msgui/conversationview/src/msgconversationwidget.cpp
changeset 31 ebfee66fde93
child 34 84197e66a4bd
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:
       
    15  *
       
    16  */
       
    17 #include "msgconversationwidget.h"
       
    18 
       
    19 #include <HbTextItem>
       
    20 #include <HbFrameItem>
       
    21 #include <HbFrameDrawer>
       
    22 #include <HbIconItem>
       
    23 #include <QPainter>
       
    24 #include <QPixmap>
       
    25 #include <QImageReader>
       
    26 #include <QDir>
       
    27 #include <HbEffect>
       
    28 #include <s32strm.h>
       
    29 #include <s32mem.h>
       
    30 #include <fbs.h>
       
    31 #include <sqldb.h>
       
    32 #include <QBool>
       
    33 #include <QCoreApplication>
       
    34 #include <HbEvent>
       
    35 
       
    36 #include "debugtraces.h"
       
    37 
       
    38 #include "convergedmessage.h"
       
    39 #include "conversationsengine.h"
       
    40 
       
    41 // Icons
       
    42 const QString MSG_HIGH_PRIORITY_ICON("qtg_small_priority_high");
       
    43 const QString MSG_LOW_PRIORITY_ICON("qtg_small_priority_low");
       
    44 const QString MSG_ATTACH_ICON("qtg_small_attachment");
       
    45 const QString MSG_AUDIO_ICON("qtg_large_music_player");
       
    46 const QString MSG_VIDEO_ICON("qtg_large_video_player");
       
    47 const QString MSG_AUDIO_PLAY_ICON("qtg_large_music_player");
       
    48 
       
    49 
       
    50 // Frames
       
    51 const QString CV_RECEIVED_NORMAL_FR("qtg_fr_convlist_received_normal");
       
    52 const QString CV_RECEIVED_PRESSED_FR("qtg_fr_convlist_received_pressed");
       
    53 const QString CV_RECEIVED_HIGHLIGHT_FR("qtg_fr_convlist_received_highlight");
       
    54 const QString CV_SENT_NORMAL_FR("qtg_fr_convlist_sent_normal");
       
    55 const QString CV_SENT_PRESSED_FR("qtg_fr_convlist_sent_pressed");
       
    56 const QString CV_SENT_HIGHLIGHT_FR("qtg_fr_convlist_sent_highlight");
       
    57 const QString NEW_ITEM_FRAME("qtg_fr_list_new_item");
       
    58 
       
    59 //selecet preview-icon query
       
    60 _LIT(KSelectPreviewIconStmt,"SELECT  message_id, preview_icon FROM conversation_messages WHERE message_id = :message_id ");
       
    61 
       
    62 //---------------------------------------------------------------
       
    63 // MsgConversationWidget::MsgConversationWidget
       
    64 // @see header file
       
    65 //---------------------------------------------------------------
       
    66 MsgConversationWidget::MsgConversationWidget(QGraphicsItem *parent) :
       
    67         HbWidget(parent),
       
    68         mHasAttachment(false),
       
    69         mHasImage(false),
       
    70         mHasAudio(false),
       
    71         mHasVideo(false),
       
    72         mIsPlayable(false),
       
    73         mIncoming(false),
       
    74         mUnread(false),
       
    75         mIsMMS(false),
       
    76         mIsMMSNotification(false),
       
    77         mPriority(0),
       
    78         mSendingState(Unknown),
       
    79         mNotificationState(0),
       
    80         mNewFrameItem(NULL),
       
    81         mBubbleFrameItem(NULL),
       
    82         mSubjectTextItem(NULL),
       
    83         mBodyTextItem(NULL),
       
    84         mTimeStampTextItem(NULL),
       
    85         mPriorityIconItem(NULL),
       
    86         mAttachmentIconItem(NULL),
       
    87         mAudioIconItem(NULL),
       
    88         mVideoIconItem(NULL),
       
    89         mPlayIconItem(NULL),
       
    90         mPreviewIconItem(NULL)
       
    91 
       
    92 
       
    93 {
       
    94     init();
       
    95 }
       
    96 
       
    97 //---------------------------------------------------------------
       
    98 // MsgConversationWidget::~MsgConversationWidget
       
    99 // @see header file
       
   100 //---------------------------------------------------------------
       
   101 MsgConversationWidget::~MsgConversationWidget()
       
   102 {
       
   103 
       
   104 }
       
   105 
       
   106 //---------------------------------------------------------------
       
   107 // MsgConversationWidget::init
       
   108 // @see header file
       
   109 //---------------------------------------------------------------
       
   110 void MsgConversationWidget::init()
       
   111 {
       
   112     // Common to SMS/MMS
       
   113 
       
   114     mBubbleFrameItem = new HbFrameItem(this);
       
   115     mBubbleFrameItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   116     HbStyle::setItemName(mBubbleFrameItem, "bubble");
       
   117 
       
   118     mNewFrameItem = new HbFrameItem(this);
       
   119     mNewFrameItem->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesVertical);
       
   120     HbStyle::setItemName(mNewFrameItem, "newItemIcon");
       
   121     	
       
   122     }
       
   123 
       
   124 //---------------------------------------------------------------
       
   125 // MsgConversationWidget::setSubject
       
   126 // @see header file
       
   127 //---------------------------------------------------------------
       
   128 void MsgConversationWidget::setSubject(const QString &subject)
       
   129 {
       
   130     if (!mSubjectTextItem)
       
   131     {
       
   132         mSubjectTextItem = new HbTextItem(this);  
       
   133         mSubjectTextItem->setTextWrapping(Hb::TextWordWrap);      
       
   134     }
       
   135     HbStyle::setItemName(mSubjectTextItem, "subject");
       
   136     mSubjectTextItem->setText(subject);
       
   137     mSubjectTextItem->show();
       
   138 }
       
   139 
       
   140 //---------------------------------------------------------------
       
   141 // MsgConversationWidget::setBodyText
       
   142 // @see header file
       
   143 //---------------------------------------------------------------
       
   144 void MsgConversationWidget::setBodyText(const QString &body)
       
   145 {
       
   146     if (!mBodyTextItem)
       
   147     {
       
   148         mBodyTextItem = new HbTextItem(this);
       
   149         mBodyTextItem->setTextWrapping(Hb::TextWordWrap);
       
   150     }
       
   151     HbStyle::setItemName(mBodyTextItem, "bodyText");
       
   152 
       
   153     mBodyTextItem->setText(body);
       
   154     mBodyTextItem->show();
       
   155 }
       
   156 
       
   157 //---------------------------------------------------------------
       
   158 // MsgConversationWidget::setPreviewIconPath
       
   159 // @see header file
       
   160 //---------------------------------------------------------------
       
   161 void MsgConversationWidget::setPreviewIconPath(const QString &filePath,int msgId)
       
   162 {
       
   163     if (!mPreviewIconItem)
       
   164     {
       
   165         mPreviewIconItem = new HbIconItem(this);
       
   166         mPreviewIconItem->setAlignment(Qt::AlignHCenter | Qt::AlignTop);        
       
   167     }
       
   168 
       
   169     HbStyle::setItemName(mPreviewIconItem, "preview");
       
   170     //sql query to get preview-icon from DB
       
   171     TBool isOpen = EFalse;
       
   172     bool imagePreviewed = false;
       
   173 
       
   174     //get DB handle and check if it is open
       
   175     RSqlDatabase& sqlDb = ConversationsEngine::instance()->getDBHandle(isOpen);
       
   176     if (isOpen)
       
   177     {
       
   178         RSqlStatement sqlSelectPreviewIconStmt;
       
   179         TInt err = sqlSelectPreviewIconStmt.Prepare(sqlDb,
       
   180             KSelectPreviewIconStmt);
       
   181 
       
   182         QCRITICAL_WRITE_FORMAT("Error from Prepare()", err)
       
   183 
       
   184         if (err == KErrNone)
       
   185         {
       
   186             //msg_id
       
   187             TInt msgIdIndex = sqlSelectPreviewIconStmt.ParameterIndex(
       
   188                 _L(":message_id"));
       
   189             sqlSelectPreviewIconStmt.BindInt(msgIdIndex, msgId);
       
   190 
       
   191             // get preview-icon from DB
       
   192             err = sqlSelectPreviewIconStmt.Next();
       
   193             QCRITICAL_WRITE_FORMAT("Error from Next()", err)
       
   194 
       
   195             if (err == KSqlAtRow)
       
   196             {
       
   197                 TInt previewIconIndex = sqlSelectPreviewIconStmt.ColumnIndex(
       
   198                     _L("preview_icon"));
       
   199 
       
   200                 RSqlColumnReadStream stream;
       
   201 
       
   202                 //Get data from binary column BLOB
       
   203                 err = stream.ColumnBinary(sqlSelectPreviewIconStmt,
       
   204                     previewIconIndex);
       
   205 
       
   206                 QCRITICAL_WRITE_FORMAT("Error from ColumnBinary()", err)
       
   207 
       
   208                 if (err == KErrNone)
       
   209                 {
       
   210                     CFbsBitmap *bitmap = new CFbsBitmap;
       
   211                     TRAPD(err,bitmap->InternalizeL(stream));
       
   212                     QCRITICAL_WRITE_FORMAT("Error from bitmap InternalizeL()", err)
       
   213 
       
   214                     //convert bitmap to pixmap
       
   215                     if (err == KErrNone)
       
   216                     {
       
   217                         TSize size = bitmap->SizeInPixels();
       
   218                         int bytesPerLine = bitmap->ScanLineLength(size.iWidth,
       
   219                             bitmap->DisplayMode());
       
   220                         const uchar* dataPtr =
       
   221                                 (const uchar*) bitmap->DataAddress();
       
   222 
       
   223                         QPixmap pixmap = QPixmap::fromImage(QImage(dataPtr,
       
   224                             size.iWidth, size.iHeight, bytesPerLine,
       
   225                             QImage::Format_RGB16));
       
   226 
       
   227                         mPreviewIconItem->setIcon(HbIcon(pixmap));
       
   228                         mPreviewIconItem->setPreferredSize(pixmap.size());
       
   229                         mPreviewIconItem->setEnabled(true);
       
   230                         mPreviewIconItem->show();
       
   231                         imagePreviewed = true;
       
   232                                                 
       
   233                         QCRITICAL_WRITE("Bitmap Conversion completed")
       
   234                     }
       
   235 					//remove bitmap
       
   236                     delete bitmap;                    
       
   237                 }
       
   238                 //close stream
       
   239                 stream.Close();
       
   240             }
       
   241         }
       
   242         sqlSelectPreviewIconStmt.Close();
       
   243     }
       
   244 
       
   245     // if not found in db, set from file path
       
   246     if(!imagePreviewed)
       
   247     {
       
   248         QPixmap pixmap(filePath);
       
   249         QPixmap scaledPixmap =pixmap.scaled(100,100,Qt::IgnoreAspectRatio);
       
   250         mPreviewIconItem->setIcon(HbIcon(scaledPixmap));
       
   251         mPreviewIconItem->setPreferredSize(scaledPixmap.size());
       
   252 	    mPreviewIconItem->setEnabled(true);
       
   253         mPreviewIconItem->show();
       
   254     }
       
   255     
       
   256     QCRITICAL_WRITE("MsgConversationWidget::setPreviewIconPath end.")  
       
   257 
       
   258 }
       
   259 
       
   260 //---------------------------------------------------------------
       
   261 // MsgConversationWidget::setPriority
       
   262 // @see header file
       
   263 //---------------------------------------------------------------
       
   264 void MsgConversationWidget::setPriority(int priority)
       
   265 {
       
   266     mPriority = priority;
       
   267 
       
   268     if (priority)
       
   269     {
       
   270         if (!mPriorityIconItem)
       
   271         {
       
   272             mPriorityIconItem = new HbIconItem(this);            
       
   273         }
       
   274         HbStyle::setItemName(mPriorityIconItem, "priority");
       
   275         if (ConvergedMessage::Low == priority)
       
   276         {
       
   277             mPriorityIconItem->setIcon(HbIcon(MSG_LOW_PRIORITY_ICON));
       
   278         }
       
   279         else if (ConvergedMessage::High == priority)
       
   280         {
       
   281             mPriorityIconItem->setIcon(HbIcon(MSG_HIGH_PRIORITY_ICON));
       
   282         }
       
   283         mPriorityIconItem->show();
       
   284     }
       
   285 }
       
   286 
       
   287 //---------------------------------------------------------------
       
   288 // MsgConversationWidget::priority
       
   289 // @see header file
       
   290 //---------------------------------------------------------------
       
   291 int MsgConversationWidget::priority()
       
   292 {
       
   293     return mPriority;
       
   294 }
       
   295 
       
   296 //---------------------------------------------------------------
       
   297 // MsgConversationWidget::setAttachment
       
   298 // @see header file
       
   299 //---------------------------------------------------------------
       
   300 void MsgConversationWidget::setAttachment(bool attachment)
       
   301 {
       
   302     mHasAttachment = attachment;
       
   303 
       
   304     if (attachment)
       
   305     {
       
   306         if (!mAttachmentIconItem)
       
   307         {
       
   308             mAttachmentIconItem = new HbIconItem(this);
       
   309         }
       
   310         HbStyle::setItemName(mAttachmentIconItem, "attachment");
       
   311         mAttachmentIconItem->setIcon(HbIcon(MSG_ATTACH_ICON));
       
   312         mAttachmentIconItem->show();
       
   313     }
       
   314 }
       
   315 
       
   316 //---------------------------------------------------------------
       
   317 // MsgConversationWidget::hasAttachment
       
   318 // @see header file
       
   319 //---------------------------------------------------------------
       
   320 bool MsgConversationWidget::hasAttachment()
       
   321 {
       
   322     return mHasAttachment;
       
   323 }
       
   324 
       
   325 //---------------------------------------------------------------
       
   326 // MsgConversationWidget::setImage
       
   327 // @see header file
       
   328 //---------------------------------------------------------------
       
   329 void MsgConversationWidget::setImage(bool image)
       
   330 {
       
   331     mHasImage = image;
       
   332 }
       
   333 
       
   334 //---------------------------------------------------------------
       
   335 // MsgConversationWidget::hasImage
       
   336 // @see header file
       
   337 //---------------------------------------------------------------
       
   338 bool MsgConversationWidget::hasImage()
       
   339 {
       
   340     return mHasImage;
       
   341 }
       
   342 
       
   343 //---------------------------------------------------------------
       
   344 // MsgConversationWidget::setAudio
       
   345 // @see header file
       
   346 //---------------------------------------------------------------
       
   347 void MsgConversationWidget::setAudio(bool audio)
       
   348 {
       
   349     mHasAudio = audio;
       
   350 }
       
   351 
       
   352 //---------------------------------------------------------------
       
   353 // MsgConversationWidget::hasAudio
       
   354 // @see header file
       
   355 //---------------------------------------------------------------
       
   356 bool MsgConversationWidget::hasAudio()
       
   357 {
       
   358     return mHasAudio;
       
   359 }
       
   360 
       
   361 //---------------------------------------------------------------
       
   362 // MsgConversationWidget::displayAudioIcon
       
   363 // @see header file
       
   364 //---------------------------------------------------------------
       
   365 void MsgConversationWidget::displayAudioIcon(const QString &iconPath)
       
   366 {
       
   367     if (hasAudio())
       
   368     {
       
   369         if (hasImage())
       
   370         {
       
   371             if (!mPlayIconItem)
       
   372             {
       
   373                 mPlayIconItem = new HbIconItem(this);                
       
   374             }
       
   375             HbStyle::setItemName(mPlayIconItem, "playIcon");
       
   376             mPlayIconItem->setIconName(iconPath.isEmpty() ? MSG_AUDIO_PLAY_ICON : iconPath);
       
   377             mPlayIconItem->show();
       
   378         }
       
   379         else
       
   380         {
       
   381             if (!mAudioIconItem)
       
   382             {
       
   383                 mAudioIconItem = new HbIconItem(this);    
       
   384             }
       
   385             HbStyle::setItemName(mAudioIconItem, "audioIcon");
       
   386             mAudioIconItem->setIconName(iconPath.isEmpty() ? MSG_AUDIO_PLAY_ICON : iconPath);
       
   387             mAudioIconItem->show();
       
   388            
       
   389         }
       
   390     }
       
   391 }
       
   392 
       
   393 //---------------------------------------------------------------
       
   394 // MsgConversationWidget::setVideo
       
   395 // @see header file
       
   396 //---------------------------------------------------------------
       
   397 void MsgConversationWidget::setVideo(bool video)
       
   398 {
       
   399     mHasVideo = video;
       
   400 
       
   401     if (video)
       
   402     {
       
   403         if (!mVideoIconItem)
       
   404         {
       
   405             mVideoIconItem = new HbIconItem(this);
       
   406         }
       
   407         HbStyle::setItemName(mVideoIconItem, "video");
       
   408         mVideoIconItem->setIcon(HbIcon(MSG_VIDEO_ICON));
       
   409         mVideoIconItem->show();
       
   410         
       
   411     }
       
   412 }
       
   413 
       
   414 //---------------------------------------------------------------
       
   415 // MsgConversationWidget::hasVideo
       
   416 // @see header file
       
   417 //---------------------------------------------------------------
       
   418 bool MsgConversationWidget::hasVideo()
       
   419 {
       
   420     return mHasVideo;
       
   421 }
       
   422 
       
   423 //---------------------------------------------------------------
       
   424 // MsgConversationWidget::setPlayable
       
   425 // @see header file
       
   426 //---------------------------------------------------------------
       
   427 void MsgConversationWidget::setPlayable(bool playable)
       
   428 {
       
   429     mIsPlayable = playable;
       
   430 }
       
   431 
       
   432 //---------------------------------------------------------------
       
   433 // MsgConversationWidget::isPlayable
       
   434 // @see header file
       
   435 //---------------------------------------------------------------
       
   436 bool MsgConversationWidget::isPlayable()
       
   437 {
       
   438     return mIsPlayable;
       
   439 }
       
   440 
       
   441 //---------------------------------------------------------------
       
   442 // MsgConversationWidget::setIncoming
       
   443 // @see header file
       
   444 //---------------------------------------------------------------
       
   445 void MsgConversationWidget::setIncoming(bool incoming)
       
   446 {
       
   447     mIncoming = incoming;
       
   448 }
       
   449 
       
   450 //---------------------------------------------------------------
       
   451 // MsgConversationWidget::isIncoming
       
   452 // @see header file
       
   453 //---------------------------------------------------------------
       
   454 bool MsgConversationWidget::isIncoming()
       
   455 {
       
   456     return mIncoming;
       
   457 }
       
   458 
       
   459 //---------------------------------------------------------------
       
   460 // MsgConversationWidget::setUnread
       
   461 // @see header file
       
   462 //---------------------------------------------------------------
       
   463 void MsgConversationWidget::setUnread(bool unread)
       
   464 {
       
   465     mUnread = unread;
       
   466 }
       
   467 
       
   468 //---------------------------------------------------------------
       
   469 // MsgConversationWidget::isUnread
       
   470 // @see header file
       
   471 //---------------------------------------------------------------
       
   472 bool MsgConversationWidget::isUnread()
       
   473 {
       
   474     return mUnread;
       
   475 }
       
   476 
       
   477 //---------------------------------------------------------------
       
   478 // MsgConversationWidget::setMMS
       
   479 // @see header file
       
   480 //---------------------------------------------------------------
       
   481 void MsgConversationWidget::setMMS(bool isMMS)
       
   482 {
       
   483     mIsMMS = isMMS;
       
   484 }
       
   485 
       
   486 //---------------------------------------------------------------
       
   487 // MsgConversationWidget::isMMS
       
   488 // @see header file
       
   489 //---------------------------------------------------------------
       
   490 bool MsgConversationWidget::isMMS()
       
   491 {
       
   492     return mIsMMS;
       
   493 }
       
   494 
       
   495 //---------------------------------------------------------------
       
   496 // MsgConversationWidget::setMMSNotification
       
   497 // @see header file
       
   498 //---------------------------------------------------------------
       
   499 void MsgConversationWidget::setMMSNotification(bool isMMSNotification)
       
   500 {
       
   501     mIsMMSNotification = isMMSNotification;
       
   502 }
       
   503 
       
   504 //---------------------------------------------------------------
       
   505 // MsgConversationWidget::isMMS
       
   506 // @see header file
       
   507 //---------------------------------------------------------------
       
   508 bool MsgConversationWidget::isMMSNotification()
       
   509 {
       
   510     return mIsMMSNotification;
       
   511 }
       
   512 
       
   513 //---------------------------------------------------------------
       
   514 // MsgConversationWidget::setSendingState
       
   515 // @see header file
       
   516 //---------------------------------------------------------------
       
   517 void MsgConversationWidget::setSendingState(int state)
       
   518 {
       
   519     switch (state)
       
   520     {
       
   521         case ConvergedMessage::SentState:
       
   522         {
       
   523             mSendingState = Sent;
       
   524             break;
       
   525         }
       
   526         case ConvergedMessage::Sending:
       
   527         {
       
   528             mSendingState = Sending;
       
   529             break;
       
   530         }
       
   531         case ConvergedMessage::Suspended:
       
   532         case ConvergedMessage::Resend:
       
   533         {
       
   534             mSendingState = Pending;
       
   535             break;
       
   536         }
       
   537         case ConvergedMessage::Failed:
       
   538         {
       
   539             mSendingState = Failed;
       
   540             break;
       
   541         }
       
   542         default:
       
   543         {
       
   544             mSendingState = Unknown;
       
   545             break;
       
   546         }
       
   547     }
       
   548 }
       
   549 
       
   550 //---------------------------------------------------------------
       
   551 // MsgConversationWidget::sendingState
       
   552 // @see header file
       
   553 //---------------------------------------------------------------
       
   554 MsgConversationWidget::SendingState MsgConversationWidget::sendingState()
       
   555 {
       
   556     return mSendingState;
       
   557 }
       
   558 
       
   559 //---------------------------------------------------------------
       
   560 // MsgConversationWidget::setNotificationState
       
   561 // @see header file
       
   562 //---------------------------------------------------------------
       
   563 void MsgConversationWidget::setNotificationState(int state)
       
   564 {
       
   565     switch (state)
       
   566     {
       
   567         case ConvergedMessage::NotifFailed:
       
   568         {
       
   569             mNotificationState = NotifFailed;
       
   570             break;
       
   571         }
       
   572         case ConvergedMessage::NotifReadyForFetching:
       
   573         {
       
   574             mNotificationState = NotifReadyForFetching;
       
   575             break;
       
   576         }
       
   577         case ConvergedMessage::NotifRetrieving:
       
   578         case ConvergedMessage::NotifWaiting:
       
   579         {
       
   580             mNotificationState = NotifRetrieving;
       
   581             break;
       
   582         }
       
   583         case ConvergedMessage::NotifExpired:
       
   584         {
       
   585             mNotificationState = NotifExpired;
       
   586             break;
       
   587         }
       
   588         default:
       
   589         {
       
   590             mNotificationState = NotifUnknown;
       
   591             break;
       
   592         }
       
   593     }
       
   594 }
       
   595 
       
   596 //---------------------------------------------------------------
       
   597 // MsgConversationWidget::notificationState
       
   598 // @see header file
       
   599 //---------------------------------------------------------------
       
   600 int MsgConversationWidget::notificationState()
       
   601 {
       
   602     return mNotificationState;
       
   603 }
       
   604 
       
   605 //---------------------------------------------------------------
       
   606 // MsgConversationWidget::setTimeStamp
       
   607 // @see header file
       
   608 //---------------------------------------------------------------
       
   609 void MsgConversationWidget::setTimeStamp(const QString &timeStamp)
       
   610 {
       
   611     if(!mTimeStampTextItem)
       
   612     {
       
   613 	  mTimeStampTextItem = new HbTextItem(this);
       
   614 	  }
       
   615     HbStyle::setItemName(mTimeStampTextItem, "timeStamp");
       
   616 
       
   617     mTimeStampTextItem->setText(timeStamp);
       
   618     mTimeStampTextItem->show();
       
   619  
       
   620 }
       
   621 
       
   622 //---------------------------------------------------------------
       
   623 // MsgConversationWidget::drawNewItemFrame
       
   624 // @see header file
       
   625 //---------------------------------------------------------------
       
   626 void MsgConversationWidget::drawNewItemFrame()
       
   627 {
       
   628     if (mUnread)
       
   629     {
       
   630         mNewFrameItem->frameDrawer().setFrameGraphicsName(NEW_ITEM_FRAME);
       
   631     }
       
   632     else
       
   633     {
       
   634         mNewFrameItem->frameDrawer().setFrameGraphicsName(QString());
       
   635     }
       
   636 }
       
   637 
       
   638 //---------------------------------------------------------------
       
   639 // MsgConversationWidget::drawBubbleFrame
       
   640 // @see header file
       
   641 //---------------------------------------------------------------
       
   642 void MsgConversationWidget::drawBubbleFrame()
       
   643 {
       
   644     if(isIncoming())
       
   645     {
       
   646         if (mIsMMSNotification && (mNotificationState == NotifUnknown
       
   647                 || mNotificationState == NotifRetrieving ))
       
   648         {
       
   649             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(
       
   650                 CV_RECEIVED_HIGHLIGHT_FR);
       
   651             //Inactive state bubble  
       
   652         }
       
   653         else
       
   654         {
       
   655             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_RECEIVED_NORMAL_FR);
       
   656         }
       
   657     }
       
   658     else
       
   659     {
       
   660         if(mSendingState == Sending || mSendingState == Pending || 
       
   661            mSendingState == Unknown || mSendingState == Failed)
       
   662         {
       
   663             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_SENT_HIGHLIGHT_FR);
       
   664         }
       
   665         else
       
   666         {
       
   667             mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_SENT_NORMAL_FR);
       
   668         }
       
   669     }
       
   670 }
       
   671 
       
   672 //---------------------------------------------------------------
       
   673 // MsgConversationWidget::drawPressedBubbleFrame
       
   674 // @see header file
       
   675 //---------------------------------------------------------------
       
   676 void MsgConversationWidget::drawPressedBubbleFrame()
       
   677 {
       
   678     if(isIncoming())
       
   679     {
       
   680         mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_RECEIVED_PRESSED_FR);
       
   681     }
       
   682     else
       
   683     {
       
   684         mBubbleFrameItem->frameDrawer().setFrameGraphicsName(CV_SENT_PRESSED_FR);
       
   685     }
       
   686 }
       
   687 
       
   688 //---------------------------------------------------------------
       
   689 // MsgConversationWidget::pressStateChanged
       
   690 // @see header file
       
   691 //---------------------------------------------------------------
       
   692 void MsgConversationWidget::pressStateChanged(bool pressed, bool animate)
       
   693 {
       
   694     Q_UNUSED(animate)
       
   695 
       
   696     if (mBubbleFrameItem) {
       
   697         (pressed) ? drawPressedBubbleFrame() : drawBubbleFrame();
       
   698     }
       
   699 }
       
   700 
       
   701     void MsgConversationWidget::resetProperties()
       
   702     	{
       
   703         mHasAttachment = false;
       
   704         mHasImage = false;
       
   705         mHasAudio = false;
       
   706         mHasVideo = false;
       
   707         mIsPlayable =false;
       
   708         mIncoming =false;
       
   709         mUnread =false;
       
   710         mIsMMS = false;
       
   711         mIsMMSNotification= false;
       
   712         mPriority = 0;
       
   713         mSendingState =Unknown;
       
   714         mNotificationState =0;
       
   715         
       
   716 		if(mBodyTextItem){
       
   717 			  mBodyTextItem->setText(QString());
       
   718         mBodyTextItem->hide();
       
   719         HbStyle::setItemName(mBodyTextItem, "");
       
   720 	    }
       
   721     
       
   722 	    if(mSubjectTextItem){
       
   723 	    	  mSubjectTextItem->setText(QString());
       
   724 	        mSubjectTextItem->hide();
       
   725 	        HbStyle::setItemName(mSubjectTextItem, "");
       
   726 	    }
       
   727     
       
   728 	    if(mTimeStampTextItem){
       
   729 	    	  mTimeStampTextItem->setText(QString());
       
   730 	        mTimeStampTextItem->hide();
       
   731 	        HbStyle::setItemName(mTimeStampTextItem, "");        
       
   732 	    }   
       
   733     
       
   734 	    if(mAttachmentIconItem){
       
   735 	        mAttachmentIconItem->hide();
       
   736 	        HbStyle::setItemName(mAttachmentIconItem, "");
       
   737 	    }
       
   738     
       
   739 	   if(mPriorityIconItem){
       
   740 	       HbStyle::setItemName(mPriorityIconItem, "");
       
   741 	        mPriorityIconItem->hide();
       
   742 	    }
       
   743    
       
   744 	    if(mAudioIconItem){
       
   745 	        HbStyle::setItemName(mAudioIconItem, "");
       
   746 	        mAudioIconItem->hide();              
       
   747 	       }
       
   748     
       
   749 	    if(mVideoIconItem){
       
   750 	        HbStyle::setItemName(mVideoIconItem, "");
       
   751 	        mVideoIconItem->hide();
       
   752 	      }
       
   753     
       
   754 	    if(mPlayIconItem){
       
   755 	        HbStyle::setItemName(mPlayIconItem, "");
       
   756 	        mPlayIconItem->hide();
       
   757 	       }
       
   758     
       
   759 	    if(mPreviewIconItem){
       
   760 	        HbStyle::setItemName(mPreviewIconItem, "");
       
   761 	        mPreviewIconItem->hide();               
       
   762 	       }    
       
   763     	}
       
   764     
       
   765     void MsgConversationWidget::repolishWidget()
       
   766     	{
       
   767     	QCoreApplication::postEvent(this, new HbEvent(HbEvent::ThemeChanged));	
       
   768     	repolish();
       
   769     	}
       
   770     
       
   771 // EOF