17 #include "nmuiheaders.h" |
17 #include "nmuiheaders.h" |
18 |
18 |
19 // Layout file and view |
19 // Layout file and view |
20 static const char *NMUI_EDITOR_VIEW_XML = ":/docml/nmeditorview.docml"; |
20 static const char *NMUI_EDITOR_VIEW_XML = ":/docml/nmeditorview.docml"; |
21 static const char *NMUI_EDITOR_VIEW = "editorview"; |
21 static const char *NMUI_EDITOR_VIEW = "editorview"; |
|
22 static const char *NMUI_EDITOR_VIEW_ATTACHMENT_EXTENSION = |
|
23 "attachmentTypeToolbarExtension"; |
22 |
24 |
23 // extension list item frame. |
25 // extension list item frame. |
24 static const QString NmPopupListFrame = "qtg_fr_popup_list_normal"; |
26 static const QString NmPopupListFrame = "qtg_fr_popup_list_normal"; |
25 static const QString NmDelimiter("; "); |
27 static const QString NmDelimiter("; "); |
26 static const QString NmPriorityLow("low"); |
28 static const QString NmPriorityLow("low"); |
27 static const QString NmPriorityNormal("normal"); |
29 static const QString NmPriorityNormal("normal"); |
28 static const QString NmPriorityHigh("high"); |
30 static const QString NmPriorityHigh("high"); |
29 |
31 |
|
32 static const QString NmMimeTypeHtml("text/html"); |
|
33 |
|
34 |
30 /*! |
35 /*! |
31 \class NmEditorView |
36 \class NmEditorView |
32 \brief Mail editor view |
37 \brief Mail editor view |
33 */ |
38 */ |
34 |
39 |
35 /*! |
40 |
36 Constructor |
41 /*! |
|
42 Class constructor. |
37 */ |
43 */ |
38 NmEditorView::NmEditorView( |
44 NmEditorView::NmEditorView( |
39 NmApplication &application, |
45 NmApplication &application, |
40 NmUiStartParam* startParam, |
46 NmUiStartParam* startParam, |
41 NmUiEngine &uiEngine, |
47 NmUiEngine &uiEngine, |
42 NmAttachmentManager &attaManager, |
48 NmAttachmentManager &attaManager, |
43 QGraphicsItem *parent) |
49 QGraphicsItem *parent) |
44 : NmBaseView(startParam, application, parent), |
50 : NmBaseView(startParam, application, parent), |
45 mApplication(application), |
51 mApplication(application), |
46 mUiEngine(uiEngine), |
52 mUiEngine(uiEngine), |
47 mAttaManager(attaManager), |
53 mAttaManager(attaManager), |
48 mDocumentLoader(NULL), |
54 mDocumentLoader(NULL), |
49 mHeaderWidget(NULL), |
55 mHeaderWidget(NULL), |
50 mMessage(NULL), |
56 mMessage(NULL), |
51 mContent(NULL), |
57 mContent(NULL), |
52 mAttachmentListContextMenu(NULL), |
58 mAttachmentListContextMenu(NULL), |
53 mMessageCreationOperation(NULL), |
59 mMessageCreationOperation(NULL), |
54 mAddAttachmentOperation(NULL), |
60 mAddAttachmentOperation(NULL), |
55 mRemoveAttachmentOperation(NULL), |
61 mRemoveAttachmentOperation(NULL), |
56 mWaitDialog(NULL), |
62 mWaitDialog(NULL), |
57 mQueryDialog(NULL), |
63 mQueryDialog(NULL), |
58 mAttachmentPicker(NULL), |
64 mAttachmentPicker(NULL), |
59 mCcBccFieldVisible(false), |
65 mCcBccFieldVisible(false), |
60 mServiceSendingDialog(NULL), |
66 mServiceSendingDialog(NULL), |
61 mHiddenPriorityName(NmPriorityNormal) |
67 mTBExtnContentWidget(NULL), |
62 { |
68 mHiddenPriorityName(NmPriorityNormal) |
63 NM_FUNCTION; |
69 { |
64 |
70 NM_FUNCTION; |
65 mDocumentLoader = new NmUiDocumentLoader( mApplication.mainWindow() ); |
71 |
66 // Set object name |
72 mDocumentLoader = new NmUiDocumentLoader(mApplication.mainWindow()); |
67 setObjectName("NmEditorView"); |
73 |
68 // call the createToolBar on load view layout |
74 // Set the object name. |
|
75 setObjectName(QString(NMUI_EDITOR_VIEW)); |
|
76 |
|
77 // Load the view layout. |
|
78 loadViewLayout(); |
|
79 |
|
80 // Create the toolbar. |
69 createToolBar(); |
81 createToolBar(); |
70 // Load view layout |
82 } |
71 loadViewLayout(); |
83 |
72 } |
84 |
73 |
85 /*! |
74 /*! |
86 Class destructor. |
75 Destructor |
|
76 */ |
87 */ |
77 NmEditorView::~NmEditorView() |
88 NmEditorView::~NmEditorView() |
78 { |
89 { |
79 NM_FUNCTION; |
90 NM_FUNCTION; |
80 |
91 |
81 if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) { |
92 if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) { |
82 mRemoveAttachmentOperation->cancelOperation(); |
93 mRemoveAttachmentOperation->cancelOperation(); |
83 } |
94 } |
|
95 |
84 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
96 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
85 mAddAttachmentOperation->cancelOperation(); |
97 mAddAttachmentOperation->cancelOperation(); |
86 } |
98 } |
|
99 |
87 if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) { |
100 if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) { |
88 mMessageCreationOperation->cancelOperation(); |
101 mMessageCreationOperation->cancelOperation(); |
89 } |
102 } |
|
103 |
90 delete mMessage; |
104 delete mMessage; |
91 mWidgetList.clear(); |
105 mWidgetList.clear(); |
92 delete mDocumentLoader; |
106 delete mDocumentLoader; |
93 delete mPrioritySubMenu; |
107 delete mPrioritySubMenu; |
94 |
108 |
95 if (mAttachmentListContextMenu) { |
109 if (mAttachmentListContextMenu) { |
96 mAttachmentListContextMenu->clearActions(); |
110 mAttachmentListContextMenu->clearActions(); |
97 delete mAttachmentListContextMenu; |
111 delete mAttachmentListContextMenu; |
98 } |
112 } |
|
113 |
99 delete mWaitDialog; |
114 delete mWaitDialog; |
100 delete mQueryDialog; |
115 delete mQueryDialog; |
101 delete mAttachmentPicker; |
116 delete mAttachmentPicker; |
102 mAttaManager.clearObserver(); |
117 mAttaManager.clearObserver(); |
103 mAttaManager.cancelFetch(); |
118 mAttaManager.cancelFetch(); |
104 |
119 |
105 // make sure virtual keyboard is closed |
120 // make sure virtual keyboard is closed |
106 QInputContext *ic = qApp->inputContext(); |
121 QInputContext *ic = qApp->inputContext(); |
|
122 |
107 if (ic) { |
123 if (ic) { |
108 QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel); |
124 QEvent *closeEvent = new QEvent(QEvent::CloseSoftwareInputPanel); |
109 ic->filterEvent(closeEvent); |
125 ic->filterEvent(closeEvent); |
110 delete closeEvent; |
126 delete closeEvent; |
111 } |
127 } |
112 } |
128 |
113 |
129 if (!mTBExtnContentWidget->parent()) { |
114 /*! |
130 delete mTBExtnContentWidget; |
115 View layout loading from XML |
131 } |
|
132 } |
|
133 |
|
134 |
|
135 /*! |
|
136 Loads the view layout from XML. |
116 */ |
137 */ |
117 void NmEditorView::loadViewLayout() |
138 void NmEditorView::loadViewLayout() |
118 { |
139 { |
119 NM_FUNCTION; |
140 NM_FUNCTION; |
120 |
141 |
121 mPrioritySubMenu = NULL; |
142 mPrioritySubMenu = NULL; |
122 |
143 |
123 // Use document loader to load the view |
144 // Use the document loader to load the view. |
124 bool ok(false); |
|
125 |
|
126 setObjectName(QString(NMUI_EDITOR_VIEW)); |
|
127 QObjectList objectList; |
145 QObjectList objectList; |
128 objectList.append(this); |
146 objectList.append(this); |
129 // Pass the view to documentloader. Document loader uses this view |
147 |
130 // when docml is parsed, instead of creating new view. |
148 // Pass the view to documentloader. Document loader uses this view when |
131 // documentloader is created in constructor |
149 // docml is parsed, instead of creating new view. The document loader is |
|
150 // created in the constructor. |
132 mDocumentLoader->setObjectTree(objectList); |
151 mDocumentLoader->setObjectTree(objectList); |
133 |
152 |
|
153 bool ok(false); |
134 mWidgetList = mDocumentLoader->load(NMUI_EDITOR_VIEW_XML, &ok); |
154 mWidgetList = mDocumentLoader->load(NMUI_EDITOR_VIEW_XML, &ok); |
135 |
155 |
136 if (ok) { |
156 if (ok) { |
137 mContent = new NmEditorContent(this, mDocumentLoader, |
157 mContent = new NmEditorContent(this, mDocumentLoader, |
138 mApplication.networkAccessManager(), mApplication); |
158 mApplication.networkAccessManager(), |
139 |
159 mApplication); |
140 mHeaderWidget = mContent->header(); |
160 |
141 |
161 mHeaderWidget = mContent->header(); |
142 // Set default color for user - entered text if editor is in re/reAll/fw mode |
162 |
143 if (mStartParam) { |
163 // Set default color for user - entered text if editor is in re/reAll/fw |
144 NmUiEditorStartMode mode = mStartParam->editorStartMode(); |
164 // mode. |
145 if (mode == NmUiEditorReply |
165 if (mStartParam) { |
146 || mode == NmUiEditorReplyAll |
166 NmUiEditorStartMode mode = mStartParam->editorStartMode(); |
147 || mode == NmUiEditorForward) { |
167 |
148 mContent->editor()->setCustomTextColor(true, Qt::blue); |
168 if (mode == NmUiEditorReply || |
149 } |
169 mode == NmUiEditorReplyAll || |
150 } |
170 mode == NmUiEditorForward) { |
151 |
171 mContent->editor()->setCustomTextColor(true, Qt::blue); |
152 // the rest of the view initialization is done in viewReady() |
172 } |
153 } |
173 } |
154 } |
174 |
|
175 // Get the toolbar extension for adding attachments. |
|
176 mTBExtnContentWidget = qobject_cast<HbListWidget *>( |
|
177 mDocumentLoader->findWidget(NMUI_EDITOR_VIEW_ATTACHMENT_EXTENSION)); |
|
178 |
|
179 // The rest of the view initialization is done in viewReady(). |
|
180 } |
|
181 } |
|
182 |
155 |
183 |
156 /*! |
184 /*! |
157 Reload view contents with new start parameters |
185 Reload view contents with new start parameters |
158 Typically when view is already open and external view activation occurs |
186 Typically when view is already open and external view activation occurs |
159 for this same view |
187 for this same view |
160 */ |
188 */ |
161 void NmEditorView::reloadViewContents(NmUiStartParam* startParam) |
189 void NmEditorView::reloadViewContents(NmUiStartParam* startParam) |
162 { |
190 { |
163 NM_FUNCTION; |
191 NM_FUNCTION; |
164 |
192 |
165 // Check start parameter validity. |
193 // Check start parameter validity. |
166 if (startParam&&startParam->viewId()==NmUiViewMessageEditor) { |
194 if (startParam&&startParam->viewId()==NmUiViewMessageEditor) { |
167 // Delete existing start parameter data |
195 // Delete existing start parameter data |
168 delete mStartParam; |
196 delete mStartParam; |
169 mStartParam=NULL; |
197 mStartParam=NULL; |
235 View id |
263 View id |
236 */ |
264 */ |
237 NmUiViewId NmEditorView::nmailViewId() const |
265 NmUiViewId NmEditorView::nmailViewId() const |
238 { |
266 { |
239 NM_FUNCTION; |
267 NM_FUNCTION; |
240 |
268 |
241 return NmUiViewMessageEditor; |
269 return NmUiViewMessageEditor; |
242 } |
270 } |
243 |
271 |
244 /* |
272 /* |
245 Launch dialog for query user if we want to exit the editor |
273 Launch dialog for query user if we want to exit the editor |
246 */ |
274 */ |
247 void NmEditorView::okToExitView() |
275 void NmEditorView::okToExitView() |
248 { |
276 { |
249 NM_FUNCTION; |
277 NM_FUNCTION; |
250 |
278 |
251 bool okToExit(true); |
279 bool okToExit(true); |
252 |
280 |
253 if (mContent) { |
281 if (mContent) { |
254 NmEditorHeader *header = mContent->header(); |
282 NmEditorHeader *header = mContent->header(); |
255 // show the query if the message has not been sent |
283 // show the query if the message has not been sent |
256 if (mMessage && header) { |
284 if (mMessage && header) { |
257 // see if editor has any content |
285 // see if editor has any content |
258 int subjectLength = 0; |
286 int subjectLength = 0; |
259 if (header->subjectEdit()) { |
287 if (header->subjectEdit()) { |
260 subjectLength = header->subjectEdit()->text().length(); |
288 subjectLength = header->subjectEdit()->text().length(); |
261 } |
289 } |
262 |
290 |
263 QList<NmMessagePart*> attachmentList; |
291 QList<NmMessagePart*> attachmentList; |
264 mMessage->attachmentList(attachmentList); |
292 mMessage->attachmentList(attachmentList); |
265 |
293 |
266 if (mContent->editor()) { |
294 if (mContent->editor()) { |
267 okToExit = (subjectLength == 0 && mContent->editor()->document()->isEmpty()); |
295 okToExit = (subjectLength == 0 && mContent->editor()->document()->isEmpty()); |
268 } |
296 } |
269 |
297 |
270 // content exists, verify exit from user |
298 // content exists, verify exit from user |
271 if (!okToExit) { |
299 if (!okToExit) { |
272 if (mQueryDialog) { |
300 if (mQueryDialog) { |
273 delete mQueryDialog; |
301 delete mQueryDialog; |
274 mQueryDialog = 0; |
302 mQueryDialog = 0; |
275 } |
303 } |
276 // Launch query dialog. |
304 // Launch query dialog. |
277 mQueryDialog = |
305 mQueryDialog = |
278 NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_save_message_to_drafts"), |
306 NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_save_message_to_drafts"), |
279 this, |
307 this, |
280 SLOT(okToExitQuery(HbAction*))); |
308 SLOT(okToExitQuery(HbAction*))); |
281 } |
309 } |
282 } |
310 } |
283 } |
311 } |
284 |
312 |
285 // no need to query anything, just exit. |
313 // no need to query anything, just exit. |
286 if(okToExit) { |
314 if(okToExit) { |
287 QMetaObject::invokeMethod(&mApplication, |
315 QMetaObject::invokeMethod(&mApplication, |
288 "popView", |
316 "popView", |
289 Qt::QueuedConnection); |
317 Qt::QueuedConnection); |
363 { |
391 { |
364 NM_FUNCTION; |
392 NM_FUNCTION; |
365 |
393 |
366 // Set mailbox name to title pane |
394 // Set mailbox name to title pane |
367 setMailboxName(); |
395 setMailboxName(); |
368 |
396 |
369 // Connect options menu about to show to create options menu function |
397 // Connect options menu about to show to create options menu function |
370 // Menu needs to be create "just-in-time" |
398 // Menu needs to be create "just-in-time" |
371 connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu())); |
399 connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu())); |
372 NmAction *dummy = new NmAction(0); |
400 NmAction *dummy = new NmAction(0); |
373 menu()->addAction(dummy); |
401 menu()->addAction(dummy); |
374 |
402 |
375 mVkbHost = new HbShrinkingVkbHost(this); |
403 mVkbHost = new HbShrinkingVkbHost(this); |
376 |
404 |
377 initializeVKB(); |
405 initializeVKB(); |
378 |
406 |
379 //start to listen VKB open and close signals for hiding the chrome. |
407 //start to listen VKB open and close signals for hiding the chrome. |
380 connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened())); |
408 connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened())); |
381 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed())); |
409 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed())); |
382 |
410 |
383 connect(mContent->header(), SIGNAL(recipientFieldsHaveContent(bool)), |
411 connect(mContent->header(), SIGNAL(recipientFieldsHaveContent(bool)), |
384 this, SLOT(setButtonsDimming(bool)) ); |
412 this, SLOT(setButtonsDimming(bool)) ); |
385 |
413 |
386 // Connect to observe orientation change events |
414 // Connect to observe orientation change events |
387 connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
415 connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
389 // Signal for handling the attachment list selection |
417 // Signal for handling the attachment list selection |
390 connect(mHeaderWidget, SIGNAL(attachmentShortPressed(NmId)), |
418 connect(mHeaderWidget, SIGNAL(attachmentShortPressed(NmId)), |
391 this, SLOT(openAttachmentTriggered(NmId))); |
419 this, SLOT(openAttachmentTriggered(NmId))); |
392 connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)), |
420 connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)), |
393 this, SLOT(attachmentLongPressed(NmId, QPointF))); |
421 this, SLOT(attachmentLongPressed(NmId, QPointF))); |
394 |
422 |
395 if (mStartParam) { |
423 if (mStartParam) { |
396 fetchMessageIfNeeded(*mStartParam); |
424 fetchMessageIfNeeded(*mStartParam); |
397 } |
425 } |
398 else { // execution cannot proceed without start param |
426 else { // execution cannot proceed without start param |
399 QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection); |
427 QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection); |
400 } |
428 } |
401 |
429 |
402 // Adjust the header width according to the current screen width. |
430 // Adjust the header width according to the current screen width. |
403 mHeaderWidget->adjustHeaderWidth(); |
431 mHeaderWidget->adjustHeaderWidth(); |
404 } |
432 } |
405 |
433 |
406 /*! |
434 /*! |
407 If entering editor for forwarding or replying, use attachment manager |
435 If entering editor for forwarding or replying, use attachment manager |
408 to check that we have all message parts fetched. Also show dialog for |
436 to check that we have all message parts fetched. Also show dialog for |
409 fetching progress. |
437 fetching progress. |
410 */ |
438 */ |
411 void NmEditorView::fetchMessageIfNeeded(NmUiStartParam &startParam) |
439 void NmEditorView::fetchMessageIfNeeded(NmUiStartParam &startParam) |
412 { |
440 { |
413 NM_FUNCTION; |
441 NM_FUNCTION; |
414 |
442 |
415 if (startParam.editorStartMode() == NmUiEditorForward |
443 if (startParam.editorStartMode() == NmUiEditorForward |
416 || startParam.editorStartMode()== NmUiEditorReply |
444 || startParam.editorStartMode()== NmUiEditorReply |
417 || startParam.editorStartMode() == NmUiEditorReplyAll) { |
445 || startParam.editorStartMode() == NmUiEditorReplyAll) { |
418 |
446 |
419 fetchProgressDialogShow(); |
447 fetchProgressDialogShow(); |
420 mAttaManager.clearObserver(); |
448 mAttaManager.clearObserver(); |
421 mAttaManager.setObserver(this); |
449 mAttaManager.setObserver(this); |
422 mAttaManager.fetchAllMessageParts( |
450 mAttaManager.fetchAllMessageParts( |
423 startParam.mailboxId(), |
451 startParam.mailboxId(), |
433 Slot. Called when attachments fetch progress changes. |
461 Slot. Called when attachments fetch progress changes. |
434 */ |
462 */ |
435 void NmEditorView::progressChanged(int value) |
463 void NmEditorView::progressChanged(int value) |
436 { |
464 { |
437 NM_FUNCTION; |
465 NM_FUNCTION; |
438 |
466 |
439 Q_UNUSED(value); |
467 Q_UNUSED(value); |
440 } |
468 } |
441 |
469 |
442 /*! |
470 /*! |
443 Slot. Called when attachments fetch is completed. We can start |
471 Slot. Called when attachments fetch is completed. We can start |
444 message creation. |
472 message creation. |
445 */ |
473 */ |
446 void NmEditorView::fetchCompleted(int result) |
474 void NmEditorView::fetchCompleted(int result) |
447 { |
475 { |
448 NM_FUNCTION; |
476 NM_FUNCTION; |
449 |
477 |
450 if (result == NmNoError && mStartParam) { |
478 if (result == NmNoError && mStartParam) { |
451 startMessageCreation(*mStartParam); |
479 startMessageCreation(*mStartParam); |
452 } |
480 } |
453 else { |
481 else { |
454 // Close "Loading mail content" dialog |
482 // Close "Loading mail content" dialog |
455 mWaitDialog->close(); |
483 mWaitDialog->close(); |
456 |
484 |
457 // Show a fetching failed note when the failure is not caused by a Device/System failure. |
485 // Show a fetching failed note when the failure is not caused by a Device/System failure. |
458 if (result != NmNoError && |
486 if (result != NmNoError && |
459 result != NmNotFoundError && |
487 result != NmNotFoundError && |
460 result != NmGeneralError && |
488 result != NmGeneralError && |
461 result != NmCancelError && |
489 result != NmCancelError && |
462 result != NmAuthenticationError && |
490 result != NmAuthenticationError && |
463 result != NmServerConnectionError && |
491 result != NmServerConnectionError && |
464 result != NmConnectionError) { |
492 result != NmConnectionError) { |
465 HbNotificationDialog *note = new HbNotificationDialog(); |
493 HbNotificationDialog *note = new HbNotificationDialog(); |
466 bool enalbeAttribute(true); |
494 bool enalbeAttribute(true); |
467 note->setAttribute(Qt::WA_DeleteOnClose, enalbeAttribute); |
495 note->setAttribute(Qt::WA_DeleteOnClose, enalbeAttribute); |
468 note->setIcon(HbIcon(QLatin1String("note_warning"))); |
496 note->setIcon(HbIcon(QLatin1String("note_warning"))); |
469 note->setTitle(hbTrId("txt_mail_dpopinfo_loading_failed")); |
497 note->setTitle(hbTrId("txt_mail_dpopinfo_loading_failed")); |
470 note->setTitleTextWrapping(Hb::TextWordWrap); |
498 note->setTitleTextWrapping(Hb::TextWordWrap); |
471 note->setDismissPolicy(HbNotificationDialog::TapAnywhere); |
499 note->setDismissPolicy(HbNotificationDialog::TapAnywhere); |
472 note->setTimeout(HbNotificationDialog::StandardTimeout); |
500 note->setTimeout(HbNotificationDialog::StandardTimeout); |
473 note->setSequentialShow(true); |
501 note->setSequentialShow(true); |
474 note->show(); |
502 note->show(); |
475 } |
503 } |
476 |
504 |
477 // Go back to Viewer view |
505 // Go back to Viewer view |
478 QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection); |
506 QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection); |
479 } |
507 } |
480 } |
508 } |
481 |
509 |
482 void NmEditorView::fetchProgressDialogShow() |
510 void NmEditorView::fetchProgressDialogShow() |
483 { |
511 { |
484 NM_FUNCTION; |
512 NM_FUNCTION; |
485 |
513 |
486 delete mWaitDialog; |
514 delete mWaitDialog; |
487 mWaitDialog = NULL; |
515 mWaitDialog = NULL; |
488 // Create new wait dialog and set it to me modal with dimmed background |
516 // Create new wait dialog and set it to me modal with dimmed background |
489 mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
517 mWaitDialog = new HbProgressDialog(HbProgressDialog::WaitDialog); |
490 mWaitDialog->setModal(true); |
518 mWaitDialog->setModal(true); |
499 This is called by mFetchProgressDialog when the note is cancelled |
527 This is called by mFetchProgressDialog when the note is cancelled |
500 */ |
528 */ |
501 void NmEditorView::fetchProgressDialogCancelled() |
529 void NmEditorView::fetchProgressDialogCancelled() |
502 { |
530 { |
503 NM_FUNCTION; |
531 NM_FUNCTION; |
504 |
532 |
505 if (mAttaManager.isFetching()) { |
533 if (mAttaManager.isFetching()) { |
506 mAttaManager.cancelFetch(); |
534 mAttaManager.cancelFetch(); |
507 mAttaManager.clearObserver(); |
535 mAttaManager.clearObserver(); |
508 } |
536 } |
509 else { |
537 else { |
510 // For those email has no attachment or attachment has fetched. |
538 // For those email has no attachment or attachment has fetched. |
511 // Go back to Viewer view. |
539 // Go back to Viewer view. |
512 QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection); |
540 QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection); |
513 } |
541 } |
514 } |
542 } |
515 |
543 |
516 void NmEditorView::startMessageCreation(NmUiStartParam &startParam) |
544 void NmEditorView::startMessageCreation(NmUiStartParam &startParam) |
517 { |
545 { |
518 NM_FUNCTION; |
546 NM_FUNCTION; |
|
547 NM_TIMESTAMP("Start editor."); |
519 |
548 |
520 NmUiEditorStartMode startMode = startParam.editorStartMode(); |
549 NmUiEditorStartMode startMode = startParam.editorStartMode(); |
521 NmId mailboxId = startParam.mailboxId(); |
550 NmId mailboxId = startParam.mailboxId(); |
522 NmId folderId = startParam.folderId(); |
551 NmId folderId = startParam.folderId(); |
523 NmId msgId = startParam.messageId(); |
552 NmId msgId = startParam.messageId(); |
524 |
553 |
525 if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) { |
554 if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) { |
526 mMessageCreationOperation->cancelOperation(); |
555 mMessageCreationOperation->cancelOperation(); |
527 } |
556 } |
528 |
557 |
529 // original message is now fetched so start message creation |
558 // original message is now fetched so start message creation |
530 if (startMode == NmUiEditorForward) { |
559 if (startMode == NmUiEditorForward) { |
531 mMessageCreationOperation = mUiEngine.createForwardMessage(mailboxId, msgId); |
560 mMessageCreationOperation = mUiEngine.createForwardMessage(mailboxId, msgId); |
532 } |
561 } |
533 else if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) { |
562 else if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll) { |
534 mMessageCreationOperation = mUiEngine.createReplyMessage(mailboxId, |
563 mMessageCreationOperation = mUiEngine.createReplyMessage(mailboxId, |
535 msgId, |
564 msgId, |
536 startMode == NmUiEditorReplyAll); |
565 startMode == NmUiEditorReplyAll); |
537 } |
566 } |
538 else if (startMode == NmUiEditorFromDrafts) { |
567 else if (startMode == NmUiEditorFromDrafts) { |
539 // Draft opened, so reload message and fill editor with message data. |
568 // Draft opened, so reload message and fill editor with message data. |
540 mMessage = mUiEngine.message( |
569 mMessage = mUiEngine.message( |
541 mStartParam->mailboxId(), |
570 mStartParam->mailboxId(), |
542 mStartParam->folderId(), |
571 mStartParam->folderId(), |
543 mStartParam->messageId()); |
572 mStartParam->messageId()); |
544 fillEditorWithMessageContents(); |
573 fillEditorWithMessageContents(); |
545 } |
574 } |
546 else { |
575 else { |
547 mMessageCreationOperation = mUiEngine.createNewMessage(mailboxId); |
576 mMessageCreationOperation = mUiEngine.createNewMessage(mailboxId); |
548 } |
577 } |
549 |
578 |
550 // operation continues in messageCreated() once it finishes ok |
579 // operation continues in messageCreated() once it finishes ok |
551 if (mMessageCreationOperation) { |
580 if (mMessageCreationOperation) { |
552 connect(mMessageCreationOperation, |
581 connect(mMessageCreationOperation, |
553 SIGNAL(operationCompleted(int)), |
582 SIGNAL(operationCompleted(int)), |
554 this, |
583 this, |
555 SLOT(messageCreated(int))); |
584 SLOT(messageCreated(int))); |
556 } |
585 } |
557 } |
586 } |
558 |
587 |
559 /*! |
588 /*! |
560 Starting the message sending is handled here. |
589 Starting the message sending is handled here. |
561 */ |
590 */ |
562 void NmEditorView::startSending() |
591 void NmEditorView::startSending() |
563 { |
592 { |
564 NM_FUNCTION; |
593 NM_FUNCTION; |
565 |
594 |
566 // The message contents should be verified |
595 // The message contents should be verified |
567 updateMessageWithEditorContents(); |
596 updateMessageWithEditorContents(); |
568 |
597 |
569 // verify addresses before sending |
598 // verify addresses before sending |
570 QList<NmAddress> invalidAddresses; |
599 QList<NmAddress> invalidAddresses; |
571 if (mMessage) { |
600 if (mMessage) { |
572 NmUtilities::getRecipientsFromMessage(*mMessage, invalidAddresses, NmUtilities::NmInvalidAddress); |
601 NmUtilities::getRecipientsFromMessage(*mMessage, invalidAddresses, NmUtilities::NmInvalidAddress); |
573 } |
602 } |
574 |
603 |
575 if (invalidAddresses.count() > 0) { |
604 if (invalidAddresses.count() > 0) { |
576 |
605 |
577 // Invalid addresses found, verify send from user. |
606 // Invalid addresses found, verify send from user. |
578 // Set the first failing address to the note. |
607 // Set the first failing address to the note. |
579 QString noteText = |
608 QString noteText = |
580 HbParameterLengthLimiter( |
609 HbParameterLengthLimiter( |
581 "txt_mail_dialog_invalid_mail_address_send" |
610 "txt_mail_dialog_invalid_mail_address_send" |
582 ).arg(invalidAddresses.at(0).address()); |
611 ).arg(invalidAddresses.at(0).address()); |
583 |
612 |
584 if (mQueryDialog) { |
613 if (mQueryDialog) { |
585 delete mQueryDialog; |
614 delete mQueryDialog; |
586 mQueryDialog = 0; |
615 mQueryDialog = 0; |
587 } |
616 } |
588 // Launch query dialog. Pressing "yes" will finalize the sending. |
617 // Launch query dialog. Pressing "yes" will finalize the sending. |
665 This is called when the view's geometry size has been changed, eg. when VKB is opened/closed. |
694 This is called when the view's geometry size has been changed, eg. when VKB is opened/closed. |
666 */ |
695 */ |
667 void NmEditorView::resizeEvent(QGraphicsSceneResizeEvent *event) |
696 void NmEditorView::resizeEvent(QGraphicsSceneResizeEvent *event) |
668 { |
697 { |
669 NM_FUNCTION; |
698 NM_FUNCTION; |
670 |
699 |
671 NmBaseView::resizeEvent(event); |
700 NmBaseView::resizeEvent(event); |
672 |
701 |
673 emit sizeChanged(); |
702 emit sizeChanged(); |
674 } |
703 } |
675 |
704 |
676 /*! |
705 /*! |
677 This is signalled by mMessageCreationOperation when message is created. |
706 This is signalled by mMessageCreationOperation when message is created. |
678 */ |
707 */ |
679 void NmEditorView::messageCreated(int result) |
708 void NmEditorView::messageCreated(int result) |
680 { |
709 { |
681 NM_FUNCTION; |
710 NM_FUNCTION; |
|
711 NM_TIMESTAMP("Editor opened."); |
682 |
712 |
683 delete mMessage; |
713 delete mMessage; |
684 mMessage = NULL; |
714 mMessage = NULL; |
685 |
715 |
686 // Close wait dialog here |
716 // Close wait dialog here |
687 if (mWaitDialog) { |
717 if (mWaitDialog) { |
688 mWaitDialog->close(); |
718 mWaitDialog->close(); |
689 } |
719 } |
690 |
720 |
691 if (result == NmNoError && mStartParam && mMessageCreationOperation) { |
721 if (result == NmNoError && mStartParam && mMessageCreationOperation) { |
692 NmUiEditorStartMode startMode = mStartParam->editorStartMode(); |
722 NmUiEditorStartMode startMode = mStartParam->editorStartMode(); |
693 |
723 |
694 // get message "again" from engine to update the message contents |
724 // get message "again" from engine to update the message contents |
695 mMessage = mUiEngine.message( |
725 mMessage = mUiEngine.message( |
696 mStartParam->mailboxId(), |
726 mStartParam->mailboxId(), |
697 mStartParam->folderId(), |
727 mStartParam->folderId(), |
698 mMessageCreationOperation->getMessageId()); |
728 mMessageCreationOperation->getMessageId()); |
699 |
729 |
700 fillEditorWithMessageContents(); |
730 fillEditorWithMessageContents(); |
701 } |
731 } |
702 } |
732 } |
703 |
733 |
704 /*! |
734 /*! |
705 Updates the message with the editor contents. |
735 Updates the message with the editor contents. |
706 */ |
736 */ |
707 void NmEditorView::updateMessageWithEditorContents() |
737 void NmEditorView::updateMessageWithEditorContents() |
708 { |
738 { |
709 NM_FUNCTION; |
739 NM_FUNCTION; |
710 |
740 |
711 if (mMessage) { |
741 if (mMessage) { |
712 if (mContent && mContent->editor()) { |
742 if (mContent && mContent->editor()) { |
713 NmMessagePart* bodyPart = mMessage->htmlBodyPart(); |
743 NmMessagePart* bodyPart = mMessage->htmlBodyPart(); |
714 if (bodyPart) { |
744 if (bodyPart) { |
715 bodyPart->setTextContent(mContent->editor()->toHtml(), NmContentTypeTextHtml); |
745 bodyPart->setTextContent(mContent->editor()->toHtml(), NmContentTypeTextHtml); |
772 |
802 |
773 NmUiEditorStartMode editorStartMode = mStartParam->editorStartMode(); |
803 NmUiEditorStartMode editorStartMode = mStartParam->editorStartMode(); |
774 |
804 |
775 if (editorStartMode == NmUiEditorMailto) { |
805 if (editorStartMode == NmUiEditorMailto) { |
776 // Retrieve the message header data e.g. recipients from mStartParam. |
806 // Retrieve the message header data e.g. recipients from mStartParam. |
777 useStartParam = true; |
807 useStartParam = true; |
778 } |
808 } |
779 |
809 |
780 // Set recipients (to, cc and bcc). |
810 // Set recipients (to, cc and bcc). |
781 QString toAddressesString; |
811 QString toAddressesString; |
782 QString ccAddressesString; |
812 QString ccAddressesString; |
783 QString bccAddressesString; |
813 QString bccAddressesString; |
784 |
814 |
785 if (useStartParam) { |
815 if (useStartParam) { |
786 toAddressesString = addressListToString(mStartParam->mailtoAddressList()); |
816 QList<NmAddress *> toAddressList = mStartParam->mailtoAddressList(); |
787 ccAddressesString = addressListToString(mStartParam->ccAddressList()); |
817 QList<NmAddress *> ccAddressList = mStartParam->ccAddressList(); |
788 bccAddressesString = addressListToString(mStartParam->bccAddressList()); |
818 QList<NmAddress *> bccAddressList = mStartParam->bccAddressList(); |
|
819 toAddressesString = addressListToString(toAddressList); |
|
820 ccAddressesString = addressListToString(ccAddressList); |
|
821 bccAddressesString = addressListToString(bccAddressList); |
|
822 // Also add recipients added for example from send service |
|
823 // interface to recipient line edits. |
|
824 mContent->header()->toEdit()->addContacts(toAddressList); |
|
825 mContent->header()->ccEdit()->addContacts(ccAddressList); |
|
826 mContent->header()->bccEdit()->addContacts(bccAddressList); |
789 } |
827 } |
790 else { |
828 else { |
791 toAddressesString = addressListToString(messageEnvelope.toRecipients()); |
829 toAddressesString = addressListToString(messageEnvelope.toRecipients()); |
792 ccAddressesString = addressListToString(messageEnvelope.ccRecipients()); |
830 ccAddressesString = addressListToString(messageEnvelope.ccRecipients()); |
793 bccAddressesString = addressListToString(messageEnvelope.bccRecipients()); |
831 bccAddressesString = addressListToString(messageEnvelope.bccRecipients()); |
889 |
927 |
890 if (fileList) { |
928 if (fileList) { |
891 addAttachments(*fileList); |
929 addAttachments(*fileList); |
892 } |
930 } |
893 |
931 |
894 } |
932 if (mStartParam->bodyText().length()) { |
895 |
933 // If the content is not HTML, use it as plain text |
896 |
934 if (mStartParam->bodyMimeType().compare(NmMimeTypeHtml, Qt::CaseInsensitive)) { |
897 /*! |
935 mContent->editor()->setPlainText(mStartParam->bodyText()); |
898 createToolBar. Function asks menu commands from extension |
936 } |
899 to be added to toolbar owned by the HbView. |
937 else { |
|
938 mContent->editor()->setHtml(mStartParam->bodyText()); |
|
939 } |
|
940 } |
|
941 } |
|
942 |
|
943 |
|
944 /*! |
|
945 Constructs the toolbar according to the actions received from the extension |
|
946 manager. |
900 */ |
947 */ |
901 void NmEditorView::createToolBar() |
948 void NmEditorView::createToolBar() |
902 { |
949 { |
903 NM_FUNCTION; |
950 NM_FUNCTION; |
904 |
951 |
905 HbToolBar *tb = toolBar(); |
952 HbToolBar *tb = toolBar(); |
906 NmUiExtensionManager &extMngr = mApplication.extManager(); |
953 NmUiExtensionManager &extMngr = mApplication.extManager(); |
907 if (tb && &extMngr && mStartParam) { |
954 |
908 tb->clearActions(); |
955 if (!tb || !mStartParam) { |
909 NmActionRequest request(this, NmActionToolbar, NmActionContextViewEditor, |
956 return; |
910 NmActionContextDataNone, mStartParam->mailboxId(), mStartParam->folderId() ); |
957 } |
911 QList<NmAction *> list; |
958 |
912 extMngr.getActions(request, list); |
959 tb->clearActions(); |
913 for (int i = 0; i < list.count(); i++) { |
960 |
914 tb->addAction(list[i]); |
961 NmActionRequest request(this, |
915 // If action has NmSendable condition, it is shown only when send action |
962 NmActionToolbar, |
916 // is available, i.e. when at least one recipient field has data. |
963 NmActionContextViewEditor, |
917 if( list[i]->availabilityCondition() == NmAction::NmSendable ) { |
964 NmActionContextDataNone, |
918 list[i]->setEnabled(false); |
965 mStartParam->mailboxId(), |
919 } |
966 mStartParam->folderId()); |
920 else if (list[i]->availabilityCondition() == NmAction::NmAttachable) { |
967 QList<NmAction *> list; |
921 HbToolBarExtension* extension = new HbToolBarExtension(); |
968 extMngr.getActions(request, list); |
922 mAttachmentPicker = new NmAttachmentPicker(this); |
969 |
923 |
970 for (int i = 0; i < list.count(); i++) { |
924 if (extension && mAttachmentPicker) { |
971 tb->addAction(list[i]); |
925 connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)), |
972 |
926 this, SLOT(onAttachmentReqCompleted(const QVariant &))); |
973 // If action has NmSendable condition, it is shown only when send |
927 |
974 // action is available, i.e. when at least one recipient field has |
928 connect(this, SIGNAL(titleChanged(QString)), mAttachmentPicker, |
975 // data. |
929 SLOT(setTitle(QString))); |
976 if (list[i]->availabilityCondition() == NmAction::NmSendable) { |
930 |
977 list[i]->setEnabled(false); |
931 list[i]->setToolBarExtension(extension); |
978 } |
932 |
979 else if (list[i]->availabilityCondition() == NmAction::NmAttachable && |
933 //content widget to get the items to a list |
980 mTBExtnContentWidget) { |
934 mTBExtnContentWidget = new HbListWidget(); |
981 // Setup the toolbar extension for attachments. |
935 mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); |
982 HbToolBarExtension* extension = new HbToolBarExtension(); |
936 |
983 extension->setParent(this); |
937 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_photo")); |
984 list[i]->setToolBarExtension(extension); |
938 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_sound")); |
985 |
939 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_video")); |
986 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_photo")); |
940 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_other")); |
987 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_sound")); |
941 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_photo")); |
988 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_video")); |
942 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_video")); |
989 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_other")); |
943 HbListViewItem *listView = mTBExtnContentWidget->listItemPrototype(); |
990 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_photo")); |
944 HbFrameBackground frame(NmPopupListFrame, HbFrameDrawer::NinePieces); |
991 mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_video")); |
945 listView->setDefaultFrame(frame); |
992 |
946 |
993 HbListViewItem *listView = mTBExtnContentWidget->listItemPrototype(); |
947 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
994 HbFrameBackground frame(NmPopupListFrame, HbFrameDrawer::NinePieces); |
948 mAttachmentPicker, SLOT (selectFetcher(HbListWidgetItem*))); |
995 listView->setDefaultFrame(frame); |
949 |
996 |
950 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
997 extension->setContentWidget(mTBExtnContentWidget); |
951 extension, SLOT(close())); |
998 |
952 |
999 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
953 extension->setContentWidget(mTBExtnContentWidget); |
1000 extension, SLOT(close())); |
954 } |
1001 |
955 } |
1002 mAttachmentPicker = new NmAttachmentPicker(this); |
956 } |
1003 |
957 } |
1004 connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)), |
958 } |
1005 this, SLOT(onAttachmentReqCompleted(const QVariant &))); |
|
1006 connect(this, SIGNAL(titleChanged(QString)), |
|
1007 mAttachmentPicker, SLOT(setTitle(QString))); |
|
1008 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
|
1009 mAttachmentPicker, SLOT (selectFetcher(HbListWidgetItem*))); |
|
1010 } |
|
1011 } // for () |
|
1012 } |
|
1013 |
959 |
1014 |
960 /*! |
1015 /*! |
961 createOptionsMenu. Functions asks menu commands from extension |
1016 createOptionsMenu. Functions asks menu commands from extension |
962 to be added to options menu. |
1017 to be added to options menu. |
963 */ |
1018 */ |
964 void NmEditorView::createOptionsMenu() |
1019 void NmEditorView::createOptionsMenu() |
965 { |
1020 { |
966 NM_FUNCTION; |
1021 NM_FUNCTION; |
967 |
1022 |
968 menu()->clearActions(); |
1023 menu()->clearActions(); |
969 |
1024 |
970 // Create CC/BCC options menu object |
1025 // Create CC/BCC options menu object |
971 if (mCcBccFieldVisible) { |
1026 if (mCcBccFieldVisible) { |
972 menu()->addAction(hbTrId("txt_mail_opt_hide_cc_bcc"), this, SLOT(switchCcBccFieldVisibility())); |
1027 menu()->addAction(hbTrId("txt_mail_opt_hide_cc_bcc"), this, SLOT(switchCcBccFieldVisibility())); |
1150 Set mailbox name to title |
1205 Set mailbox name to title |
1151 */ |
1206 */ |
1152 void NmEditorView::setMailboxName() |
1207 void NmEditorView::setMailboxName() |
1153 { |
1208 { |
1154 NM_FUNCTION; |
1209 NM_FUNCTION; |
1155 |
1210 |
1156 if (mStartParam){ |
1211 if (mStartParam){ |
1157 NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId()); |
1212 NmMailboxMetaData *meta = mUiEngine.mailboxById(mStartParam->mailboxId()); |
1158 if (meta){ |
1213 if (meta){ |
1159 setTitle(meta->name()); |
1214 setTitle(meta->name()); |
1160 } |
1215 } |
1161 } |
1216 } |
1162 } |
1217 } |
1163 |
1218 |
1164 /*! |
1219 /*! |
1165 Adds a prefix to the subject for reply or forward. |
1220 Adds a prefix to the subject for reply or forward. |
1166 Strips other occurrences of the prefix from the beginning. |
1221 Strips other occurrences of the prefix from the beginning. |
1167 */ |
1222 */ |
1168 QString NmEditorView::addSubjectPrefix( NmUiEditorStartMode startMode, const QString &subject ) |
1223 QString NmEditorView::addSubjectPrefix( NmUiEditorStartMode startMode, const QString &subject ) |
1169 { |
1224 { |
1170 NM_FUNCTION; |
1225 NM_FUNCTION; |
1171 |
1226 |
1172 QString newSubject(subject.trimmed()); |
1227 QString newSubject(subject.trimmed()); |
1173 |
1228 |
1174 if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll || |
1229 if (startMode == NmUiEditorReply || startMode == NmUiEditorReplyAll || |
1175 startMode == NmUiEditorForward) { |
1230 startMode == NmUiEditorForward) { |
1176 QString rePrefix(hbTrId("txt_nmailui_reply_subject_prefix")); |
1231 QString rePrefix(hbTrId("txt_mail_reply_subject_prefix")); |
1177 QString fwPrefix(hbTrId("txt_nmailui_forward_subject_prefix")); |
1232 QString fwPrefix(hbTrId("txt_mail_forward_subject_prefix")); |
1178 |
1233 |
1179 // strip extra prefixes from beginning |
1234 // strip extra prefixes from beginning |
1180 int rePrefixLength(rePrefix.length()); |
1235 int rePrefixLength(rePrefix.length()); |
1181 int fwPrefixLength(fwPrefix.length()); |
1236 int fwPrefixLength(fwPrefix.length()); |
1182 |
1237 |
1183 bool startswithRe(newSubject.startsWith(rePrefix, Qt::CaseInsensitive)); |
1238 bool startswithRe(newSubject.startsWith(rePrefix, Qt::CaseInsensitive)); |
1184 bool startswithFw(newSubject.startsWith(fwPrefix, Qt::CaseInsensitive)); |
1239 bool startswithFw(newSubject.startsWith(fwPrefix, Qt::CaseInsensitive)); |
1185 |
1240 |
1186 while (startswithRe || startswithFw) { |
1241 while (startswithRe || startswithFw) { |
1187 if (startswithRe) { |
1242 if (startswithRe) { |
1188 newSubject.remove(0,rePrefixLength); |
1243 newSubject.remove(0,rePrefixLength); |
1189 newSubject = newSubject.trimmed(); |
1244 newSubject = newSubject.trimmed(); |
1190 } |
1245 } |
1191 else if (startswithFw) { |
1246 else if (startswithFw) { |
1337 completed for one attachment. |
1393 completed for one attachment. |
1338 */ |
1394 */ |
1339 void NmEditorView::oneAttachmentAdded(const QString &fileName, const NmId &msgPartId, int result) |
1395 void NmEditorView::oneAttachmentAdded(const QString &fileName, const NmId &msgPartId, int result) |
1340 { |
1396 { |
1341 NM_FUNCTION; |
1397 NM_FUNCTION; |
1342 |
1398 |
1343 if (result == NmNoError && mMessage) { |
1399 if (result == NmNoError && mMessage) { |
1344 // Need to get the message again because new attachment part has been added. |
1400 // Need to get the message again because new attachment part has been added. |
1345 NmId mailboxId = mMessage->envelope().mailboxId(); |
1401 NmId mailboxId = mMessage->envelope().mailboxId(); |
1346 NmId folderId = mMessage->envelope().folderId(); |
1402 NmId folderId = mMessage->envelope().folderId(); |
1347 NmId msgId = mMessage->envelope().messageId(); |
1403 NmId msgId = mMessage->envelope().messageId(); |
1348 NmMessagePriority messagePriority = mMessage->envelope().priority(); |
1404 NmMessagePriority messagePriority = mMessage->envelope().priority(); |
1349 |
1405 |
1350 delete mMessage; |
1406 delete mMessage; |
1351 mMessage = NULL; |
1407 mMessage = NULL; |
1352 |
1408 |
1353 mMessage = mUiEngine.message(mailboxId, folderId, msgId); |
1409 mMessage = mUiEngine.message(mailboxId, folderId, msgId); |
1354 |
1410 |
1355 if (mMessage) { |
1411 if (mMessage) { |
1356 mMessage->envelope().setPriority(messagePriority); |
1412 mMessage->envelope().setPriority(messagePriority); |
1357 mMessage->envelope().setHasAttachments(true); |
1413 mMessage->envelope().setHasAttachments(true); |
1358 // Get attachment list from the message |
1414 // Get attachment list from the message |
1359 QList<NmMessagePart*> attachmentList; |
1415 QList<NmMessagePart*> attachmentList; |
1360 mMessage->attachmentList(attachmentList); |
1416 mMessage->attachmentList(attachmentList); |
1361 |
1417 |
1362 // Search newly added attachment from the list |
1418 // Search newly added attachment from the list |
1363 for (int i=0; i<attachmentList.count(); i++) { |
1419 for (int i=0; i<attachmentList.count(); i++) { |
1364 if (attachmentList[i]->partId() == msgPartId) { |
1420 if (attachmentList[i]->partId() == msgPartId) { |
1365 // Get attachment file size and set it into UI |
1421 // Get attachment file size and set it into UI |
1366 mHeaderWidget->setAttachmentParameters(fileName, |
1422 mHeaderWidget->setAttachmentParameters(fileName, |