87 */ |
87 */ |
88 NmEditorView::~NmEditorView() |
88 NmEditorView::~NmEditorView() |
89 { |
89 { |
90 NM_FUNCTION; |
90 NM_FUNCTION; |
91 |
91 |
|
92 // Delete opened temporary files. |
|
93 NmUtilities::deleteTempFiles(mTempFiles); |
|
94 |
92 if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) { |
95 if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) { |
93 mRemoveAttachmentOperation->cancelOperation(); |
96 mRemoveAttachmentOperation->cancelOperation(); |
94 } |
97 } |
95 |
98 |
96 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
99 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
137 */ |
139 */ |
138 void NmEditorView::loadViewLayout() |
140 void NmEditorView::loadViewLayout() |
139 { |
141 { |
140 NM_FUNCTION; |
142 NM_FUNCTION; |
141 |
143 |
142 mPrioritySubMenu = NULL; |
|
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 |
581 connect(mMessageCreationOperation, |
581 connect(mMessageCreationOperation, |
582 SIGNAL(operationCompleted(int)), |
582 SIGNAL(operationCompleted(int)), |
583 this, |
583 this, |
584 SLOT(messageCreated(int))); |
584 SLOT(messageCreated(int))); |
585 } |
585 } |
|
586 |
|
587 // Set focus |
|
588 if (mContent && mContent->header() ) { |
|
589 if (startMode == NmUiEditorCreateNew || XQServiceUtil::isEmbedded()) { |
|
590 if (mContent->header()->toEdit()) { |
|
591 mContent->header()->toEdit()->setFocus(Qt::OtherFocusReason); |
|
592 } |
|
593 } |
|
594 else |
|
595 { |
|
596 if (mContent->editor()) { |
|
597 mContent->editor()->setFocus(Qt::OtherFocusReason); |
|
598 } |
|
599 } |
|
600 } |
|
601 |
|
602 // Show VKB |
|
603 QInputContext *ic = qApp->inputContext(); |
|
604 |
|
605 if(ic) { |
|
606 QEvent *event = new QEvent(QEvent::RequestSoftwareInputPanel); |
|
607 ic->filterEvent(event); |
|
608 delete event; |
|
609 } |
586 } |
610 } |
587 |
611 |
588 /*! |
612 /*! |
589 Starting the message sending is handled here. |
613 Starting the message sending is handled here. |
590 */ |
614 */ |
749 bodyPart->setTextContent(mContent->editor()->toPlainText(), NmContentTypeTextPlain); |
773 bodyPart->setTextContent(mContent->editor()->toPlainText(), NmContentTypeTextPlain); |
750 } |
774 } |
751 } |
775 } |
752 if (mContent && mContent->header() ) { |
776 if (mContent && mContent->header() ) { |
753 if (mContent->header()->subjectEdit()) { |
777 if (mContent->header()->subjectEdit()) { |
754 mMessage->envelope().setSubject( |
778 mMessage->envelope().setSubject(mContent->header()->subjectEdit()->text()); |
755 mContent->header()->subjectEdit()->text()); |
|
756 } |
779 } |
757 if (mContent->header()->toEdit()) { |
780 if (mContent->header()->toEdit()) { |
758 QString toFieldText = |
781 mMessage->envelope().setToRecipients( |
759 mContent->header()->toEdit()->text(); |
782 mContent->header()->toEdit()->emailAddressList()); |
760 |
|
761 // This verification of zero length string isn't needed |
|
762 // after list of addresses |
|
763 if (toFieldText.length() > 0) { |
|
764 mMessage->envelope().setToRecipients(mContent->header()->toEdit()->emailAddressList()); |
|
765 } |
|
766 } |
783 } |
767 if (mContent->header()->ccEdit()) { |
784 if (mContent->header()->ccEdit()) { |
768 QString ccFieldText = |
785 mMessage->envelope().setCcRecipients( |
769 mContent->header()->ccEdit()->text(); |
786 mContent->header()->ccEdit()->emailAddressList()); |
770 |
|
771 if (ccFieldText.length() > 0) { |
|
772 mMessage->envelope().setCcRecipients(mContent->header()->ccEdit()->emailAddressList()); |
|
773 } |
|
774 } |
787 } |
775 if (mContent->header()->bccEdit()) { |
788 if (mContent->header()->bccEdit()) { |
776 QString bccFieldText = |
789 mMessage->envelope().setBccRecipients( |
777 mContent->header()->bccEdit()->text(); |
790 mContent->header()->bccEdit()->emailAddressList()); |
778 |
|
779 if (bccFieldText.length() > 0) { |
|
780 mMessage->envelope().setBccRecipients(mContent->header()->bccEdit()->emailAddressList()); |
|
781 } |
|
782 } |
791 } |
783 } |
792 } |
784 } |
793 } |
785 } |
794 } |
786 |
795 |
1029 else { |
1038 else { |
1030 menu()->addAction(hbTrId("txt_mail_opt_show_cc_bcc"), this, SLOT(switchCcBccFieldVisibility())); |
1039 menu()->addAction(hbTrId("txt_mail_opt_show_cc_bcc"), this, SLOT(switchCcBccFieldVisibility())); |
1031 } |
1040 } |
1032 |
1041 |
1033 // Create Priority options menu object |
1042 // Create Priority options menu object |
1034 if (!mPrioritySubMenu) { |
1043 HbMenu *prioritySubMenu = new HbMenu(); |
1035 mPrioritySubMenu = new HbMenu(); |
|
1036 } |
|
1037 mPrioritySubMenu->clearActions(); |
|
1038 NmActionRequest request(this, NmActionOptionsMenu, NmActionContextViewEditor, |
1044 NmActionRequest request(this, NmActionOptionsMenu, NmActionContextViewEditor, |
1039 NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(), |
1045 NmActionContextDataMessage, mStartParam->mailboxId(), mStartParam->folderId(), |
1040 mStartParam->messageId()); |
1046 mStartParam->messageId()); |
1041 NmUiExtensionManager &extMngr = mApplication.extManager(); |
1047 NmUiExtensionManager &extMngr = mApplication.extManager(); |
1042 QList<NmAction*> list; |
1048 QList<NmAction*> list; |
1043 extMngr.getActions(request, list); |
1049 extMngr.getActions(request, list); |
1044 for (int i = 0; i < list.count(); i++) { |
1050 for (int i = 0; i < list.count(); i++) { |
1045 // check what priority has already been selected and hide it from options menu |
1051 // check what priority has already been selected and hide it from options menu |
1046 if (!list[i]->objectName().contains(mHiddenPriorityName)) { |
1052 if (!list[i]->objectName().contains(mHiddenPriorityName)) { |
1047 mPrioritySubMenu->addAction(list[i]); |
1053 prioritySubMenu->addAction(list[i]); |
1048 } |
1054 } |
1049 } |
1055 } |
1050 mPrioritySubMenu->setObjectName("editorPrioritySubMenu"); |
1056 prioritySubMenu->setObjectName("editorPrioritySubMenu"); |
1051 mPrioritySubMenu->setTitle(hbTrId("txt_mail_opt_add_priority")); |
1057 prioritySubMenu->setTitle(hbTrId("txt_mail_opt_add_priority")); |
1052 menu()->addMenu(mPrioritySubMenu); |
1058 menu()->addMenu(prioritySubMenu); |
1053 } |
1059 } |
1054 |
1060 |
1055 /*! |
1061 /*! |
1056 Show or hide Cc field |
1062 Show or hide Cc field |
1057 */ |
1063 */ |
1485 QString NmEditorView::addressListToString(const QList<NmAddress*> &list) const |
1491 QString NmEditorView::addressListToString(const QList<NmAddress*> &list) const |
1486 { |
1492 { |
1487 NM_FUNCTION; |
1493 NM_FUNCTION; |
1488 |
1494 |
1489 QString addressesString; |
1495 QString addressesString; |
1490 QList<NmAddress*>::const_iterator i = list.constBegin(); |
1496 foreach (NmAddress *nmAddress,list) { |
1491 |
1497 if (nmAddress->displayName().length() > 0) { |
1492 while (i != list.constEnd() && *i) { |
1498 addressesString += nmAddress->displayName(); |
1493 // Prioritize display name. Add the delimiter in the end also if |
|
1494 // address list ends to display name. |
|
1495 if ((*i)->displayName().length() > 0) { |
|
1496 addressesString += (*i)->displayName(); |
|
1497 addressesString += NmDelimiter; |
|
1498 } |
1499 } |
1499 else { |
1500 else { |
1500 if (i > list.constBegin()) { |
1501 addressesString += nmAddress->address(); |
1501 // Add the delimiter. |
1502 } |
1502 addressesString += NmDelimiter; |
1503 addressesString += NmDelimiter; |
1503 } |
1504 } |
1504 addressesString += (*i)->address(); |
|
1505 } |
|
1506 ++i; |
|
1507 } |
|
1508 |
|
1509 return addressesString; |
1505 return addressesString; |
1510 } |
1506 } |
1511 |
1507 |
1512 |
1508 |
1513 /*! |
1509 /*! |
1608 NM_FUNCTION; |
1604 NM_FUNCTION; |
1609 NmId mailboxId = mMessage->envelope().mailboxId(); |
1605 NmId mailboxId = mMessage->envelope().mailboxId(); |
1610 NmId folderId = mMessage->envelope().folderId(); |
1606 NmId folderId = mMessage->envelope().folderId(); |
1611 NmId msgId = mMessage->envelope().messageId(); |
1607 NmId msgId = mMessage->envelope().messageId(); |
1612 |
1608 |
1613 XQSharableFile file = mUiEngine.messagePartFile(mailboxId, folderId, |
1609 QList<NmMessagePart *> attachments; |
1614 msgId, attachmentId); |
1610 mMessage->attachmentList(attachments); |
1615 int error = NmUtilities::openFile(file); |
1611 foreach (NmMessagePart *part, attachments) { |
1616 file.close(); |
1612 if (part->partId() == attachmentId) { |
1617 if ( error == NmNotFoundError ) { |
1613 // We need to fill the part before opening the attachment. |
1618 HbMessageBox *box = NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty")); |
1614 mUiEngine.contentToMessagePart(mailboxId,folderId,msgId, *part); |
1619 box->setAttribute(Qt::WA_DeleteOnClose); |
1615 int error = NmUtilities::openAttachment(part,mTempFiles); |
|
1616 if ( error == NmGeneralError ) { |
|
1617 HbMessageBox *box = NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_unable_to_open_attachment_file_ty")); |
|
1618 box->setAttribute(Qt::WA_DeleteOnClose); |
|
1619 } |
|
1620 break; |
|
1621 } |
1620 } |
1622 } |
1621 } |
1623 } |
1622 |
1624 |
1623 /*! |
1625 /*! |
1624 Enables/disables toolbar extension for attach |
1626 Enables/disables toolbar extension for attach |