--- a/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp Tue Oct 05 13:58:47 2010 +0530
+++ b/messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp Tue Oct 19 11:30:16 2010 +0530
@@ -19,29 +19,25 @@
#include <e32base.h>
#include <HbMenu>
#include <HbAction>
-#include <HbToolBar>
#include <QGraphicsLinearLayout>
-#include <HbGroupBox>
-#include <HbScrollArea>
#include <QDateTime>
#include <QDir>
#include <QBuffer>
#include <QFile>
#include <QFileInfo>
+#include <QApplication>
#include <xqconversions.h>
-#include <HbToolBarExtension>
-#include <HbListWidget>
-#include <HbFrameBackground>
-#include <HbListViewItem>
-#include <HbListWidgetItem>
#include <HbNotificationDialog>
#include <HbDeviceNotificationDialog>
#include <HbMessageBox>
-#include <HbAbstractVkbHost>
#include <HbMainWindow>
#include <xqaiwrequest.h>
#include <xqappmgr.h>
#include <HbStyleLoader>
+#include<HbInputMethod>
+#include <QTimer>
+#include<QInputContext>
+
// QT Mobility for fetching business card
#include <qmobilityglobal.h>
#include <qversitwriter.h>
@@ -55,11 +51,7 @@
// USER INCLUDES
#include "debugtraces.h"
#include "msgunieditorview.h"
-#include "msgunieditoraddress.h"
-#include "msgunieditorsubject.h"
-#include "msgunieditorbody.h"
#include "msgunieditormonitor.h"
-#include "msgunieditorattachmentcontainer.h"
#include "msgsendutil.h"
#include "convergedmessageaddress.h"
#include "UniEditorGenUtils.h"
@@ -68,11 +60,12 @@
#include "msgsettingsview.h"
#include "msgcontacthandler.h"
#include "msgaudiofetcherdialog.h"
+#include "msgunieditorscrollarea.h"
+#include "msgunieditorbodyeditor.h"
QTM_USE_NAMESPACE
// Constants
-const QString SEND_ICON("qtg_mono_send");
-const QString ATTACH_ICON("qtg_mono_attach");
+
// temporary folder for unieditor
const QString UNIFIED_EDITOR_TEMP_FOLDER("unifiededitor");
// invalid chars in vcard
@@ -89,17 +82,14 @@
// LOCALIZED CONSTANTS
#define LOC_TITLE hbTrId("txt_messaging_title_messaging")
-//To,Cc.Bcc
-#define LOC_TO hbTrId("txt_messaging_formlabel_to")
-#define LOC_CC hbTrId("txt_messaging_formlabel_cc")
-#define LOC_BCC hbTrId("txt_messaging_formlabel_bcc")
//attach options
#define LOC_PHOTO hbTrId("txt_messaging_opt_attach_sub_photo")
#define LOC_SOUND hbTrId("txt_messaging_opt_attach_sub_sound")
#define LOC_BUSINESS_CARD hbTrId("txt_messaging_opt_sub_business_card")
-//options menu.
+////options menu.
+#define LOC_ATTACH hbTrId("txt_messaging_opt_attach")
#define LOC_ADD_SUBJECT hbTrId("txt_messaging_opt_add_subject")
#define LOC_ADD_CC_BCC hbTrId("txt_messaging_opt_add_cc_bcc")
#define LOC_PRIORITY hbTrId("txt_messaging_opt_priority")
@@ -110,21 +100,12 @@
#define LOC_NORMAL hbTrId("txt_messaging_opt_attach_sub_normal")
#define LOC_LOW hbTrId("txt_messaging_opt_attach_sub_low")
-//group box
-#define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_title_ln_other_recipients",n)
-#define LOC_OTHER_RECIPIENTS_EXPAND hbTrId("txt_messaging_title_other_recipients")
-
//saved to draft note
#define LOC_SAVED_TO_DRAFTS hbTrId("txt_messaging_dpopinfo_saved_to_drafts")
//delete confermation
#define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
-// attachment addition failure note
-#define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2")
-
-//extension list item frame.
-const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal");
//settings confirmation
#define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e")
@@ -153,30 +134,26 @@
//---------------------------------------------------------------
MsgUnifiedEditorView::MsgUnifiedEditorView( QGraphicsItem *parent ) :
MsgBaseView(parent),
- mSubjectAction(0),
- mCcBccAction(0),
- mSendAction(0),
mMainLayout(0),
- mSubjectField(0),
- mToField(0),
- mCcField(0),
- mBccField(0),
- mBody(0),
- mContentWidget(0),
mMsgMonitor(0),
- mAttachmentContainer(0),
mPluginLoader(0),
mCanSaveToDrafts(true),
mVkbHost(NULL),
mDialog(NULL),
mOriginatingSC(0),
mOriginatingSME(0),
- mReplyPath(false)
- {
- connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
-
- addToolBar();
+ mReplyPath(false),
+ mSubjectAction(0),
+ mCcBccAction(0),
+ mPhotoAction(0),
+ mSoundAction(0),
+ mFocusedWidget(0),
+ mMinHeight(0.0),
+ mMaxHeight(0.0)
+ {
+ connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
initView();
+ addMenu();
}
//---------------------------------------------------------------
@@ -201,64 +178,66 @@
if (!HbStyleLoader::registerFilePath(":/layouts")) {
QDEBUG_WRITE("ERROR: MsgUnifiedEditorView -> HbStyleLoader::registerFilePath");
}
- HbScrollArea* scrollArea = new HbScrollArea(this);
- this->setWidget(scrollArea);
- mContentWidget = new HbWidget(this);
- scrollArea->setContentWidget(mContentWidget);
+ //message monitor.
+ mMsgMonitor = new MsgUnifiedEditorMonitor(this);
+
+ //Set the invalid msg id
+ mOpenedMessageId.setId(-1);
- mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget);
+ mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
qreal vTopSpacing = 0.0;
qreal vItemSpacing = 0.0;
style()->parameter("hb-param-margin-gene-top",vTopSpacing);
- style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
-
+ style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
mMainLayout->setContentsMargins(0,vTopSpacing,0,0);
- mMainLayout->setSpacing(vItemSpacing);
-
- mMsgMonitor = new MsgUnifiedEditorMonitor(this);
- connect(mMsgMonitor, SIGNAL(enableSend(bool)), this, SLOT(enableSendButton(bool)));
-
- mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget );
+ mMainLayout->setSpacing(vItemSpacing);
+
+ mScrollArea = new MsgUnifiedEditorScrollArea(mMsgMonitor,this);
+ mMainLayout->addItem(mScrollArea);
+
+ mBodyEditor = new MsgUnifiedEditorBodyEditor(this);
+
+ connect(mScrollArea,SIGNAL(enableMenuAction(int,bool)),this,SLOT(enableMenuAction(int,bool)));
- mBody = new MsgUnifiedEditorBody( mContentWidget);
-
- mMainLayout->addItem(mToField);
- mMainLayout->addItem(mBody);
-
- //Set the invalid msg id
- mOpenedMessageId.setId(-1);
-
- connect(mToField, SIGNAL(sendMessage()), this, SLOT(send()));
- connect(mToField, SIGNAL(contentChanged()),
- mMsgMonitor, SLOT(handleContentChange()));
- connect(mToField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
+ connect(mBodyEditor, SIGNAL(contentsChanged(const QVariant&)),
+ mMsgMonitor,SLOT(handleContentsChanged(const QVariant&)));
+
+ connect(mMsgMonitor,SIGNAL(enableSend(bool)),
+ mBodyEditor,SLOT(enableSendButton(bool)));
- connect(mBody, SIGNAL(sendMessage()), this, SLOT(send()));
- connect(mBody, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
- connect(mBody, SIGNAL(contentChanged()),
- mMsgMonitor, SLOT(handleContentChange()));
- connect(mBody, SIGNAL(enableSendButton(bool)), this, SLOT(enableSendButton(bool)));
+ connect(mBodyEditor,SIGNAL(sendMessage()),this,SLOT(send()));
+
+ connect(mMsgMonitor,SIGNAL(contentsChanged()),this,SLOT(onContentChanged()));
+
+ mMainLayout->addItem(mBodyEditor);
}
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::addMenu
+// @see header file
+//---------------------------------------------------------------
void MsgUnifiedEditorView::addMenu()
{
//Create Menu Options
HbMenu* mainMenu = this->menu();
- mainMenu->setFocusPolicy(Qt::NoFocus);
-
- //if subject field / cc,bcc fields are already present don't add corresponding actions.
- if(!mSubjectField)
- {
- mSubjectAction = mainMenu->addAction(LOC_ADD_SUBJECT);
- }
+ mainMenu->setFocusPolicy(Qt::NoFocus);
+
+ //attach sub menu
+ HbMenu* attachMenu = mainMenu->addMenu(LOC_ATTACH);
+ mPhotoAction = attachMenu->addAction(LOC_PHOTO,this,SLOT(fetchImages()));
+ mSoundAction = attachMenu->addAction(LOC_SOUND,this,SLOT(fetchAudio()));
+ attachMenu->addAction(LOC_BUSINESS_CARD,this,SLOT(fetchContacts()));
- if(!mCcField)
- {
- mCcBccAction = mainMenu->addAction(LOC_ADD_CC_BCC);
- }
+ //subject action
+ mSubjectAction = mainMenu->addAction(LOC_ADD_SUBJECT);
+ //CcBcc action
+ mCcBccAction = mainMenu->addAction(LOC_ADD_CC_BCC);
+ connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject()));
+ connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc()));
+ //priority sub menu
HbMenu* prioritySubMenu = mainMenu->addMenu(LOC_PRIORITY);
HbAction* highPriorityAction = prioritySubMenu->addAction(LOC_HIGH);
@@ -268,19 +247,22 @@
normalPriorityAction->setData(ConvergedMessage::Normal);
HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW);
- lowPriorityAction->setData(ConvergedMessage::Low);
-
- HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE);
+ lowPriorityAction->setData(ConvergedMessage::Low);
- connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject()));
- connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc()));
- connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
- connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
- connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority()));
+ connect(highPriorityAction, SIGNAL(triggered()), mScrollArea, SLOT(changePriority()));
+ connect(normalPriorityAction, SIGNAL(triggered()), mScrollArea, SLOT(changePriority()));
+ connect(lowPriorityAction, SIGNAL(triggered()), mScrollArea, SLOT(changePriority()));
+
+
+ HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE);
connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage()));
}
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::openDraftsMessage
+// @see header file
+//---------------------------------------------------------------
void MsgUnifiedEditorView::openDraftsMessage(const QVariantList& editorData)
{
// unpack editor's data
@@ -302,11 +284,9 @@
mPluginLoader->getUniEditorPlugin(messageType);
mOpenedMessageId.setId(messageId.getId());
- mmOpenedMessageType = messageType;
//Fetch the converged message from the msgId
- ConvergedMessage* msg;
- msg = pluginInterface->convertFrom(messageId.getId());
+ ConvergedMessage* msg = pluginInterface->convertFrom(messageId.getId());
if( msg != NULL )
{
@@ -317,17 +297,19 @@
mOriginatingSME = msg->toAddressList().at(0)->address();
}
//Populate the content inside editor
- populateContentIntoEditor(*msg,true); // true as it is draft message
+ populateContentIntoEditor(*msg,true,true); // true as it is draft message
delete msg;
}
mCanSaveToDrafts = false;
}
-void MsgUnifiedEditorView::fetchMessageFromStore(
- ConvergedMessageId& messageId,
- ConvergedMessage::MessageType messageType,
- int editorOperation)
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::fetchMessageFromStore
+// @see header file
+//---------------------------------------------------------------
+void MsgUnifiedEditorView::fetchMessageFromStore(ConvergedMessageId& messageId,
+ ConvergedMessage::MessageType messageType, int editorOperation)
{
if(!mPluginLoader)
{
@@ -336,13 +318,11 @@
UniEditorPluginInterface* pluginInterface = NULL;
if( messageType == ConvergedMessage::Mms )
{
- pluginInterface =
- mPluginLoader->getUniEditorPlugin(ConvergedMessage::Mms);
+ pluginInterface = mPluginLoader->getUniEditorPlugin(ConvergedMessage::Mms);
}
else // For sms,vcard,vcal cases
{
- pluginInterface =
- mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms);
+ pluginInterface = mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms);
}
//Fetch the converged message from the msgId
@@ -361,11 +341,15 @@
}
}
//Populate the content inside editor
- populateContentIntoEditor(*msg);
+ populateContentIntoEditor(*msg,false,true);
delete msg;
}
}
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::populateContent
+// @see header file
+//---------------------------------------------------------------
void MsgUnifiedEditorView::populateContent(const QVariantList& editorData)
{
// unpack editor's data
@@ -387,8 +371,8 @@
{
case MsgBaseView::ADD_SUBJECT:
{
- addSubject();
- setFocus(mSubjectField);
+ //setfocus also.
+ addSubject(true);
}
break;
case MsgBaseView::ADD_VCARD:
@@ -401,373 +385,90 @@
fetchMessageFromStore(*messageDetails->id(),
messageDetails->messageType(),
UniEditorPluginInterface::Forward);
+ return;
}
- break;
case MsgBaseView::REPLY_MSG:
{
fetchMessageFromStore(*messageDetails->id(),
messageDetails->messageType(),
UniEditorPluginInterface::Reply);
+ return;
}
- break;
case MsgBaseView::REPLY_ALL_MSG:
{
fetchMessageFromStore(*messageDetails->id(),
messageDetails->messageType(),
UniEditorPluginInterface::ReplyAll);
+ return;
}
- break;
default:
break;
}
- // additional common operations for non-forwarded messages
- if(editorOp != MsgBaseView::FORWARD_MSG)
- {
- if(editorOp == MsgBaseView::ADD_RECIPIENTS)
- {
- // CV sends contact card address as the first address
- ConvergedMessageAddressList toAddresses =
- messageDetails->toAddressList();
- int addrCount = toAddresses.count();
- if(addrCount > 0)
- {
- // add contact card address first
- ConvergedMessageAddress *firstAddress =
- new ConvergedMessageAddress();
- firstAddress->setAlias(toAddresses.at(0)->alias());
- firstAddress->setAddress(toAddresses.at(0)->address());
- ConvergedMessageAddressList firstList;
- firstList << firstAddress;
- mToField->setAddresses(firstList);
-
- // add remaining contacts now
- ConvergedMessageAddressList otherList;
- for(int i=1; i<addrCount; i++)
- {
- otherList << toAddresses.at(i);
- }
- mToField->setAddresses(otherList);
- }
- }
- else
- {
- mToField->setAddresses(messageDetails->toAddressList());
- }
- QString bodyTxt = messageDetails->bodyText();
- mBody->setText(bodyTxt);
+ populateContentIntoEditor(*messageDetails,false,false);
- int attachmentCount = messageDetails->attachments().count();
- QStringList pendingAttList;
- for(int i=0; i<attachmentCount; i++)
- {
- int imageSize=0;
- QString mimeType;
- TMsgMediaType mediaType = EMsgMediaUnknown;
- QString filePath = messageDetails->attachments().at(i)->filePath();
-
-
- UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
-
- TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize,
- mimeType,mediaType));
- delete genUtils;
- switch(mediaType)
- {
- case EMsgMediaImage:
- {
- mBody->setImage(filePath);
- }
- break;
- case EMsgMediaAudio:
- {
- mBody->setAudio(filePath);
- }
- break;
- default:
- {
- pendingAttList << filePath;
- }
- break;
- }
- }
- // add pending attachments in bulk
- addAttachments(pendingAttList);
- }
delete messageDetails;
}
-void MsgUnifiedEditorView::populateContentIntoEditor(
- const ConvergedMessage& messageDetails,bool draftMessage)
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::populateContentIntoEditor
+// @see header file
+//---------------------------------------------------------------
+void MsgUnifiedEditorView::populateContentIntoEditor(const ConvergedMessage& messageDetails,
+ bool draftMessage,
+ bool checkForInline)
{
// skip first-time MMS type switch note for draft
- mMsgMonitor->setSkipNote(true);
- mToField->skipMaxRecipientQuery(true);
-
- mToField->setAddresses(messageDetails.toAddressList(),draftMessage);
- if(messageDetails.ccAddressList().count() > 0 )
- {
- if(!mCcField)
- {
- addCcBcc();
- }
- mCcField->setAddresses(messageDetails.ccAddressList(),draftMessage);
- }
- if(messageDetails.bccAddressList().count() > 0 )
+ if(draftMessage)
{
- if(!mBccField)
- {
- addCcBcc();
- }
- mBccField->setAddresses(messageDetails.bccAddressList(),draftMessage);
- }
- if(messageDetails.subject().size() > 0)
- {
- if(!mSubjectField)
- {
- addSubject();
- }
- mSubjectField->setText(messageDetails.subject());
- }
-
- if(messageDetails.priority()==ConvergedMessage::High ||
- messageDetails.priority() == ConvergedMessage::Low)
- {
- if(!mSubjectField)
- {
- addSubject();
- }
- mSubjectField->setPriority(messageDetails.priority());
+ mMsgMonitor->setSkipNote(true);
}
- QString bodyTxt = messageDetails.bodyText();
- mBody->setText(bodyTxt);
-
- ConvergedMessageAttachmentList attachmentList =
- messageDetails.attachments();
- int attachmentCount = attachmentList.count();
-
- UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
-
- QStringList pendingAttList;
- for( int i=0; i < attachmentCount; i++ )
- {
- QString filePath = messageDetails.attachments().at(i)->filePath();
-
- if(attachmentList.at(i)->attachmentType() ==
- ConvergedMessageAttachment::EInline)
- {
- int imageSize=0;
- QString mimeType;
- TMsgMediaType mediaType = EMsgMediaUnknown;
- TRAP_IGNORE(genUtils->getFileInfoL(filePath,imageSize,
- mimeType,mediaType));
+ //scrollarea populate contents
+ mScrollArea->populateContent(messageDetails,draftMessage,checkForInline);
- switch(mediaType)
- {
- case EMsgMediaImage:
- {
- mBody->setImage(filePath,draftMessage);
- break;
- }
- case EMsgMediaAudio:
- {
- mBody->setAudio(filePath);
- break;
- }
- default:
- {
- pendingAttList << filePath;
- break;
- }
- }
- }
- else
- {
- pendingAttList << filePath;
- }
- }
- // add pending attachments to editor
- addAttachments(pendingAttList);
+ //body editor populate contents
+ mBodyEditor->populateContent(messageDetails);
- delete genUtils;
- // ensure that any msg-type change after this are shown
- mToField->skipMaxRecipientQuery(false);
mMsgMonitor->setSkipNote(false);
}
-void MsgUnifiedEditorView::addToolBar()
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::addSubject
+// @see header file
+//---------------------------------------------------------------
+void MsgUnifiedEditorView::addSubject(bool needFocus)
{
- //Create Tool Bar
- HbToolBar *toolBar = new HbToolBar();
- toolBar->setOrientation(Qt::Horizontal);
-
- //tool bar extension for attach action.
- HbToolBarExtension* attachExtension = new HbToolBarExtension();
- mAttachAction = toolBar->addExtension(attachExtension);
- mAttachAction->setIcon(HbIcon(ATTACH_ICON));
-
- mTBExtnContentWidget = new HbListWidget();
- mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
- mTBExtnContentWidget->addItem(LOC_PHOTO);
- mTBExtnContentWidget->addItem(LOC_SOUND);
- mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD);
-
- HbListViewItem *prototype = mTBExtnContentWidget->listItemPrototype();
- HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces);
- prototype->setDefaultFrame(frame);
-
- connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
- this, SLOT(handleViewExtnActivated(HbListWidgetItem*)));
- connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)),
- attachExtension, SLOT(close()));
-
- attachExtension->setContentWidget(mTBExtnContentWidget);
-
- //Add Action to the toolbar and show toolbar
- mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send()));
- mSendAction->setDisabled(true);
-
- setToolBar(toolBar);
-}
-
-void MsgUnifiedEditorView::addSubject()
-{
- if(mSubjectField)
- { // do nothing if already present
- return;
- }
-
- int index =0;
- int offset = 1;
- if(mAttachmentContainer)
- {
- ++offset;
- }
- index = mMainLayout->count() - offset;
-
- mSubjectField = new MsgUnifiedEditorSubject( mContentWidget);
-
- mMainLayout->insertItem(index,mSubjectField);
- connect(mSubjectField, SIGNAL(contentChanged()),
- mMsgMonitor, SLOT(handleContentChange()));
- connect(mSubjectField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
-
- //set focus to subject field.
+ //triggered from menu so need a focus.
HbAction* subjectAction = qobject_cast<HbAction*>(this->sender());
if(subjectAction)
{
- setFocus(mSubjectField);
+ needFocus = true;
}
-
- // remove mainmenu's "Add Subject" action
- if(mSubjectAction)
- {
- HbMenu* mainMenu = this->menu();
- mainMenu->removeAction(mSubjectAction);
- mSubjectAction->setParent(NULL);
- delete mSubjectAction;
- }
+ mScrollArea->addSubject(needFocus);
}
-void MsgUnifiedEditorView::addCcBcc()
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::addCcBcc
+// @see header file
+//---------------------------------------------------------------
+void MsgUnifiedEditorView::addCcBcc(bool needFocus)
{
- if(mCcField && mBccField)
- { // do nothing if already present
- return;
+ //set focus to Cc field.
+ HbAction* ccBccAction = qobject_cast<HbAction*>(this->sender());
+ if(ccBccAction)
+ {
+ needFocus = true;
}
- mCcField = new MsgUnifiedEditorAddress( LOC_CC, mContentWidget );
- mBccField = new MsgUnifiedEditorAddress( LOC_BCC, mContentWidget );
- mCcField->skipMaxRecipientQuery(true);
- mBccField->skipMaxRecipientQuery(true);
-
- connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send()));
- connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange()));
- connect(mCcField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
-
- connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send()));
- connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange()));
- connect(mBccField, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
-
- HbWidget* groupWidget = new HbWidget(mContentWidget);
- groupWidget->setContentsMargins(0,0,0,0);
-
- QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget);
- ccBccLayout->setContentsMargins(0,0,0,0);
-
- qreal vItemSpacing = 0.0;
- style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
- ccBccLayout->setSpacing(vItemSpacing);
- ccBccLayout->addItem(mCcField);
- ccBccLayout->addItem(mBccField);
-
- HbGroupBox* groupBox = new HbGroupBox(0);
- groupBox->setObjectName("groupBox");
-
- groupBox->setContentWidget(groupWidget);
- groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
- mMainLayout->insertItem(1,groupBox);
- connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool)));
-
- // add subject field too
+ mScrollArea->addCcBcc(needFocus);
addSubject();
-
- //set focus to Cc field.
- HbAction* ccBccAction = qobject_cast<HbAction*>(this->sender());
- if(mCcBccAction)
- {
- setFocus(mCcField);
- }
-
- // remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions
- if(mCcBccAction)
- {
- HbMenu* mainmenu = this->menu();
- mainmenu->removeAction(mCcBccAction);
- mCcBccAction->setParent(NULL);
- delete mCcBccAction;
- }
-
- this->updateGeometry();
}
-void MsgUnifiedEditorView::updateOtherRecipientCount(bool state)
-{
- HbGroupBox* groupBox = qobject_cast<HbGroupBox*>(sender());
- if(groupBox)
- {
- if(!state)
- {
- groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND);
- }
- else
- {
- int addrCount = mCcField->addressCount();
- addrCount += mBccField->addressCount();
- if(addrCount > 0)
- {
- groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount));
- }
- }
- }
-}
-
-void MsgUnifiedEditorView::changePriority()
-{
- HbAction* action = qobject_cast<HbAction*>(sender());
-
- ConvergedMessage::Priority priority = ConvergedMessage::Normal;
- if(action)
- {
- int data = action->data().toInt();
- priority = ConvergedMessage::Priority(data);
- }
-
- addSubject();
- mSubjectField->setPriority(priority);
-}
-
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::deleteMessage
+// @see header file
+//---------------------------------------------------------------
void MsgUnifiedEditorView::deleteMessage()
{
HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this,
@@ -775,76 +476,26 @@
HbMessageBox::Delete | HbMessageBox::Cancel);
}
-void MsgUnifiedEditorView::removeAttachmentContainer()
-{
- if(mAttachmentContainer)
- {
- mMainLayout->removeItem(mAttachmentContainer);
- mAttachmentContainer->setParent(NULL);
- delete mAttachmentContainer;
- mAttachmentContainer = NULL;
- }
-}
-
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::addAttachments
+// @see header file
+//---------------------------------------------------------------
void MsgUnifiedEditorView::addAttachments(QStringList files)
{
- int fcount = files.count();
- int i=0;
- for(i=0; i<fcount; i++)
- {
- int status = addAttachment(files.at(i));
- if(status == MsgAttachmentContainer::EAddSizeExceed)
- {
- QString displayStr = QString(LOC_UNABLE_TO_ADD_ATTACHMENTS)
- .arg(fcount-i).arg(fcount);
- HbNotificationDialog::launchDialog(displayStr);
- break;
- }
- }
+ mScrollArea->addAttachments(files);
}
-int MsgUnifiedEditorView::addAttachment(const QString& filepath)
-{
- // do nothing if filepath is empty
- if(filepath.isEmpty())
- {
- return MsgAttachmentContainer::EAddSuccess;
- }
-
- if(!mAttachmentContainer)
- {
- mAttachmentContainer = new MsgAttachmentContainer( mContentWidget);
- connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()),
- this, SLOT(removeAttachmentContainer()));
- connect(mAttachmentContainer, SIGNAL(contentChanged()),
- mMsgMonitor, SLOT(handleContentChange()));
- connect(mAttachmentContainer, SIGNAL(contentChanged()),
- this,SLOT(onContentChanged()));
-
- int index = mMainLayout->count() - 1;
- mMainLayout->insertItem(index,mAttachmentContainer);
- }
-
- int ret = mAttachmentContainer->addAttachment(filepath);
- if(ret != MsgAttachmentContainer::EAddSuccess)
- {
- // delete container, if it is empty
- if(mAttachmentContainer->count() == 0)
- {
- removeAttachmentContainer();
- }
- }
- return ret;
-}
-
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::send
+// @see header file
+//---------------------------------------------------------------
void MsgUnifiedEditorView::send()
{
activateInputBlocker();
-
+
// first run the address validation tests
- if( !mToField->validateContacts() ||
- (mCcField && !mCcField->validateContacts()) ||
- (mBccField && !mBccField->validateContacts()) )
+ if(!mScrollArea->contactsValid() ||
+ !MsgUnifiedEditorMonitor::readyForSend())
{
deactivateInputBlocker();
return;
@@ -855,38 +506,7 @@
ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
msg.setMessageType(messageType);
- // we need to remove duplicate addresses
- bool removeDuplicates = true;
- ConvergedMessageAddressList addresses =
- mToField->addresses(removeDuplicates);
- if(messageType == ConvergedMessage::Sms &&
- addresses.isEmpty())
- {
- // no recipient specified for sms, do not send msg
- deactivateInputBlocker();
- return;
- }
- ConvergedMessageAddressList ccAddresses;
- ConvergedMessageAddressList bccAddresses;
- if(mCcField)
- {
- ccAddresses = mCcField->addresses(removeDuplicates);
- }
- if(mBccField)
- {
- bccAddresses = mBccField->addresses(removeDuplicates);
- }
- if( messageType == ConvergedMessage::Mms &&
- addresses.isEmpty() &&
- ccAddresses.isEmpty() &&
- bccAddresses.isEmpty())
- {
- // no recipient specified for mms, do not send msg
- deactivateInputBlocker();
- return;
- }
-
//close vkb before switching view.
mVkbHost->closeKeypad(true);
@@ -901,7 +521,7 @@
MsgSendUtil *sendUtil = new MsgSendUtil(this);
int sendResult = sendUtil->send(msg);
delete sendUtil;
-
+
// all checks and validations happen before send
if( sendResult == KErrNone)
{
@@ -917,54 +537,34 @@
UniEditorPluginInterface* pluginInterface =
mPluginLoader->getUniEditorPlugin(messageType);
- //TODO delete the entry
+ //delete the entry
pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
}
- ConvergedMessageAddressList addrList = addresses;
- QString receipient;
-
+ ConvergedMessageAddressList addrList = msg.toAddressList() +
+ msg.ccAddressList() +
+ msg.bccAddressList();
+
int recepientCount = addrList.count();
- if(recepientCount)
- {
- receipient = addrList.at(0)->address();
- }
- if( mCcField && mBccField)
- {
- addrList = ccAddresses;
- int ccCount = addrList.count();
- recepientCount += ccCount;
- if(ccCount)
- {
- receipient = addrList.at(0)->address();
- }
+ QVariantList params;
- addrList = bccAddresses;
- int bccCount = addrList.count();
- recepientCount += bccCount;
- if(bccCount)
- {
- receipient = addrList.at(0)->address();
- }
+ if(recepientCount == 1 )
+ {
+ params << MsgBaseView::CV; // target view
+ params << MsgBaseView::UNIEDITOR; // source view
+ QString receipient = addrList.at(0)->address();
+ params << receipient;
}
-
- QVariantList params;
-
- if(recepientCount == 1 )
+ else
{
- params << MsgBaseView::CV; // target view
- params << MsgBaseView::UNIEDITOR; // source view
-
- params << receipient;
- }
- else
- {
- params << MsgBaseView::CLV;// target view
- params << MsgBaseView::UNIEDITOR; // source view
+ params << MsgBaseView::CLV;// target view
+ params << MsgBaseView::UNIEDITOR; // source view
}
deactivateInputBlocker();
emit switchView(params);
+
+ mCanSaveToDrafts = false;
}
else
{
@@ -974,19 +574,23 @@
if (messageType == ConvergedMessage::Sms)
{
HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE,
- this,SLOT(onDialogSmsSettings(HbAction*)),
- HbMessageBox::Ok | HbMessageBox::Cancel);
+ this,SLOT(onDialogSmsSettings(HbAction*)),
+ HbMessageBox::Ok | HbMessageBox::Cancel);
}
else
{
HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE,
- this,SLOT(onDialogMmsSettings(HbAction*)),
- HbMessageBox::Ok | HbMessageBox::Cancel);
+ this,SLOT(onDialogMmsSettings(HbAction*)),
+ HbMessageBox::Ok | HbMessageBox::Cancel);
}
}
}
}
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::packMessage
+// @see header file
+//---------------------------------------------------------------
int MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave)
{
// reset reply-path if originating SME constraint is broken
@@ -1003,157 +607,24 @@
ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
msg.setMessageType(messageType);
- // If isSave is true (save to draft usecase), then don't remove duplicates
- // If isSave is false (send usecase), then remove duplicates
- bool removeDuplicates = !isSave;
- ConvergedMessageAddressList addresses =
- mToField->addresses(removeDuplicates);
- ConvergedMessageAddressList ccAddresses;
- ConvergedMessageAddressList bccAddresses;
- ConvergedMessageAttachmentList mediaList;
- int errorCode = 0;
- //Don't format the addresses for save to drfats case
- if(!isSave)
- {
- formatAddresses(addresses);
- }
-
- msg.addToRecipients(addresses);
- msg.setBodyText(mBody->text());
msg.setDirection(ConvergedMessage::Outgoing);
QDateTime time = QDateTime::currentDateTime();
msg.setTimeStamp(time.toTime_t());
-
- if(messageType == ConvergedMessage::Mms)
- {
- if(mCcField)
- {
- ccAddresses = mCcField->addresses(removeDuplicates);
- }
-
- if(mBccField)
- {
- bccAddresses = mBccField->addresses(removeDuplicates);
- }
-
- if(removeDuplicates)
- {
- int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits();
- //comapre cc and to field,remove duplicate from cc
- foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
- {
- foreach(ConvergedMessageAddress *toAddress,addresses)
- {
- if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
- {
- ccAddresses.removeOne(ccAddress);
- }
- }
- }
- //comapre bcc and cc field,remove duplicate from bcc
- foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
- {
- foreach(ConvergedMessageAddress *ccAddress,ccAddresses)
- {
- if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount)))
- {
- bccAddresses.removeOne(bccAddress);
- }
- }
- }
- //comapre bcc and to field,remove duplicate from bcc
- foreach(ConvergedMessageAddress *bccAddress,bccAddresses)
- {
- foreach(ConvergedMessageAddress *toAddress,addresses)
- {
- if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount)))
- {
- bccAddresses.removeOne(bccAddress);
- }
- }
- }
- }
-
- if(ccAddresses.count()>0)
- {
- //Don't format the addresses for save to drfats case
- if(!isSave)
- {
- formatAddresses(ccAddresses);
- }
- msg.addCcRecipients(ccAddresses);
- }
- if(bccAddresses.count()>0)
- {
- //Don't format the addresses for save to drfats case
- if(!isSave)
- {
- formatAddresses(bccAddresses);
- }
- msg.addBccRecipients(bccAddresses);
- }
- if(mSubjectField)
- {
- msg.setSubject(mSubjectField->text());
- msg.setPriority(mSubjectField->priority());
- }
-
- QStringList mediafiles(mBody->mediaContent());
- if (!mediafiles.isEmpty())
- {
- for (int i = 0; i < mediafiles.size(); ++i)
- {
- if(QFile::exists(mediafiles.at(i)))
- {
- ConvergedMessageAttachment* attachment =
- new ConvergedMessageAttachment(
- mediafiles.at(i),
- ConvergedMessageAttachment::EInline);
- mediaList << attachment;
- }
- else
- { mBody->removeMediaContent(mediafiles.at(i));
- errorCode = KErrNotFound;
- }
- }
-
- }
- if(mediaList.count() > 0)
- {
- msg.addAttachments(mediaList);
- }
- }
-
- // sms/mms attachment list
- ConvergedMessageAttachmentList attachmentList;
- if(mAttachmentContainer)
- {
- MsgUnifiedEditorAttachmentList editorAttachmentList =
- mAttachmentContainer->attachmentList();
- for (int i = 0; i < editorAttachmentList.count(); ++i)
- {
- if(QFile::exists(editorAttachmentList.at(i)->path()))
- {
- ConvergedMessageAttachment* attachment =
- new ConvergedMessageAttachment(
- editorAttachmentList.at(i)->path(),
- ConvergedMessageAttachment::EAttachment);
- attachmentList << attachment;
- }
- else
- {
- mAttachmentContainer->deleteAttachment(editorAttachmentList.at(i));
- errorCode = KErrNotFound;
- }
- }
- }
- if(attachmentList.count() > 0)
- {
- msg.addAttachments(attachmentList);
- }
- return errorCode;
+
+
+ //pack message data from mscrollarea.
+ int errorCode = mScrollArea->packMessage(msg,isSave);
+
+ //pack message data from body editor.
+ mBodyEditor->packMessage(msg);
+
+ return errorCode;
}
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::saveContentToDrafts
+// @see header file
+//---------------------------------------------------------------
int MsgUnifiedEditorView::saveContentToDrafts()
{
if(!mCanSaveToDrafts)
@@ -1164,8 +635,6 @@
activateInputBlocker();
ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
- ConvergedMessageAddressList addresses = mToField->addresses();
-
UniEditorPluginInterface* pluginInterface = NULL;
if( mOpenedMessageId.getId() != -1)
@@ -1175,77 +644,29 @@
mPluginLoader = new UniEditorPluginLoader(this);
}
- pluginInterface =
- mPluginLoader->getUniEditorPlugin(messageType);
- }
-
- if(messageType == ConvergedMessage::Sms &&
- addresses.isEmpty() &&
- MsgUnifiedEditorMonitor::bodySize() <= 0 &&
- MsgUnifiedEditorMonitor::containerSize() <= 0)
- {
- if(mOpenedMessageId.getId() != -1)
- {
- pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
- }
-
- // if empty msg, do not save
- deactivateInputBlocker();
- return INVALID_MSGID;
+ pluginInterface = mPluginLoader->getUniEditorPlugin(messageType);
}
- ConvergedMessageAddressList ccAddresses;
- ConvergedMessageAddressList bccAddresses;
- if(mCcField)
- {
- ccAddresses = mCcField->addresses();
- }
- if(mBccField)
- {
- bccAddresses = mBccField->addresses();
- }
- int subectSize =0;
- if(mSubjectField)
- {
- subectSize = mSubjectField->text().size();
- }
-
- if( messageType == ConvergedMessage::Mms &&
- addresses.isEmpty() &&
- ccAddresses.isEmpty() &&
- bccAddresses.isEmpty() &&
- subectSize <= 0 &&
- MsgUnifiedEditorMonitor::bodySize() <= 0 &&
- MsgUnifiedEditorMonitor::containerSize() <= 0)
+ // if empty msg, do not save
+ if( MsgUnifiedEditorMonitor::messageSize() <= 0 &&
+ MsgUnifiedEditorMonitor::msgAddressCount() <= 0 )
{
if(mOpenedMessageId.getId() != -1)
{
pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
}
- // if empty msg, do not send
+
deactivateInputBlocker();
return INVALID_MSGID;
}
+
ConvergedMessage msg;
int result = packMessage(msg, true);
if(result == KErrNotFound)
{
HbNotificationDialog::launchDialog(LOC_NOTE_FILES_MISSED_DRAFTS);
- if(messageType == ConvergedMessage::Sms &&
- addresses.isEmpty() &&
- MsgUnifiedEditorMonitor::bodySize() <= 0 &&
- MsgUnifiedEditorMonitor::containerSize() <= 0)
- {
- if(mOpenedMessageId.getId() != -1)
- {
- pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
- }
-
- // if empty msg, do not save
- deactivateInputBlocker();
- return INVALID_MSGID;
- }
}
+
// save to drafts
MsgSendUtil *sendUtil = new MsgSendUtil(this);
int msgId = sendUtil->saveToDrafts(msg);
@@ -1267,13 +688,21 @@
{
HbDeviceNotificationDialog::notification("", LOC_SAVED_TO_DRAFTS);
}
+
+ mCanSaveToDrafts = false;
+
return msgId;
}
+
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::handleKeyEvent
+// @see header file
+//---------------------------------------------------------------
bool MsgUnifiedEditorView::handleKeyEvent(int key)
{
bool eventHandled = false;
- if (Qt::Key_Yes == key && mSendAction->isEnabled()) {
+ if (Qt::Key_Yes == key) {
eventHandled = true;
send();
}
@@ -1281,16 +710,6 @@
return eventHandled;
}
-void MsgUnifiedEditorView::resizeEvent( QGraphicsSceneResizeEvent * event )
-{
- Q_UNUSED(event)
- #ifdef _DEBUG_TRACES_
- qDebug()<<"resize event";
-#endif
-
- mContentWidget->resize(this->rect().width(),this->rect().height()+1);
-}
-
//---------------------------------------------------------------
// MsgUnifiedEditorView::createVCards
// @see header file
@@ -1415,24 +834,7 @@
searchFileName.append(FILE_EXTN);
// check if filename is already used by an attachment in container
- bool alreadyExists = false;
- if(mAttachmentContainer)
- {
- MsgUnifiedEditorAttachmentList attList =
- mAttachmentContainer->attachmentList();
- int attCount = attList.count();
- for(int j=0; j<attCount; j++)
- {
- QFileInfo fileinfo(attList.at(j)->path());
- if(searchFileName == fileinfo.fileName())
- {
- alreadyExists = true;
- break;
- }
- }
- }
-
- if(!alreadyExists)
+ if(!mScrollArea->fileNameInUse(searchFileName))
{
if(i>0)
{
@@ -1447,27 +849,6 @@
return filepath;
}
-void MsgUnifiedEditorView::handleViewExtnActivated(HbListWidgetItem* item)
- {
- QString itemText = item->text();
-
- if(itemText == LOC_PHOTO)
- {
- //launch photo picker.
- fetchImages();
- }
- else if(itemText == LOC_SOUND)
- {
- //launch audio picker
- fetchAudio();
- }
- else if(itemText == LOC_BUSINESS_CARD)
- {
- //launch contact card picker.
- fetchContacts();
- }
-
-}
//---------------------------------------------------------------
// MsgUnifiedEditorView::fetchContacts
@@ -1488,7 +869,7 @@
return;
}
- request->setSynchronous(false); // synchronous
+ request->setSynchronous(false); // asynchronous
// Result handlers
connect (request, SIGNAL(requestOk(const QVariant&)),
@@ -1524,7 +905,7 @@
QCRITICAL_WRITE("AIW-ERROR: NULL request");
return;
}
- request->setSynchronous(false); // synchronous
+ request->setSynchronous(false); // asynchronous
connect(request, SIGNAL(requestOk(const QVariant&)),
this, SLOT(imagesFetched(const QVariant&)));
@@ -1596,7 +977,7 @@
if ( fileList.size()>0 )
{
QString filepath(QDir::toNativeSeparators(fileList.at(0)));
- mBody->setImage(filepath);
+ mScrollArea->setImage(filepath);
}
}
}
@@ -1637,14 +1018,57 @@
}
//---------------------------------------------------------------
-// MsgUnifiedEditorView::setAttachOptionEnabled
+// MsgUnifiedEditorView::enableMenuAction
// @see header file
//--------------------------------------------------------------
-void MsgUnifiedEditorView::setAttachOptionEnabled(
- MsgUnifiedEditorView::TBE_AttachOption opt, bool enable)
+void MsgUnifiedEditorView::enableMenuAction(int action, bool enable)
{
- HbListWidgetItem* wgtItem = mTBExtnContentWidget->item(opt);
- wgtItem->setEnabled(enable);
+ switch(action)
+ {
+ case SOUND:
+ {
+ if(mSoundAction)
+ {
+ mSoundAction->setEnabled(enable);
+ }
+ break;
+ }
+ case PHOTO:
+ {
+ if(mPhotoAction)
+ {
+ mPhotoAction->setEnabled(enable);
+ }
+ break;
+ }
+ case SUBJECT: //subject action has to be removed
+ {
+ // remove mainmenu's "Add Subject" action
+ if(mSubjectAction)
+ {
+ this->menu()->removeAction(mSubjectAction);
+ mSubjectAction->setParent(NULL);
+ delete mSubjectAction;
+ mSubjectAction = NULL;
+ }
+ break;
+ }
+ case CCBCC: //CcBcc action has to be removed
+ {
+ // remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions
+ if(mCcBccAction)
+ {
+ this->menu()->removeAction(mCcBccAction);
+ mCcBccAction->setParent(NULL);
+ delete mCcBccAction;
+ mCcBccAction = NULL;
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
}
//---------------------------------------------------------------
@@ -1655,55 +1079,220 @@
{
hideChrome(true);
+ //get focussed object.
+ HbInputMethod* im = HbInputMethod::activeInputMethod();
+ HbInputFocusObject* focusObj = im->focusObject();
+ if(focusObj)
+ {
+ QObject* obj = focusObj->object();
+ mFocusedWidget = qobject_cast<QGraphicsWidget*>(obj);
+ HbAbstractEdit* editor = qobject_cast<HbAbstractEdit*>(obj);
+ if(editor)
+ {
+ connect(editor,SIGNAL(contentsChanged()),this,SLOT(ensureVisibility()));
+ }
+ }
+
+ QRectF appRect = mVkbHost->applicationArea();
+
+ if(this->mainWindow()->orientation() == Qt::Vertical)
+ {
+ this->setMaximumHeight(appRect.height());
+ mScrollArea->resize(-1,-1);
+ }
+ else
+ {
+ if(mFocusedWidget)
+ {
+ qreal vItemSpacing = 0.0;
+ style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
+
+ mMinHeight = mFocusedWidget->minimumHeight();
+ mMaxHeight = mFocusedWidget->maximumHeight();
+ qreal newHeight = appRect.height()-vItemSpacing-1;
+ mFocusedWidget->setMinimumHeight(newHeight);
+ mFocusedWidget->setMaximumHeight(newHeight);
+ mFocusedWidget->resize(mFocusedWidget->rect().width(),newHeight);
+
+ }
+ }
+
+ //do layouting after some delay.
+ QTimer::singleShot(50,this,SLOT(doLayout()));
+
disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
+ connect(this->mainWindow(),SIGNAL(aboutToChangeOrientation()),this,SLOT(resetLayout()));
}
-
+
//---------------------------------------------------------------
// MsgUnifiedEditorView::vkbClosed
// @see header file
//---------------------------------------------------------------
void MsgUnifiedEditorView::vkbClosed()
{
- hideChrome(false);
+ hideChrome(false);
+
+ resetLayout();
+
+ connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
- connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
+ disconnect(this->mainWindow(),SIGNAL(aboutToChangeOrientation()),this,SLOT(resetLayout()));
+}
+
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::doLayout
+// @see header file
+//---------------------------------------------------------------
+void MsgUnifiedEditorView::doLayout()
+{
+ if(mFocusedWidget && mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusOpened)
+ {
+ if(this->mainWindow()->orientation() == Qt::Vertical)
+ {
+ ensureVisibility();
+ }
+ else
+ {
+ qreal vItemSpacing = 0.0;
+ style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
+
+ if(mScrollArea->isAncestorOf(mFocusedWidget))
+ {
+ QPointF p = mScrollArea->mapFromScene(mFocusedWidget->scenePos());
+ mScrollArea->scrollContentsTo(p,0);
+ mScrollArea->enableScrolling(false);
+ mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
+ }
+
+ QPointF pp = mapFromScene(mFocusedWidget->scenePos());
+ qreal delta = pp.y() - vItemSpacing;
+ this->setTransform(QTransform::fromTranslate(0, -delta), true);
+ }
+ }
}
//---------------------------------------------------------------
-// MsgUnifiedEditorView::vkbAboutToOpen
+// MsgUnifiedEditorView::resetLayout
+// @see header file
+//---------------------------------------------------------------
+void MsgUnifiedEditorView::resetLayout()
+{
+ //disconnect signal from previously focused object.
+ if(mFocusedWidget)
+ {
+ HbAbstractEdit* editor = qobject_cast<HbAbstractEdit*>(mFocusedWidget);
+ disconnect(editor,SIGNAL(contentsChanged()),this,SLOT(ensureVisibility()));
+ }
+
+ if(this->mainWindow()->orientation() == Qt::Vertical)
+ {
+ this->setMaximumHeight(-1);
+ mScrollArea->scrollContentsTo(QPointF(0,0),0);
+ mScrollArea->resize(-1,-1);
+ }
+ else
+ {
+ this->resetTransform();
+
+ if(mFocusedWidget)
+ {
+ if(mMinHeight >0)
+ {
+ mFocusedWidget->setMinimumHeight(mMinHeight);
+ mMinHeight = 0.0;
+ }
+ if(mMaxHeight >0)
+ {
+ mFocusedWidget->setMaximumHeight(mMaxHeight);
+ mMaxHeight = 0.0;
+ }
+
+ if(mScrollArea->isAncestorOf(mFocusedWidget))
+ {
+ mScrollArea->enableScrolling(true);
+ mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAutoHide);
+ mScrollArea->scrollContentsTo(QPointF(0,0),0);
+ }
+
+ mFocusedWidget = NULL;
+ }
+
+ }
+}
+
+//---------------------------------------------------------------
+// MsgUnifiedEditorView::ensureVisibility
// @see header file
//---------------------------------------------------------------
-void MsgUnifiedEditorView::vkbAboutToOpen()
-{
- //This is done to avoid user action on attachment
- //toolbar button when vkb is opening
- mAttachAction->setDisabled(true);
- disconnect(mVkbHost,SIGNAL(aboutToOpen()),
- this,SLOT(vkbAboutToOpen()));
+void MsgUnifiedEditorView::ensureVisibility()
+{
+ if(mFocusedWidget && mVkbHost->keypadStatus() == HbVkbHost::HbVkbStatusOpened)
+ {
+ if(this->mainWindow()->orientation() == Qt::Vertical)
+ {
+ if ( mScrollArea->isAncestorOf(mFocusedWidget))
+ {
+ QRectF scrollRect = mScrollArea->sceneBoundingRect();
+ QRectF editorRect = mFocusedWidget->sceneBoundingRect();
+
+ if (!scrollRect.contains(editorRect) ||
+ scrollRect.intersects(editorRect))
+ {
+
+ if (editorRect.height() < scrollRect.height()) {
+ // Whole editor rect fits into scroll area. Move it there.
+ if (editorRect.bottom() > scrollRect.bottom()) {
+ // Scroll upwards.
+ mScrollArea->ensureVisible(mScrollArea->contentWidget()->mapFromScene(editorRect.bottomLeft()));
+ } else {
+ // Scroll downwards.
+ mScrollArea->ensureVisible(mScrollArea->contentWidget()->mapFromScene(editorRect.topLeft()));
+ }
+ }
+ }
+ }
+ }
+ }
}
-
+
//---------------------------------------------------------------
-// MsgUnifiedEditorView::vkbAboutToClose
+// MsgUnifiedEditorView::focusChanged
// @see header file
//---------------------------------------------------------------
-void MsgUnifiedEditorView::vkbAboutToClose()
-{
- mAttachAction->setDisabled(false);
- connect(mVkbHost,SIGNAL(aboutToOpen()),
- this,SLOT(vkbAboutToOpen()));
+void MsgUnifiedEditorView::focusChanged()
+{
+ //disconnect signal from previously focused object.
+ if(mFocusedWidget)
+ {
+ HbAbstractEdit* editor = qobject_cast<HbAbstractEdit*>(mFocusedWidget);
+ disconnect(editor,SIGNAL(contentsChanged()),this,SLOT(ensureVisibility()));
+ }
+
+ //connect signal for newly focused object.
+ HbInputMethod* im = HbInputMethod::activeInputMethod();
+ HbInputFocusObject* focusObj = im->focusObject();
+ if(focusObj)
+ {
+ QObject* obj = focusObj->object();
+ mFocusedWidget = qobject_cast<QGraphicsWidget*>(obj);
+ HbAbstractEdit* editor = qobject_cast<HbAbstractEdit*>(obj);
+ if(editor)
+ {
+ connect(editor,SIGNAL(contentsChanged()),this,SLOT(ensureVisibility()));
+ }
+ }
}
//---------------------------------------------------------------
// MsgUnifiedEditorView::onAudioSelected
// @see header file
//---------------------------------------------------------------
-void
-MsgUnifiedEditorView::onAudioSelected(QString& filePath)
+void MsgUnifiedEditorView::onAudioSelected(QString& filePath)
{
if (!filePath.isEmpty())
- {
- mBody->setAudio(filePath);
- }
+ {
+ mScrollArea->setAudio(filePath);
+ }
}
//---------------------------------------------------------------
@@ -1730,18 +1319,16 @@
//---------------------------------------------------------------
void MsgUnifiedEditorView::doDelayedConstruction()
{
- addMenu();
createTempFolder();
//Create VKB instance and listen to VKB open and close signals.
- mVkbHost = new HbAbstractVkbHost(this);
+ mVkbHost = new MsgUniEditorVkbHost(this);
+
+ connect(mVkbHost, SIGNAL(focusChanged()), this, SLOT(focusChanged()));
connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened()));
connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed()));
- connect(mVkbHost,SIGNAL(aboutToOpen()),this,SLOT(vkbAboutToOpen()));
- connect(mVkbHost,SIGNAL(aboutToClose()),this,SLOT(vkbAboutToClose()));
disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction()));
-
}
//---------------------------------------------------------------
@@ -1826,7 +1413,6 @@
if (backAction) {
backAction->trigger();
}
-
}
}
@@ -1836,14 +1422,13 @@
void MsgUnifiedEditorView::onDialogSmsSettings(HbAction* action)
{
HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
- if (action == dlg->actions().at(0)) {
-
+ if (action == dlg->actions().at(0))
+ {
QVariantList params;
params << MsgBaseView::MSGSETTINGS;// target view
params << MsgBaseView::UNIEDITOR; // source view
params << MsgSettingsView::SMSView;
emit switchView(params);
-
}
}
@@ -1863,50 +1448,6 @@
}
}
-//---------------------------------------------------------------
-// MsgUnifiedEditorView::enableSendButton
-// @see header file
-//--------------------------------------------------------------
-void MsgUnifiedEditorView::enableSendButton(bool enable)
- {
- if(mSendAction)
- {
- // enable/disable based on only if its disabled/enabled.
- // this check is to avoid unnecessary calls to mSendAction->setEnabled(enable);
- if(mSendAction->isEnabled() != enable )
- mSendAction->setEnabled(enable);
- }
- }
-
-// ----------------------------------------------------------------------------
-// MsgUnifiedEditorView::formatAddresses
-// @see header
-// ----------------------------------------------------------------------------
-void MsgUnifiedEditorView::formatAddresses(
- ConvergedMessageAddressList& addresses)
-{
-
- for(int i=0; i < addresses.count() ;i++ )
- {
- QString addr = addresses[i]->address();
-
- HBufC *tempAddr = XQConversions::qStringToS60Desc(addr);
-
- TPtr ptr = tempAddr->Des();
-
- // Note: This is just to parse spaces etc away from phonenumbers.
- // Ignore EFalse returned for email addresses.
- CommonPhoneParser::ParsePhoneNumber(ptr ,
- CommonPhoneParser::ESMSNumber );
-
- addr = XQConversions::s60DescToQString(tempAddr->Des());
-
- addresses[i]->setAddress(addr);
-
- delete tempAddr;
- }
-}
-
// ----------------------------------------------------------------------------
// MsgUnifiedEditorView::isReplyPathBroken
// @see header
@@ -1916,7 +1457,7 @@
// 1. Never set for MMS
// 2. if additional recipients exits
if( (MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Mms) ||
- (mToField->addressCount() != 1) )
+ (MsgUnifiedEditorMonitor::msgAddressCount() != 1) )
{
// broken
return true;
@@ -1926,9 +1467,16 @@
QString dispName;
int phCount;
int origCntLocalId = MsgContactHandler::resolveContactDisplayName(
- mOriginatingSME, dispName, phCount);
+ mOriginatingSME, dispName, phCount);
int currCntLocalId = -1;
- QString currAddress(mToField->addresses().at(0)->address());
+ QString currAddress;
+ ConvergedMessageAddress* currentAdd = mScrollArea->currentAddress();
+ if(currentAdd)
+ {
+ currAddress = currentAdd->address();
+ delete currentAdd;
+ }
+
if(origCntLocalId != -1)
{
currCntLocalId = MsgContactHandler::resolveContactDisplayName(
@@ -1944,11 +1492,11 @@
}
else
{ // atleast one contact is not present in contacts db
- // direct compare
+ // direct compare
UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils);
bool compareResult = false;
TRAP_IGNORE(
- compareResult = genUtils->MatchPhoneNumberL(
+ compareResult = genUtils->MatchPhoneNumberL(
*XQConversions::qStringToS60Desc(mOriginatingSME),
*XQConversions::qStringToS60Desc(currAddress))
);