messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp
changeset 52 12db4185673b
parent 44 36f374c67aa8
child 70 a15d9966050f
equal deleted inserted replaced
44:36f374c67aa8 52:12db4185673b
    33 #include <HbListWidget>
    33 #include <HbListWidget>
    34 #include <HbFrameBackground>
    34 #include <HbFrameBackground>
    35 #include <HbListViewItem>
    35 #include <HbListViewItem>
    36 #include <HbListWidgetItem>
    36 #include <HbListWidgetItem>
    37 #include <HbNotificationDialog>
    37 #include <HbNotificationDialog>
       
    38 #include <HbDeviceNotificationDialog>
    38 #include <HbMessageBox>
    39 #include <HbMessageBox>
    39 #include <HbAbstractVkbHost>
    40 #include <HbAbstractVkbHost>
    40 #include <HbMainWindow>
    41 #include <HbMainWindow>
    41 #include <xqaiwrequest.h>
    42 #include <xqaiwrequest.h>
    42 #include <xqappmgr.h>
    43 #include <xqappmgr.h>
    85 #define LOC_TO  hbTrId("txt_messaging_formlabel_to")
    86 #define LOC_TO  hbTrId("txt_messaging_formlabel_to")
    86 #define LOC_CC hbTrId("txt_messaging_formlabel_cc")
    87 #define LOC_CC hbTrId("txt_messaging_formlabel_cc")
    87 #define LOC_BCC hbTrId("txt_messaging_formlabel_bcc")
    88 #define LOC_BCC hbTrId("txt_messaging_formlabel_bcc")
    88 
    89 
    89 //attach options
    90 //attach options
    90 #define LOC_PHOTO           hbTrId("txt_messaging_button_photo")
    91 #define LOC_PHOTO           hbTrId("txt_messaging_opt_attach_sub_photo")
    91 #define LOC_SOUND           hbTrId("txt_messaging_button_sound")
    92 #define LOC_SOUND           hbTrId("txt_messaging_opt_attach_sub_sound")
    92 #define LOC_BUSINESS_CARD   hbTrId("txt_messaging_button_business_card")
    93 #define LOC_BUSINESS_CARD   hbTrId("txt_messaging_opt_sub_business_card")
    93 
    94 
    94 //options menu.
    95 //options menu.
    95 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
    96 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
    96 #define LOC_ADD_CC_BCC      hbTrId("txt_messaging_opt_add_cc_bcc")
    97 #define LOC_ADD_CC_BCC      hbTrId("txt_messaging_opt_add_cc_bcc")
    97 #define LOC_PRIORITY        hbTrId("txt_messaging_opt_priority")
    98 #define LOC_PRIORITY        hbTrId("txt_messaging_opt_priority")
   101 #define LOC_HIGH hbTrId("txt_messaging_opt_attach_sub_high")
   102 #define LOC_HIGH hbTrId("txt_messaging_opt_attach_sub_high")
   102 #define LOC_NORMAL hbTrId("txt_messaging_opt_attach_sub_normal")
   103 #define LOC_NORMAL hbTrId("txt_messaging_opt_attach_sub_normal")
   103 #define LOC_LOW hbTrId("txt_messaging_opt_attach_sub_low")
   104 #define LOC_LOW hbTrId("txt_messaging_opt_attach_sub_low")
   104 
   105 
   105 //group box
   106 //group box
   106 #define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_group_title_ln_other_recipients",n)
   107 #define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_title_ln_other_recipients",n)
   107 #define LOC_OTHER_RECIPIENTS_EXPAND hbTrId("txt_messaging_title_other_recipients")
   108 #define LOC_OTHER_RECIPIENTS_EXPAND hbTrId("txt_messaging_title_other_recipients")
   108 
   109 
   109 //saved to draft note
   110 //saved to draft note
   110 #define LOC_SAVED_TO_DRAFTS    hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
   111 #define LOC_SAVED_TO_DRAFTS    hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
   111 
   112 
   300     }
   301     }
   301     
   302     
   302     mCanSaveToDrafts = false;  
   303     mCanSaveToDrafts = false;  
   303 }
   304 }
   304 
   305 
   305 void MsgUnifiedEditorView::forwardMessage(ConvergedMessageId& messageId,
   306 void MsgUnifiedEditorView::fetchMessageFromStore(
   306     ConvergedMessage::MessageType messageType )
   307         ConvergedMessageId& messageId,
       
   308         ConvergedMessage::MessageType messageType,
       
   309         int editorOperation)
   307 {
   310 {
   308     if(!mPluginLoader)
   311     if(!mPluginLoader)
   309     {
   312     {
   310         mPluginLoader = new UniEditorPluginLoader(this);
   313         mPluginLoader = new UniEditorPluginLoader(this);
   311   
       
   312     }
   314     }
   313     UniEditorPluginInterface* pluginInterface = NULL;
   315     UniEditorPluginInterface* pluginInterface = NULL;
   314     if( messageType == ConvergedMessage::Mms )
   316     if( messageType == ConvergedMessage::Mms )
   315     {
   317     {
   316         pluginInterface =
   318         pluginInterface =
   323     }
   325     }
   324 
   326 
   325     //Fetch the converged message from the msgId
   327     //Fetch the converged message from the msgId
   326     ConvergedMessage* msg;
   328     ConvergedMessage* msg;
   327     msg = pluginInterface->convertFrom(messageId.getId(),
   329     msg = pluginInterface->convertFrom(messageId.getId(),
   328         UniEditorPluginInterface::Forward);
   330                     (UniEditorPluginInterface::EditorOperation)editorOperation);
   329 
       
   330     if( msg != NULL )
   331     if( msg != NULL )
   331     {
   332     {
   332         //Populate the content inside editor
   333         //Populate the content inside editor
   333         populateContentIntoEditor(*msg);
   334         populateContentIntoEditor(*msg);
   334         delete msg;
   335         delete msg;
   365             contactsFetched(editorData.at(2));
   366             contactsFetched(editorData.at(2));
   366         }
   367         }
   367         break;
   368         break;
   368         case MsgBaseView::FORWARD_MSG:
   369         case MsgBaseView::FORWARD_MSG:
   369         {
   370         {
   370             forwardMessage(*messageDetails->id(), messageDetails->messageType());
   371             fetchMessageFromStore(*messageDetails->id(),
       
   372                                    messageDetails->messageType(),
       
   373                                    UniEditorPluginInterface::Forward);
       
   374         }
       
   375         break;
       
   376         case MsgBaseView::REPLY_MSG:
       
   377         {
       
   378             fetchMessageFromStore(*messageDetails->id(),
       
   379                                    messageDetails->messageType(),
       
   380                                    UniEditorPluginInterface::Reply);
       
   381         }
       
   382         break;
       
   383         case MsgBaseView::REPLY_ALL_MSG:
       
   384         {
       
   385             fetchMessageFromStore(*messageDetails->id(),
       
   386                                    messageDetails->messageType(),
       
   387                                    UniEditorPluginInterface::ReplyAll);
   371         }
   388         }
   372         break;
   389         break;
   373         default:
   390         default:
   374         break;
   391         break;
   375     }
   392     }
   416         {
   433         {
   417             int imageSize=0;
   434             int imageSize=0;
   418             QString mimeType;
   435             QString mimeType;
   419             TMsgMediaType mediaType = EMsgMediaUnknown;
   436             TMsgMediaType mediaType = EMsgMediaUnknown;
   420             QString filePath = messageDetails->attachments().at(i)->filePath();
   437             QString filePath = messageDetails->attachments().at(i)->filePath();
   421             UniEditorGenUtils* genUtils = new UniEditorGenUtils;
   438             
       
   439            
       
   440             UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
       
   441             
   422             TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize,
   442             TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize,
   423                                            mimeType,mediaType));
   443                                            mimeType,mediaType));
   424             delete genUtils;
   444             delete genUtils;
   425             switch(mediaType)
   445             switch(mediaType)
   426             {
   446             {
   494     mBody->setText(bodyTxt);
   514     mBody->setText(bodyTxt);
   495 
   515 
   496     ConvergedMessageAttachmentList attachmentList =
   516     ConvergedMessageAttachmentList attachmentList =
   497         messageDetails.attachments();
   517         messageDetails.attachments();
   498     int attachmentCount = attachmentList.count();
   518     int attachmentCount = attachmentList.count();
   499 
   519      
   500     UniEditorGenUtils* genUtils = new UniEditorGenUtils;
   520     UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
   501 
   521 
   502     QStringList pendingAttList;
   522     QStringList pendingAttList;
   503     for( int i=0; i < attachmentCount; i++ )
   523     for( int i=0; i < attachmentCount; i++ )
   504     {
   524     {
   505         QString filePath = messageDetails.attachments().at(i)->filePath();
   525         QString filePath = messageDetails.attachments().at(i)->filePath();
   552     HbToolBar *toolBar = new HbToolBar();
   572     HbToolBar *toolBar = new HbToolBar();
   553     toolBar->setOrientation(Qt::Horizontal);
   573     toolBar->setOrientation(Qt::Horizontal);
   554     
   574     
   555     //tool bar extension for attach action.
   575     //tool bar extension for attach action.
   556     HbToolBarExtension* attachExtension = new HbToolBarExtension();
   576     HbToolBarExtension* attachExtension = new HbToolBarExtension();
   557     HbAction *attachAction = toolBar->addExtension(attachExtension);    
   577     mAttachAction = toolBar->addExtension(attachExtension);    
   558     attachAction->setIcon(HbIcon(ATTACH_ICON));
   578     mAttachAction->setIcon(HbIcon(ATTACH_ICON));
   559     
   579     
   560     mTBExtnContentWidget = new HbListWidget();
   580     mTBExtnContentWidget = new HbListWidget();
   561     mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
   581     mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
   562     mTBExtnContentWidget->addItem(LOC_PHOTO);
   582     mTBExtnContentWidget->addItem(LOC_PHOTO);
   563     mTBExtnContentWidget->addItem(LOC_SOUND);
   583     mTBExtnContentWidget->addItem(LOC_SOUND);
   650     style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
   670     style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
   651     ccBccLayout->setSpacing(vItemSpacing);
   671     ccBccLayout->setSpacing(vItemSpacing);
   652     ccBccLayout->addItem(mCcField);
   672     ccBccLayout->addItem(mCcField);
   653     ccBccLayout->addItem(mBccField);
   673     ccBccLayout->addItem(mBccField);
   654 
   674 
   655     HbGroupBox* groupBox = new HbGroupBox(0);    
   675     HbGroupBox* groupBox = new HbGroupBox(0);  
   656     groupBox->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred);
   676     groupBox->setObjectName("groupBox");
   657     
   677     
   658     groupBox->setContentWidget(groupWidget);
   678     groupBox->setContentWidget(groupWidget);
   659     groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
   679     groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
   660     mMainLayout->insertItem(1,groupBox);
   680     mMainLayout->insertItem(1,groupBox);
   661     connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool)));
   681     connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool)));
  1164 
  1184 
  1165     bool res = ((msgId > INVALID_MSGID)? true : false);
  1185     bool res = ((msgId > INVALID_MSGID)? true : false);
  1166     
  1186     
  1167     if(res)
  1187     if(res)
  1168         {
  1188         {
  1169         HbNotificationDialog::launchDialog(LOC_SAVED_TO_DRAFTS);
  1189         HbDeviceNotificationDialog::notification("", LOC_SAVED_TO_DRAFTS);
  1170         }
  1190         }
  1171     return msgId;
  1191     return msgId;
  1172 }
  1192 }
  1173 
  1193 
  1174 void MsgUnifiedEditorView::resizeEvent( QGraphicsSceneResizeEvent * event )
  1194 void MsgUnifiedEditorView::resizeEvent( QGraphicsSceneResizeEvent * event )
  1506     
  1526     
  1507     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1527     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1508 }
  1528 }
  1509 
  1529 
  1510 //---------------------------------------------------------------
  1530 //---------------------------------------------------------------
       
  1531 // MsgUnifiedEditorView::vkbAboutToOpen
       
  1532 // @see header file
       
  1533 //---------------------------------------------------------------
       
  1534 void MsgUnifiedEditorView::vkbAboutToOpen()
       
  1535 {    
       
  1536 	  //This is done to avoid user action on attachment
       
  1537 	  //toolbar button when vkb is opening
       
  1538     mAttachAction->setDisabled(true);
       
  1539     disconnect(mVkbHost,SIGNAL(aboutToOpen()),
       
  1540             this,SLOT(vkbAboutToOpen()));
       
  1541 }
       
  1542       
       
  1543 //---------------------------------------------------------------
       
  1544 // MsgUnifiedEditorView::vkbAboutToClose
       
  1545 // @see header file
       
  1546 //---------------------------------------------------------------
       
  1547 void MsgUnifiedEditorView::vkbAboutToClose()
       
  1548 {      
       
  1549     mAttachAction->setDisabled(false);
       
  1550     connect(mVkbHost,SIGNAL(aboutToOpen()),
       
  1551             this,SLOT(vkbAboutToOpen()));
       
  1552 }
       
  1553 //---------------------------------------------------------------
  1511 // MsgUnifiedEditorView::hideChrome
  1554 // MsgUnifiedEditorView::hideChrome
  1512 //
  1555 //
  1513 //---------------------------------------------------------------
  1556 //---------------------------------------------------------------
  1514 void MsgUnifiedEditorView::hideChrome(bool hide)
  1557 void MsgUnifiedEditorView::hideChrome(bool hide)
  1515 {
  1558 {
  1536     
  1579     
  1537     //Create VKB instance and listen to VKB open and close signals.
  1580     //Create VKB instance and listen to VKB open and close signals.
  1538     mVkbHost = new HbAbstractVkbHost(this);
  1581     mVkbHost = new HbAbstractVkbHost(this);
  1539     connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
  1582     connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
  1540     connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
  1583     connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
       
  1584     connect(mVkbHost,SIGNAL(aboutToOpen()),this,SLOT(vkbAboutToOpen()));
       
  1585     connect(mVkbHost,SIGNAL(aboutToClose()),this,SLOT(vkbAboutToClose()));
  1541     
  1586     
  1542     disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
  1587     disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
  1543     
  1588     
  1544 }
  1589 }
  1545 
  1590