diff -r bf7eb7911fc5 -r 997a02608b3a emailuis/nmailui/src/nmeditorheader.cpp --- a/emailuis/nmailui/src/nmeditorheader.cpp Wed Jun 23 18:00:21 2010 +0300 +++ b/emailuis/nmailui/src/nmeditorheader.cpp Tue Jul 06 14:04:34 2010 +0300 @@ -19,7 +19,7 @@ // Layout // These match to the defintions in nmeditorview.docml -static const char *NMUI_EDITOR_CONTAINER = "containerContents"; +static const char *NMUI_EDITOR_CONTAINER = "scrollAreaContents"; static const char *NMUI_EDITOR_SUBJECT_FIELD = "editorSubjectField"; static const char *NMUI_EDITOR_SUBJECT_EDIT = "editorSubjectEdit"; static const char *NMUI_EDITOR_CC_FIELD = "editorCcField"; @@ -31,15 +31,16 @@ static const char *NMUI_EDITOR_PREFIX_CC = "editorCc"; static const char *NMUI_EDITOR_PREFIX_BCC = "editorBcc"; -static const int MaxRows = 10000; +static const int NmMaxRows = 10000; // this timeout seems to be long enough for all cases. see sendDelayedHeaderHeightChanged -static const int LayoutSystemWaitTimer = 500; // 0.5 sec +static const int NmLayoutSystemWaitTimer = 500; // 0.5 sec /*! Constructor */ -NmEditorHeader::NmEditorHeader(HbDocumentLoader *documentLoader) : +NmEditorHeader::NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader) : + QObject(parent), mDocumentLoader(documentLoader), mHeaderHeight(0), mIconVisible(false), @@ -76,52 +77,62 @@ // are hidden and removed from the layout at this phase. HbWidget *contentWidget = qobject_cast(mDocumentLoader->findWidget(NMUI_EDITOR_CONTAINER)); - mLayout = static_cast(contentWidget->layout()); - - // base class QObject takes the deleting responsibility - mToField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_TO); - mCcField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_CC); - mBccField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_BCC); + if (contentWidget) { + mLayout = static_cast(contentWidget->layout()); + + // base class QObject takes the deleting responsibility + mToField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_TO); + mCcField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_CC); + mBccField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_BCC); + + // Sets up editor properties like no prediction, lower case preferred etc. + HbEditorInterface toEditorInterface(mToField->editor()); + HbEditorInterface ccEditorInterface(mCcField->editor()); + HbEditorInterface bccEditorInterface(mBccField->editor()); + toEditorInterface.setUpAsLatinAlphabetOnlyEditor(); + ccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); + bccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); - // Cc field is not shown by default. It needs to be both hidden and removed from the layout. - mCcWidget = qobject_cast(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD)); - mCcWidget->hide(); - mLayout->removeItem(mCcWidget); - - // Bcc field is not shown by default. It needs to be both hidden and removed from the layout. - mBccWidget = qobject_cast(mDocumentLoader->findWidget(NMUI_EDITOR_BCC_FIELD)); - mBccWidget->hide(); - mLayout->removeItem(mBccWidget); - - mSubjectWidget = - qobject_cast(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_FIELD)); - mSubjectLayout = static_cast(mSubjectWidget->layout()); + // Cc field is not shown by default. It needs to be both hidden and removed from the layout. + mCcWidget = qobject_cast(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD)); + mCcWidget->hide(); + mLayout->removeItem(mCcWidget); + + // Bcc field is not shown by default. It needs to be both hidden and removed from the layout. + mBccWidget = qobject_cast(mDocumentLoader->findWidget(NMUI_EDITOR_BCC_FIELD)); + mBccWidget->hide(); + mLayout->removeItem(mBccWidget); - // Add Subject: field - mSubjectEdit = qobject_cast - (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT)); - mSubjectEdit->setMaxRows(MaxRows); - - // Add attachment list - NmAttachmentListWidget *attachmentList = qobject_cast - (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST)); - // Create attachment list handling object - mAttachmentList = new NmAttachmentList(*attachmentList); - mAttachmentList->setParent(this); // ownership changes - attachmentList->hide(); - mLayout->removeItem(attachmentList); - - // Add priority icon - mPriorityIcon = qobject_cast - (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON)); - mPriorityIcon->hide(); - mSubjectLayout->removeItem(mPriorityIcon); - - // follow-up icon is not yet supported - HbLabel *followUpIcon = qobject_cast - (mDocumentLoader->findWidget(NMUI_EDITOR_FOLLOWUP_ICON)); - followUpIcon->hide(); - mSubjectLayout->removeItem(followUpIcon); + mSubjectWidget = + qobject_cast(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_FIELD)); + mSubjectLayout = static_cast(mSubjectWidget->layout()); + + // Add Subject: field + mSubjectEdit = qobject_cast + (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT)); + mSubjectEdit->setMaxRows(NmMaxRows); + + // Add attachment list + NmAttachmentListWidget *attachmentList = qobject_cast + (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST)); + // Create attachment list handling object + mAttachmentList = new NmAttachmentList(*attachmentList); + mAttachmentList->setParent(this); // ownership changes + attachmentList->hide(); + mLayout->removeItem(attachmentList); + + // Add priority icon + mPriorityIcon = qobject_cast + (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON)); + mPriorityIcon->hide(); + mSubjectLayout->removeItem(mPriorityIcon); + + // follow-up icon is not yet supported + HbLabel *followUpIcon = qobject_cast + (mDocumentLoader->findWidget(NMUI_EDITOR_FOLLOWUP_ICON)); + followUpIcon->hide(); + mSubjectLayout->removeItem(followUpIcon); + } } /*! @@ -179,7 +190,7 @@ } /*! - Return the height of the whole header widget. + Return the sum of the header widget heights. This contains all the spacings a well. */ qreal NmEditorHeader::headerHeight() const { @@ -225,7 +236,7 @@ void NmEditorHeader::sendDelayedHeaderHeightChanged() { NM_FUNCTION; - QTimer::singleShot(LayoutSystemWaitTimer, this, SLOT(sendHeaderHeightChanged())); + QTimer::singleShot(NmLayoutSystemWaitTimer, this, SLOT(sendHeaderHeightChanged())); } /*! @@ -289,7 +300,7 @@ { NM_FUNCTION; - bool recipientsFieldsEmpty = true; + bool recipientsFieldsEmpty(true); if (mToField->text().length()) { recipientsFieldsEmpty = false; } @@ -380,7 +391,7 @@ mLayout->insertItem(mLayout->count() - 1, &mAttachmentList->listWidget()); mAttachmentList->listWidget().show(); } - sendDelayedHeaderHeightChanged(); + sendHeaderHeightChanged(); } /*! @@ -439,8 +450,7 @@ void NmEditorHeader::attachmentActivated(int arrayIndex) { NM_FUNCTION; - - // + emit attachmentShortPressed(mAttachmentList->nmIdByIndex(arrayIndex)); }