messagingapp/msgui/conversationview/src/msgconversationviewitem.cpp
changeset 37 518b245aa84c
parent 25 84d9eb65b26f
child 48 4f501b74aeb1
equal deleted inserted replaced
25:84d9eb65b26f 37:518b245aa84c
    24 #include <QChar>
    24 #include <QChar>
    25 #include <HbTextItem>
    25 #include <HbTextItem>
    26 #include <HbIconItem>
    26 #include <HbIconItem>
    27 #include <HbIconAnimationManager>
    27 #include <HbIconAnimationManager>
    28 #include <HbIconAnimator>
    28 #include <HbIconAnimator>
       
    29 #include <ccsdefs.h>
       
    30 #include <HbInstance>
    29 
    31 
    30 // USER INCLUDES
    32 // USER INCLUDES
    31 #include "msgconversationwidget.h"
    33 #include "msgconversationwidget.h"
    32 #include "msgviewdefines.h"
    34 #include "msgviewdefines.h"
    33 #include "msgviewutils.h"
    35 #include "msgviewutils.h"
    38 const QString MSG_OUTBOX_ICON("qtg_small_outbox");
    40 const QString MSG_OUTBOX_ICON("qtg_small_outbox");
    39 const QString MSG_FAIL_ICON("qtg_small_fail");
    41 const QString MSG_FAIL_ICON("qtg_small_fail");
    40 const QString ANIMATION_FILE(":/qtg_anim_loading.axml");
    42 const QString ANIMATION_FILE(":/qtg_anim_loading.axml");
    41 const QString ANIMATION_ICON_NAME("qtg_anim_loading");
    43 const QString ANIMATION_ICON_NAME("qtg_anim_loading");
    42 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");
    43 
    48 
    44 // LOCALIZATION
    49 // LOCALIZATION
    45 #define LOC_RINGING_TONE hbTrId("txt_messaging_dpopinfo_ringing_tone")
    50 #define LOC_RINGING_TONE hbTrId("txt_messaging_dpopinfo_ringing_tone")
    46 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_list_business_card")
    51 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_list_business_card")
    47 #define LOC_CALENDAR_EVENT hbTrId("txt_messaging_list_calendar_event")
    52 #define LOC_CALENDAR_EVENT hbTrId("txt_messaging_list_calendar_event")
    52 // MsgConversationViewItem::MsgConversationViewItem
    57 // MsgConversationViewItem::MsgConversationViewItem
    53 // Constructor
    58 // Constructor
    54 //---------------------------------------------------------------
    59 //---------------------------------------------------------------
    55 MsgConversationViewItem::MsgConversationViewItem(QGraphicsItem* parent) :
    60 MsgConversationViewItem::MsgConversationViewItem(QGraphicsItem* parent) :
    56     HbListViewItem(parent), mIncoming(false), mConversation(0),
    61     HbListViewItem(parent), mIncoming(false), mConversation(0),
    57             mMessageStateIconItem(0)
    62             mIncomingMsgStateIconItem(0), mOutgoingMsgStateIconItem(0)
    58 {
    63 {
    59     mConversation = new MsgConversationWidget(this);
       
    60     HbStyle::setItemName(mConversation, "msgconvwidget");
       
    61 
       
    62     mMessageStateIconItem = new HbIconItem(this);
       
    63     HbStyle::setItemName(mMessageStateIconItem, "msgStateIcon");
       
    64 }
    64 }
    65 
    65 
    66 //---------------------------------------------------------------
    66 //---------------------------------------------------------------
    67 // MsgConversationViewItem::MsgConversationViewItem
    67 // MsgConversationViewItem::MsgConversationViewItem
    68 // Destructor
    68 // Destructor
    69 //---------------------------------------------------------------
    69 //---------------------------------------------------------------
    70 MsgConversationViewItem::~MsgConversationViewItem()
    70 MsgConversationViewItem::~MsgConversationViewItem()
    71 {
    71 {
    72 
       
    73 }
    72 }
    74 
    73 
    75 //---------------------------------------------------------------
    74 //---------------------------------------------------------------
    76 // MsgConversationViewItem::createItem
    75 // MsgConversationViewItem::createItem
    77 // Create a new decorator item.
    76 // Create a new decorator item.
    78 //---------------------------------------------------------------
    77 //---------------------------------------------------------------
    79 MsgConversationViewItem* MsgConversationViewItem::createItem()
    78 MsgConversationViewItem* MsgConversationViewItem::createItem()
    80 {
    79 {
    81     return new MsgConversationViewItem();
    80     MsgConversationViewItem *item = new MsgConversationViewItem(*this);
       
    81     item->init();
       
    82     return item;
    82 }
    83 }
    83 
    84 
    84 //---------------------------------------------------------------
    85 //---------------------------------------------------------------
    85 // MsgConversationViewItem::updateChildItems
    86 // MsgConversationViewItem::updateChildItems
    86 //
    87 //
    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
   312 // MsgConversationViewItem::setMessageStateIcon
   454 // MsgConversationViewItem::setMessageStateIcon
   313 // @see header file
   455 // @see header file
   314 //---------------------------------------------------------------
   456 //---------------------------------------------------------------
   315 void MsgConversationViewItem::setMessageStateIcon(int messageState)
   457 void MsgConversationViewItem::setMessageStateIcon(int messageState)
   316 {
   458 {
   317     HbIconAnimator& iconAnimator = mMessageStateIconItem->animator();
   459     HbIconAnimator& iconAnimator = mOutgoingMsgStateIconItem->animator();
   318     HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global();
   460     HbIconAnimationManager* iconAnimationManager =
       
   461             HbIconAnimationManager::global();
   319     switch (messageState)
   462     switch (messageState)
   320     {
   463     {
   321 
       
   322         case ConvergedMessage::Waiting:
   464         case ConvergedMessage::Waiting:
   323         case ConvergedMessage::Scheduled:
   465         case ConvergedMessage::Scheduled:
   324         case ConvergedMessage::Sending:
   466         case ConvergedMessage::Sending:
   325         { 
   467         {
   326  	        bool defined = iconAnimationManager->addDefinitionFile(ANIMATION_FILE);
   468             bool defined = iconAnimationManager->addDefinitionFile(
   327      	    HbIcon animIcon;
   469                 ANIMATION_FILE);
       
   470             HbIcon animIcon;
   328             animIcon.setIconName(ANIMATION_ICON_NAME);
   471             animIcon.setIconName(ANIMATION_ICON_NAME);
   329             QSizeF size = mMessageStateIconItem->size();
   472             QSizeF size = mOutgoingMsgStateIconItem->size();
   330             mMessageStateIconItem->setIcon(animIcon);
   473             mOutgoingMsgStateIconItem->setIcon(animIcon);
   331             mMessageStateIconItem->setVisible(true);
   474             mOutgoingMsgStateIconItem->setVisible(true);
   332             iconAnimator.startAnimation();
   475             iconAnimator.startAnimation();
   333             repolish();
       
   334             break;
   476             break;
   335         }     
   477         }     
   336         case ConvergedMessage::Suspended:
   478         case ConvergedMessage::Suspended:
   337         {
   479         {
   338            iconAnimator.stopAnimation();
   480             iconAnimator.stopAnimation();
   339            mMessageStateIconItem->setIcon(MSG_OUTBOX_ICON);
   481             mOutgoingMsgStateIconItem->setIcon(MSG_OUTBOX_ICON);
   340            mMessageStateIconItem->setVisible(true);
   482             mOutgoingMsgStateIconItem->setVisible(true);
   341            break;
   483             break;
   342         
   484 
   343         }
   485         }
   344         case ConvergedMessage::Resend:
   486         case ConvergedMessage::Resend:
   345         {
   487         {
   346             iconAnimator.stopAnimation();
   488             iconAnimator.stopAnimation();
   347             mMessageStateIconItem->setIcon(MSG_OUTBOX_ICON);
   489             mOutgoingMsgStateIconItem->setIcon(MSG_OUTBOX_ICON);
   348             mMessageStateIconItem->setVisible(true);
   490             mOutgoingMsgStateIconItem->setVisible(true);
   349             break;
   491             break;
   350         }
   492         }
   351         case ConvergedMessage::Failed:
   493         case ConvergedMessage::Failed:
   352         {
   494         {
   353             iconAnimator.stopAnimation();
   495             iconAnimator.stopAnimation();
   354             mMessageStateIconItem->setIcon(MSG_FAIL_ICON);
   496             mOutgoingMsgStateIconItem->setIcon(MSG_FAIL_ICON);
   355             mMessageStateIconItem->setVisible(true);
   497             mOutgoingMsgStateIconItem->setVisible(true);
   356             break;
   498             break;
   357         }   
   499         }   
   358         case ConvergedMessage::Unknown:
   500         case ConvergedMessage::Unknown:
   359         default:
   501         default:
   360         {
   502         {
   361             iconAnimator.stopAnimation();
   503             iconAnimator.stopAnimation();
   362             mMessageStateIconItem->setVisible(false);
   504             mOutgoingMsgStateIconItem->setVisible(false);
   363             break;
   505             break;
   364         }
   506         }
   365     }
   507     }
   366 }
   508 }
   367 
   509 
   370 // @see header file
   512 // @see header file
   371 //---------------------------------------------------------------
   513 //---------------------------------------------------------------
   372 
   514 
   373 void MsgConversationViewItem::setNotificationStateIcon(int notificationState)
   515 void MsgConversationViewItem::setNotificationStateIcon(int notificationState)
   374 {
   516 {
   375     HbIconAnimator& iconAnimator = mMessageStateIconItem->animator();
   517     HbIconAnimator& iconAnimator = mIncomingMsgStateIconItem->animator();
   376     HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global();
   518     HbIconAnimationManager* iconAnimationManager =
       
   519             HbIconAnimationManager::global();
   377     switch (notificationState)
   520     switch (notificationState)
   378     {
   521     {
   379 
       
   380         case ConvergedMessage::NotifRetrieving:
   522         case ConvergedMessage::NotifRetrieving:
   381         case ConvergedMessage::NotifWaiting:
   523         case ConvergedMessage::NotifWaiting:
   382         { 
   524         { 
   383             //TODO: Temp icon until official icons are received
   525             //TODO: Temp icon until official icons are received
   384             bool defined = iconAnimationManager->addDefinitionFile(ANIMATION_FILE);
   526             bool defined = iconAnimationManager->addDefinitionFile(
       
   527                 ANIMATION_FILE);
   385             HbIcon animIcon;
   528             HbIcon animIcon;
   386             animIcon.setIconName(ANIMATION_ICON_NAME);
   529             animIcon.setIconName(ANIMATION_ICON_NAME);
   387             QSizeF size = mMessageStateIconItem->size();
   530             QSizeF size = mIncomingMsgStateIconItem->size();
   388             mMessageStateIconItem->setIcon(animIcon);
   531             mIncomingMsgStateIconItem->setIcon(animIcon);
   389             mMessageStateIconItem->setVisible(true);
   532             mIncomingMsgStateIconItem->setVisible(true);
   390             iconAnimator.startAnimation();
   533             iconAnimator.startAnimation();
   391             repolish();
       
   392             break;
   534             break;
   393         }     
   535         }     
   394         default:
   536         default:
   395         {
   537         {
   396             iconAnimator.stopAnimation();
   538             iconAnimator.stopAnimation();
   397             mMessageStateIconItem->setVisible(false);
   539             mIncomingMsgStateIconItem->setVisible(false);
   398             break;
   540             break;
   399         }
   541         }
   400     }
   542     }
   401 }
   543 }
   402 
   544 
   407 void MsgConversationViewItem::pressStateChanged (bool pressed, bool animate)
   549 void MsgConversationViewItem::pressStateChanged (bool pressed, bool animate)
   408 {
   550 {
   409     mConversation->pressStateChanged(pressed, animate);
   551     mConversation->pressStateChanged(pressed, animate);
   410 }
   552 }
   411 
   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 
   412 // EOF
   591 // EOF