--- a/emailuis/nmailui/src/nmeditorview.cpp Thu Sep 30 11:43:07 2010 +0300
+++ b/emailuis/nmailui/src/nmeditorview.cpp Thu Oct 14 17:33:43 2010 +0300
@@ -91,7 +91,7 @@
// Delete opened temporary files.
NmUtilities::deleteTempFiles(mTempFiles);
-
+
if (mRemoveAttachmentOperation && mRemoveAttachmentOperation->isRunning()) {
mRemoveAttachmentOperation->cancelOperation();
}
@@ -140,7 +140,7 @@
void NmEditorView::loadViewLayout()
{
NM_FUNCTION;
-
+
// Use the document loader to load the view.
QObjectList objectList;
objectList.append(this);
@@ -154,7 +154,7 @@
mWidgetList = mDocumentLoader->load(NMUI_EDITOR_VIEW_XML, &ok);
if (ok) {
- mContent = new NmEditorContent(this, mDocumentLoader,
+ mContent = new NmEditorContent(this, mDocumentLoader,
mApplication.networkAccessManager(),
mApplication);
@@ -166,7 +166,7 @@
NmUiEditorStartMode mode = mStartParam->editorStartMode();
if (mode == NmUiEditorReply ||
- mode == NmUiEditorReplyAll ||
+ mode == NmUiEditorReplyAll ||
mode == NmUiEditorForward) {
mContent->editor()->setCustomTextColor(true, Qt::blue);
}
@@ -328,13 +328,14 @@
HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
// The first action in dialogs action list is for the "Yes"-button.
if (action == dlg->actions().at(0)) {
+ connect(&mUiEngine, SIGNAL(draftSaved()),this, SLOT(closeView()));
safeToDraft();
+ } else {
+ // delete draft now because it is always created in the beginning
+ // of new email creation process
+ connect(&mUiEngine, SIGNAL(draftDeleted()),this, SLOT(closeView()));
+ deleteDraft();
}
-
- // Close the view
- QMetaObject::invokeMethod(&mApplication,
- "popView",
- Qt::QueuedConnection);
}
/*!
@@ -345,6 +346,9 @@
// Update draft message with content.
updateMessageWithEditorContents();
+ // Draft messages are always read.
+ mMessage->envelope().setRead(true);
+
// Save message to drafts
QList<NmOperation *> preliminaryOperations;
if (mAddAttachmentOperation && mAddAttachmentOperation->isRunning()) {
@@ -361,6 +365,25 @@
}
/*!
+ Public slot to handle draft deletion.
+*/
+void NmEditorView::deleteDraft()
+{
+ // ownership of mMessage is transferred
+ // NmOperations are automatically deleted after completion
+ mUiEngine.removeDraftMessage(mMessage);
+ mMessage = NULL;
+}
+
+void NmEditorView::closeView()
+{
+ // Close the view
+ QMetaObject::invokeMethod(&mApplication,
+ "popView",
+ Qt::QueuedConnection);
+}
+
+/*!
About to exit view. Application calls this function when user has
pressed back key and editor needs to delete the draft message. This is
called when "auto-exiting" after a successful mail sending.
@@ -545,7 +568,7 @@
{
NM_FUNCTION;
NM_TIMESTAMP("Start editor.");
-
+
NmUiEditorStartMode startMode = startParam.editorStartMode();
NmId mailboxId = startParam.mailboxId();
NmId folderId = startParam.folderId();
@@ -583,7 +606,7 @@
this,
SLOT(messageCreated(int)));
}
-
+
// Set focus
if (mContent && mContent->header() ) {
if (startMode == NmUiEditorCreateNew || XQServiceUtil::isEmbedded()) {
@@ -733,7 +756,7 @@
{
NM_FUNCTION;
NM_TIMESTAMP("Editor opened.");
-
+
delete mMessage;
mMessage = NULL;
@@ -828,8 +851,8 @@
toAddressesString = addressListToString(toAddressList);
ccAddressesString = addressListToString(ccAddressList);
bccAddressesString = addressListToString(bccAddressList);
- // Also add recipients added for example from send service
- // interface to recipient line edits.
+ // Also add recipients added for example from send service
+ // interface to recipient line edits.
mContent->header()->toEdit()->addContacts(toAddressList);
mContent->header()->ccEdit()->addContacts(ccAddressList);
mContent->header()->bccEdit()->addContacts(bccAddressList);
@@ -957,7 +980,7 @@
void NmEditorView::createToolBar()
{
NM_FUNCTION;
-
+
HbToolBar *tb = toolBar();
NmUiExtensionManager &extMngr = mApplication.extManager();
@@ -972,7 +995,7 @@
NmActionContextViewEditor,
NmActionContextDataNone,
mStartParam->mailboxId(),
- mStartParam->folderId());
+ mStartParam->folderId());
QList<NmAction *> list;
extMngr.getActions(request, list);
@@ -1002,22 +1025,22 @@
HbListViewItem *listView = mTBExtnContentWidget->listItemPrototype();
HbFrameBackground frame(NmPopupListFrame, HbFrameDrawer::NinePieces);
listView->setDefaultFrame(frame);
-
+
extension->setContentWidget(mTBExtnContentWidget);
connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
extension, SLOT(close()));
mAttachmentPicker = new NmAttachmentPicker(this);
-
+
connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)),
this, SLOT(onAttachmentReqCompleted(const QVariant &)));
connect(this, SIGNAL(titleChanged(QString)),
mAttachmentPicker, SLOT(setTitle(QString)));
- connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
+ connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
mAttachmentPicker, SLOT (selectFetcher(HbListWidgetItem*)));
}
- } // for ()
+ } // for ()
}
@@ -1327,7 +1350,7 @@
{
NM_FUNCTION;
NM_TIMESTAMP("Add attachments.");
-
+
// Add attachment name into UI
foreach (QString fileName, fileNames) {
// At this phase attachment size and nmid are not known
@@ -1448,7 +1471,7 @@
{
NM_FUNCTION;
NM_TIMESTAMP("All attachments added.");
-
+
enableToolBarAttach(true);
if (result != NmNoError) {
NmUtilities::displayWarningNote(hbTrId("txt_mail_dialog_unable_to_add_attachment"));
@@ -1637,11 +1660,6 @@
NmAction *action = static_cast<NmAction *>(toolbarList[i]);
if (action->availabilityCondition() == NmAction::NmAttachable) {
action->setEnabled(enable);
- if (enable) {
- // For some reason 'Add attachment' toolbar button stays dimmed sometimes,
- // showItems will fix the situation.
- showItems(Hb::ToolBarItem);
- }
}
}
}