29 static const char *NMUI_EDITOR_ATTACHMENT_LIST = "attachmentListWidget"; |
29 static const char *NMUI_EDITOR_ATTACHMENT_LIST = "attachmentListWidget"; |
30 static const char *NMUI_EDITOR_PREFIX_TO = "editorTo"; |
30 static const char *NMUI_EDITOR_PREFIX_TO = "editorTo"; |
31 static const char *NMUI_EDITOR_PREFIX_CC = "editorCc"; |
31 static const char *NMUI_EDITOR_PREFIX_CC = "editorCc"; |
32 static const char *NMUI_EDITOR_PREFIX_BCC = "editorBcc"; |
32 static const char *NMUI_EDITOR_PREFIX_BCC = "editorBcc"; |
33 |
33 |
34 static const int MaxRows = 10000; |
34 static const int NmMaxRows = 10000; |
35 |
35 |
36 // this timeout seems to be long enough for all cases. see sendDelayedHeaderHeightChanged |
36 // this timeout seems to be long enough for all cases. see sendDelayedHeaderHeightChanged |
37 static const int LayoutSystemWaitTimer = 500; // 0.5 sec |
37 static const int NmLayoutSystemWaitTimer = 500; // 0.5 sec |
38 |
38 |
39 /*! |
39 /*! |
40 Constructor |
40 Constructor |
41 */ |
41 */ |
42 NmEditorHeader::NmEditorHeader(HbDocumentLoader *documentLoader) : |
42 NmEditorHeader::NmEditorHeader(QObject *parent, HbDocumentLoader *documentLoader) : |
|
43 QObject(parent), |
43 mDocumentLoader(documentLoader), |
44 mDocumentLoader(documentLoader), |
44 mHeaderHeight(0), |
45 mHeaderHeight(0), |
45 mIconVisible(false), |
46 mIconVisible(false), |
46 mSubjectEdit(NULL), |
47 mSubjectEdit(NULL), |
47 mRecipientFieldsEmpty(true), |
48 mRecipientFieldsEmpty(true), |
74 |
75 |
75 // Load widgets from docml and construct handlers. Those widgets that are not shown by default |
76 // Load widgets from docml and construct handlers. Those widgets that are not shown by default |
76 // are hidden and removed from the layout at this phase. |
77 // are hidden and removed from the layout at this phase. |
77 HbWidget *contentWidget = |
78 HbWidget *contentWidget = |
78 qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CONTAINER)); |
79 qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CONTAINER)); |
79 mLayout = static_cast<QGraphicsLinearLayout *>(contentWidget->layout()); |
80 if (contentWidget) { |
80 |
81 mLayout = static_cast<QGraphicsLinearLayout *>(contentWidget->layout()); |
81 // base class QObject takes the deleting responsibility |
82 |
82 mToField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_TO); |
83 // base class QObject takes the deleting responsibility |
83 mCcField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_CC); |
84 mToField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_TO); |
84 mBccField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_BCC); |
85 mCcField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_CC); |
85 |
86 mBccField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_BCC); |
86 // Cc field is not shown by default. It needs to be both hidden and removed from the layout. |
87 |
87 mCcWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD)); |
88 // Sets up editor properties like no prediction, lower case preferred etc. |
88 mCcWidget->hide(); |
89 HbEditorInterface toEditorInterface(mToField->editor()); |
89 mLayout->removeItem(mCcWidget); |
90 HbEditorInterface ccEditorInterface(mCcField->editor()); |
90 |
91 HbEditorInterface bccEditorInterface(mBccField->editor()); |
91 // Bcc field is not shown by default. It needs to be both hidden and removed from the layout. |
92 toEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
92 mBccWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_BCC_FIELD)); |
93 ccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
93 mBccWidget->hide(); |
94 bccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
94 mLayout->removeItem(mBccWidget); |
95 |
95 |
96 // Cc field is not shown by default. It needs to be both hidden and removed from the layout. |
96 mSubjectWidget = |
97 mCcWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD)); |
97 qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_FIELD)); |
98 mCcWidget->hide(); |
98 mSubjectLayout = static_cast<QGraphicsLinearLayout *>(mSubjectWidget->layout()); |
99 mLayout->removeItem(mCcWidget); |
99 |
100 |
100 // Add Subject: field |
101 // Bcc field is not shown by default. It needs to be both hidden and removed from the layout. |
101 mSubjectEdit = qobject_cast<NmHtmlLineEdit *> |
102 mBccWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_BCC_FIELD)); |
102 (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT)); |
103 mBccWidget->hide(); |
103 mSubjectEdit->setMaxRows(MaxRows); |
104 mLayout->removeItem(mBccWidget); |
104 |
105 |
105 // Add attachment list |
106 mSubjectWidget = |
106 NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *> |
107 qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_FIELD)); |
107 (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST)); |
108 mSubjectLayout = static_cast<QGraphicsLinearLayout *>(mSubjectWidget->layout()); |
108 // Create attachment list handling object |
109 |
109 mAttachmentList = new NmAttachmentList(*attachmentList); |
110 // Add Subject: field |
110 mAttachmentList->setParent(this); // ownership changes |
111 mSubjectEdit = qobject_cast<NmHtmlLineEdit *> |
111 attachmentList->hide(); |
112 (mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT)); |
112 mLayout->removeItem(attachmentList); |
113 mSubjectEdit->setMaxRows(NmMaxRows); |
113 |
114 |
114 // Add priority icon |
115 // Add attachment list |
115 mPriorityIcon = qobject_cast<HbLabel *> |
116 NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *> |
116 (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON)); |
117 (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST)); |
117 mPriorityIcon->hide(); |
118 // Create attachment list handling object |
118 mSubjectLayout->removeItem(mPriorityIcon); |
119 mAttachmentList = new NmAttachmentList(*attachmentList); |
119 |
120 mAttachmentList->setParent(this); // ownership changes |
120 // follow-up icon is not yet supported |
121 attachmentList->hide(); |
121 HbLabel *followUpIcon = qobject_cast<HbLabel *> |
122 mLayout->removeItem(attachmentList); |
122 (mDocumentLoader->findWidget(NMUI_EDITOR_FOLLOWUP_ICON)); |
123 |
123 followUpIcon->hide(); |
124 // Add priority icon |
124 mSubjectLayout->removeItem(followUpIcon); |
125 mPriorityIcon = qobject_cast<HbLabel *> |
|
126 (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON)); |
|
127 mPriorityIcon->hide(); |
|
128 mSubjectLayout->removeItem(mPriorityIcon); |
|
129 |
|
130 // follow-up icon is not yet supported |
|
131 HbLabel *followUpIcon = qobject_cast<HbLabel *> |
|
132 (mDocumentLoader->findWidget(NMUI_EDITOR_FOLLOWUP_ICON)); |
|
133 followUpIcon->hide(); |
|
134 mSubjectLayout->removeItem(followUpIcon); |
|
135 } |
125 } |
136 } |
126 |
137 |
127 /*! |
138 /*! |
128 Create signal - slot connections. |
139 Create signal - slot connections. |
129 */ |
140 */ |