emailuis/nmailui/src/nmeditorview.cpp
changeset 44 c2d07d913565
parent 43 99bcbff212ad
child 47 f83bd4ae1fe3
child 54 997a02608b3a
equal deleted inserted replaced
43:99bcbff212ad 44:c2d07d913565
    65     mDocumentLoader	= new HbDocumentLoader();
    65     mDocumentLoader	= new HbDocumentLoader();
    66     // Set object name
    66     // Set object name
    67     setObjectName("NmEditorView");
    67     setObjectName("NmEditorView");
    68     // Set mailbox name to title pane
    68     // Set mailbox name to title pane
    69     setMailboxName();
    69     setMailboxName();
       
    70     // call the createToolBar on load view layout
       
    71     createToolBar();
    70     // Load view layout
    72     // Load view layout
    71     loadViewLayout();
    73     loadViewLayout();
    72 }
    74 }
    73 
    75 
    74 /*!
    76 /*!
   100     delete mWaitDialog;
   102     delete mWaitDialog;
   101     delete mQueryDialog;
   103     delete mQueryDialog;
   102     delete mAttachmentPicker;    
   104     delete mAttachmentPicker;    
   103     mAttaManager.clearObserver();
   105     mAttaManager.clearObserver();
   104     mAttaManager.cancelFetch();
   106     mAttaManager.cancelFetch();
       
   107     
       
   108     // make sure virtual keyboard is closed
       
   109     QInputContext *ic = qApp->inputContext();
       
   110     if (ic) {
       
   111         QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
       
   112         ic->filterEvent(closeEvent);
       
   113         delete closeEvent;
       
   114     }
   105 }
   115 }
   106 
   116 
   107 /*!
   117 /*!
   108     View layout loading from XML
   118     View layout loading from XML
   109 */
   119 */
   133             mApplication.networkAccessManager());
   143             mApplication.networkAccessManager());
   134         mEditWidget = mContentWidget->editor();
   144         mEditWidget = mContentWidget->editor();
   135         mHeaderWidget = mContentWidget->header();
   145         mHeaderWidget = mContentWidget->header();
   136 
   146 
   137         // Set default color for user - entered text if editor is in re/reAll/fw mode
   147         // Set default color for user - entered text if editor is in re/reAll/fw mode
   138         NmUiEditorStartMode mode = mStartParam->editorStartMode();
   148         if (mStartParam) {
   139         if (mode == NmUiEditorReply || mode == NmUiEditorReplyAll || mode == NmUiEditorForward) {
   149             NmUiEditorStartMode mode = mStartParam->editorStartMode();
   140             mEditWidget->setCustomTextColor(true, Qt::blue);
   150             if (mode == NmUiEditorReply
       
   151                 || mode == NmUiEditorReplyAll 
       
   152                 || mode == NmUiEditorForward) {
       
   153                 mEditWidget->setCustomTextColor(true, Qt::blue);
       
   154             }
   141         }
   155         }
   142 
   156 
   143         // the rest of the view initialization is done in viewReady()
   157         // the rest of the view initialization is done in viewReady()
   144     }
   158     }
   145 }
   159 }
   162         mStartParam=startParam;
   176         mStartParam=startParam;
   163         // Store existing edited message to drafts and reload
   177         // Store existing edited message to drafts and reload
   164         // editor with new start parameters.
   178         // editor with new start parameters.
   165         // ..
   179         // ..
   166         // Reload editor with new message data
   180         // Reload editor with new message data
   167         fetchMessageIfNeeded();
   181         fetchMessageIfNeeded(*mStartParam);
   168     }
   182     }
   169     else {
   183     else {
   170         NM_ERROR(1,"nmailui: Invalid editor start parameter");
   184         NM_ERROR(1,"nmailui: Invalid editor start parameter");
   171         // Unused start parameter needs to be deleted
   185         // Unused start parameter needs to be deleted
   172         delete startParam;
   186         delete startParam;
   278     
   292     
   279     HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
   293     HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
   280     // The first action in dialogs action list is for the "Yes"-button.
   294     // The first action in dialogs action list is for the "Yes"-button.
   281     if (action == dlg->actions().at(0)) {
   295     if (action == dlg->actions().at(0)) {
   282         
   296         
       
   297         // Update draft message with content.
       
   298         updateMessageWithEditorContents();
       
   299 
   283         // Save message to drafts
   300         // Save message to drafts
   284         QList<NmOperation *> preliminaryOperations;
   301         QList<NmOperation *> preliminaryOperations;
   285         if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
   302         if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
   286             preliminaryOperations.append(mAddAttachmentOperation);
   303             preliminaryOperations.append(mAddAttachmentOperation);
   287         }
   304         }
   316     }
   333     }
   317     if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
   334     if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
   318         mRemoveAttachmentOperation->cancelOperation();
   335         mRemoveAttachmentOperation->cancelOperation();
   319     }
   336     }
   320 
   337 
   321     if (mMessage) { // this is NULL if sending is started
   338     if (mMessage) { // this is NULL if sending or saving is started
   322         // Delete message from drafts
   339         // Delete message from drafts
   323         mUiEngine.removeDraftMessage(mMessage);
   340         mUiEngine.removeDraftMessage(mMessage);
   324         mMessage = NULL;
   341         mMessage = NULL;
   325     }
   342     }
   326 }
   343 }
   339     menu()->addAction(dummy);
   356     menu()->addAction(dummy);
   340 
   357 
   341     initializeVKB();
   358     initializeVKB();
   342     connect(mContentWidget->header(), SIGNAL(recipientFieldsHaveContent(bool)),
   359     connect(mContentWidget->header(), SIGNAL(recipientFieldsHaveContent(bool)),
   343             this, SLOT(setButtonsDimming(bool)) );
   360             this, SLOT(setButtonsDimming(bool)) );
   344 
       
   345     // call the createToolBar on load view layout
       
   346     createToolBar();
       
   347 
   361 
   348     // Set dimensions
   362     // Set dimensions
   349     adjustViewDimensions();
   363     adjustViewDimensions();
   350 	
   364 	
   351     // Connect to observe orientation change events
   365     // Connect to observe orientation change events
   352     connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
   366     connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
   353             this, SLOT(orientationChanged(Qt::Orientation)));
   367             this, SLOT(orientationChanged(Qt::Orientation)));
   354     // Signal for handling the attachment list selection
   368     // Signal for handling the attachment list selection
       
   369     connect(mHeaderWidget, SIGNAL(attachmentShortPressed(NmId)),
       
   370             this, SLOT(openAttachmentTriggered(NmId)));
   355     connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)),
   371     connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)),
   356             this, SLOT(attachmentLongPressed(NmId, QPointF)));
   372             this, SLOT(attachmentLongPressed(NmId, QPointF)));
   357     
   373     
   358     // Set message data
   374     if (mStartParam) {
   359     fetchMessageIfNeeded();
   375         fetchMessageIfNeeded(*mStartParam);
       
   376     }
       
   377     else { // execution cannot proceed without start param 
       
   378         QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
       
   379     }
   360 }
   380 }
   361 
   381 
   362 /*!
   382 /*!
   363     If entering editor for forwarding or replying, use attachment manager
   383     If entering editor for forwarding or replying, use attachment manager
   364     to check that we have all message parts fetched. Also show dialog for
   384     to check that we have all message parts fetched. Also show dialog for
   365     fetching progress.
   385     fetching progress.
   366 */
   386 */
   367 void NmEditorView::fetchMessageIfNeeded()
   387 void NmEditorView::fetchMessageIfNeeded(NmUiStartParam &startParam)
   368 {
   388 {
   369     NM_FUNCTION;
   389     NM_FUNCTION;
   370     
   390     
   371     if (mStartParam->editorStartMode() == NmUiEditorForward ||
   391     if (startParam.editorStartMode() == NmUiEditorForward
   372         mStartParam->editorStartMode() == NmUiEditorReply ||
   392         || startParam.editorStartMode()== NmUiEditorReply
   373         mStartParam->editorStartMode() == NmUiEditorReplyAll) {
   393         || startParam.editorStartMode() == NmUiEditorReplyAll) {
   374         
   394         
   375         fetchProgressDialogShow();
   395         fetchProgressDialogShow();
   376         mAttaManager.clearObserver();
   396         mAttaManager.clearObserver();
   377         mAttaManager.setObserver(this);
   397         mAttaManager.setObserver(this);
   378         mAttaManager.fetchAllMessageParts(
   398         mAttaManager.fetchAllMessageParts(
   379             mStartParam->mailboxId(),
   399             startParam.mailboxId(),
   380             mStartParam->folderId(),
   400             startParam.folderId(),
   381             mStartParam->messageId());
   401             startParam.messageId());
   382     }
   402     }
   383     else {
   403     else {
   384         startMessageCreation(mStartParam->editorStartMode());
   404         startMessageCreation(startParam);
   385     }
   405     }
   386 }
   406 }
   387 
   407 
   388 /*!
   408 /*!
   389     Slot. Called when attachments fetch progress changes.
   409     Slot. Called when attachments fetch progress changes.
   401 */
   421 */
   402 void NmEditorView::fetchCompleted(int result)
   422 void NmEditorView::fetchCompleted(int result)
   403 {
   423 {
   404     NM_FUNCTION;
   424     NM_FUNCTION;
   405     
   425     
   406     if (result == NmNoError) {
   426     if (result == NmNoError && mStartParam) {
   407         startMessageCreation(mStartParam->editorStartMode());
   427         startMessageCreation(*mStartParam);
   408     }
   428     }
   409     else {
   429     else {
   410         mWaitDialog->close();
   430         mWaitDialog->close();
       
   431 		
       
   432         // Show fetching failed note         
       
   433         HbNotificationDialog *note = new HbNotificationDialog(); 
       
   434         note->setIcon(HbIcon(QLatin1String("note_warning")));
       
   435         QString noteText = hbTrId("txt_mail_dpopinfo_loading_failed");
       
   436         note->setTitle(noteText);
       
   437         note->setTitleTextWrapping(Hb::TextWordWrap);
       
   438         note->setDismissPolicy(HbPopup::TapAnywhere);
       
   439         note->setAttribute(Qt::WA_DeleteOnClose);
       
   440         note->setSequentialShow(true);
       
   441         note->show();
       
   442         
   411         QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
   443         QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
   412     }
   444     }
   413 }
   445 }
   414 
   446 
   415 void NmEditorView::fetchProgressDialogShow()
   447 void NmEditorView::fetchProgressDialogShow()
   440         mAttaManager.clearObserver();
   472         mAttaManager.clearObserver();
   441     }
   473     }
   442     QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
   474     QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
   443 }
   475 }
   444 
   476 
   445 void NmEditorView::startMessageCreation(NmUiEditorStartMode startMode)
   477 void NmEditorView::startMessageCreation(NmUiStartParam &startParam)
   446 {
   478 {
   447     NM_FUNCTION;
   479     NM_FUNCTION;
   448     
   480     
   449     NmId mailboxId = mStartParam->mailboxId();
   481     NmUiEditorStartMode startMode = startParam.editorStartMode();
   450     NmId folderId = mStartParam->folderId();
   482     NmId mailboxId = startParam.mailboxId();
   451     NmId msgId = mStartParam->messageId();
   483     NmId folderId = startParam.folderId();
       
   484     NmId msgId = startParam.messageId();
   452     
   485     
   453     if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
   486     if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
   454         mMessageCreationOperation->cancelOperation();
   487         mMessageCreationOperation->cancelOperation();
   455     }
   488     }
   456 	
   489 	
   460     }
   493     }
   461     else if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) {
   494     else if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) {
   462         mMessageCreationOperation = mUiEngine.createReplyMessage(mailboxId, 
   495         mMessageCreationOperation = mUiEngine.createReplyMessage(mailboxId, 
   463             msgId, 
   496             msgId, 
   464             startMode == NmUiEditorReplyAll);
   497             startMode == NmUiEditorReplyAll);
       
   498     }
       
   499     else if (startMode == NmUiEditorFromDrafts) {
       
   500         // Draft opened, so reload message and fill editor with message data.
       
   501         mMessage = mUiEngine.message(
       
   502             mStartParam->mailboxId(), 
       
   503             mStartParam->folderId(), 
       
   504             mStartParam->messageId());
       
   505         fillEditorWithMessageContents();
   465     }
   506     }
   466     else {
   507     else {
   467         mMessageCreationOperation = mUiEngine.createNewMessage(mailboxId);
   508         mMessageCreationOperation = mUiEngine.createNewMessage(mailboxId);
   468     }
   509     }
   469     
   510     
   540     bool service = false;
   581     bool service = false;
   541 #endif
   582 #endif
   542 
   583 
   543     // If sending is started as a service, progress dialog needs to be shown
   584     // If sending is started as a service, progress dialog needs to be shown
   544     // so long that sending is finished otherwise we can close pop current view.
   585     // so long that sending is finished otherwise we can close pop current view.
   545     if (service && mUiEngine.isSendingMessage()) {
   586     if (service && mStartParam && mStartParam->service() && 
       
   587         mUiEngine.isSendingMessage()) {
   546         connect(&mUiEngine, SIGNAL(sendOperationCompleted()),
   588         connect(&mUiEngine, SIGNAL(sendOperationCompleted()),
   547             this, SLOT(handleSendOperationCompleted()), Qt::UniqueConnection);
   589             this, SLOT(handleSendOperationCompleted()), Qt::UniqueConnection);
   548 
   590 
   549         // Construct and setup the wait dialog.
   591         // Construct and setup the wait dialog.
   550         mServiceSendingDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
   592         mServiceSendingDialog = new HbProgressDialog(HbProgressDialog::WaitDialog);
   597     // Close wait dialog here
   639     // Close wait dialog here
   598     if (mWaitDialog) {
   640     if (mWaitDialog) {
   599         mWaitDialog->close();
   641         mWaitDialog->close();
   600     }
   642     }
   601     
   643     
   602     if (result == NmNoError && mMessageCreationOperation) {
   644     if (result == NmNoError && mStartParam && mMessageCreationOperation) {
   603         NmUiEditorStartMode startMode = mStartParam->editorStartMode();
   645         NmUiEditorStartMode startMode = mStartParam->editorStartMode();
   604         
   646         
   605         // get message "again" from engine to update the message contents 
   647         // get message "again" from engine to update the message contents 
   606         mMessage = mUiEngine.message(
   648         mMessage = mUiEngine.message(
   607             mStartParam->mailboxId(), 
   649             mStartParam->mailboxId(), 
   672 */
   714 */
   673 void NmEditorView::fillEditorWithMessageContents()
   715 void NmEditorView::fillEditorWithMessageContents()
   674 {
   716 {
   675     NM_FUNCTION;
   717     NM_FUNCTION;
   676     
   718     
   677     if (!mMessage || !mContentWidget) {
   719     if (!mStartParam || !mMessage || !mContentWidget) {
   678         return;
   720         return;
   679     }
   721     }
   680 
   722 
   681     NmMessageEnvelope messageEnvelope(mMessage->envelope());
   723     NmMessageEnvelope messageEnvelope(mMessage->envelope());
   682     NmUiEditorStartMode editorStartMode = NmUiEditorCreateNew;
       
   683     bool useStartParam(false);
   724     bool useStartParam(false);
   684 
   725 
   685     if (mStartParam) {
   726     NmUiEditorStartMode editorStartMode = mStartParam->editorStartMode();
   686         editorStartMode = mStartParam->editorStartMode();
   727 
   687 
   728     if (editorStartMode == NmUiEditorMailto) {
   688         if (editorStartMode == NmUiEditorMailto) {
   729         // Retrieve the message header data e.g. recipients from mStartParam.
   689             // Retrieve the message header data e.g. recipients from mStartParam.
   730         useStartParam = true;        
   690             useStartParam = true;        
       
   691         }
       
   692     }
   731     }
   693     
   732     
   694     // Set recipients (to, cc and bcc).
   733     // Set recipients (to, cc and bcc).
   695     QString toAddressesString;
   734     QString toAddressesString;
   696     QString ccAddressesString;
   735     QString ccAddressesString;
   735     mHeaderWidget->setPriority(messageEnvelope.priority());
   774     mHeaderWidget->setPriority(messageEnvelope.priority());
   736     
   775     
   737     // Set the message body.
   776     // Set the message body.
   738     if (editorStartMode==NmUiEditorReply||
   777     if (editorStartMode==NmUiEditorReply||
   739         editorStartMode==NmUiEditorReplyAll||
   778         editorStartMode==NmUiEditorReplyAll||
   740         editorStartMode==NmUiEditorForward){
   779         editorStartMode==NmUiEditorForward||
       
   780         editorStartMode==NmUiEditorFromDrafts){
   741 
   781 
   742         // Use the body from the original message.
   782         // Use the body from the original message.
   743         NmMessage *originalMessage = mUiEngine.message(mStartParam->mailboxId(), 
   783         NmMessage *originalMessage = mUiEngine.message(mStartParam->mailboxId(), 
   744                                                        mStartParam->folderId(), 
   784                                                        mStartParam->folderId(), 
   745                                                        mStartParam->messageId());
   785                                                        mStartParam->messageId());
   761                                                originalMessage->envelope().folderId(),
   801                                                originalMessage->envelope().folderId(),
   762                                                originalMessage->envelope().messageId(),
   802                                                originalMessage->envelope().messageId(),
   763                                                *htmlPart);
   803                                                *htmlPart);
   764             }
   804             }
   765 
   805 
   766             mContentWidget->setMessageData(*originalMessage);
   806             if (editorStartMode==NmUiEditorFromDrafts) {
       
   807                 mContentWidget->setMessageData(*originalMessage, false);
       
   808             }
       
   809             else {
       
   810                 mContentWidget->setMessageData(*originalMessage);
       
   811             }
   767         }
   812         }
   768 
   813 
   769         delete originalMessage;
   814         delete originalMessage;
   770         originalMessage = NULL;
   815         originalMessage = NULL;
   771     }
   816     }
   779             attachments[i]->attachmentName(),
   824             attachments[i]->attachmentName(),
   780             QString::number(attachments[i]->size()),
   825             QString::number(attachments[i]->size()),
   781             attachments[i]->partId());
   826             attachments[i]->partId());
   782     }
   827     }
   783 
   828 
   784     if (mStartParam) {
   829     // Attach passed files to the message.
   785         // Attach passed files to the message.
   830     QStringList *fileList = mStartParam->attachmentList();
   786         QStringList *fileList = mStartParam->attachmentList();
   831 
   787 
   832     if (fileList) {
   788         if (fileList) {
   833         addAttachments(*fileList);
   789             addAttachments(*fileList);
   834     }
   790         }
   835 
   791     }
       
   792 
       
   793     // TODO Switch the following arbitrary (magic number) timeout to a
       
   794     // meaningful constant, please!
       
   795     QTimer::singleShot(200, mHeaderWidget, SLOT(sendHeaderHeightChanged()));
       
   796 }
   836 }
   797 
   837 
   798 
   838 
   799 /*!
   839 /*!
   800     createToolBar. Function asks menu commands from extension
   840     createToolBar. Function asks menu commands from extension
   907     }
   947     }
   908     else {
   948     else {
   909     	mCcBccFieldVisible = true;
   949     	mCcBccFieldVisible = true;
   910     }
   950     }
   911     mHeaderWidget->setFieldVisibility( mCcBccFieldVisible );
   951     mHeaderWidget->setFieldVisibility( mCcBccFieldVisible );
   912 
       
   913     QTimer::singleShot(NmOrientationTimer, this, SLOT(sendHeaderHeightChanged()));
       
   914 }
   952 }
   915 
   953 
   916 /*!
   954 /*!
   917     handleActionCommand. From NmActionObserver, extension manager calls this
   955     handleActionCommand. From NmActionObserver, extension manager calls this
   918     call to handle menu command in the UI.
   956     call to handle menu command in the UI.
   946         case NmActionResponseCommandRemoveAttachment: {
   984         case NmActionResponseCommandRemoveAttachment: {
   947             removeAttachmentTriggered();
   985             removeAttachmentTriggered();
   948             break;
   986             break;
   949         }
   987         }
   950         case NmActionResponseCommandOpenAttachment: {
   988         case NmActionResponseCommandOpenAttachment: {
   951             openAttachmentTriggered();
   989             openAttachmentTriggered(mSelectedAttachment);
   952             break;
   990             break;
   953         }
   991         }
   954         default:
   992         default:
   955             break;
   993             break;
   956         }
   994         }
   960 /*!
   998 /*!
   961     Slot. Cancelled sending progress dialog.
   999     Slot. Cancelled sending progress dialog.
   962 */
  1000 */
   963 void NmEditorView::sendProgressDialogCancelled()
  1001 void NmEditorView::sendProgressDialogCancelled()
   964 {
  1002 {
   965     // Needs to be called before closing the application otherwise nmail panics
       
   966     // in destruction.
       
   967     QGraphicsScene *graphicsScene = scene();
       
   968     if (graphicsScene) {
       
   969         graphicsScene->clearFocus();
       
   970     }
       
   971 
       
   972     // Must use delayed editor view destruction so that dialog
  1003     // Must use delayed editor view destruction so that dialog
   973     // gets time to complete, closes also nmail.
  1004     // gets time to complete, closes also nmail.
   974     QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
  1005     QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
   975 }
  1006 }
   976 
  1007 
  1014     for all editors of the view.
  1045     for all editors of the view.
  1015 */
  1046 */
  1016 void NmEditorView::initializeVKB()
  1047 void NmEditorView::initializeVKB()
  1017 {
  1048 {
  1018     NM_FUNCTION;
  1049     NM_FUNCTION;
       
  1050     
       
  1051     if (!mStartParam) {
       
  1052         return;
       
  1053     }
  1019     
  1054     
  1020     NmActionRequest request(this, NmActionVKB, NmActionContextViewEditor,
  1055     NmActionRequest request(this, NmActionVKB, NmActionContextViewEditor,
  1021          NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
  1056          NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() );
  1022     NmUiExtensionManager &extMngr = mApplication.extManager();
  1057     NmUiExtensionManager &extMngr = mApplication.extManager();
  1023     if (&extMngr) {
  1058     if (&extMngr) {
  1135     Parameter 'errorMessage' is the error message returned by the service
  1170     Parameter 'errorMessage' is the error message returned by the service
  1136 */
  1171 */
  1137 void NmEditorView::onAttachmentsFetchError(int errorCode, const QString& errorMessage)
  1172 void NmEditorView::onAttachmentsFetchError(int errorCode, const QString& errorMessage)
  1138 {
  1173 {
  1139     NM_FUNCTION;
  1174     NM_FUNCTION;
       
  1175     Q_UNUSED(errorCode);
       
  1176     Q_UNUSED(errorMessage);
  1140     NM_COMMENT(QString("Error code: %1").arg(errorCode));
  1177     NM_COMMENT(QString("Error code: %1").arg(errorCode));
  1141     NM_COMMENT(QString("Error message: %1").arg(errorMessage));
  1178     NM_COMMENT(QString("Error message: %1").arg(errorMessage));
  1142 }
  1179 }
  1143 
  1180 
  1144 /*!
  1181 /*!
  1153     NM_FUNCTION;
  1190     NM_FUNCTION;
  1154 
  1191 
  1155     if (mServiceSendingDialog) {
  1192     if (mServiceSendingDialog) {
  1156         mServiceSendingDialog->close();
  1193         mServiceSendingDialog->close();
  1157     }
  1194     }
  1158 
       
  1159     // Needs to be called before closing the application otherwise nmail panics
       
  1160     // in destruction.
       
  1161     QGraphicsScene *graphicsScene = scene();
       
  1162     if (graphicsScene) {
       
  1163         graphicsScene->clearFocus();
       
  1164     }
       
  1165 
       
  1166     // Must use delayed editor view destruction so that dialog
  1195     // Must use delayed editor view destruction so that dialog
  1167     // gets time to complete, closes also nmail.
  1196     // gets time to complete, closes also nmail.
  1168     QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
  1197     QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
  1169 }
  1198 }
  1170 
  1199 
  1427 }
  1456 }
  1428 
  1457 
  1429 /*!
  1458 /*!
  1430     This slot is called when 'open' is selected from attachment list context menu.
  1459     This slot is called when 'open' is selected from attachment list context menu.
  1431 */
  1460 */
  1432 void NmEditorView::openAttachmentTriggered()
  1461 void NmEditorView::openAttachmentTriggered(NmId attachmentId)
  1433 {
  1462 {
  1434     NM_FUNCTION;
  1463     NM_FUNCTION;
  1435     
  1464     NmId mailboxId = mMessage->envelope().mailboxId();
  1436     mHeaderWidget->launchAttachment(mSelectedAttachment);
  1465     NmId folderId = mMessage->envelope().folderId();
       
  1466     NmId msgId = mMessage->envelope().messageId();
       
  1467 
       
  1468     XQSharableFile file = mUiEngine.messagePartFile(mailboxId, folderId,
       
  1469     		msgId, attachmentId);
       
  1470     int error = NmUtilities::openFile(file);
       
  1471     file.close();
       
  1472     if ( error == NmNotFoundError ) {
       
  1473         NmUtilities::displayErrorNote(hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty")); 
       
  1474     }
  1437 }
  1475 }
  1438 
  1476 
  1439 /*!
  1477 /*!
  1440    Enables/disables toolbar extension for attach
  1478    Enables/disables toolbar extension for attach
  1441 */
  1479 */