author | hgs |
Thu, 30 Sep 2010 11:43:07 +0300 | |
changeset 74 | 6c59112cfd31 |
parent 66 | 084b5b1f02a7 |
permissions | -rw-r--r-- |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
43 | 14 |
* Description: Message editor header container class. Collects the header widgets. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include "nmuiheaders.h" |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
// Layout |
43 | 21 |
// These match to the defintions in nmeditorview.docml |
48 | 22 |
static const char *NMUI_EDITOR_CONTAINER = "scrollAreaContents"; |
43 | 23 |
static const char *NMUI_EDITOR_SUBJECT_FIELD = "editorSubjectField"; |
24 |
static const char *NMUI_EDITOR_SUBJECT_EDIT = "editorSubjectEdit"; |
|
74 | 25 |
static const char *NMUI_EDITOR_SUBJECT_LABEL = "editorSubjectLabel"; |
51 | 26 |
static const char *NMUI_EDITOR_TO_FIELD = "editorToField"; |
43 | 27 |
static const char *NMUI_EDITOR_CC_FIELD = "editorCcField"; |
28 |
static const char *NMUI_EDITOR_BCC_FIELD = "editorBccField"; |
|
29 |
static const char *NMUI_EDITOR_PRIORITY_ICON = "editPriorityIcon"; |
|
30 |
static const char *NMUI_EDITOR_FOLLOWUP_ICON = "editFollowUpIcon"; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
static const char *NMUI_EDITOR_ATTACHMENT_LIST = "attachmentListWidget"; |
43 | 32 |
static const char *NMUI_EDITOR_PREFIX_TO = "editorTo"; |
33 |
static const char *NMUI_EDITOR_PREFIX_CC = "editorCc"; |
|
34 |
static const char *NMUI_EDITOR_PREFIX_BCC = "editorBcc"; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
|
47 | 36 |
static const int NmMaxRows = 10000; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
|
44 | 38 |
// this timeout seems to be long enough for all cases. see sendDelayedHeaderHeightChanged |
47 | 39 |
static const int NmLayoutSystemWaitTimer = 500; // 0.5 sec |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
Constructor |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
*/ |
51 | 44 |
NmEditorHeader::NmEditorHeader( |
45 |
QObject *parent, NmApplication &application, HbDocumentLoader *documentLoader) : |
|
47 | 46 |
QObject(parent), |
51 | 47 |
mApplication(application), |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
mDocumentLoader(documentLoader), |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
mHeaderHeight(0), |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
mIconVisible(false), |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
mSubjectEdit(NULL), |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
mRecipientFieldsEmpty(true), |
40 | 53 |
mAttachmentList(NULL), |
54 |
mToField(NULL), |
|
55 |
mCcField(NULL), |
|
56 |
mBccField(NULL), |
|
57 |
mCcBccFieldVisible(false) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
{ |
43 | 59 |
NM_FUNCTION; |
60 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
loadWidgets(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
createConnections(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
65 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
66 |
Destructor |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
NmEditorHeader::~NmEditorHeader() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
{ |
43 | 70 |
NM_FUNCTION; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
Load widgets from XML for the header. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
void NmEditorHeader::loadWidgets() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
{ |
43 | 78 |
NM_FUNCTION; |
79 |
||
80 |
// Load widgets from docml and construct handlers. Those widgets that are not shown by default |
|
81 |
// are hidden and removed from the layout at this phase. |
|
82 |
HbWidget *contentWidget = |
|
83 |
qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CONTAINER)); |
|
47 | 84 |
if (contentWidget) { |
85 |
mLayout = static_cast<QGraphicsLinearLayout *>(contentWidget->layout()); |
|
86 |
||
87 |
// base class QObject takes the deleting responsibility |
|
88 |
mToField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_TO); |
|
89 |
mCcField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_CC); |
|
90 |
mBccField = new NmRecipientField(this, *mDocumentLoader, NMUI_EDITOR_PREFIX_BCC); |
|
74 | 91 |
// Connection for adjusting recipient field labels. Connection done earlier than other connections |
92 |
// so that we don't miss signal. |
|
93 |
connect(mToField->editor(), SIGNAL(layoutChanged ()), this, SLOT(toFieldLayoutReady())); |
|
47 | 94 |
|
95 |
// Sets up editor properties like no prediction, lower case preferred etc. |
|
96 |
HbEditorInterface toEditorInterface(mToField->editor()); |
|
97 |
HbEditorInterface ccEditorInterface(mCcField->editor()); |
|
98 |
HbEditorInterface bccEditorInterface(mBccField->editor()); |
|
99 |
toEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
|
100 |
ccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
|
101 |
bccEditorInterface.setUpAsLatinAlphabetOnlyEditor(); |
|
40 | 102 |
|
51 | 103 |
mToWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_TO_FIELD)); |
104 |
||
47 | 105 |
// Cc field is not shown by default. It needs to be both hidden and removed from the layout. |
106 |
mCcWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_CC_FIELD)); |
|
107 |
mCcWidget->hide(); |
|
108 |
mLayout->removeItem(mCcWidget); |
|
109 |
||
110 |
// Bcc field is not shown by default. It needs to be both hidden and removed from the layout. |
|
111 |
mBccWidget = qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_BCC_FIELD)); |
|
112 |
mBccWidget->hide(); |
|
113 |
mLayout->removeItem(mBccWidget); |
|
43 | 114 |
|
47 | 115 |
mSubjectWidget = |
116 |
qobject_cast<HbWidget *>(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_FIELD)); |
|
117 |
mSubjectLayout = static_cast<QGraphicsLinearLayout *>(mSubjectWidget->layout()); |
|
74 | 118 |
mSubjectLabel = |
119 |
qobject_cast<HbLabel *>(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_LABEL)); |
|
47 | 120 |
|
121 |
// Add Subject: field |
|
122 |
mSubjectEdit = qobject_cast<NmHtmlLineEdit *> |
|
123 |
(mDocumentLoader->findWidget(NMUI_EDITOR_SUBJECT_EDIT)); |
|
124 |
mSubjectEdit->setMaxRows(NmMaxRows); |
|
125 |
||
126 |
// Add attachment list |
|
51 | 127 |
mAttachmentListWidget = qobject_cast<NmAttachmentListWidget *> |
47 | 128 |
(mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST)); |
129 |
// Create attachment list handling object |
|
51 | 130 |
mAttachmentList = new NmAttachmentList(*mAttachmentListWidget); |
47 | 131 |
mAttachmentList->setParent(this); // ownership changes |
51 | 132 |
mAttachmentListWidget->hide(); |
57 | 133 |
mLayout->removeItem(&mAttachmentList->listWidget()); |
47 | 134 |
|
135 |
// Add priority icon |
|
136 |
mPriorityIcon = qobject_cast<HbLabel *> |
|
137 |
(mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON)); |
|
138 |
mPriorityIcon->hide(); |
|
139 |
mSubjectLayout->removeItem(mPriorityIcon); |
|
140 |
||
141 |
// follow-up icon is not yet supported |
|
142 |
HbLabel *followUpIcon = qobject_cast<HbLabel *> |
|
143 |
(mDocumentLoader->findWidget(NMUI_EDITOR_FOLLOWUP_ICON)); |
|
144 |
followUpIcon->hide(); |
|
145 |
mSubjectLayout->removeItem(followUpIcon); |
|
146 |
} |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
147 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
148 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
149 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
150 |
Create signal - slot connections. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
151 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
152 |
void NmEditorHeader::createConnections() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
153 |
{ |
43 | 154 |
NM_FUNCTION; |
155 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
// Signals for checking if the recipient fields have text. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
connect(mToField, SIGNAL(textChanged(const QString &)), |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
158 |
this, SLOT(editorContentChanged())); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
159 |
connect(mCcField, SIGNAL(textChanged(const QString &)), |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
160 |
this, SLOT(editorContentChanged())); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
161 |
connect(mBccField, SIGNAL(textChanged(const QString &)), |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
162 |
this, SLOT(editorContentChanged())); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
163 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
164 |
// Signals for handling the recipient field expanding |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
165 |
connect(mToField, SIGNAL(textChanged(const QString &)), |
43 | 166 |
this, SLOT(sendDelayedHeaderHeightChanged())); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
connect(mCcField, SIGNAL(textChanged(const QString &)), |
43 | 168 |
this, SLOT(sendDelayedHeaderHeightChanged())); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
connect(mBccField, SIGNAL(textChanged(const QString &)), |
43 | 170 |
this, SLOT(sendDelayedHeaderHeightChanged())); |
171 |
connect(mSubjectEdit, SIGNAL(contentsChanged()), this, SLOT(sendDelayedHeaderHeightChanged())); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
172 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
173 |
// Signals for handling the attachment list |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
174 |
connect(&mAttachmentList->listWidget(), SIGNAL(itemActivated(int)), |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
175 |
this, SLOT(attachmentActivated(int))); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
176 |
connect(&mAttachmentList->listWidget(), SIGNAL(longPressed(int, QPointF)), |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
177 |
this, SLOT(attachmentLongPressed(int, QPointF))); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
178 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
179 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
180 |
/*! |
40 | 181 |
Show or hide recipient field |
182 |
*/ |
|
183 |
void NmEditorHeader::setFieldVisibility(bool isVisible) |
|
184 |
{ |
|
185 |
if ( mCcBccFieldVisible != isVisible ) { |
|
186 |
mCcBccFieldVisible = isVisible; |
|
187 |
if (mCcBccFieldVisible) { |
|
43 | 188 |
mLayout->insertItem(1, mBccWidget); |
189 |
mLayout->insertItem(1, mCcWidget); |
|
190 |
mCcWidget->show(); |
|
191 |
mBccWidget->show(); |
|
40 | 192 |
} |
193 |
else { |
|
43 | 194 |
mCcWidget->hide(); |
195 |
mBccWidget->hide(); |
|
196 |
mLayout->removeItem(mCcWidget); |
|
197 |
mLayout->removeItem(mBccWidget); |
|
40 | 198 |
} |
44 | 199 |
sendDelayedHeaderHeightChanged(); |
40 | 200 |
} |
201 |
} |
|
202 |
||
203 |
/*! |
|
47 | 204 |
Return the sum of the header widget heights. This contains all the spacings a well. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
205 |
*/ |
43 | 206 |
qreal NmEditorHeader::headerHeight() const |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
207 |
{ |
43 | 208 |
NM_FUNCTION; |
209 |
||
210 |
// get the layout's vertical spacing |
|
211 |
qreal spacing = 0; |
|
66 | 212 |
HbInstance::instance()->style()->parameter("hb-param-margin-gene-middle-vertical", spacing); |
43 | 213 |
|
214 |
// calculate the height |
|
215 |
qreal height = 0; |
|
216 |
||
217 |
height += mToField->height(); // returns widget's geometry height |
|
218 |
height += spacing; |
|
219 |
||
40 | 220 |
if (mCcBccFieldVisible) { |
43 | 221 |
height += mCcField->height(); // returns widget's geometry height |
222 |
height += spacing; |
|
223 |
||
224 |
height += mBccField->height(); // returns widget's geometry height |
|
225 |
height += spacing; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
226 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
227 |
|
43 | 228 |
height += mSubjectWidget->geometry().height(); |
229 |
height += spacing; |
|
230 |
||
231 |
if (mAttachmentList->listWidget().isVisible()) { |
|
232 |
height += mAttachmentList->listWidget().geometry().height(); |
|
233 |
height += spacing; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
234 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
235 |
|
43 | 236 |
return height; |
40 | 237 |
} |
238 |
||
239 |
/*! |
|
44 | 240 |
This is called when the contents of some of the header widgets have been changed. When the |
241 |
contents change the widget's actual size may also change. The header area height is needed to |
|
242 |
calculate the size hints of the body and the scroll area widgets. We need to use a timer to let |
|
243 |
the Orbit FW adjust the heights eg. if the subject and recipient fields are expanded by the FW. |
|
244 |
It would be best to find a solution which doesn't depend on the header area's actual height size |
|
245 |
information. |
|
40 | 246 |
*/ |
43 | 247 |
void NmEditorHeader::sendDelayedHeaderHeightChanged() |
40 | 248 |
{ |
43 | 249 |
NM_FUNCTION; |
47 | 250 |
QTimer::singleShot(NmLayoutSystemWaitTimer, this, SLOT(sendHeaderHeightChanged())); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
251 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
252 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
253 |
/*! |
44 | 254 |
Send a signal that the header area height has been changed if necessary. This is needed for the |
255 |
body and scroll area widgets. See NmEditorTextEdit::setHeaderHeight for more info. |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
256 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
257 |
void NmEditorHeader::sendHeaderHeightChanged() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
258 |
{ |
43 | 259 |
qreal hHeight = headerHeight(); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
260 |
if (mHeaderHeight != hHeight) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
261 |
mHeaderHeight = hHeight; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
262 |
emit headerHeightChanged(mHeaderHeight); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
263 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
264 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
265 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
266 |
/*! |
51 | 267 |
Because header filds have fixed size policy. This function must be called to set |
268 |
new width for every header field when orintation has been changed. |
|
269 |
*/ |
|
270 |
void NmEditorHeader::adjustHeaderWidth() |
|
271 |
{ |
|
272 |
NM_FUNCTION; |
|
273 |
||
274 |
int newWidth = mApplication.screenSize().width(); |
|
275 |
mToWidget->setPreferredWidth(newWidth); |
|
276 |
mCcWidget->setPreferredWidth(newWidth); |
|
277 |
mBccWidget->setPreferredWidth(newWidth); |
|
278 |
mSubjectWidget->setPreferredWidth(newWidth); |
|
279 |
mAttachmentListWidget->setPreferredWidth(newWidth); |
|
280 |
mSubjectWidget->setPreferredWidth(newWidth); |
|
281 |
} |
|
282 |
||
283 |
/*! |
|
40 | 284 |
Return pointer to to edit |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
285 |
*/ |
40 | 286 |
NmRecipientLineEdit* NmEditorHeader::toEdit() const |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
287 |
{ |
43 | 288 |
NM_FUNCTION; |
289 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
290 |
return mToField->editor(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
291 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
292 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
293 |
/*! |
40 | 294 |
Return pointer to cc edit |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
295 |
*/ |
40 | 296 |
NmRecipientLineEdit* NmEditorHeader::ccEdit() const |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
297 |
{ |
43 | 298 |
NM_FUNCTION; |
299 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
300 |
return mCcField->editor(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
301 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
302 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
303 |
/*! |
40 | 304 |
Return pointer to bcc edit |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
305 |
*/ |
40 | 306 |
NmRecipientLineEdit* NmEditorHeader::bccEdit() const |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
307 |
{ |
43 | 308 |
NM_FUNCTION; |
309 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
310 |
return mBccField->editor(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
311 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
312 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
313 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
314 |
Return pointer to subject field |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
315 |
*/ |
40 | 316 |
NmHtmlLineEdit* NmEditorHeader::subjectEdit() const |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
317 |
{ |
43 | 318 |
NM_FUNCTION; |
319 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
320 |
return mSubjectEdit; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
321 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
322 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
323 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
324 |
Checks if recipient editors are empty and emits a signal if |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
325 |
the state is changed. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
326 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
327 |
void NmEditorHeader::editorContentChanged() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
328 |
{ |
43 | 329 |
NM_FUNCTION; |
330 |
||
47 | 331 |
bool recipientsFieldsEmpty(true); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
332 |
if (mToField->text().length()) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
333 |
recipientsFieldsEmpty = false; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
334 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
335 |
else if (mCcField->text().length()) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
336 |
recipientsFieldsEmpty = false; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
337 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
338 |
else if (mBccField->text().length()) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
339 |
recipientsFieldsEmpty = false; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
340 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
341 |
if (mRecipientFieldsEmpty != recipientsFieldsEmpty) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
342 |
mRecipientFieldsEmpty = recipientsFieldsEmpty; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
343 |
emit recipientFieldsHaveContent(!mRecipientFieldsEmpty); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
344 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
345 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
346 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
347 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
348 |
Sets the icon for priority |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
349 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
350 |
void NmEditorHeader::setPriority(NmMessagePriority priority) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
351 |
{ |
43 | 352 |
NM_FUNCTION; |
353 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
354 |
switch (priority) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
355 |
case NmMessagePriorityHigh: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
356 |
setPriority(NmActionResponseCommandPriorityHigh); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
357 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
358 |
case NmMessagePriorityLow: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
359 |
setPriority(NmActionResponseCommandPriorityLow); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
360 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
361 |
default: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
362 |
setPriority(NmActionResponseCommandNone); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
363 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
364 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
365 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
366 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
367 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
368 |
Sets the icon for priority |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
369 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
370 |
void NmEditorHeader::setPriority(NmActionResponseCommand prio) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
371 |
{ |
43 | 372 |
NM_FUNCTION; |
373 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
374 |
switch(prio) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
375 |
case NmActionResponseCommandPriorityHigh: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
376 |
if (!mIconVisible) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
377 |
mIconVisible = true; |
43 | 378 |
// icon widget is just after the subject line edit (see docml) |
379 |
mSubjectLayout->insertItem(2, mPriorityIcon); |
|
380 |
mPriorityIcon->show(); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
381 |
} |
43 | 382 |
mPriorityIcon->setIcon( |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
383 |
NmIcons::getIcon(NmIcons::NmIconPriorityHigh)); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
384 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
385 |
case NmActionResponseCommandPriorityLow: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
386 |
if (!mIconVisible) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
387 |
mIconVisible = true; |
43 | 388 |
// icon widget is just after the subject line edit (see docml) |
389 |
mSubjectLayout->insertItem(2, mPriorityIcon); |
|
390 |
mPriorityIcon->show(); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
391 |
} |
43 | 392 |
mPriorityIcon->setIcon( |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
393 |
NmIcons::getIcon(NmIcons::NmIconPriorityLow)); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
394 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
395 |
default: |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
396 |
if (mIconVisible) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
397 |
mIconVisible = false; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
398 |
HbIcon emptyIcon; |
43 | 399 |
mPriorityIcon->setIcon(emptyIcon); |
400 |
mSubjectLayout->removeItem(mPriorityIcon); |
|
401 |
mPriorityIcon->hide(); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
402 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
403 |
break; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
404 |
} |
44 | 405 |
sendDelayedHeaderHeightChanged(); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
406 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
407 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
408 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
409 |
Adds an attachment to attachment list for mail. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
410 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
411 |
void NmEditorHeader::addAttachment( |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
412 |
const QString &fileName, const QString &fileSize, const NmId &nmid) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
413 |
{ |
43 | 414 |
NM_FUNCTION; |
415 |
||
56 | 416 |
mAttachmentList->insertAttachment(fileName, fileSize, nmid); |
417 |
||
43 | 418 |
if (!mAttachmentList->listWidget().isVisible()) { |
57 | 419 |
// attachment list is inserted just before the body widget (see docml). |
420 |
mLayout->insertItem(mLayout->count() - 1, &mAttachmentList->listWidget()); |
|
43 | 421 |
mAttachmentList->listWidget().show(); |
422 |
} |
|
51 | 423 |
|
47 | 424 |
sendHeaderHeightChanged(); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
425 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
426 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
427 |
/*! |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
428 |
Remove attachment from the list. This function is used when |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
429 |
attachment adding has failed and attachment id is not known. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
430 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
431 |
void NmEditorHeader::removeAttachment(const QString &fileName) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
432 |
{ |
43 | 433 |
NM_FUNCTION; |
434 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
435 |
mAttachmentList->removeAttachment(fileName); |
43 | 436 |
if (mAttachmentList->count() == 0) { |
437 |
mAttachmentList->listWidget().hide(); |
|
438 |
mLayout->removeItem(&mAttachmentList->listWidget()); |
|
439 |
} |
|
44 | 440 |
sendDelayedHeaderHeightChanged(); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
441 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
442 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
443 |
/*! |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
444 |
Remove attachment from the list. This function is used when |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
445 |
attachment has been selected for remove. |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
446 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
447 |
void NmEditorHeader::removeAttachment(const NmId &nmid) |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
448 |
{ |
43 | 449 |
NM_FUNCTION; |
450 |
||
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
451 |
mAttachmentList->removeAttachment(nmid); |
44 | 452 |
if (mAttachmentList->count() == 0) { |
453 |
mAttachmentList->listWidget().hide(); |
|
454 |
mLayout->removeItem(&mAttachmentList->listWidget()); |
|
455 |
} |
|
456 |
sendDelayedHeaderHeightChanged(); |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
457 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
458 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
459 |
/*! |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
460 |
This function set messagePartId and fileSize for attachment. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
461 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
462 |
void NmEditorHeader::setAttachmentParameters( |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
463 |
const QString &fileName, |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
464 |
const NmId &msgPartId, |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
465 |
const QString &fileSize, |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
466 |
int result) |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
467 |
{ |
43 | 468 |
NM_FUNCTION; |
469 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
470 |
if (result == NmNoError) { |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
471 |
// Attachment adding succesful, set message part id and size for attachment |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
472 |
mAttachmentList->setAttachmentPartId(fileName, msgPartId); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
473 |
mAttachmentList->setAttachmentSize(msgPartId, fileSize); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
474 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
475 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
476 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
477 |
/*! |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
478 |
Slot attachment activated from attachment list by short tap. |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
479 |
*/ |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
480 |
void NmEditorHeader::attachmentActivated(int arrayIndex) |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
481 |
{ |
43 | 482 |
NM_FUNCTION; |
47 | 483 |
|
44 | 484 |
emit attachmentShortPressed(mAttachmentList->nmIdByIndex(arrayIndex)); |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
485 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
486 |
|
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
487 |
/*! |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
488 |
Slot attachment selected from attachment list by longtap. |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
489 |
*/ |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
490 |
void NmEditorHeader::attachmentLongPressed(int arrayIndex, QPointF point) |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
491 |
{ |
43 | 492 |
NM_FUNCTION; |
493 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
494 |
// Remove selected attachment |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
495 |
emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
496 |
} |
51 | 497 |
|
498 |
/*! |
|
62 | 499 |
This function is called when scroll position has been changed. |
500 |
Function performs the pre calculated translation to set new positions for header fields |
|
501 |
so that header stays visible when body is scrolled horizontally. |
|
51 | 502 |
*/ |
62 | 503 |
void NmEditorHeader::repositHeader(const QTransform &transform) |
51 | 504 |
{ |
505 |
NM_FUNCTION; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
506 |
|
62 | 507 |
mToWidget->setTransform(transform); |
508 |
mCcWidget->setTransform(transform); |
|
509 |
mBccWidget->setTransform(transform); |
|
510 |
mSubjectWidget->setTransform(transform); |
|
511 |
mAttachmentListWidget->setTransform(transform); |
|
51 | 512 |
} |
513 |
||
74 | 514 |
/*! |
515 |
This slot will set the geometry, margin and font for the To,Cc,Bcc and Subject |
|
516 |
labels located inside the edit fields. These adjustments are done to fix label text |
|
517 |
position so that it is in same lavel than first line of the edit widget. |
|
518 |
Slot is called once when 'To' field layout is ready after editor startup. |
|
519 |
Because all fields are similar it is enough to use only 'To' field information |
|
520 |
to adjust all header fields. |
|
521 |
*/ |
|
522 |
void NmEditorHeader::toFieldLayoutReady() |
|
523 |
{ |
|
524 |
NM_FUNCTION; |
|
525 |
||
526 |
// Set same font for label and edit. |
|
527 |
QFont editorFont = mToField->editor()->font(); |
|
528 |
mToField->label()->setFont(editorFont); |
|
529 |
mCcField->label()->setFont(editorFont); |
|
530 |
mBccField->label()->setFont(editorFont); |
|
531 |
mSubjectLabel->setFont(editorFont); |
|
532 |
||
533 |
// Set same height for label and edit. |
|
534 |
qreal editorWidgetHeight = mToField->editor()->geometry().height(); |
|
535 |
mToField->label()->setPreferredHeight(editorWidgetHeight); |
|
536 |
mCcField->label()->setPreferredHeight(editorWidgetHeight); |
|
537 |
mBccField->label()->setPreferredHeight(editorWidgetHeight); |
|
538 |
mSubjectLabel->setPreferredHeight(editorWidgetHeight); |
|
539 |
||
540 |
// Set left margin for labels. |
|
541 |
qreal leftMargin; |
|
542 |
mToField->editor()->layout()->getContentsMargins(&leftMargin, 0, 0, 0); |
|
543 |
mToField->label()->setContentsMargins(leftMargin, 0, 0, 0); |
|
544 |
mCcField->label()->setContentsMargins(leftMargin, 0, 0, 0); |
|
545 |
mBccField->label()->setContentsMargins(leftMargin, 0, 0, 0); |
|
546 |
mSubjectLabel->setContentsMargins(leftMargin, 0, 0, 0); |
|
547 |
||
548 |
adjustIndentForEditFields(); |
|
549 |
} |
|
550 |
||
551 |
/*! |
|
552 |
Set the length of the label and the indention of the edit fields (To,Cc,Bcc,Subject) so |
|
553 |
that there is enough space for the label field. |
|
554 |
*/ |
|
555 |
void NmEditorHeader::adjustIndentForEditFields() |
|
556 |
{ |
|
557 |
NM_FUNCTION; |
|
558 |
||
559 |
// Get spacing between label and edit. |
|
560 |
qreal spacingBetweenLabelAndEdit = 0; |
|
561 |
HbStyle().parameter("hb-param-margin-gene-middle-horizontal", spacingBetweenLabelAndEdit); |
|
562 |
// Add more space for label right margin. Without this, last letter ':' of the label is not |
|
563 |
// fit into field. |
|
564 |
spacingBetweenLabelAndEdit *= 2; |
|
565 |
||
566 |
// Get font metrics (We assume that every label has same font). |
|
567 |
QFontMetrics fm(mToField->label()->font()); |
|
568 |
||
569 |
// Set length of the label widgets based on the string width. |
|
570 |
// Also set indent for the first line of the edit widget. |
|
571 |
qreal textWidth = 0; |
|
572 |
textWidth = fm.width(mToField->label()->plainText()) + spacingBetweenLabelAndEdit; |
|
573 |
mToField->label()->setPreferredWidth(textWidth); |
|
574 |
mToField->editor()->setIndentForLabel(textWidth); |
|
575 |
||
576 |
textWidth = fm.width(mCcField->label()->plainText()) + spacingBetweenLabelAndEdit; |
|
577 |
mCcField->label()->setPreferredWidth(textWidth); |
|
578 |
mCcField->editor()->setIndentForLabel(textWidth); |
|
579 |
||
580 |
textWidth = fm.width(mBccField->label()->plainText()) + spacingBetweenLabelAndEdit; |
|
581 |
mBccField->label()->setPreferredWidth(textWidth); |
|
582 |
mBccField->editor()->setIndentForLabel(textWidth); |
|
583 |
||
584 |
textWidth = fm.width(mSubjectLabel->plainText()) + spacingBetweenLabelAndEdit; |
|
585 |
mSubjectLabel->setPreferredWidth(textWidth); |
|
586 |
mSubjectEdit->setIndentForLabel(textWidth); |
|
587 |
} |