89 { |
89 { |
90 NM_FUNCTION; |
90 NM_FUNCTION; |
91 |
91 |
92 // Delete opened temporary files. |
92 // Delete opened temporary files. |
93 NmUtilities::deleteTempFiles(mTempFiles); |
93 NmUtilities::deleteTempFiles(mTempFiles); |
94 |
94 |
95 if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) { |
95 if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) { |
96 mRemoveAttachmentOperation->cancelOperation(); |
96 mRemoveAttachmentOperation->cancelOperation(); |
97 } |
97 } |
98 |
98 |
99 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
99 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
138 Loads the view layout from XML. |
138 Loads the view layout from XML. |
139 */ |
139 */ |
140 void NmEditorView::loadViewLayout() |
140 void NmEditorView::loadViewLayout() |
141 { |
141 { |
142 NM_FUNCTION; |
142 NM_FUNCTION; |
143 |
143 |
144 // Use the document loader to load the view. |
144 // Use the document loader to load the view. |
145 QObjectList objectList; |
145 QObjectList objectList; |
146 objectList.append(this); |
146 objectList.append(this); |
147 |
147 |
148 // Pass the view to documentloader. Document loader uses this view when |
148 // Pass the view to documentloader. Document loader uses this view when |
152 |
152 |
153 bool ok(false); |
153 bool ok(false); |
154 mWidgetList = mDocumentLoader->load(NMUI_EDITOR_VIEW_XML, &ok); |
154 mWidgetList = mDocumentLoader->load(NMUI_EDITOR_VIEW_XML, &ok); |
155 |
155 |
156 if (ok) { |
156 if (ok) { |
157 mContent = new NmEditorContent(this, mDocumentLoader, |
157 mContent = new NmEditorContent(this, mDocumentLoader, |
158 mApplication.networkAccessManager(), |
158 mApplication.networkAccessManager(), |
159 mApplication); |
159 mApplication); |
160 |
160 |
161 mHeaderWidget = mContent->header(); |
161 mHeaderWidget = mContent->header(); |
162 |
162 |
164 // mode. |
164 // mode. |
165 if (mStartParam) { |
165 if (mStartParam) { |
166 NmUiEditorStartMode mode = mStartParam->editorStartMode(); |
166 NmUiEditorStartMode mode = mStartParam->editorStartMode(); |
167 |
167 |
168 if (mode == NmUiEditorReply || |
168 if (mode == NmUiEditorReply || |
169 mode == NmUiEditorReplyAll || |
169 mode == NmUiEditorReplyAll || |
170 mode == NmUiEditorForward) { |
170 mode == NmUiEditorForward) { |
171 mContent->editor()->setCustomTextColor(true, Qt::blue); |
171 mContent->editor()->setCustomTextColor(true, Qt::blue); |
172 } |
172 } |
173 } |
173 } |
174 |
174 |
326 NM_FUNCTION; |
326 NM_FUNCTION; |
327 |
327 |
328 HbMessageBox *dlg = static_cast<HbMessageBox*>(sender()); |
328 HbMessageBox *dlg = static_cast<HbMessageBox*>(sender()); |
329 // The first action in dialogs action list is for the "Yes"-button. |
329 // The first action in dialogs action list is for the "Yes"-button. |
330 if (action == dlg->actions().at(0)) { |
330 if (action == dlg->actions().at(0)) { |
|
331 connect(&mUiEngine, SIGNAL(draftSaved()),this, SLOT(closeView())); |
331 safeToDraft(); |
332 safeToDraft(); |
332 } |
333 } else { |
333 |
334 // delete draft now because it is always created in the beginning |
334 // Close the view |
335 // of new email creation process |
335 QMetaObject::invokeMethod(&mApplication, |
336 connect(&mUiEngine, SIGNAL(draftDeleted()),this, SLOT(closeView())); |
336 "popView", |
337 deleteDraft(); |
337 Qt::QueuedConnection); |
338 } |
338 } |
339 } |
339 |
340 |
340 /*! |
341 /*! |
341 Public slot to handle draft saving. |
342 Public slot to handle draft saving. |
342 */ |
343 */ |
343 void NmEditorView::safeToDraft() |
344 void NmEditorView::safeToDraft() |
344 { |
345 { |
345 // Update draft message with content. |
346 // Update draft message with content. |
346 updateMessageWithEditorContents(); |
347 updateMessageWithEditorContents(); |
|
348 |
|
349 // Draft messages are always read. |
|
350 mMessage->envelope().setRead(true); |
347 |
351 |
348 // Save message to drafts |
352 // Save message to drafts |
349 QList<NmOperation *> preliminaryOperations; |
353 QList<NmOperation *> preliminaryOperations; |
350 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
354 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
351 preliminaryOperations.append(mAddAttachmentOperation); |
355 preliminaryOperations.append(mAddAttachmentOperation); |
356 // ownership of mMessage is transferred |
360 // ownership of mMessage is transferred |
357 // NmOperations are automatically deleted after completion |
361 // NmOperations are automatically deleted after completion |
358 mUiEngine.saveDraftMessage(mMessage, preliminaryOperations); |
362 mUiEngine.saveDraftMessage(mMessage, preliminaryOperations); |
359 mMessage = NULL; |
363 mMessage = NULL; |
360 preliminaryOperations.clear(); |
364 preliminaryOperations.clear(); |
|
365 } |
|
366 |
|
367 /*! |
|
368 Public slot to handle draft deletion. |
|
369 */ |
|
370 void NmEditorView::deleteDraft() |
|
371 { |
|
372 // ownership of mMessage is transferred |
|
373 // NmOperations are automatically deleted after completion |
|
374 mUiEngine.removeDraftMessage(mMessage); |
|
375 mMessage = NULL; |
|
376 } |
|
377 |
|
378 void NmEditorView::closeView() |
|
379 { |
|
380 // Close the view |
|
381 QMetaObject::invokeMethod(&mApplication, |
|
382 "popView", |
|
383 Qt::QueuedConnection); |
361 } |
384 } |
362 |
385 |
363 /*! |
386 /*! |
364 About to exit view. Application calls this function when user has |
387 About to exit view. Application calls this function when user has |
365 pressed back key and editor needs to delete the draft message. This is |
388 pressed back key and editor needs to delete the draft message. This is |
543 |
566 |
544 void NmEditorView::startMessageCreation(NmUiStartParam &startParam) |
567 void NmEditorView::startMessageCreation(NmUiStartParam &startParam) |
545 { |
568 { |
546 NM_FUNCTION; |
569 NM_FUNCTION; |
547 NM_TIMESTAMP("Start editor."); |
570 NM_TIMESTAMP("Start editor."); |
548 |
571 |
549 NmUiEditorStartMode startMode = startParam.editorStartMode(); |
572 NmUiEditorStartMode startMode = startParam.editorStartMode(); |
550 NmId mailboxId = startParam.mailboxId(); |
573 NmId mailboxId = startParam.mailboxId(); |
551 NmId folderId = startParam.folderId(); |
574 NmId folderId = startParam.folderId(); |
552 NmId msgId = startParam.messageId(); |
575 NmId msgId = startParam.messageId(); |
553 |
576 |
581 connect(mMessageCreationOperation, |
604 connect(mMessageCreationOperation, |
582 SIGNAL(operationCompleted(int)), |
605 SIGNAL(operationCompleted(int)), |
583 this, |
606 this, |
584 SLOT(messageCreated(int))); |
607 SLOT(messageCreated(int))); |
585 } |
608 } |
586 |
609 |
587 // Set focus |
610 // Set focus |
588 if (mContent && mContent->header() ) { |
611 if (mContent && mContent->header() ) { |
589 if (startMode == NmUiEditorCreateNew || XQServiceUtil::isEmbedded()) { |
612 if (startMode == NmUiEditorCreateNew || XQServiceUtil::isEmbedded()) { |
590 if (mContent->header()->toEdit()) { |
613 if (mContent->header()->toEdit()) { |
591 mContent->header()->toEdit()->setFocus(Qt::OtherFocusReason); |
614 mContent->header()->toEdit()->setFocus(Qt::OtherFocusReason); |
826 QList<NmAddress *> ccAddressList = mStartParam->ccAddressList(); |
849 QList<NmAddress *> ccAddressList = mStartParam->ccAddressList(); |
827 QList<NmAddress *> bccAddressList = mStartParam->bccAddressList(); |
850 QList<NmAddress *> bccAddressList = mStartParam->bccAddressList(); |
828 toAddressesString = addressListToString(toAddressList); |
851 toAddressesString = addressListToString(toAddressList); |
829 ccAddressesString = addressListToString(ccAddressList); |
852 ccAddressesString = addressListToString(ccAddressList); |
830 bccAddressesString = addressListToString(bccAddressList); |
853 bccAddressesString = addressListToString(bccAddressList); |
831 // Also add recipients added for example from send service |
854 // Also add recipients added for example from send service |
832 // interface to recipient line edits. |
855 // interface to recipient line edits. |
833 mContent->header()->toEdit()->addContacts(toAddressList); |
856 mContent->header()->toEdit()->addContacts(toAddressList); |
834 mContent->header()->ccEdit()->addContacts(ccAddressList); |
857 mContent->header()->ccEdit()->addContacts(ccAddressList); |
835 mContent->header()->bccEdit()->addContacts(bccAddressList); |
858 mContent->header()->bccEdit()->addContacts(bccAddressList); |
836 } |
859 } |
837 else { |
860 else { |
970 NmActionRequest request(this, |
993 NmActionRequest request(this, |
971 NmActionToolbar, |
994 NmActionToolbar, |
972 NmActionContextViewEditor, |
995 NmActionContextViewEditor, |
973 NmActionContextDataNone, |
996 NmActionContextDataNone, |
974 mStartParam->mailboxId(), |
997 mStartParam->mailboxId(), |
975 mStartParam->folderId()); |
998 mStartParam->folderId()); |
976 QList<NmAction *> list; |
999 QList<NmAction *> list; |
977 extMngr.getActions(request, list); |
1000 extMngr.getActions(request, list); |
978 |
1001 |
979 for (int i = 0; i < list.count(); i++) { |
1002 for (int i = 0; i < list.count(); i++) { |
980 tb->addAction(list[i]); |
1003 tb->addAction(list[i]); |
1000 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_video")); |
1023 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_video")); |
1001 |
1024 |
1002 HbListViewItem *listView = mTBExtnContentWidget->listItemPrototype(); |
1025 HbListViewItem *listView = mTBExtnContentWidget->listItemPrototype(); |
1003 HbFrameBackground frame(NmPopupListFrame, HbFrameDrawer::NinePieces); |
1026 HbFrameBackground frame(NmPopupListFrame, HbFrameDrawer::NinePieces); |
1004 listView->setDefaultFrame(frame); |
1027 listView->setDefaultFrame(frame); |
1005 |
1028 |
1006 extension->setContentWidget(mTBExtnContentWidget); |
1029 extension->setContentWidget(mTBExtnContentWidget); |
1007 |
1030 |
1008 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
1031 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
1009 extension, SLOT(close())); |
1032 extension, SLOT(close())); |
1010 |
1033 |
1011 mAttachmentPicker = new NmAttachmentPicker(this); |
1034 mAttachmentPicker = new NmAttachmentPicker(this); |
1012 |
1035 |
1013 connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)), |
1036 connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)), |
1014 this, SLOT(onAttachmentReqCompleted(const QVariant &))); |
1037 this, SLOT(onAttachmentReqCompleted(const QVariant &))); |
1015 connect(this, SIGNAL(titleChanged(QString)), |
1038 connect(this, SIGNAL(titleChanged(QString)), |
1016 mAttachmentPicker, SLOT(setTitle(QString))); |
1039 mAttachmentPicker, SLOT(setTitle(QString))); |
1017 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
1040 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
1018 mAttachmentPicker, SLOT (selectFetcher(HbListWidgetItem*))); |
1041 mAttachmentPicker, SLOT (selectFetcher(HbListWidgetItem*))); |
1019 } |
1042 } |
1020 } // for () |
1043 } // for () |
1021 } |
1044 } |
1022 |
1045 |
1023 |
1046 |
1024 /*! |
1047 /*! |
1025 createOptionsMenu. Functions asks menu commands from extension |
1048 createOptionsMenu. Functions asks menu commands from extension |
1325 */ |
1348 */ |
1326 void NmEditorView::addAttachments(const QStringList& fileNames) |
1349 void NmEditorView::addAttachments(const QStringList& fileNames) |
1327 { |
1350 { |
1328 NM_FUNCTION; |
1351 NM_FUNCTION; |
1329 NM_TIMESTAMP("Add attachments."); |
1352 NM_TIMESTAMP("Add attachments."); |
1330 |
1353 |
1331 // Add attachment name into UI |
1354 // Add attachment name into UI |
1332 foreach (QString fileName, fileNames) { |
1355 foreach (QString fileName, fileNames) { |
1333 // At this phase attachment size and nmid are not known |
1356 // At this phase attachment size and nmid are not known |
1334 mHeaderWidget->addAttachment(fileName, QString("0"), NmId(0)); |
1357 mHeaderWidget->addAttachment(fileName, QString("0"), NmId(0)); |
1335 NM_COMMENT(fileName); |
1358 NM_COMMENT(fileName); |
1446 */ |
1469 */ |
1447 void NmEditorView::allAttachmentsAdded(int result) |
1470 void NmEditorView::allAttachmentsAdded(int result) |
1448 { |
1471 { |
1449 NM_FUNCTION; |
1472 NM_FUNCTION; |
1450 NM_TIMESTAMP("All attachments added."); |
1473 NM_TIMESTAMP("All attachments added."); |
1451 |
1474 |
1452 enableToolBarAttach(true); |
1475 enableToolBarAttach(true); |
1453 if (result != NmNoError) { |
1476 if (result != NmNoError) { |
1454 NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_unable_to_add_attachment")); |
1477 NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_unable_to_add_attachment")); |
1455 } |
1478 } |
1456 } |
1479 } |
1635 int count = toolbarList.count(); |
1658 int count = toolbarList.count(); |
1636 for (int i = 0; i < count; i++) { |
1659 for (int i = 0; i < count; i++) { |
1637 NmAction *action = static_cast<NmAction *>(toolbarList[i]); |
1660 NmAction *action = static_cast<NmAction *>(toolbarList[i]); |
1638 if (action->availabilityCondition() == NmAction::NmAttachable) { |
1661 if (action->availabilityCondition() == NmAction::NmAttachable) { |
1639 action->setEnabled(enable); |
1662 action->setEnabled(enable); |
1640 if (enable) { |
1663 } |
1641 // For some reason 'Add attachment' toolbar button stays dimmed sometimes, |
1664 } |
1642 // showItems will fix the situation. |
1665 } |
1643 showItems(Hb::ToolBarItem); |
1666 } |
1644 } |
|
1645 } |
|
1646 } |
|
1647 } |
|
1648 } |
|