57 mAttachmentPicker(NULL) |
57 mAttachmentPicker(NULL) |
58 { |
58 { |
59 mDocumentLoader = new HbDocumentLoader(); |
59 mDocumentLoader = new HbDocumentLoader(); |
60 // Set object name |
60 // Set object name |
61 setObjectName("NmEditorView"); |
61 setObjectName("NmEditorView"); |
|
62 // Set mailbox name to title pane |
|
63 setMailboxName(); |
62 // Load view layout |
64 // Load view layout |
63 loadViewLayout(); |
65 loadViewLayout(); |
64 // Set mailbox name to title pane |
|
65 setMailboxName(); |
|
66 // Set message data |
|
67 setMessageData(); |
|
68 } |
66 } |
69 |
67 |
70 /*! |
68 /*! |
71 Destructor |
69 Destructor |
72 */ |
70 */ |
73 NmEditorView::~NmEditorView() |
71 NmEditorView::~NmEditorView() |
74 { |
72 { |
75 // It is clearer that the operations are not owned by parent QObject as |
73 if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) { |
76 // they are not allocated in the constructor. |
74 mRemoveAttachmentOperation->cancelOperation(); |
77 delete mRemoveAttachmentOperation; |
75 } |
78 delete mAddAttachmentOperation; |
76 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
79 delete mMessageCreationOperation; |
77 mAddAttachmentOperation->cancelOperation(); |
80 delete mCheckOutboxOperation; |
78 } |
|
79 if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) { |
|
80 mMessageCreationOperation->cancelOperation(); |
|
81 } |
|
82 if (mCheckOutboxOperation && mCheckOutboxOperation->isRunning()) { |
|
83 mCheckOutboxOperation->cancelOperation(); |
|
84 } |
81 delete mMessage; |
85 delete mMessage; |
82 mWidgetList.clear(); |
86 mWidgetList.clear(); |
83 delete mDocumentLoader; |
87 delete mDocumentLoader; |
84 delete mContentWidget; |
88 delete mContentWidget; |
85 delete mPrioritySubMenu; |
89 delete mPrioritySubMenu; |
121 mHeaderWidget = mContentWidget->header(); |
125 mHeaderWidget = mContentWidget->header(); |
122 |
126 |
123 // Set default color for user - entered text if editor is in re/reAll/fw mode |
127 // Set default color for user - entered text if editor is in re/reAll/fw mode |
124 NmUiEditorStartMode mode = mStartParam->editorStartMode(); |
128 NmUiEditorStartMode mode = mStartParam->editorStartMode(); |
125 if (mode == NmUiEditorReply || mode == NmUiEditorReplyAll || mode == NmUiEditorForward) { |
129 if (mode == NmUiEditorReply || mode == NmUiEditorReplyAll || mode == NmUiEditorForward) { |
126 mEditWidget->setCustomTextColor(true, Qt::blue); |
130 mEditWidget->setCustomTextColor(true, Qt::blue); |
127 } |
131 } |
128 } |
132 |
129 |
133 // the rest of the view initialization is done in viewReady() |
130 // Connect signals from background scroll area |
134 } |
131 connect(mScrollArea, SIGNAL(handleMousePressEvent(QGraphicsSceneMouseEvent*)), |
|
132 this, SLOT(sendMousePressEventToScroll(QGraphicsSceneMouseEvent*))); |
|
133 connect(mScrollArea, SIGNAL(handleMouseReleaseEvent(QGraphicsSceneMouseEvent*)), |
|
134 this, SLOT(sendMouseReleaseEventToScroll(QGraphicsSceneMouseEvent*))); |
|
135 connect(mScrollArea, SIGNAL(handleMouseMoveEvent(QGraphicsSceneMouseEvent*)), |
|
136 this, SLOT(sendMouseMoveEventToScroll(QGraphicsSceneMouseEvent*))); |
|
137 |
|
138 connect(mScrollArea, SIGNAL(handleLongPressGesture(const QPointF &)), |
|
139 this, SLOT(sendLongPressGesture(const QPointF &))); |
|
140 |
|
141 // Connect options menu about to show to create options menu function |
|
142 // Menu needs to be create "just-in-time" |
|
143 connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu())); |
|
144 NmAction *dummy = new NmAction(0); |
|
145 menu()->addAction(dummy); |
|
146 |
|
147 initializeVKB(); |
|
148 connect(mContentWidget->header(), SIGNAL(recipientFieldsHaveContent(bool)), |
|
149 this, SLOT(setButtonsDimming(bool)) ); |
|
150 |
|
151 // call the createToolBar on load view layout |
|
152 createToolBar(); |
|
153 |
|
154 // Set dimensions |
|
155 adjustViewDimensions(); |
|
156 |
|
157 // Connect to observe orientation change events |
|
158 connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
|
159 this, SLOT(orientationChanged(Qt::Orientation))); |
|
160 // Signal for handling the attachment list selection |
|
161 connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)), |
|
162 this, SLOT(attachmentLongPressed(NmId, QPointF))); |
|
163 } |
135 } |
164 |
136 |
165 /*! |
137 /*! |
166 Reload view contents with new start parameters |
138 Reload view contents with new start parameters |
167 Typically when view is already open and external view activation occurs |
139 Typically when view is already open and external view activation occurs |
261 int subjectLength = 0; |
233 int subjectLength = 0; |
262 if (header->subjectField()) { |
234 if (header->subjectField()) { |
263 subjectLength = header->subjectField()->text().length(); |
235 subjectLength = header->subjectField()->text().length(); |
264 } |
236 } |
265 |
237 |
|
238 QList<NmMessagePart*> attachmentList; |
|
239 mMessage->attachmentList(attachmentList); |
|
240 |
266 okToExit = (toTextLength == 0 && ccTextLength == 0 && bccTextLength == 0 && |
241 okToExit = (toTextLength == 0 && ccTextLength == 0 && bccTextLength == 0 && |
267 subjectLength == 0 && mContentWidget->editor()->document()->isEmpty()); |
242 subjectLength == 0 && mContentWidget->editor()->document()->isEmpty() && |
|
243 attachmentList.count() < 1); |
268 |
244 |
269 // content exists, verify exit from user |
245 // content exists, verify exit from user |
270 if (!okToExit) { |
246 if (!okToExit) { |
271 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
247 okToExit = NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_delete_message")); |
272 messageBox->setText(hbTrId("txt_mail_dialog_delete_message")); |
|
273 messageBox->setTimeout(HbMessageBox::NoTimeout); |
|
274 |
|
275 // Read user selection |
|
276 HbAction *action = messageBox->exec(); |
|
277 okToExit = (action == messageBox->primaryAction()); |
|
278 } |
248 } |
279 } |
249 } |
280 |
250 |
281 return okToExit; |
251 return okToExit; |
282 } |
252 } |
312 // Hide the application. |
282 // Hide the application. |
313 XQServiceUtil::toBackground(true); |
283 XQServiceUtil::toBackground(true); |
314 } |
284 } |
315 |
285 |
316 // Display the wait dialog. |
286 // Display the wait dialog. |
317 mWaitDialog->exec(); |
287 mWaitDialog->setModal(false); |
|
288 mWaitDialog->setBackgroundFaded(false); |
|
289 mWaitDialog->show(); |
318 delete mWaitDialog; |
290 delete mWaitDialog; |
319 mWaitDialog = NULL; |
291 mWaitDialog = NULL; |
320 } |
292 } |
321 |
293 |
322 // These operations need to be stopped before message can be deleted |
294 // These operations need to be stopped before message can be deleted |
323 delete mAddAttachmentOperation; |
295 if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) { |
324 mAddAttachmentOperation = NULL; |
296 mAddAttachmentOperation->cancelOperation(); |
325 delete mRemoveAttachmentOperation; |
297 } |
326 mRemoveAttachmentOperation = NULL; |
298 if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) { |
|
299 mRemoveAttachmentOperation->cancelOperation(); |
|
300 } |
327 |
301 |
328 if (mMessage) { // this is NULL if sending is started |
302 if (mMessage) { // this is NULL if sending is started |
329 // Delete message from drafts |
303 // Delete message from drafts |
330 NmId mailboxId = mMessage->mailboxId(); |
304 NmId mailboxId = mMessage->envelope().mailboxId(); |
331 NmId folderId = mMessage->parentId(); |
305 NmId folderId = mMessage->envelope().folderId(); |
332 NmId msgId = mMessage->envelope().id(); |
306 NmId msgId = mMessage->envelope().messageId(); |
333 mUiEngine.removeMessage(mailboxId, folderId, msgId); |
307 mUiEngine.removeMessage(mailboxId, folderId, msgId); |
334 } |
308 } |
|
309 } |
|
310 |
|
311 /*! |
|
312 Lazy loading when view layout has been loaded |
|
313 */ |
|
314 void NmEditorView::viewReady() |
|
315 { |
|
316 // Connect signals from background scroll area |
|
317 connect(mScrollArea, SIGNAL(handleMousePressEvent(QGraphicsSceneMouseEvent*)), |
|
318 this, SLOT(sendMousePressEventToScroll(QGraphicsSceneMouseEvent*))); |
|
319 connect(mScrollArea, SIGNAL(handleMouseReleaseEvent(QGraphicsSceneMouseEvent*)), |
|
320 this, SLOT(sendMouseReleaseEventToScroll(QGraphicsSceneMouseEvent*))); |
|
321 connect(mScrollArea, SIGNAL(handleMouseMoveEvent(QGraphicsSceneMouseEvent*)), |
|
322 this, SLOT(sendMouseMoveEventToScroll(QGraphicsSceneMouseEvent*))); |
|
323 |
|
324 connect(mScrollArea, SIGNAL(handleLongPressGesture(const QPointF &)), |
|
325 this, SLOT(sendLongPressGesture(const QPointF &))); |
|
326 |
|
327 // Connect options menu about to show to create options menu function |
|
328 // Menu needs to be create "just-in-time" |
|
329 connect(menu(), SIGNAL(aboutToShow()), this, SLOT(createOptionsMenu())); |
|
330 NmAction *dummy = new NmAction(0); |
|
331 menu()->addAction(dummy); |
|
332 |
|
333 initializeVKB(); |
|
334 connect(mContentWidget->header(), SIGNAL(recipientFieldsHaveContent(bool)), |
|
335 this, SLOT(setButtonsDimming(bool)) ); |
|
336 |
|
337 // call the createToolBar on load view layout |
|
338 createToolBar(); |
|
339 |
|
340 // Set dimensions |
|
341 adjustViewDimensions(); |
|
342 |
|
343 // Connect to observe orientation change events |
|
344 connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), |
|
345 this, SLOT(orientationChanged(Qt::Orientation))); |
|
346 // Signal for handling the attachment list selection |
|
347 connect(mHeaderWidget, SIGNAL(attachmentLongPressed(NmId, QPointF)), |
|
348 this, SLOT(attachmentLongPressed(NmId, QPointF))); |
|
349 |
|
350 // Set message data |
|
351 setMessageData(); |
335 } |
352 } |
336 |
353 |
337 /*! |
354 /*! |
338 Find message data based on start parameters. Method is called |
355 Find message data based on start parameters. Method is called |
339 when editor is started. If message data is found it means that |
356 when editor is started. If message data is found it means that |
340 operation is forward or reply message. |
357 operation is forward or reply message. |
341 */ |
358 */ |
342 void NmEditorView::setMessageData() |
359 void NmEditorView::setMessageData() |
343 { |
360 { |
344 // Check the outbox. |
361 // Check the outbox. |
345 delete mCheckOutboxOperation; |
362 if (mCheckOutboxOperation && mCheckOutboxOperation->isRunning()) { |
346 mCheckOutboxOperation = NULL; |
363 mCheckOutboxOperation->cancelOperation(); |
|
364 NMLOG("NmEditorView::setMessageData old mCheckOutboxOperation running"); |
|
365 } |
347 |
366 |
348 mCheckOutboxOperation = mUiEngine.checkOutbox(mStartParam->mailboxId()); |
367 mCheckOutboxOperation = mUiEngine.checkOutbox(mStartParam->mailboxId()); |
349 |
368 |
350 if (mCheckOutboxOperation) { |
369 if (mCheckOutboxOperation) { |
351 connect(mCheckOutboxOperation, SIGNAL(operationCompleted(int)), |
370 connect(mCheckOutboxOperation, SIGNAL(operationCompleted(int)), |
358 |
377 |
359 /*! |
378 /*! |
360 */ |
379 */ |
361 void NmEditorView::startMessageCreation(NmUiEditorStartMode startMode) |
380 void NmEditorView::startMessageCreation(NmUiEditorStartMode startMode) |
362 { |
381 { |
|
382 NMLOG("NmEditorView::startMessageCreation "); |
363 NmId mailboxId = mStartParam->mailboxId(); |
383 NmId mailboxId = mStartParam->mailboxId(); |
364 NmId folderId = mStartParam->folderId(); |
384 NmId folderId = mStartParam->folderId(); |
365 NmId msgId = mStartParam->messageId(); |
385 NmId msgId = mStartParam->messageId(); |
366 |
386 |
367 delete mMessageCreationOperation; |
387 if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) { |
368 mMessageCreationOperation = NULL; |
388 mMessageCreationOperation->cancelOperation(); |
|
389 } |
369 |
390 |
370 // original message is now fetched so start message creation |
391 // original message is now fetched so start message creation |
371 if (startMode == NmUiEditorForward) { |
392 if (startMode == NmUiEditorForward) { |
372 mMessageCreationOperation = mUiEngine.createForwardMessage(mailboxId, msgId); |
393 mMessageCreationOperation = mUiEngine.createForwardMessage(mailboxId, msgId); |
373 } |
394 } |
405 |
426 |
406 bool okToSend = true; |
427 bool okToSend = true; |
407 if (invalidAddresses.count() > 0) { |
428 if (invalidAddresses.count() > 0) { |
408 |
429 |
409 // invalid addresses found, verify send from user |
430 // invalid addresses found, verify send from user |
410 HbMessageBox *messageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
|
411 QString noteText = hbTrId("txt_mail_dialog_invalid_mail_address_send"); |
431 QString noteText = hbTrId("txt_mail_dialog_invalid_mail_address_send"); |
412 // set the first failing address to the note |
432 // set the first failing address to the note |
413 noteText = noteText.arg(invalidAddresses.at(0).address()); |
433 noteText = noteText.arg(invalidAddresses.at(0).address()); |
414 messageBox->setText(noteText); |
434 okToSend = NmUtilities::displayQuestionNote(noteText); |
415 messageBox->setTimeout(HbMessageBox::NoTimeout); |
|
416 |
|
417 // Read user selection |
|
418 HbAction *action = messageBox->exec(); |
|
419 okToSend = (action == messageBox->primaryAction()); |
|
420 } |
435 } |
421 |
436 |
422 if (okToSend) { |
437 if (okToSend) { |
423 QList<NmOperation *> preliminaryOperations; |
438 QList<NmOperation *> preliminaryOperations; |
424 preliminaryOperations.append(mAddAttachmentOperation); |
439 preliminaryOperations.append(mAddAttachmentOperation); |
425 preliminaryOperations.append(mRemoveAttachmentOperation); |
440 preliminaryOperations.append(mRemoveAttachmentOperation); |
426 // ownership of mMessage is transferred |
441 // ownership of mMessage is transferred |
427 // ownerships of NmOperations in preliminaryOperations are transferred |
442 // NmOperations are automatically deleted after completion |
428 mUiEngine.sendMessage(mMessage, preliminaryOperations); |
443 mUiEngine.sendMessage(mMessage, preliminaryOperations); |
429 mMessage = NULL; |
444 mMessage = NULL; |
430 mAddAttachmentOperation = NULL; |
|
431 mRemoveAttachmentOperation = NULL; |
|
432 preliminaryOperations.clear(); |
445 preliminaryOperations.clear(); |
433 // sending animation should be shown here, then exit |
446 mApplication.popView(); |
434 QTimer::singleShot(1000, &mApplication, SLOT(popView())); |
|
435 } |
447 } |
436 } |
448 } |
437 |
449 |
438 /*! |
450 /*! |
439 This is signalled by mMessageCreationOperation when message is created. |
451 This is signalled by mMessageCreationOperation when message is created. |
585 // Set the message body. |
597 // Set the message body. |
586 // Fetch plain text part form message store. |
598 // Fetch plain text part form message store. |
587 NmMessagePart *plainPart = mMessage->plainTextBodyPart(); |
599 NmMessagePart *plainPart = mMessage->plainTextBodyPart(); |
588 |
600 |
589 if (plainPart) { |
601 if (plainPart) { |
590 mUiEngine.contentToMessagePart(mMessage->mailboxId(), |
602 mUiEngine.contentToMessagePart(mMessage->envelope().mailboxId(), |
591 mMessage->parentId(), |
603 mMessage->envelope().folderId(), |
592 mMessage->envelope().id(), |
604 mMessage->envelope().messageId(), |
593 *plainPart); |
605 *plainPart); |
594 } |
606 } |
595 |
607 |
596 // Fetch html part form message store. |
608 // Fetch html part form message store. |
597 NmMessagePart *htmlPart = mMessage->htmlBodyPart(); |
609 NmMessagePart *htmlPart = mMessage->htmlBodyPart(); |
598 |
610 |
599 if (htmlPart) { |
611 if (htmlPart) { |
600 mUiEngine.contentToMessagePart(mMessage->mailboxId(), |
612 mUiEngine.contentToMessagePart(mMessage->envelope().mailboxId(), |
601 mMessage->parentId(), |
613 mMessage->envelope().folderId(), |
602 mMessage->envelope().id(), |
614 mMessage->envelope().messageId(), |
603 *htmlPart); |
615 *htmlPart); |
604 } |
616 } |
605 |
617 |
606 // Fetch attachment.html part form message store if such exists. |
618 // Fetch attachment.html part form message store if such exists. |
607 QList<NmMessagePart*> parts; |
619 QList<NmMessagePart*> parts; |
682 // If action has NmSendable condition, it is shown only when send action |
694 // If action has NmSendable condition, it is shown only when send action |
683 // is available, i.e. when at least one recipient field has data. |
695 // is available, i.e. when at least one recipient field has data. |
684 if( list[i]->availabilityCondition() == NmAction::NmSendable ) { |
696 if( list[i]->availabilityCondition() == NmAction::NmSendable ) { |
685 list[i]->setEnabled(false); |
697 list[i]->setEnabled(false); |
686 } |
698 } |
687 //object name set in NmBaseClientPlugin::createEditorViewCommands |
699 else if (list[i]->availabilityCondition() == NmAction::NmAttachable) { |
688 //temporary solution |
|
689 else if (list[i]->objectName() == "baseclientplugin_attachaction") { |
|
690 HbToolBarExtension* extension = new HbToolBarExtension(); |
700 HbToolBarExtension* extension = new HbToolBarExtension(); |
691 mAttachmentPicker = new NmAttachmentPicker(this); |
701 mAttachmentPicker = new NmAttachmentPicker(this); |
692 |
702 |
693 if (extension && mAttachmentPicker) { |
703 if (extension && mAttachmentPicker) { |
694 connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)), |
704 connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)), |
1010 foreach (QString fileName, fileNames) { |
1011 foreach (QString fileName, fileNames) { |
1011 // At this phase attachment size and nmid are not known |
1012 // At this phase attachment size and nmid are not known |
1012 mHeaderWidget->addAttachment(fileName, QString("0"), NmId(0)); |
1013 mHeaderWidget->addAttachment(fileName, QString("0"), NmId(0)); |
1013 NMLOG(fileName); |
1014 NMLOG(fileName); |
1014 } |
1015 } |
1015 |
1016 // Cancel previous operation if it's not running. |
1016 // Delete previous operation if it's not running. |
|
1017 if (mAddAttachmentOperation) { |
1017 if (mAddAttachmentOperation) { |
1018 if (!mAddAttachmentOperation->isRunning()) { |
1018 if (!mAddAttachmentOperation->isRunning()) { |
1019 delete mAddAttachmentOperation; |
1019 mAddAttachmentOperation->cancelOperation(); |
1020 mAddAttachmentOperation = NULL; |
1020 } |
1021 } |
1021 } |
1022 } |
1022 // Start operation to attach file or list of files into mail message. |
1023 if (!mAddAttachmentOperation) { |
1023 // This will also copy files into message store. |
1024 // Start operation to attach file or list of files into mail message. |
1024 mAddAttachmentOperation = mUiEngine.addAttachments(*mMessage, fileNames); |
1025 // This will also copy files into message store. |
1025 |
1026 mAddAttachmentOperation = mUiEngine.addAttachments(*mMessage, fileNames); |
1026 if (mAddAttachmentOperation) { |
1027 |
1027 enableToolBarAttach(false); |
1028 if (mAddAttachmentOperation) { |
1028 // Signal to inform completion of one attachment |
1029 enableToolBarAttach(false); |
1029 connect(mAddAttachmentOperation, |
1030 // Signal to inform completion of one attachment |
1030 SIGNAL(operationPartCompleted(const QString &, const NmId &, int)), |
1031 connect(mAddAttachmentOperation, |
1031 this, |
1032 SIGNAL(operationPartCompleted(const QString &, const NmId &, int)), |
1032 SLOT(oneAttachmentAdded(const QString &, const NmId &, int))); |
1033 this, |
1033 |
1034 SLOT(oneAttachmentAdded(const QString &, const NmId &, int))); |
1034 // Signal to inform the completion of the whole operation |
1035 |
1035 connect(mAddAttachmentOperation, |
1036 // Signal to inform the completion of the whole operation |
1036 SIGNAL(operationCompleted(int)), |
1037 connect(mAddAttachmentOperation, |
1037 this, |
1038 SIGNAL(operationCompleted(int)), |
1038 SLOT(allAttachmentsAdded(int))); |
1039 this, |
|
1040 SLOT(allAttachmentsAdded(int))); |
|
1041 } |
|
1042 } |
1039 } |
1043 } |
1040 } |
1044 |
1041 |
1045 /*! |
1042 /*! |
1046 This slot is called to create context menu when attachment has been selected |
1043 This slot is called to create context menu when attachment has been selected |
1068 } |
1065 } |
1069 } |
1066 } |
1070 |
1067 |
1071 // Add menu position check here, so that it does not go outside of the screen |
1068 // Add menu position check here, so that it does not go outside of the screen |
1072 QPointF menuPos(point.x(),point.y()); |
1069 QPointF menuPos(point.x(),point.y()); |
1073 mAttachmentListContextMenu->exec(menuPos); |
1070 mAttachmentListContextMenu->setPreferredPos(menuPos); |
|
1071 mAttachmentListContextMenu->open(this, SLOT(contextButton(NmActionResponse&))); |
|
1072 } |
|
1073 |
|
1074 /*! |
|
1075 Slot. Signaled when menu option is selected |
|
1076 */ |
|
1077 void NmEditorView::contextButton(NmActionResponse &result) |
|
1078 { |
|
1079 if (result.menuType() == NmActionContextMenu) { |
|
1080 switch (result.responseCommand()) { |
|
1081 case NmActionResponseCommandRemoveAttachment: { |
|
1082 removeAttachmentTriggered(); |
|
1083 break; |
|
1084 } |
|
1085 case NmActionResponseCommandOpenAttachment: { |
|
1086 openAttachmentTriggered(); |
|
1087 break; |
|
1088 } |
|
1089 default: |
|
1090 break; |
|
1091 } |
|
1092 } |
1074 } |
1093 } |
1075 |
1094 |
1076 /*! |
1095 /*! |
1077 This is signalled by mAddAttachmentOperation when the operation is |
1096 This is signalled by mAddAttachmentOperation when the operation is |
1078 completed for one attachment. |
1097 completed for one attachment. |
1079 */ |
1098 */ |
1080 void NmEditorView::oneAttachmentAdded(const QString &fileName, const NmId &msgPartId, int result) |
1099 void NmEditorView::oneAttachmentAdded(const QString &fileName, const NmId &msgPartId, int result) |
1081 { |
1100 { |
1082 if (result == NmNoError && mMessage) { |
1101 if (result == NmNoError && mMessage) { |
1083 // Need to get the message again because new attachment part has been added. |
1102 // Need to get the message again because new attachment part has been added. |
1084 NmId mailboxId = mMessage->mailboxId(); |
1103 NmId mailboxId = mMessage->envelope().mailboxId(); |
1085 NmId folderId = mMessage->parentId(); |
1104 NmId folderId = mMessage->envelope().folderId(); |
1086 NmId msgId = mMessage->envelope().id(); |
1105 NmId msgId = mMessage->envelope().messageId(); |
1087 |
1106 |
1088 delete mMessage; |
1107 delete mMessage; |
1089 mMessage = NULL; |
1108 mMessage = NULL; |
1090 |
1109 |
1091 mMessage = mUiEngine.message(mailboxId, folderId, msgId); |
1110 mMessage = mUiEngine.message(mailboxId, folderId, msgId); |
1239 /*! |
1258 /*! |
1240 This slot is called when 'remove' is selected from attachment list context menu. |
1259 This slot is called when 'remove' is selected from attachment list context menu. |
1241 */ |
1260 */ |
1242 void NmEditorView::removeAttachmentTriggered() |
1261 void NmEditorView::removeAttachmentTriggered() |
1243 { |
1262 { |
1244 // Delete previous operation |
1263 // Cancel will delete previous operation |
1245 if (mRemoveAttachmentOperation) { |
1264 if (mRemoveAttachmentOperation) { |
1246 if (!mRemoveAttachmentOperation->isRunning()) { |
1265 if (!mRemoveAttachmentOperation->isRunning()) { |
1247 delete mRemoveAttachmentOperation; |
1266 mRemoveAttachmentOperation->cancelOperation(); |
1248 mRemoveAttachmentOperation = NULL; |
1267 } |
1249 } |
1268 } |
1250 } |
1269 // Remove from UI |
1251 if (!mRemoveAttachmentOperation) { |
1270 mHeaderWidget->removeAttachment(mSelectedAttachment); |
1252 // Remove from UI |
1271 // Remove from message store |
1253 mHeaderWidget->removeAttachment(mSelectedAttachment); |
1272 mRemoveAttachmentOperation = mUiEngine.removeAttachment(*mMessage, mSelectedAttachment); |
1254 // Remove from message store |
1273 if (mRemoveAttachmentOperation) { |
1255 mRemoveAttachmentOperation = mUiEngine.removeAttachment(*mMessage, mSelectedAttachment); |
1274 // Signal to inform the remove operation completion |
1256 if (mRemoveAttachmentOperation) { |
1275 connect(mRemoveAttachmentOperation, |
1257 // Signal to inform the remove operation completion |
1276 SIGNAL(operationCompleted(int)), |
1258 connect(mRemoveAttachmentOperation, |
1277 this, |
1259 SIGNAL(operationCompleted(int)), |
1278 SLOT(attachmentRemoved(int))); |
1260 this, |
|
1261 SLOT(attachmentRemoved(int))); |
|
1262 } |
|
1263 } |
1279 } |
1264 } |
1280 } |
1265 |
1281 |
1266 /*! |
1282 /*! |
1267 This slot is called by mRemoveAttachmentOperation when the operation is |
1283 This slot is called by mRemoveAttachmentOperation when the operation is |