20 // Layout |
20 // Layout |
21 // These match to the defintions in nmeditorview.docml |
21 // These match to the defintions in nmeditorview.docml |
22 static const char *NMUI_EDITOR_CONTAINER = "scrollAreaContents"; |
22 static const char *NMUI_EDITOR_CONTAINER = "scrollAreaContents"; |
23 static const char *NMUI_EDITOR_SUBJECT_FIELD = "editorSubjectField"; |
23 static const char *NMUI_EDITOR_SUBJECT_FIELD = "editorSubjectField"; |
24 static const char *NMUI_EDITOR_SUBJECT_EDIT = "editorSubjectEdit"; |
24 static const char *NMUI_EDITOR_SUBJECT_EDIT = "editorSubjectEdit"; |
|
25 static const char *NMUI_EDITOR_TO_FIELD = "editorToField"; |
25 static const char *NMUI_EDITOR_CC_FIELD = "editorCcField"; |
26 static const char *NMUI_EDITOR_CC_FIELD = "editorCcField"; |
26 static const char *NMUI_EDITOR_BCC_FIELD = "editorBccField"; |
27 static const char *NMUI_EDITOR_BCC_FIELD = "editorBccField"; |
27 static const char *NMUI_EDITOR_PRIORITY_ICON = "editPriorityIcon"; |
28 static const char *NMUI_EDITOR_PRIORITY_ICON = "editPriorityIcon"; |
28 static const char *NMUI_EDITOR_FOLLOWUP_ICON = "editFollowUpIcon"; |
29 static const char *NMUI_EDITOR_FOLLOWUP_ICON = "editFollowUpIcon"; |
29 static const char *NMUI_EDITOR_ATTACHMENT_LIST = "attachmentListWidget"; |
30 static const char *NMUI_EDITOR_ATTACHMENT_LIST = "attachmentListWidget"; |
37 static const int NmLayoutSystemWaitTimer = 500; // 0.5 sec |
38 static const int NmLayoutSystemWaitTimer = 500; // 0.5 sec |
38 |
39 |
39 /*! |
40 /*! |
40 Constructor |
41 Constructor |
41 */ |
42 */ |
42 NmEditorHeader::NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader) : |
43 NmEditorHeader::NmEditorHeader( |
|
44 QObject *parent, NmApplication &application, HbDocumentLoader *documentLoader) : |
43 QObject(parent), |
45 QObject(parent), |
|
46 mApplication(application), |
44 mDocumentLoader(documentLoader), |
47 mDocumentLoader(documentLoader), |
45 mHeaderHeight(0), |
48 mHeaderHeight(0), |
46 mIconVisible(false), |
49 mIconVisible(false), |
47 mSubjectEdit(NULL), |
50 mSubjectEdit(NULL), |
48 mRecipientFieldsEmpty(true), |
51 mRecipientFieldsEmpty(true), |
91 HbEditorInterface bccEditorInterface(mBccField->editor()); |
94 HbEditorInterface bccEditorInterface(mBccField->editor()); |
92 toEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
95 toEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
93 ccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
96 ccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
94 bccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
97 bccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
95 |
98 |
|
99 mToWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_TO_FIELD)); |
|
100 |
96 // Cc field is not shown by default. It needs to be both hidden and removed from the layout. |
101 // Cc field is not shown by default. It needs to be both hidden and removed from the layout. |
97 mCcWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD)); |
102 mCcWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD)); |
98 mCcWidget->hide(); |
103 mCcWidget->hide(); |
99 mLayout->removeItem(mCcWidget); |
104 mLayout->removeItem(mCcWidget); |
100 |
105 |
111 mSubjectEdit = qobject_cast<NmHtmlLineEdit *> |
116 mSubjectEdit = qobject_cast<NmHtmlLineEdit *> |
112 (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT)); |
117 (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT)); |
113 mSubjectEdit->setMaxRows(NmMaxRows); |
118 mSubjectEdit->setMaxRows(NmMaxRows); |
114 |
119 |
115 // Add attachment list |
120 // Add attachment list |
116 NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *> |
121 mAttachmentListWidget = qobject_cast<NmAttachmentListWidget *> |
117 (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST)); |
122 (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST)); |
118 // Create attachment list handling object |
123 // Create attachment list handling object |
119 mAttachmentList = new NmAttachmentList(*attachmentList); |
124 mAttachmentList = new NmAttachmentList(*mAttachmentListWidget); |
120 mAttachmentList->setParent(this); // ownership changes |
125 mAttachmentList->setParent(this); // ownership changes |
121 attachmentList->hide(); |
126 mAttachmentListWidget->hide(); |
122 mLayout->removeItem(attachmentList); |
127 mLayout->removeItem(&mAttachmentList->listWidget()); |
123 |
128 |
124 // Add priority icon |
129 // Add priority icon |
125 mPriorityIcon = qobject_cast<HbLabel *> |
130 mPriorityIcon = qobject_cast<HbLabel *> |
126 (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON)); |
131 (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON)); |
127 mPriorityIcon->hide(); |
132 mPriorityIcon->hide(); |
248 qreal hHeight = headerHeight(); |
253 qreal hHeight = headerHeight(); |
249 if (mHeaderHeight != hHeight) { |
254 if (mHeaderHeight != hHeight) { |
250 mHeaderHeight = hHeight; |
255 mHeaderHeight = hHeight; |
251 emit headerHeightChanged(mHeaderHeight); |
256 emit headerHeightChanged(mHeaderHeight); |
252 } |
257 } |
|
258 } |
|
259 |
|
260 /*! |
|
261 Because header filds have fixed size policy. This function must be called to set |
|
262 new width for every header field when orintation has been changed. |
|
263 */ |
|
264 void NmEditorHeader::adjustHeaderWidth() |
|
265 { |
|
266 NM_FUNCTION; |
|
267 |
|
268 int newWidth = mApplication.screenSize().width(); |
|
269 mToWidget->setPreferredWidth(newWidth); |
|
270 mCcWidget->setPreferredWidth(newWidth); |
|
271 mBccWidget->setPreferredWidth(newWidth); |
|
272 mSubjectWidget->setPreferredWidth(newWidth); |
|
273 mAttachmentListWidget->setPreferredWidth(newWidth); |
|
274 mSubjectWidget->setPreferredWidth(newWidth); |
253 } |
275 } |
254 |
276 |
255 /*! |
277 /*! |
256 Return pointer to to edit |
278 Return pointer to to edit |
257 */ |
279 */ |
384 const QString &fileName, const QString &fileSize, const NmId &nmid) |
406 const QString &fileName, const QString &fileSize, const NmId &nmid) |
385 { |
407 { |
386 NM_FUNCTION; |
408 NM_FUNCTION; |
387 |
409 |
388 mAttachmentList->insertAttachment(fileName, fileSize, nmid); |
410 mAttachmentList->insertAttachment(fileName, fileSize, nmid); |
|
411 |
389 if (!mAttachmentList->listWidget().isVisible()) { |
412 if (!mAttachmentList->listWidget().isVisible()) { |
390 // attachment list is inserted just before the body widget (see docml). |
413 // attachment list is inserted just before the body widget (see docml). |
391 mLayout->insertItem(mLayout->count() - 1, &mAttachmentList->listWidget()); |
414 mLayout->insertItem(mLayout->count() - 1, &mAttachmentList->listWidget()); |
392 mAttachmentList->listWidget().show(); |
415 mAttachmentList->listWidget().show(); |
393 } |
416 } |
|
417 |
394 sendHeaderHeightChanged(); |
418 sendHeaderHeightChanged(); |
395 } |
419 } |
396 |
420 |
397 /*! |
421 /*! |
398 Remove attachment from the list. This function is used when |
422 Remove attachment from the list. This function is used when |
462 NM_FUNCTION; |
486 NM_FUNCTION; |
463 |
487 |
464 // Remove selected attachment |
488 // Remove selected attachment |
465 emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point); |
489 emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point); |
466 } |
490 } |
467 |
491 |
|
492 /*! |
|
493 This slot is called when scroll position has been changed. |
|
494 Function set new positions for header fields so that header stays visible |
|
495 when body is scrolled horizontally. |
|
496 */ |
|
497 void NmEditorHeader::repositHeader(const QPointF &scrollPosition) |
|
498 { |
|
499 NM_FUNCTION; |
|
500 |
|
501 QTransform tr; |
|
502 tr.translate(scrollPosition.x(),0); |
|
503 mToWidget->setTransform(tr); |
|
504 mCcWidget->setTransform(tr); |
|
505 mBccWidget->setTransform(tr); |
|
506 mSubjectWidget->setTransform(tr); |
|
507 mAttachmentListWidget->setTransform(tr); |
|
508 } |
|
509 |