emailuis/nmailui/src/nmeditorview.cpp
changeset 59 16ed8d08d0b1
parent 54 997a02608b3a
child 65 478bc57ad291
--- a/emailuis/nmailui/src/nmeditorview.cpp	Tue Jul 06 14:04:34 2010 +0300
+++ b/emailuis/nmailui/src/nmeditorview.cpp	Wed Aug 18 09:37:47 2010 +0300
@@ -18,9 +18,14 @@
 
 // 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_VIEW = "editorview";
 
+// extension list item frame.
+static const QString NmPopupListFrame = "qtg_fr_popup_list_normal";
 static const QString NmDelimiter("; ");
+static const QString NmPriorityLow("low");
+static const QString NmPriorityNormal("normal");
+static const QString NmPriorityHigh("high");
 
 /*!
 	\class NmEditorView
@@ -52,7 +57,9 @@
       mQueryDialog(NULL),
       mAttachmentPicker(NULL),
       mCcBccFieldVisible(false),
-      mServiceSendingDialog(NULL)
+      mServiceSendingDialog(NULL),
+      mIsNotFetchedBefore(true),
+      mHiddenPriorityName(NmPriorityNormal)
 {
     NM_FUNCTION;
     
@@ -193,6 +200,7 @@
     // content widget height needs to be set according to the new orientation to get the scroll
 	// area work correctly
 	mHeaderWidget->sendDelayedHeaderHeightChanged();
+	mHeaderWidget->adjustHeaderWidth();
 }
 
 /*!
@@ -392,20 +400,24 @@
 {
     NM_FUNCTION;
     
-    if (startParam.editorStartMode() == NmUiEditorForward
-        || startParam.editorStartMode()== NmUiEditorReply
-        || startParam.editorStartMode() == NmUiEditorReplyAll) {
+    if (mIsNotFetchedBefore == true) {
+        if (startParam.editorStartMode() == NmUiEditorForward
+            || startParam.editorStartMode()== NmUiEditorReply
+            || startParam.editorStartMode() == NmUiEditorReplyAll) {
         
-        fetchProgressDialogShow();
-        mAttaManager.clearObserver();
-        mAttaManager.setObserver(this);
-        mAttaManager.fetchAllMessageParts(
-            startParam.mailboxId(),
-            startParam.folderId(),
-            startParam.messageId());
-    }
-    else {
-        startMessageCreation(startParam);
+            fetchProgressDialogShow();
+            mAttaManager.clearObserver();
+            mAttaManager.setObserver(this);
+            mAttaManager.fetchAllMessageParts(
+                startParam.mailboxId(),
+                startParam.folderId(),
+                startParam.messageId());
+        }
+        else {
+            startMessageCreation(startParam);
+        }
+        
+        mIsNotFetchedBefore = false;
     }
 }
 
@@ -890,32 +902,30 @@
                 if (extension && mAttachmentPicker) {
                     connect(mAttachmentPicker, SIGNAL(attachmentsFetchOk(const QVariant &)),
                         this, SLOT(onAttachmentReqCompleted(const QVariant &)));            
-                                                
-                    HbAction* actionPhoto = 
-                        extension->addAction(hbTrId("txt_mail_list_photo"), extension, SLOT(close()));
-                    connect(actionPhoto, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchImage()));
+                    
+                    list[i]->setToolBarExtension(extension);
                     
-                    HbAction* actionMusic = 
-                        extension->addAction(hbTrId("txt_mail_list_music"), extension, SLOT(close()));
-                    connect(actionMusic, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchAudio()));
-                    
-                    HbAction* actionVideo = 
-                        extension->addAction(hbTrId("txt_mail_list_video"), extension, SLOT(close()));
-                    connect(actionVideo, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchVideo()));
+                    //content widget to get the items to a list
+                    mTBExtnContentWidget = new HbListWidget();
+                    mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
                     
-                    HbAction* actionOther = 
-                        extension->addAction(hbTrId("txt_mail_list_other"), extension, SLOT(close()));
-                    connect(actionOther, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchOther()));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_photo"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_music"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_video"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_other"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_photo"));
+                    mTBExtnContentWidget->addItem(hbTrId("txt_mail_list_new_video"));
+                    HbListViewItem *listView = mTBExtnContentWidget->listItemPrototype();
+                    HbFrameBackground frame(NmPopupListFrame, HbFrameDrawer::NinePieces);
+                    listView->setDefaultFrame(frame);
                     
-                    HbAction* actionCameraStill = 
-                       extension->addAction(hbTrId("txt_mail_list_new_photo"), extension, SLOT(close()));
-                    connect(actionCameraStill, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchCameraStill()));
+                    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), 
+                    		mAttachmentPicker, SLOT (selectFetcher(HbListWidgetItem*)));
             
-                    HbAction* actionCameraVideo = 
-                        extension->addAction(hbTrId("txt_mail_list_new_video"), extension, SLOT(close()));
-                    connect(actionCameraVideo, SIGNAL(triggered()), mAttachmentPicker, SLOT(fetchCameraVideo()));
+                    connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
+                            extension, SLOT(close()));
                                         
-                    list[i]->setToolBarExtension(extension);
+                    extension->setContentWidget(mTBExtnContentWidget);
                 }
             }            
         }        
@@ -952,7 +962,10 @@
     QList<NmAction*> list;
     extMngr.getActions(request, list);
     for (int i = 0; i < list.count(); i++) {
-        mPrioritySubMenu->addAction(list[i]);
+        // check what priority has already been selected and hide it from options menu
+        if (!list[i]->objectName().contains(mHiddenPriorityName)) {
+            mPrioritySubMenu->addAction(list[i]);
+        }
     }
     mPrioritySubMenu->setObjectName("editorPrioritySubMenu");
     mPrioritySubMenu->setTitle(hbTrId("txt_mail_opt_add_priority"));
@@ -1365,12 +1378,15 @@
 
     if (mMessage) {
         NmMessagePriority messagePriority = NmMessagePriorityNormal;
+        mHiddenPriorityName = NmPriorityNormal;
         
         if (priority == NmActionResponseCommandPriorityHigh) {
             messagePriority = NmMessagePriorityHigh;
+            mHiddenPriorityName = NmPriorityHigh;
         }
         else if (priority == NmActionResponseCommandPriorityLow) {
             messagePriority = NmMessagePriorityLow;
+            mHiddenPriorityName = NmPriorityLow;
         }
         mMessage->envelope().setPriority(messagePriority);
     }