--- a/emailuis/nmailui/src/nmeditorview.cpp Wed Jun 23 18:00:21 2010 +0300
+++ b/emailuis/nmailui/src/nmeditorview.cpp Tue Jul 06 14:04:34 2010 +0300
@@ -19,12 +19,8 @@
// Layout file and view
static const char *NMUI_EDITOR_VIEW_XML = ":/docml/nmeditorview.docml";
static const char *NMUI_EDITOR_VIEW= "editorview";
-static const char *NMUI_EDITOR_SCROLL_AREA = "scrollArea";
-static const char *NMUI_EDITOR_SCROLL_AREA_CONTENTS = "scrollAreaContents";
-static const int NmOrientationTimer=100;
-
-static const QString Delimiter("; ");
+static const QString NmDelimiter("; ");
/*!
\class NmEditorView
@@ -45,11 +41,9 @@
mUiEngine(uiEngine),
mAttaManager(attaManager),
mDocumentLoader(NULL),
- mScrollArea(NULL),
- mEditWidget(NULL),
mHeaderWidget(NULL),
mMessage(NULL),
- mContentWidget(NULL),
+ mContent(NULL),
mAttachmentListContextMenu(NULL),
mMessageCreationOperation(NULL),
mAddAttachmentOperation(NULL),
@@ -92,7 +86,6 @@
delete mMessage;
mWidgetList.clear();
delete mDocumentLoader;
- delete mContentWidget;
delete mPrioritySubMenu;
if (mAttachmentListContextMenu) {
@@ -124,25 +117,23 @@
mPrioritySubMenu = NULL;
// Use document loader to load the view
- bool ok = false;
+ bool ok(false);
+
+ setObjectName(QString(NMUI_EDITOR_VIEW));
+ QObjectList objectList;
+ objectList.append(this);
+ // Pass the view to documentloader. Document loader uses this view
+ // when docml is parsed, instead of creating new view.
+ // documentloader is created in constructor
+ mDocumentLoader->setObjectTree(objectList);
+
mWidgetList = mDocumentLoader->load(NMUI_EDITOR_VIEW_XML, &ok);
- if (ok == true && mWidgetList.count()) {
- // Set view
- QGraphicsWidget *view = mDocumentLoader->findWidget(NMUI_EDITOR_VIEW);
- if (view){
- setWidget(view);
- }
+ if (ok) {
+ mContent = new NmEditorContent(this, mDocumentLoader,
+ mApplication.networkAccessManager(), mApplication);
- mScrollArea = qobject_cast<NmBaseViewScrollArea *>
- (mDocumentLoader->findObject(NMUI_EDITOR_SCROLL_AREA));
- mScrollAreaContents = qobject_cast<HbWidget *>
- (mDocumentLoader->findObject(NMUI_EDITOR_SCROLL_AREA_CONTENTS));
-
- mContentWidget = new NmEditorContent(mScrollArea, this, mDocumentLoader,
- mApplication.networkAccessManager());
- mEditWidget = mContentWidget->editor();
- mHeaderWidget = mContentWidget->header();
+ mHeaderWidget = mContent->header();
// Set default color for user - entered text if editor is in re/reAll/fw mode
if (mStartParam) {
@@ -150,7 +141,7 @@
if (mode == NmUiEditorReply
|| mode == NmUiEditorReplyAll
|| mode == NmUiEditorForward) {
- mEditWidget->setCustomTextColor(true, Qt::blue);
+ mContent->editor()->setCustomTextColor(true, Qt::blue);
}
}
@@ -198,22 +189,38 @@
NM_FUNCTION;
Q_UNUSED(orientation);
- // Adjust content height
- QTimer::singleShot(NmOrientationTimer, this, SLOT(adjustViewDimensions()));
- QTimer::singleShot(NmOrientationTimer, mHeaderWidget, SLOT(sendHeaderHeightChanged()));
+
+ // content widget height needs to be set according to the new orientation to get the scroll
+ // area work correctly
+ mHeaderWidget->sendDelayedHeaderHeightChanged();
+}
+
+/*!
+ This slot is signaled by VKB when it opens
+ */
+void NmEditorView::vkbOpened()
+{
+ showChrome(false);
}
/*!
- Set new dimensions after orientation change.
-*/
-void NmEditorView::adjustViewDimensions()
+ This slot is signaled by VKB when it closes.
+ */
+void NmEditorView::vkbClosed()
{
- NM_FUNCTION;
-
- if (mScrollAreaContents) {
- const QSize reso = mApplication.screenSize();
- mScrollAreaContents->setMinimumWidth(reso.width());
- mScrollAreaContents->setMaximumWidth(reso.width());
+ showChrome(true);
+}
+
+/*!
+ Hide or show chrome.
+ */
+void NmEditorView::showChrome(bool show)
+{
+ if (show) {
+ showItems(Hb::StatusBarItem | Hb::TitleBarItem | Hb::ToolBarItem);
+ }
+ else {
+ hideItems(Hb::StatusBarItem | Hb::TitleBarItem | Hb::ToolBarItem);
}
}
@@ -227,52 +234,45 @@
return NmUiViewMessageEditor;
}
-/*!
- ScrollArea contents
-*/
-HbWidget* NmEditorView::scrollAreaContents()
-{
- NM_FUNCTION;
-
- return mScrollAreaContents;
-}
-
/*
Launch dialog for query user if we want to exit the editor
*/
void NmEditorView::okToExitView()
{
NM_FUNCTION;
-
- NmEditorHeader *header = mContentWidget->header();
-
- bool okToExit = true;
+
+ bool okToExit(true);
- // show the query if the message has not been sent
- if (mMessage && header) {
- // see if editor has any content
- int subjectLength = 0;
- if (header->subjectEdit()) {
- subjectLength = header->subjectEdit()->text().length();
- }
-
- QList<NmMessagePart*> attachmentList;
- mMessage->attachmentList(attachmentList);
-
- okToExit = (subjectLength == 0 && mContentWidget->editor()->document()->isEmpty());
-
- // content exists, verify exit from user
- if (!okToExit) {
- if (mQueryDialog) {
- delete mQueryDialog;
- mQueryDialog = 0;
+ if (mContent) {
+ NmEditorHeader *header = mContent->header();
+ // show the query if the message has not been sent
+ if (mMessage && header) {
+ // see if editor has any content
+ int subjectLength = 0;
+ if (header->subjectEdit()) {
+ subjectLength = header->subjectEdit()->text().length();
}
- // Launch query dialog.
- mQueryDialog =
- NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_save_message_to_drafts"),
- this,
- SLOT(okToExitQuery(HbAction*)));
- }
+
+ QList<NmMessagePart*> attachmentList;
+ mMessage->attachmentList(attachmentList);
+
+ if (mContent->editor()) {
+ okToExit = (subjectLength == 0 && mContent->editor()->document()->isEmpty());
+ }
+
+ // content exists, verify exit from user
+ if (!okToExit) {
+ if (mQueryDialog) {
+ delete mQueryDialog;
+ mQueryDialog = 0;
+ }
+ // Launch query dialog.
+ mQueryDialog =
+ NmUtilities::displayQuestionNote(hbTrId("txt_mail_dialog_save_message_to_drafts"),
+ this,
+ SLOT(okToExitQuery(HbAction*)));
+ }
+ }
}
// no need to query anything, just exit.
@@ -286,7 +286,7 @@
/*!
Handle the user selection is it ok to exit.
*/
-void NmEditorView::okToExitQuery(HbAction* action)
+void NmEditorView::okToExitQuery(HbAction *action)
{
NM_FUNCTION;
@@ -355,13 +355,17 @@
NmAction *dummy = new NmAction(0);
menu()->addAction(dummy);
+ mVkbHost = new HbShrinkingVkbHost(this);
+
initializeVKB();
- connect(mContentWidget->header(), SIGNAL(recipientFieldsHaveContent(bool)),
+
+ //start to listen VKB open and close signals for hiding the chrome.
+ connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
+ connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
+
+ connect(mContent->header(), SIGNAL(recipientFieldsHaveContent(bool)),
this, SLOT(setButtonsDimming(bool)) );
- // Set dimensions
- adjustViewDimensions();
-
// Connect to observe orientation change events
connect(mApplication.mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
this, SLOT(orientationChanged(Qt::Orientation)));
@@ -427,19 +431,34 @@
startMessageCreation(*mStartParam);
}
else {
- mWaitDialog->close();
-
- // Show fetching failed note
- HbNotificationDialog *note = new HbNotificationDialog();
- note->setIcon(HbIcon(QLatin1String("note_warning")));
- QString noteText = hbTrId("txt_mail_dpopinfo_loading_failed");
- note->setTitle(noteText);
- note->setTitleTextWrapping(Hb::TextWordWrap);
- note->setDismissPolicy(HbPopup::TapAnywhere);
- note->setAttribute(Qt::WA_DeleteOnClose);
- note->setSequentialShow(true);
- note->show();
+ // Show the fetching failed note only when
+ // the error is not Device/System errors,
+ if (result != NmNoError &&
+ result != NmNotFoundError &&
+ result != NmGeneralError &&
+ result != NmCancelError &&
+ result != NmAuthenticationError &&
+ result != NmServerConnectionError &&
+ result != NmConnectionError) {
+
+ HbNotificationDialog *note = new HbNotificationDialog();
+
+ bool enalbeAttribute(true);
+ note->setAttribute(Qt::WA_DeleteOnClose, enalbeAttribute);
+
+ note->setIcon(HbIcon(QLatin1String("note_warning")));
+
+ note->setTitle(hbTrId("txt_mail_dpopinfo_loading_failed"));
+ note->setTitleTextWrapping(Hb::TextWordWrap);
+
+ note->setDismissPolicy(HbNotificationDialog::TapAnywhere);
+ note->setTimeout(HbNotificationDialog::StandardTimeout);
+
+ note->setSequentialShow(true);
+ note->show();
+ }
+ mWaitDialog->close();
QMetaObject::invokeMethod(&mApplication, "popView", Qt::QueuedConnection);
}
}
@@ -486,7 +505,7 @@
if (mMessageCreationOperation && mMessageCreationOperation->isRunning()) {
mMessageCreationOperation->cancelOperation();
}
-
+
// original message is now fetched so start message creation
if (startMode == NmUiEditorForward) {
mMessageCreationOperation = mUiEngine.createForwardMessage(mailboxId, msgId);
@@ -530,7 +549,7 @@
// verify addresses before sending
QList<NmAddress> invalidAddresses;
if (mMessage) {
- NmUtilities::getRecipientsFromMessage(*mMessage, invalidAddresses, NmUtilities::InvalidAddress);
+ NmUtilities::getRecipientsFromMessage(*mMessage, invalidAddresses, NmUtilities::NmInvalidAddress);
}
if (invalidAddresses.count() > 0) {
@@ -575,11 +594,7 @@
mMessage = NULL;
preliminaryOperations.clear();
-#ifndef NM_WINS_ENV
bool service = XQServiceUtil::isService();
-#else
- bool service = false;
-#endif
// If sending is started as a service, progress dialog needs to be shown
// so long that sending is finished otherwise we can close pop current view.
@@ -595,12 +610,10 @@
connect(mServiceSendingDialog, SIGNAL(cancelled()),
this, SLOT(sendProgressDialogCancelled()));
-#ifndef NM_WINS_ENV
if (!XQServiceUtil::isEmbedded()) {
// Hide the application.
XQServiceUtil::toBackground(true);
}
-#endif
// Display the wait dialog.
mServiceSendingDialog->setModal(true);
mServiceSendingDialog->setBackgroundFaded(true);
@@ -627,6 +640,18 @@
}
/*!
+ This is called when the view's geometry size has been changed, eg. when VKB is opened/closed.
+*/
+void NmEditorView::resizeEvent(QGraphicsSceneResizeEvent *event)
+{
+ NM_FUNCTION;
+
+ NmBaseView::resizeEvent(event);
+
+ emit sizeChanged();
+}
+
+/*!
This is signalled by mMessageCreationOperation when message is created.
*/
void NmEditorView::messageCreated(int result)
@@ -662,45 +687,45 @@
NM_FUNCTION;
if (mMessage) {
- if (mContentWidget && mContentWidget->editor()) {
+ if (mContent && mContent->editor()) {
NmMessagePart* bodyPart = mMessage->htmlBodyPart();
if (bodyPart) {
- bodyPart->setTextContent(mContentWidget->editor()->toHtml(), NmContentTypeTextHtml);
+ bodyPart->setTextContent(mContent->editor()->toHtml(), NmContentTypeTextHtml);
}
bodyPart = mMessage->plainTextBodyPart();
if (bodyPart) {
- bodyPart->setTextContent(mContentWidget->editor()->toPlainText(), NmContentTypeTextPlain);
+ bodyPart->setTextContent(mContent->editor()->toPlainText(), NmContentTypeTextPlain);
}
}
- if (mContentWidget && mContentWidget->header() ) {
- if (mContentWidget->header()->subjectEdit()) {
+ if (mContent && mContent->header() ) {
+ if (mContent->header()->subjectEdit()) {
mMessage->envelope().setSubject(
- mContentWidget->header()->subjectEdit()->text());
+ mContent->header()->subjectEdit()->text());
}
- if (mContentWidget->header()->toEdit()) {
+ if (mContent->header()->toEdit()) {
QString toFieldText =
- mContentWidget->header()->toEdit()->text();
+ mContent->header()->toEdit()->text();
// This verification of zero length string isn't needed
// after list of addresses
if (toFieldText.length() > 0) {
- mMessage->envelope().setToRecipients(mContentWidget->header()->toEdit()->emailAddressList());
+ mMessage->envelope().setToRecipients(mContent->header()->toEdit()->emailAddressList());
}
}
- if (mContentWidget->header()->ccEdit()) {
+ if (mContent->header()->ccEdit()) {
QString ccFieldText =
- mContentWidget->header()->ccEdit()->text();
+ mContent->header()->ccEdit()->text();
if (ccFieldText.length() > 0) {
- mMessage->envelope().setCcRecipients(mContentWidget->header()->ccEdit()->emailAddressList());
+ mMessage->envelope().setCcRecipients(mContent->header()->ccEdit()->emailAddressList());
}
}
- if (mContentWidget->header()->bccEdit()) {
+ if (mContent->header()->bccEdit()) {
QString bccFieldText =
- mContentWidget->header()->bccEdit()->text();
+ mContent->header()->bccEdit()->text();
if (bccFieldText.length() > 0) {
- mMessage->envelope().setBccRecipients(mContentWidget->header()->bccEdit()->emailAddressList());
+ mMessage->envelope().setBccRecipients(mContent->header()->bccEdit()->emailAddressList());
}
}
}
@@ -716,7 +741,7 @@
{
NM_FUNCTION;
- if (!mStartParam || !mMessage || !mContentWidget) {
+ if (!mStartParam || !mMessage || !mContent) {
return;
}
@@ -746,14 +771,14 @@
bccAddressesString = addressListToString(messageEnvelope.bccRecipients());
}
- mContentWidget->header()->toEdit()->setPlainText(toAddressesString);
- mContentWidget->header()->ccEdit()->setPlainText(ccAddressesString);
- mContentWidget->header()->bccEdit()->setPlainText(bccAddressesString);
+ mContent->header()->toEdit()->setPlainText(toAddressesString);
+ mContent->header()->ccEdit()->setPlainText(ccAddressesString);
+ mContent->header()->bccEdit()->setPlainText(bccAddressesString);
if (ccAddressesString.length() || bccAddressesString.length()) {
// Since cc or/and bcc recipients exist, expand the group box to display
// the addresses by expanding the group box.
- mContentWidget->header()->setFieldVisibility(true);
+ mContent->header()->setFieldVisibility(true);
}
// Set subject.
@@ -761,16 +786,20 @@
QString *subject = mStartParam->subject();
if (subject) {
- mContentWidget->header()->subjectEdit()->setPlainText(*subject);
+ mContent->header()->subjectEdit()->setPlainText(*subject);
}
}
else {
// Construct the subject field.
- mContentWidget->header()->subjectEdit()->setPlainText(
+ mContent->header()->subjectEdit()->setPlainText(
addSubjectPrefix(editorStartMode, messageEnvelope.subject()));
}
// Set priority.
+ if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll) {
+ //Clear the importance flag. Replied messages dont keep the importance
+ setPriority(NmActionResponseCommandNone);
+ }
mHeaderWidget->setPriority(messageEnvelope.priority());
// Set the message body.
@@ -803,12 +832,7 @@
*htmlPart);
}
- if (editorStartMode==NmUiEditorFromDrafts) {
- mContentWidget->setMessageData(*originalMessage, false);
- }
- else {
- mContentWidget->setMessageData(*originalMessage);
- }
+ mContent->setMessageData(*originalMessage, editorStartMode);
}
delete originalMessage;
@@ -1028,7 +1052,7 @@
// Set the VKB action states
// All editors of the view share the same action, so it is enough to set
// this only to one of them.
- HbEditorInterface editorInterface(mContentWidget->editor());
+ HbEditorInterface editorInterface(mContent->editor());
QList<HbAction *> vkbList = editorInterface.actions();
count = vkbList.count();
for (int i = 0; i < count; i++) {
@@ -1070,15 +1094,15 @@
// Link VKB to the action. This must be done to all
// editors that show the button in VKB.
- HbEditorInterface editorInterface(mContentWidget->editor());
+ HbEditorInterface editorInterface(mContent->editor());
editorInterface.addAction(list[i]);
- HbEditorInterface toEditorInterface(mContentWidget->header()->toEdit());
+ HbEditorInterface toEditorInterface(mContent->header()->toEdit());
toEditorInterface.addAction(list[i]);
- HbEditorInterface ccEditorInterface(mContentWidget->header()->ccEdit());
+ HbEditorInterface ccEditorInterface(mContent->header()->ccEdit());
ccEditorInterface.addAction(list[i]);
- HbEditorInterface bccEditorInterface(mContentWidget->header()->bccEdit());
+ HbEditorInterface bccEditorInterface(mContent->header()->bccEdit());
bccEditorInterface.addAction(list[i]);
- HbEditorInterface subjectEditorInterface(mContentWidget->header()->subjectEdit());
+ HbEditorInterface subjectEditorInterface(mContent->header()->subjectEdit());
subjectEditorInterface.addAction(list[i]);
}
}
@@ -1283,13 +1307,16 @@
NmId mailboxId = mMessage->envelope().mailboxId();
NmId folderId = mMessage->envelope().folderId();
NmId msgId = mMessage->envelope().messageId();
-
+ NmMessagePriority messagePriority = mMessage->envelope().priority();
+
delete mMessage;
mMessage = NULL;
mMessage = mUiEngine.message(mailboxId, folderId, msgId);
if (mMessage) {
+ mMessage->envelope().setPriority(messagePriority);
+ mMessage->envelope().setHasAttachments(true);
// Get attachment list from the message
QList<NmMessagePart*> attachmentList;
mMessage->attachmentList(attachmentList);
@@ -1367,7 +1394,7 @@
while (i != list.constEnd() && *i) {
if (i > list.constBegin()) {
// Add the delimiter.
- addressesString += Delimiter;
+ addressesString += NmDelimiter;
}
addressesString += (*i)->address();
@@ -1395,7 +1422,7 @@
while (i != list.constEnd()) {
if (i > list.constBegin()) {
// Add the delimiter.
- addressesString += Delimiter;
+ addressesString += NmDelimiter;
}
addressesString += (*i).address();
@@ -1447,11 +1474,24 @@
NmId mailboxId = mMessage->envelope().mailboxId();
NmId folderId = mMessage->envelope().folderId();
NmId msgId = mMessage->envelope().messageId();
+ NmMessagePriority messagePriority = mMessage->envelope().priority();
delete mMessage;
mMessage = NULL;
mMessage = mUiEngine.message(mailboxId, folderId, msgId);
+
+ if(mMessage) {
+ // Set the correct priority
+ mMessage->envelope().setPriority(messagePriority);
+
+ // If there is no more attachments in the message, set the correct value
+ QList<NmMessagePart*> attachmentList;
+ mMessage->attachmentList(attachmentList);
+ if(attachmentList.count() == 0) {
+ mMessage->envelope().setHasAttachments(false);
+ }
+ }
}
}
@@ -1493,6 +1533,3 @@
}
}
}
-
-
-// End of file.