39 : NmBaseView(startParam, application, parent), |
39 : NmBaseView(startParam, application, parent), |
40 mApplication(application), |
40 mApplication(application), |
41 mUiEngine(uiEngine), |
41 mUiEngine(uiEngine), |
42 mAttaManager(attaManager), |
42 mAttaManager(attaManager), |
43 mDocumentLoader(NULL), |
43 mDocumentLoader(NULL), |
44 mEditWidget(NULL), |
|
45 mHeaderWidget(NULL), |
44 mHeaderWidget(NULL), |
46 mMessage(NULL), |
45 mMessage(NULL), |
47 mContentWidget(NULL), |
46 mContent(NULL), |
48 mAttachmentListContextMenu(NULL), |
47 mAttachmentListContextMenu(NULL), |
49 mMessageCreationOperation(NULL), |
48 mMessageCreationOperation(NULL), |
50 mAddAttachmentOperation(NULL), |
49 mAddAttachmentOperation(NULL), |
51 mRemoveAttachmentOperation(NULL), |
50 mRemoveAttachmentOperation(NULL), |
52 mWaitDialog(NULL), |
51 mWaitDialog(NULL), |
126 QGraphicsWidget *view = mDocumentLoader->findWidget(NMUI_EDITOR_VIEW); |
125 QGraphicsWidget *view = mDocumentLoader->findWidget(NMUI_EDITOR_VIEW); |
127 if (view){ |
126 if (view){ |
128 setWidget(view); |
127 setWidget(view); |
129 } |
128 } |
130 |
129 |
131 mContentWidget = new NmEditorContent(this, mDocumentLoader, |
130 mContent = new NmEditorContent(this, mDocumentLoader, |
132 mApplication.networkAccessManager(), mApplication); |
131 mApplication.networkAccessManager(), mApplication); |
133 |
132 |
134 mEditWidget = mContentWidget->editor(); |
133 mHeaderWidget = mContent->header(); |
135 |
|
136 mHeaderWidget = mContentWidget->header(); |
|
137 |
134 |
138 // Set default color for user - entered text if editor is in re/reAll/fw mode |
135 // Set default color for user - entered text if editor is in re/reAll/fw mode |
139 if (mStartParam) { |
136 if (mStartParam) { |
140 NmUiEditorStartMode mode = mStartParam->editorStartMode(); |
137 NmUiEditorStartMode mode = mStartParam->editorStartMode(); |
141 if (mode == NmUiEditorReply |
138 if (mode == NmUiEditorReply |
142 || mode == NmUiEditorReplyAll |
139 || mode == NmUiEditorReplyAll |
143 || mode == NmUiEditorForward) { |
140 || mode == NmUiEditorForward) { |
144 mEditWidget->setCustomTextColor(true, Qt::blue); |
141 mContent->editor()->setCustomTextColor(true, Qt::blue); |
145 } |
142 } |
146 } |
143 } |
147 |
144 |
148 // the rest of the view initialization is done in viewReady() |
145 // the rest of the view initialization is done in viewReady() |
149 } |
146 } |
186 */ |
183 */ |
187 void NmEditorView::orientationChanged(Qt::Orientation orientation) |
184 void NmEditorView::orientationChanged(Qt::Orientation orientation) |
188 { |
185 { |
189 NM_FUNCTION; |
186 NM_FUNCTION; |
190 |
187 |
191 // If switching to horizontal, chrome must be hided |
188 Q_UNUSED(orientation); |
192 if (mVkbHost && orientation == Qt::Horizontal && |
|
193 mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusOpened) { |
|
194 showChrome(false); |
|
195 } |
|
196 |
189 |
197 // content widget height needs to be set according to the new orientation to get the scroll |
190 // content widget height needs to be set according to the new orientation to get the scroll |
198 // area work correctly |
191 // area work correctly |
199 mHeaderWidget->sendDelayedHeaderHeightChanged(); |
192 mHeaderWidget->sendDelayedHeaderHeightChanged(); |
200 } |
193 } |
247 { |
238 { |
248 NM_FUNCTION; |
239 NM_FUNCTION; |
249 |
240 |
250 bool okToExit(true); |
241 bool okToExit(true); |
251 |
242 |
252 if (mContentWidget) { |
243 if (mContent) { |
253 NmEditorHeader *header = mContentWidget->header(); |
244 NmEditorHeader *header = mContent->header(); |
254 // show the query if the message has not been sent |
245 // show the query if the message has not been sent |
255 if (mMessage && header) { |
246 if (mMessage && header) { |
256 // see if editor has any content |
247 // see if editor has any content |
257 int subjectLength = 0; |
248 int subjectLength = 0; |
258 if (header->subjectEdit()) { |
249 if (header->subjectEdit()) { |
359 // Menu needs to be create "just-in-time" |
350 // Menu needs to be create "just-in-time" |
360 connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu())); |
351 connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu())); |
361 NmAction *dummy = new NmAction(0); |
352 NmAction *dummy = new NmAction(0); |
362 menu()->addAction(dummy); |
353 menu()->addAction(dummy); |
363 |
354 |
|
355 mVkbHost = new HbShrinkingVkbHost(this); |
|
356 |
364 initializeVKB(); |
357 initializeVKB(); |
365 |
358 |
366 //Get VKB host instance and start to listen VKB open and close signals for hiding the chrome. |
359 //start to listen VKB open and close signals for hiding the chrome. |
367 HbEditorInterface editorInterface(mContentWidget->editor()); |
|
368 mVkbHost = editorInterface.vkbHost(); |
|
369 connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened())); |
360 connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened())); |
370 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed())); |
361 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed())); |
371 |
362 |
372 connect(mContentWidget->header(), SIGNAL(recipientFieldsHaveContent(bool)), |
363 connect(mContent->header(), SIGNAL(recipientFieldsHaveContent(bool)), |
373 this, SLOT(setButtonsDimming(bool)) ); |
364 this, SLOT(setButtonsDimming(bool)) ); |
374 |
365 |
375 // Connect to observe orientation change events |
366 // Connect to observe orientation change events |
376 connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
367 connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
377 this, SLOT(orientationChanged(Qt::Orientation))); |
368 this, SLOT(orientationChanged(Qt::Orientation))); |
679 void NmEditorView::updateMessageWithEditorContents() |
682 void NmEditorView::updateMessageWithEditorContents() |
680 { |
683 { |
681 NM_FUNCTION; |
684 NM_FUNCTION; |
682 |
685 |
683 if (mMessage) { |
686 if (mMessage) { |
684 if (mContentWidget && mContentWidget->editor()) { |
687 if (mContent && mContent->editor()) { |
685 NmMessagePart* bodyPart = mMessage->htmlBodyPart(); |
688 NmMessagePart* bodyPart = mMessage->htmlBodyPart(); |
686 if (bodyPart) { |
689 if (bodyPart) { |
687 bodyPart->setTextContent(mContentWidget->editor()->toHtml(), NmContentTypeTextHtml); |
690 bodyPart->setTextContent(mContent->editor()->toHtml(), NmContentTypeTextHtml); |
688 } |
691 } |
689 bodyPart = mMessage->plainTextBodyPart(); |
692 bodyPart = mMessage->plainTextBodyPart(); |
690 if (bodyPart) { |
693 if (bodyPart) { |
691 bodyPart->setTextContent(mContentWidget->editor()->toPlainText(), NmContentTypeTextPlain); |
694 bodyPart->setTextContent(mContent->editor()->toPlainText(), NmContentTypeTextPlain); |
692 } |
695 } |
693 } |
696 } |
694 if (mContentWidget && mContentWidget->header() ) { |
697 if (mContent && mContent->header() ) { |
695 if (mContentWidget->header()->subjectEdit()) { |
698 if (mContent->header()->subjectEdit()) { |
696 mMessage->envelope().setSubject( |
699 mMessage->envelope().setSubject( |
697 mContentWidget->header()->subjectEdit()->text()); |
700 mContent->header()->subjectEdit()->text()); |
698 } |
701 } |
699 if (mContentWidget->header()->toEdit()) { |
702 if (mContent->header()->toEdit()) { |
700 QString toFieldText = |
703 QString toFieldText = |
701 mContentWidget->header()->toEdit()->text(); |
704 mContent->header()->toEdit()->text(); |
702 |
705 |
703 // This verification of zero length string isn't needed |
706 // This verification of zero length string isn't needed |
704 // after list of addresses |
707 // after list of addresses |
705 if (toFieldText.length() > 0) { |
708 if (toFieldText.length() > 0) { |
706 mMessage->envelope().setToRecipients(mContentWidget->header()->toEdit()->emailAddressList()); |
709 mMessage->envelope().setToRecipients(mContent->header()->toEdit()->emailAddressList()); |
707 } |
710 } |
708 } |
711 } |
709 if (mContentWidget->header()->ccEdit()) { |
712 if (mContent->header()->ccEdit()) { |
710 QString ccFieldText = |
713 QString ccFieldText = |
711 mContentWidget->header()->ccEdit()->text(); |
714 mContent->header()->ccEdit()->text(); |
712 |
715 |
713 if (ccFieldText.length() > 0) { |
716 if (ccFieldText.length() > 0) { |
714 mMessage->envelope().setCcRecipients(mContentWidget->header()->ccEdit()->emailAddressList()); |
717 mMessage->envelope().setCcRecipients(mContent->header()->ccEdit()->emailAddressList()); |
715 } |
718 } |
716 } |
719 } |
717 if (mContentWidget->header()->bccEdit()) { |
720 if (mContent->header()->bccEdit()) { |
718 QString bccFieldText = |
721 QString bccFieldText = |
719 mContentWidget->header()->bccEdit()->text(); |
722 mContent->header()->bccEdit()->text(); |
720 |
723 |
721 if (bccFieldText.length() > 0) { |
724 if (bccFieldText.length() > 0) { |
722 mMessage->envelope().setBccRecipients(mContentWidget->header()->bccEdit()->emailAddressList()); |
725 mMessage->envelope().setBccRecipients(mContent->header()->bccEdit()->emailAddressList()); |
723 } |
726 } |
724 } |
727 } |
725 } |
728 } |
726 } |
729 } |
727 } |
730 } |
763 toAddressesString = addressListToString(messageEnvelope.toRecipients()); |
766 toAddressesString = addressListToString(messageEnvelope.toRecipients()); |
764 ccAddressesString = addressListToString(messageEnvelope.ccRecipients()); |
767 ccAddressesString = addressListToString(messageEnvelope.ccRecipients()); |
765 bccAddressesString = addressListToString(messageEnvelope.bccRecipients()); |
768 bccAddressesString = addressListToString(messageEnvelope.bccRecipients()); |
766 } |
769 } |
767 |
770 |
768 mContentWidget->header()->toEdit()->setPlainText(toAddressesString); |
771 mContent->header()->toEdit()->setPlainText(toAddressesString); |
769 mContentWidget->header()->ccEdit()->setPlainText(ccAddressesString); |
772 mContent->header()->ccEdit()->setPlainText(ccAddressesString); |
770 mContentWidget->header()->bccEdit()->setPlainText(bccAddressesString); |
773 mContent->header()->bccEdit()->setPlainText(bccAddressesString); |
771 |
774 |
772 if (ccAddressesString.length() || bccAddressesString.length()) { |
775 if (ccAddressesString.length() || bccAddressesString.length()) { |
773 // Since cc or/and bcc recipients exist, expand the group box to display |
776 // Since cc or/and bcc recipients exist, expand the group box to display |
774 // the addresses by expanding the group box. |
777 // the addresses by expanding the group box. |
775 mContentWidget->header()->setFieldVisibility(true); |
778 mContent->header()->setFieldVisibility(true); |
776 } |
779 } |
777 |
780 |
778 // Set subject. |
781 // Set subject. |
779 if (useStartParam) { |
782 if (useStartParam) { |
780 QString *subject = mStartParam->subject(); |
783 QString *subject = mStartParam->subject(); |
781 |
784 |
782 if (subject) { |
785 if (subject) { |
783 mContentWidget->header()->subjectEdit()->setPlainText(*subject); |
786 mContent->header()->subjectEdit()->setPlainText(*subject); |
784 } |
787 } |
785 } |
788 } |
786 else { |
789 else { |
787 // Construct the subject field. |
790 // Construct the subject field. |
788 mContentWidget->header()->subjectEdit()->setPlainText( |
791 mContent->header()->subjectEdit()->setPlainText( |
789 addSubjectPrefix(editorStartMode, messageEnvelope.subject())); |
792 addSubjectPrefix(editorStartMode, messageEnvelope.subject())); |
790 } |
793 } |
791 |
794 |
792 // Set priority. |
795 // Set priority. |
|
796 if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll) { |
|
797 //Clear the importance flag. Replied messages dont keep the importance |
|
798 setPriority(NmActionResponseCommandNone); |
|
799 } |
793 mHeaderWidget->setPriority(messageEnvelope.priority()); |
800 mHeaderWidget->setPriority(messageEnvelope.priority()); |
794 |
801 |
795 // Set the message body. |
802 // Set the message body. |
796 if (editorStartMode==NmUiEditorReply|| |
803 if (editorStartMode==NmUiEditorReply|| |
797 editorStartMode==NmUiEditorReplyAll|| |
804 editorStartMode==NmUiEditorReplyAll|| |
820 originalMessage->envelope().folderId(), |
827 originalMessage->envelope().folderId(), |
821 originalMessage->envelope().messageId(), |
828 originalMessage->envelope().messageId(), |
822 *htmlPart); |
829 *htmlPart); |
823 } |
830 } |
824 |
831 |
825 mContentWidget->setMessageData(*originalMessage, editorStartMode); |
832 mContent->setMessageData(*originalMessage, editorStartMode); |
826 } |
833 } |
827 |
834 |
828 delete originalMessage; |
835 delete originalMessage; |
829 originalMessage = NULL; |
836 originalMessage = NULL; |
830 } |
837 } |
1040 } |
1047 } |
1041 |
1048 |
1042 // Set the VKB action states |
1049 // Set the VKB action states |
1043 // All editors of the view share the same action, so it is enough to set |
1050 // All editors of the view share the same action, so it is enough to set |
1044 // this only to one of them. |
1051 // this only to one of them. |
1045 HbEditorInterface editorInterface(mContentWidget->editor()); |
1052 HbEditorInterface editorInterface(mContent->editor()); |
1046 QList<HbAction *> vkbList = editorInterface.actions(); |
1053 QList<HbAction *> vkbList = editorInterface.actions(); |
1047 count = vkbList.count(); |
1054 count = vkbList.count(); |
1048 for (int i = 0; i < count; i++) { |
1055 for (int i = 0; i < count; i++) { |
1049 NmAction *action = static_cast<NmAction *>(vkbList[i]); |
1056 NmAction *action = static_cast<NmAction *>(vkbList[i]); |
1050 if (action->availabilityCondition() == NmAction::NmSendable) { |
1057 if (action->availabilityCondition() == NmAction::NmSendable) { |
1082 } |
1089 } |
1083 list[i]->setIcon(NmIcons::getIcon(NmIcons::NmIconSend)); |
1090 list[i]->setIcon(NmIcons::getIcon(NmIcons::NmIconSend)); |
1084 |
1091 |
1085 // Link VKB to the action. This must be done to all |
1092 // Link VKB to the action. This must be done to all |
1086 // editors that show the button in VKB. |
1093 // editors that show the button in VKB. |
1087 HbEditorInterface editorInterface(mContentWidget->editor()); |
1094 HbEditorInterface editorInterface(mContent->editor()); |
1088 editorInterface.addAction(list[i]); |
1095 editorInterface.addAction(list[i]); |
1089 HbEditorInterface toEditorInterface(mContentWidget->header()->toEdit()); |
1096 HbEditorInterface toEditorInterface(mContent->header()->toEdit()); |
1090 toEditorInterface.addAction(list[i]); |
1097 toEditorInterface.addAction(list[i]); |
1091 HbEditorInterface ccEditorInterface(mContentWidget->header()->ccEdit()); |
1098 HbEditorInterface ccEditorInterface(mContent->header()->ccEdit()); |
1092 ccEditorInterface.addAction(list[i]); |
1099 ccEditorInterface.addAction(list[i]); |
1093 HbEditorInterface bccEditorInterface(mContentWidget->header()->bccEdit()); |
1100 HbEditorInterface bccEditorInterface(mContent->header()->bccEdit()); |
1094 bccEditorInterface.addAction(list[i]); |
1101 bccEditorInterface.addAction(list[i]); |
1095 HbEditorInterface subjectEditorInterface(mContentWidget->header()->subjectEdit()); |
1102 HbEditorInterface subjectEditorInterface(mContent->header()->subjectEdit()); |
1096 subjectEditorInterface.addAction(list[i]); |
1103 subjectEditorInterface.addAction(list[i]); |
1097 } |
1104 } |
1098 } |
1105 } |
1099 } |
1106 } |
1100 |
1107 |