author | hgs |
Fri, 02 Jul 2010 15:55:16 +0300 | |
changeset 49 | 00c7ae862740 |
parent 48 | 10eaf342f539 |
child 51 | d845db10c0d4 |
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 |
* |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: Message editor contents widget |
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 |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
static const char *NMUI_EDITOR_BODY = "BodyTextEdit"; |
47 | 22 |
static const char *NMUI_EDITOR_SCROLL_AREA = "scrollArea"; |
23 |
static const char *NMUI_EDITOR_SCROLL_AREA_CONTENTS = "scrollAreaContents"; |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
|
47 | 25 |
// Regular expression for selecting img tags with "cid" in the mail. |
26 |
static const char *NMUI_EDITOR_REMOVE_EMBD_IMAGES_REG = |
|
48 | 27 |
"(<img[^<]+(src\\s*=\\s*)(.{0,1}cid)([^<]+)(>\\s*|/>\\s*|></img>\\s*))"; |
47 | 28 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
Constructor |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
*/ |
47 | 32 |
NmEditorContent::NmEditorContent(QObject *parent, |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
33 |
HbDocumentLoader *documentLoader, |
47 | 34 |
QNetworkAccessManager &manager, |
35 |
NmApplication &application) : |
|
36 |
QObject(parent), |
|
48 | 37 |
mHeader(NULL), |
47 | 38 |
mMessageBodyType(NmPlainText), |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
mEditorWidget(NULL), |
47 | 40 |
mScrollArea(NULL), |
41 |
mScrollAreaContents(NULL), |
|
42 |
mApplication(application) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
{ |
43 | 44 |
NM_FUNCTION; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
|
47 | 46 |
// Construct container for the header widgets |
48 | 47 |
mHeader = new NmEditorHeader(this, documentLoader); |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
// Get pointer to body text area handling widget |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
mEditorWidget = qobject_cast<NmEditorTextEdit *>(documentLoader->findWidget(NMUI_EDITOR_BODY)); |
43 | 51 |
|
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
52 |
// Set body editor to use NmEditorTextDocument |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
53 |
NmEditorTextDocument *textDocument = new NmEditorTextDocument(manager); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
54 |
mEditorWidget->setDocument(textDocument); |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
55 |
textDocument->setParent(mEditorWidget); // ownership changes |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
56 |
|
47 | 57 |
mScrollArea = qobject_cast<NmBaseViewScrollArea *> |
49 | 58 |
(documentLoader->findWidget(NMUI_EDITOR_SCROLL_AREA)); |
48 | 59 |
mScrollArea->setScrollDirections(Qt::Vertical | Qt::Horizontal); |
60 |
||
23
2dc6caa42ec3
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
61 |
// Enable style picker menu item. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
mEditorWidget->setFormatDialog(new HbFormatDialog()); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
|
47 | 64 |
mScrollAreaContents = |
65 |
qobject_cast<HbWidget *>(documentLoader->findWidget(NMUI_EDITOR_SCROLL_AREA_CONTENTS)); |
|
66 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
// Create signal slot connections |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
createConnections(); |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
|
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 |
Destructor |
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 |
NmEditorContent::~NmEditorContent() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
{ |
43 | 76 |
NM_FUNCTION; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
/*! |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
80 |
Fill message data into header and body fileds. If reply envelopw is |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
81 |
present, reply header is generated and set to editor. Reply |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
82 |
envelope ownership is not transferred here. |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
83 |
*/ |
47 | 84 |
void NmEditorContent::setMessageData(const NmMessage &originalMessage, |
85 |
NmUiEditorStartMode &editorStartMode) |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
{ |
43 | 87 |
NM_FUNCTION; |
44 | 88 |
|
89 |
QString bodyContent; |
|
90 |
||
47 | 91 |
// Create the "reply" header (also for forward message) |
92 |
if (editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll || |
|
93 |
editorStartMode==NmUiEditorForward) { |
|
94 |
bodyContent.append(NmUtilities::createReplyHeader(originalMessage.envelope())); |
|
44 | 95 |
} |
96 |
||
43 | 97 |
// Check which part is present. Html or plain text part. We use the original message parts. |
98 |
const NmMessagePart *htmlPart = originalMessage.htmlBodyPart(); |
|
99 |
const NmMessagePart *plainPart = originalMessage.plainTextBodyPart(); |
|
44 | 100 |
|
47 | 101 |
if (htmlPart) { |
44 | 102 |
bodyContent.append(htmlPart->textContent()); |
47 | 103 |
if(editorStartMode==NmUiEditorReply || editorStartMode==NmUiEditorReplyAll ) { |
104 |
removeEmbeddedImages(bodyContent); |
|
105 |
} |
|
44 | 106 |
emit setHtml(bodyContent); |
47 | 107 |
mMessageBodyType = NmHTMLText; |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
108 |
} |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
109 |
else if (plainPart) { |
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
110 |
// Plain text part was present, set it to HbTextEdit |
44 | 111 |
bodyContent.append(plainPart->textContent()); |
112 |
emit setPlainText(bodyContent); |
|
47 | 113 |
mMessageBodyType = NmPlainText; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
114 |
} |
20
ecc8def7944a
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
115 |
} |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
117 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
118 |
This method creates all needed signal-slot connections |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
*/ |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
120 |
void NmEditorContent::createConnections() |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
{ |
43 | 122 |
NM_FUNCTION; |
123 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
124 |
// Signal for setting HbTextEdit widgets html content |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
connect(this, SIGNAL(setHtml(QString)), |
44 | 126 |
mEditorWidget, SLOT(setHtml(QString)), Qt::QueuedConnection); |
47 | 127 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
// Signal for setting HbTextEdit widgets plain text content |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
connect(this, SIGNAL(setPlainText(QString)), |
44 | 130 |
mEditorWidget, SLOT(setPlainText(QString)), Qt::QueuedConnection); |
47 | 131 |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
132 |
// Inform text edit widget that header height has been changed |
48 | 133 |
connect(mHeader, SIGNAL(headerHeightChanged(int)), this, SLOT(setEditorContentHeight()), |
47 | 134 |
Qt::QueuedConnection); |
135 |
||
136 |
// we are interested in the document's height changes |
|
137 |
connect(mEditorWidget->document()->documentLayout(), SIGNAL(documentSizeChanged(QSizeF)), this, |
|
138 |
SLOT(setEditorContentHeight()), Qt::QueuedConnection); |
|
139 |
||
48 | 140 |
// We need to update the scroll position according the editor's cursor position |
141 |
connect(mHeader->toEdit(), SIGNAL(cursorPositionChanged(int, int)), this, |
|
142 |
SLOT(ensureCursorVisibility()), Qt::QueuedConnection); |
|
143 |
connect(mHeader->ccEdit(), SIGNAL(cursorPositionChanged(int, int)), this, |
|
144 |
SLOT(ensureCursorVisibility()), Qt::QueuedConnection); |
|
145 |
connect(mHeader->bccEdit(), SIGNAL(cursorPositionChanged(int, int)), this, |
|
146 |
SLOT(ensureCursorVisibility()), Qt::QueuedConnection); |
|
147 |
connect(mHeader->subjectEdit(), SIGNAL(cursorPositionChanged(int, int)), this, |
|
148 |
SLOT(ensureCursorVisibility()), Qt::QueuedConnection); |
|
47 | 149 |
connect(mEditorWidget, SIGNAL(cursorPositionChanged(int, int)), this, |
48 | 150 |
SLOT(ensureCursorVisibility()), Qt::QueuedConnection); |
151 |
||
152 |
// listen to the parent's (NmEditorView) size changes which happen eg. when VKB is opened/closed |
|
153 |
connect(parent(), SIGNAL(sizeChanged()), this, SLOT(ensureCursorVisibility()), |
|
154 |
Qt::QueuedConnection); |
|
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
155 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
158 |
Return pointer to the email body text edit widget |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
159 |
*/ |
47 | 160 |
NmEditorTextEdit *NmEditorContent::editor() const |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
161 |
{ |
43 | 162 |
NM_FUNCTION; |
163 |
||
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
164 |
return mEditorWidget; |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
165 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
|
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
/*! |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
168 |
Return pointer to the header widget |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
*/ |
47 | 170 |
NmEditorHeader *NmEditorContent::header() const |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
171 |
{ |
43 | 172 |
NM_FUNCTION; |
173 |
||
48 | 174 |
return mHeader; |
18
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
175 |
} |
578830873419
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
176 |
|
47 | 177 |
/*! |
178 |
This slot is called when header widget height has been changed. Function performs |
|
179 |
the repositioning of the body field and resizing of the editor and content area. |
|
180 |
*/ |
|
181 |
void NmEditorContent::setEditorContentHeight() |
|
182 |
{ |
|
183 |
NM_FUNCTION; |
|
184 |
||
48 | 185 |
// the height of the margin between the title bar and the header |
47 | 186 |
qreal topMargin = 0; |
187 |
HbStyle().parameter("hb-param-margin-gene-top", topMargin); |
|
188 |
||
189 |
// header height |
|
48 | 190 |
qreal headerHeight = mHeader->headerHeight(); |
47 | 191 |
|
192 |
// body area editor's document height with margins added |
|
193 |
qreal documentHeightAndMargins = mEditorWidget->document()->size().height() + |
|
194 |
(mEditorWidget->document()->documentMargin() * 2); |
|
195 |
||
48 | 196 |
// chrome height |
47 | 197 |
qreal chromeHeight = 0; |
198 |
HbStyle().parameter("hb-param-widget-chrome-height", chromeHeight); |
|
199 |
||
200 |
// screen height |
|
201 |
qreal screenHeight = mApplication.screenSize().height(); |
|
202 |
||
203 |
// set min size for the body area so that at least the screen area is always filled |
|
204 |
qreal bodyAreaMinSize = screenHeight - chromeHeight - topMargin - headerHeight; |
|
205 |
||
206 |
qreal bodyAreaSize = fmax(bodyAreaMinSize, documentHeightAndMargins); |
|
207 |
||
208 |
mScrollAreaContents->setPreferredHeight(topMargin + headerHeight + bodyAreaSize); |
|
209 |
} |
|
210 |
||
211 |
/*! |
|
48 | 212 |
This slot is called when the cursor visibility has to be ensured ie. the scroll position is |
213 |
adjusted so that the cursor can be seen. |
|
214 |
*/ |
|
215 |
void NmEditorContent::ensureCursorVisibility() |
|
47 | 216 |
{ |
217 |
NM_FUNCTION; |
|
218 |
||
48 | 219 |
// check which of the editors has the focus and get the x/y coordinates for the cursor position |
220 |
QGraphicsWidget *focused = mScrollAreaContents->focusWidget(); |
|
221 |
||
222 |
if (focused) { |
|
223 |
QRectF localRect(0, 0, 0, 0); |
|
224 |
bool notFound = false; |
|
225 |
||
226 |
if (focused == mHeader->toEdit()) { |
|
227 |
localRect = mHeader->toEdit()->rectForCursorPosition(); |
|
228 |
} |
|
229 |
else if (focused == mHeader->ccEdit()) { |
|
230 |
localRect = mHeader->ccEdit()->rectForCursorPosition(); |
|
231 |
} |
|
232 |
else if (focused == mHeader->bccEdit()) { |
|
233 |
localRect = mHeader->bccEdit()->rectForCursorPosition(); |
|
234 |
} |
|
235 |
else if (focused == mHeader->subjectEdit()) { |
|
236 |
localRect = mHeader->subjectEdit()->rectForCursorPosition(); |
|
237 |
} |
|
238 |
else if (focused == mEditorWidget) { |
|
239 |
localRect = mEditorWidget->rectForCursorPosition(); |
|
240 |
} |
|
241 |
else { |
|
242 |
notFound = true; |
|
243 |
} |
|
47 | 244 |
|
48 | 245 |
if (!notFound) { |
246 |
QPointF topLeftPos = focused->mapToItem(mScrollAreaContents, localRect.topLeft()); |
|
247 |
QPointF bottomRightPos = |
|
248 |
focused->mapToItem(mScrollAreaContents, localRect.bottomRight()); |
|
249 |
qreal marginRight = 0; |
|
250 |
HbStyle().parameter("hb-param-margin-gene-right", marginRight); |
|
251 |
bottomRightPos.rx() += marginRight; |
|
252 |
mScrollArea->ensureVisible(topLeftPos); |
|
253 |
mScrollArea->ensureVisible(bottomRightPos); |
|
254 |
} |
|
47 | 255 |
} |
256 |
} |
|
257 |
/*! |
|
258 |
Removes embedded images from the message body |
|
259 |
*/ |
|
260 |
void NmEditorContent::removeEmbeddedImages(QString &bodyContent) |
|
261 |
{ |
|
262 |
NM_FUNCTION; |
|
263 |
||
264 |
QRegExp regExp(NMUI_EDITOR_REMOVE_EMBD_IMAGES_REG, Qt::CaseInsensitive); |
|
265 |
bodyContent.remove(regExp); |
|
48 | 266 |
} |