author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:32:06 +0100 | |
branch | GCC_SURGE |
changeset 47 | 5b14749788d7 |
parent 27 | e4592d119491 |
parent 44 | 36f374c67aa8 |
permissions | -rw-r--r-- |
31 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// INCLUDES |
|
19 |
#include <HbTextEdit> |
|
20 |
#include <HbTextItem> |
|
21 |
#include <HbFrameItem> |
|
22 |
#include <HbFrameDrawer> |
|
23 |
#include <HbIconItem> |
|
24 |
#include <HbAction> |
|
25 |
#include <HbMainWindow> |
|
26 |
#include <HbDeviceProfile> |
|
27 |
#include <QImageReader> |
|
28 |
#include <QFileInfo> |
|
29 |
#include <MsgMediaResolver.h> |
|
30 |
#include <MsgImageInfo.h> |
|
31 |
#include <HbIconAnimationManager> |
|
32 |
#include <HbIconAnimator> |
|
33 |
#include <HbIcon> |
|
34 |
#include <QGraphicsLinearLayout> |
|
35 |
#include <HbNotificationDialog> |
|
36 |
||
37 |
#include <csmsaccount.h> |
|
38 |
#include <smutset.h> |
|
39 |
#include <xqaiwrequest.h> |
|
40 |
#include <xqrequestinfo.h> |
|
41 |
#include <xqsharablefile.h> |
|
42 |
#include <xqappmgr.h> |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
43 |
#include <xqconversions.h> |
31 | 44 |
// USER INCLUDES |
45 |
#include "msgunieditorbody.h" |
|
46 |
#include "UniEditorGenUtils.h" |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
47 |
#include "UniSendingSettings.h" |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
48 |
#include "msgunieditormonitor.h" |
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
49 |
|
31 | 50 |
#include "mmsconformancecheck.h" |
51 |
#include "unieditorpluginloader.h" |
|
52 |
#include "unieditorplugininterface.h" |
|
53 |
#include "convergedmessage.h" |
|
54 |
#include "msgmediautil.h" |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
55 |
#include "msgunieditorpixmapwidget.h" |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
56 |
#include "msgunieditoraudiowidget.h" |
31 | 57 |
|
58 |
// Constants |
|
59 |
const QString BACKGROUND_FRAME("qtg_fr_btn_normal"); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
60 |
|
31 | 61 |
const int KShowCounterLimit = 10; |
62 |
const int BYTES_TO_KBYTES_FACTOR = 1024; |
|
63 |
||
64 |
//Localized Constants for item specific menu |
|
65 |
#define LOC_TITLE hbTrId("txt_messaging_title_messaging") |
|
66 |
#define LOC_UNABLE_TO_ADD_CONTENT hbTrId("txt_messaging_dpopinfo_unable_to_add_more_content") |
|
67 |
#define LOC_UNABLE_TO_ATTACH_ITEM hbTrId("txt_messaging_dpopinfo_unable_to_attach_item_avai") |
|
68 |
#define LOC_PROCESSING hbTrId("txt_messaging_formlabel_loading") |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
69 |
#define LOC_HINT_TEXT hbTrId("txt_messaging_formlabel_enter_message_here") |
31 | 70 |
|
71 |
const QString ANIMATION_ICON("qtg_anim_loading"); |
|
72 |
const QString ANIMATION_FILE(":/qtg_anim_loading.axml"); |
|
73 |
// LOCAL FUNCTIONS |
|
74 |
||
75 |
//--------------------------------------------------------------- |
|
76 |
// showInsertFailureNote |
|
77 |
// @return fullPath of unified editor's temporary dir |
|
78 |
//--------------------------------------------------------------- |
|
79 |
void showInsertFailureNote() |
|
80 |
{ |
|
81 |
int availableSize = |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
82 |
(MsgUnifiedEditorMonitor::maxMmsSize() - MsgUnifiedEditorMonitor::messageSize()) |
31 | 83 |
/BYTES_TO_KBYTES_FACTOR; |
84 |
QString displayStr = QString(LOC_UNABLE_TO_ATTACH_ITEM) |
|
85 |
.arg(availableSize); |
|
86 |
HbNotificationDialog* dlg = new HbNotificationDialog(); |
|
87 |
dlg->setFocusPolicy(Qt::NoFocus); |
|
88 |
dlg->setDismissPolicy(HbPopup::TapAnywhere); |
|
89 |
dlg->setAttribute(Qt::WA_DeleteOnClose, true); |
|
90 |
dlg->setText(displayStr); |
|
91 |
dlg->show(); |
|
92 |
} |
|
93 |
||
94 |
||
95 |
MsgUnifiedEditorBody::MsgUnifiedEditorBody( QGraphicsItem *parent ) : |
|
96 |
MsgUnifiedEditorBaseWidget(parent), |
|
97 |
mHasImage(false), |
|
98 |
mHasAudio(false), |
|
99 |
mTextEdit(0), |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
100 |
mPixmapItem(0), |
31 | 101 |
mAudioItem(0), |
102 |
mImageSize(0), |
|
103 |
mAudioSize(0), |
|
104 |
mVideoSize(0), |
|
105 |
mProcessImageOperation(0), |
|
106 |
mMediaResolver(0), |
|
107 |
mImageInfo(0), |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
108 |
mProcessingWidget(0), |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
109 |
mDraftMessage(false), |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
110 |
mIsImageResizing(false) |
31 | 111 |
{ |
112 |
mTextEdit = new HbTextEdit(this); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
113 |
mTextEdit->setPlaceholderText(LOC_HINT_TEXT); |
31 | 114 |
HbStyle::setItemName(mTextEdit,"textEdit"); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
115 |
connect(mTextEdit, SIGNAL(contentsChanged()), this, SLOT(onTextChanged())); |
31 | 116 |
|
117 |
mMmsConformanceCheck = new MmsConformanceCheck; |
|
118 |
||
119 |
mCharCounter = new HbTextItem(this); |
|
120 |
HbStyle::setItemName(mCharCounter, "charCounter"); |
|
121 |
mCharCounter->setZValue(1.5); |
|
122 |
mCharCounter->setText("160(1)"); |
|
123 |
||
124 |
mBackgroundItem = new HbFrameItem(this); |
|
125 |
HbStyle::setItemName(mBackgroundItem, "charCounterFrame"); |
|
126 |
||
127 |
mBackgroundItem->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
128 |
mBackgroundItem->frameDrawer().setFillWholeRect(true); |
|
129 |
||
130 |
mBackgroundItem->frameDrawer().setFrameGraphicsName( |
|
131 |
BACKGROUND_FRAME); |
|
132 |
||
133 |
mPluginLoader = new UniEditorPluginLoader(this); |
|
134 |
||
135 |
mPluginInterface = |
|
136 |
mPluginLoader->getUniEditorPlugin(ConvergedMessage::Sms); |
|
137 |
||
138 |
TRAP_IGNORE( |
|
139 |
CSmsSettings* settings = CSmsSettings::NewLC(); |
|
140 |
CSmsAccount* account = CSmsAccount::NewLC(); |
|
141 |
account->LoadSettingsL( *settings ); |
|
142 |
||
143 |
if( settings->CharacterSet() == TSmsDataCodingScheme::ESmsAlphabetUCS2) |
|
144 |
{ |
|
145 |
mCharSupportType = TUniSendingSettings::EUniCharSupportFull; |
|
146 |
} |
|
147 |
else |
|
148 |
{ |
|
149 |
mCharSupportType = TUniSendingSettings::EUniCharSupportReduced; |
|
150 |
} |
|
151 |
||
152 |
CleanupStack::PopAndDestroy( account ); |
|
153 |
CleanupStack::PopAndDestroy( settings ); |
|
154 |
); |
|
155 |
||
156 |
mCharCounter->setVisible(false); |
|
157 |
mBackgroundItem->setVisible(false); |
|
158 |
} |
|
159 |
||
160 |
MsgUnifiedEditorBody::~MsgUnifiedEditorBody() |
|
161 |
{ |
|
162 |
delete mMmsConformanceCheck; |
|
163 |
delete mProcessImageOperation; |
|
164 |
delete mMediaResolver; |
|
165 |
delete mImageInfo; |
|
166 |
} |
|
167 |
||
168 |
QString MsgUnifiedEditorBody::text() |
|
169 |
{ |
|
170 |
return mTextEdit->toPlainText(); |
|
171 |
} |
|
172 |
||
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
173 |
void MsgUnifiedEditorBody::setImage(QString& imagefile, bool draftMessage) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
174 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
175 |
// do nothing if filepath is empty |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
176 |
if (imagefile.isEmpty()) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
177 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
178 |
return; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
179 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
180 |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
181 |
mDraftMessage = draftMessage; |
31 | 182 |
if (!mImageInfo) |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
183 |
{ |
31 | 184 |
setImage(true); |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
185 |
|
31 | 186 |
mImageFile = imagefile; |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
187 |
if (mPixmapItem) |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
188 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
189 |
mPixmapItem->setParent(NULL); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
190 |
delete mPixmapItem; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
191 |
mPixmapItem = NULL; |
31 | 192 |
mImageSize = 0; |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
193 |
} |
31 | 194 |
|
195 |
int error = KErrNone; |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
196 |
if (!mDraftMessage) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
197 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
198 |
// if image is in draft, no need to resize it because it is resized already |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
199 |
if (!mProcessImageOperation) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
200 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
201 |
TRAP(error,mProcessImageOperation = |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
202 |
CUniEditorProcessImageOperation::NewL(*this)); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
203 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
204 |
if (!mMediaResolver && error == KErrNone) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
205 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
206 |
TRAP(error,mMediaResolver = CMsgMediaResolver::NewL()); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
207 |
} |
31 | 208 |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
209 |
if (error == KErrNone) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
210 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
211 |
mMediaResolver->SetCharacterSetRecognition(EFalse); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
212 |
HBufC *name = XQConversions::qStringToS60Desc(imagefile); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
213 |
RFile file; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
214 |
TRAP(error, file = mMediaResolver->FileHandleL(*name)); |
31 | 215 |
if (error == KErrNone) |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
216 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
217 |
TRAP(error,mImageInfo = static_cast<CMsgImageInfo*> |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
218 |
(mMediaResolver->CreateMediaInfoL(file))); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
219 |
if (error == KErrNone) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
220 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
221 |
TRAP(error, mMediaResolver->ParseInfoDetailsL( |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
222 |
mImageInfo, file)); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
223 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
224 |
file.Close(); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
225 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
226 |
delete name; |
31 | 227 |
} |
228 |
} |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
229 |
if (error == KErrNone && !mDraftMessage) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
230 |
{ |
31 | 231 |
mSavedImageFile = imagefile; |
232 |
startResizeAnimation(); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
233 |
mIsImageResizing = true; |
31 | 234 |
mProcessImageOperation->Process(mImageInfo); |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
235 |
} |
31 | 236 |
else |
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
237 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
238 |
if (mImageInfo) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
239 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
240 |
delete mImageInfo; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
241 |
mImageInfo = NULL; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
242 |
} |
31 | 243 |
mSavedImageFile.clear(); |
244 |
handleSetImage(); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
245 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
246 |
|
31 | 247 |
} |
248 |
} |
|
249 |
||
250 |
void MsgUnifiedEditorBody::handleSetImage() |
|
251 |
{ |
|
252 |
//check for insert conformance |
|
253 |
if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(mImageFile)) |
|
254 |
return; |
|
255 |
||
256 |
int msgSize = messageSize(); |
|
257 |
QFileInfo fileinfo(mImageFile); |
|
258 |
int imageSize = fileinfo.size() + KEstimatedMimeHeaderSize; |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
259 |
if ( (imageSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize()) |
31 | 260 |
{ |
261 |
mImageSize = imageSize; |
|
262 |
} |
|
263 |
else |
|
264 |
{ |
|
265 |
mImageFile.clear(); |
|
266 |
setImage(false); |
|
267 |
//Show appropriate note and leave |
|
268 |
showInsertFailureNote(); |
|
269 |
return; |
|
270 |
} |
|
271 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
272 |
mPixmapItem = new MsgUnifiedEditorPixmapWidget(this); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
273 |
mPixmapItem->hide(); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
274 |
HbStyle::setItemName(mPixmapItem, "pixmap"); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
275 |
mPixmapItem->setAlignment(Qt::AlignHCenter | Qt::AlignTop); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
276 |
mPixmapItem->populate(mImageFile); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
277 |
connect(mPixmapItem,SIGNAL(remove()),this,SLOT(removeMedia())); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
278 |
|
31 | 279 |
// repolish the body widget |
280 |
this->repolish(); |
|
281 |
||
282 |
// emit signal to indicate addition of image |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
283 |
emit contentChanged(); |
31 | 284 |
} |
285 |
||
286 |
void MsgUnifiedEditorBody::setAudio(QString& audiofile) |
|
287 |
{ |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
288 |
// do nothing if filepath is empty |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
289 |
if(audiofile.isEmpty()) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
290 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
291 |
return; |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
292 |
} |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
293 |
|
31 | 294 |
//check for insert conformance |
295 |
if(EInsertSuccess != mMmsConformanceCheck->checkModeForInsert(audiofile)) |
|
296 |
return; |
|
297 |
||
298 |
setAudio(true); |
|
299 |
mAudioFile = audiofile; |
|
300 |
if(mAudioItem) |
|
301 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
302 |
mAudioItem->setParent(NULL); |
31 | 303 |
delete mAudioItem; |
304 |
mAudioItem = NULL; |
|
305 |
mAudioSize = 0; |
|
306 |
} |
|
307 |
||
308 |
int msgSize = messageSize(); |
|
309 |
QFileInfo fileinfo(mAudioFile); |
|
310 |
int audioSize = fileinfo.size() + KEstimatedMimeHeaderSize; |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
311 |
if((audioSize + msgSize) <= MsgUnifiedEditorMonitor::maxMmsSize() ) |
31 | 312 |
{ |
313 |
mAudioSize = audioSize; |
|
314 |
} |
|
315 |
else |
|
316 |
{ |
|
317 |
mAudioFile.clear(); |
|
318 |
setAudio(false); |
|
319 |
//Show appropriate note and leave |
|
320 |
showInsertFailureNote(); |
|
321 |
return; |
|
322 |
} |
|
323 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
324 |
mAudioItem = new MsgUniFiedEditorAudioWidget(this); |
31 | 325 |
mAudioItem->hide(); |
326 |
HbStyle::setItemName(mAudioItem,"audioItem"); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
327 |
mAudioItem->populate(mAudioFile); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
328 |
connect(mAudioItem,SIGNAL(remove()),this,SLOT(removeMedia())); |
31 | 329 |
|
330 |
// repolish the body widget |
|
331 |
this->repolish(); |
|
332 |
||
333 |
// emit signal to indicate addition of audio |
|
334 |
emit contentChanged(); |
|
335 |
} |
|
336 |
||
337 |
void MsgUnifiedEditorBody::setText(QString& text) |
|
338 |
{ |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
339 |
if(!text.isEmpty()) |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
340 |
{ |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
341 |
mTextEdit->setPlainText(text); |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
342 |
} |
31 | 343 |
} |
344 |
||
345 |
const QStringList MsgUnifiedEditorBody::mediaContent() |
|
346 |
{ |
|
347 |
QStringList mediaFiles; |
|
348 |
// Pick mImageFile only if mSavedImageFile is empty |
|
349 |
// as it means we are not in middle of resizing |
|
350 |
if (mHasImage && mSavedImageFile.isEmpty()) |
|
351 |
mediaFiles << mImageFile; |
|
352 |
if(mHasAudio) |
|
353 |
mediaFiles << mAudioFile; |
|
354 |
||
355 |
return mediaFiles; |
|
356 |
} |
|
357 |
||
358 |
QSizeF MsgUnifiedEditorBody::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
359 |
{ |
|
360 |
QSizeF szHint = HbWidget::sizeHint(which,constraint); |
|
361 |
||
362 |
HbMainWindow* mMainWindow = this->mainWindow(); |
|
363 |
if(!mMainWindow) |
|
364 |
{ |
|
365 |
return szHint; |
|
366 |
} |
|
367 |
||
368 |
qreal leftMargin = 0.0; |
|
369 |
qreal rightMargin = 0.0; |
|
370 |
qreal chromeHeight = 0.0; |
|
371 |
qreal toolbarHeight = 0.0; |
|
372 |
qreal bodyItemSpacing = 0.0; |
|
373 |
||
374 |
style()->parameter("hb-param-margin-gene-left",leftMargin); |
|
375 |
style()->parameter("hb-param-margin-gene-right",rightMargin); |
|
376 |
style()->parameter("hb-param-widget-chrome-height",chromeHeight); |
|
377 |
style()->parameter("hb-param-widget-toolbar-height",toolbarHeight); |
|
378 |
style()->parameter("hb-param-margin-gene-middle-vertical",bodyItemSpacing); |
|
379 |
||
380 |
HbDeviceProfile prf = HbDeviceProfile::profile(mMainWindow); |
|
381 |
qreal unt = prf.unitValue(); |
|
382 |
||
383 |
// Note: With NGA, the orientation change does not cause HW to switch orientation. |
|
384 |
// So, the HW resolution also remains unchanged. We need to swap values of width & |
|
385 |
// height to map portrait resolution to landscape resolution. |
|
386 |
qreal maxWidth = 0.0, maxHeight = 0.0; |
|
387 |
||
388 |
// Landscape |
|
389 |
if(mMainWindow->orientation() == Qt::Horizontal) |
|
390 |
{ |
|
391 |
maxHeight = mMainWindow->width()-chromeHeight-toolbarHeight; |
|
392 |
maxWidth = (mMainWindow->height()-leftMargin-rightMargin-(2*unt))/2; |
|
393 |
} |
|
394 |
else |
|
395 |
{ |
|
396 |
maxWidth = mMainWindow->width()-leftMargin-rightMargin; |
|
397 |
maxHeight = mMainWindow->height()-chromeHeight-toolbarHeight; |
|
398 |
} |
|
399 |
szHint.setHeight(maxHeight); |
|
400 |
||
401 |
// add space for audio |
|
402 |
if(mAudioItem) |
|
403 |
{ |
|
404 |
if(mMainWindow->orientation() == Qt::Horizontal) |
|
405 |
{ |
|
406 |
mAudioItem->setStretched(true); |
|
407 |
} |
|
408 |
else |
|
409 |
{ |
|
410 |
mAudioItem->setStretched(false); |
|
411 |
} |
|
412 |
QSizeF audioSize = mAudioItem->effectiveSizeHint(which, constraint); |
|
413 |
szHint.rheight() += (audioSize.height() + bodyItemSpacing); |
|
414 |
mAudioItem->show(); |
|
415 |
} |
|
416 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
417 |
if(mPixmapItem || mProcessingWidget) |
31 | 418 |
{ |
419 |
QSizeF imageSize(0.0,0.0); |
|
420 |
QSizeF defaultImageSize(QImageReader(mImageFile).size()); |
|
421 |
||
422 |
if(!defaultImageSize.isEmpty()) |
|
423 |
{ |
|
424 |
imageSize.setWidth(maxWidth); |
|
425 |
if(mMainWindow->orientation() == Qt::Vertical) |
|
426 |
{ |
|
427 |
szHint.rheight() += bodyItemSpacing; |
|
428 |
} |
|
429 |
||
430 |
qreal newHeight = 0.0; |
|
431 |
if(defaultImageSize.width() <= imageSize.width()) |
|
432 |
{ |
|
433 |
// resize not needed |
|
434 |
newHeight = qMin(defaultImageSize.height(), maxHeight); |
|
435 |
imageSize.setHeight(newHeight); |
|
436 |
} |
|
437 |
else |
|
438 |
{ |
|
439 |
// keep aspect-ratio and resize |
|
440 |
newHeight = imageSize.width()*(defaultImageSize.height()/defaultImageSize.width()); |
|
441 |
newHeight = qMin(newHeight,maxHeight); |
|
442 |
imageSize.setHeight(newHeight); |
|
443 |
} |
|
444 |
||
445 |
if(newHeight == maxHeight) |
|
446 |
{ |
|
447 |
qreal newWidth = defaultImageSize.width()*newHeight/defaultImageSize.height(); |
|
448 |
imageSize.setWidth(newWidth); |
|
449 |
} |
|
450 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
451 |
if(mPixmapItem) |
31 | 452 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
453 |
mPixmapItem->setPreferredSize(imageSize); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
454 |
mPixmapItem->setSize(imageSize); |
31 | 455 |
if(mMainWindow->orientation() == Qt::Horizontal) |
456 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
457 |
QPointF currPos = mPixmapItem->pos(); |
31 | 458 |
currPos.setX(leftMargin+((maxWidth-imageSize.width())/2)); |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
459 |
mPixmapItem->setPos(currPos); |
31 | 460 |
} |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
461 |
mPixmapItem->show(); |
31 | 462 |
} |
463 |
||
464 |
if(mProcessingWidget) |
|
465 |
{ |
|
466 |
imageSize.setHeight(mProcessingWidget->preferredHeight()); |
|
467 |
mProcessingWidget->setPreferredSize(imageSize); |
|
468 |
mProcessingWidget->show(); |
|
469 |
} |
|
470 |
szHint.rheight() += imageSize.height(); |
|
471 |
} |
|
472 |
} |
|
473 |
||
474 |
||
475 |
mTextEdit->setMinimumHeight(maxHeight); |
|
476 |
szHint.rheight() += bodyItemSpacing; |
|
477 |
return szHint; |
|
478 |
} |
|
479 |
||
480 |
void MsgUnifiedEditorBody::removeMedia() |
|
481 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
482 |
QObject* senderObject = sender(); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
483 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
484 |
MsgUnifiedEditorPixmapWidget* pixmap = |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
485 |
qobject_cast<MsgUnifiedEditorPixmapWidget*>(senderObject); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
486 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
487 |
MsgUniFiedEditorAudioWidget* audio = |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
488 |
qobject_cast<MsgUniFiedEditorAudioWidget*>(senderObject); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
489 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
490 |
if(pixmap) //remove image |
31 | 491 |
{ |
492 |
mImageFile.clear(); |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
493 |
if(mPixmapItem) |
31 | 494 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
495 |
mPixmapItem->setParent(NULL); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
496 |
delete mPixmapItem; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
497 |
mPixmapItem = NULL; |
31 | 498 |
} |
499 |
setImage(false); |
|
500 |
mImageSize = 0; |
|
501 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
502 |
else if(audio)//remove audio item |
31 | 503 |
{ |
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
504 |
mAudioFile.clear(); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
505 |
if(mAudioItem) |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
506 |
{ |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
507 |
mAudioItem->setParent(NULL); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
508 |
delete mAudioItem; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
509 |
mAudioItem = NULL; |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
510 |
} |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
511 |
setAudio(false); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
512 |
mAudioSize = 0; |
31 | 513 |
} |
514 |
||
515 |
this->repolish(); |
|
516 |
||
517 |
emit contentChanged(); |
|
518 |
} |
|
519 |
||
520 |
bool MsgUnifiedEditorBody::hasImage() |
|
521 |
{ |
|
522 |
return mHasImage; |
|
523 |
} |
|
524 |
||
525 |
void MsgUnifiedEditorBody::setImage(bool image) |
|
526 |
{ |
|
527 |
mHasImage = image; |
|
528 |
} |
|
529 |
||
530 |
bool MsgUnifiedEditorBody::hasAudio() |
|
531 |
{ |
|
532 |
return mHasAudio; |
|
533 |
} |
|
534 |
||
535 |
void MsgUnifiedEditorBody::setAudio(bool audio) |
|
536 |
{ |
|
537 |
mHasAudio = audio; |
|
538 |
} |
|
539 |
||
540 |
int MsgUnifiedEditorBody::bodySize() |
|
541 |
{ |
|
542 |
int bodysize = 0; |
|
543 |
||
544 |
if( mImageSize || mTextEdit->toPlainText().size() || |
|
545 |
mAudioSize || mVideoSize ) |
|
546 |
{ |
|
547 |
UniEditorGenUtils* uniEditorGenUtils = new UniEditorGenUtils; |
|
548 |
bodysize += mImageSize + mAudioSize + mVideoSize + |
|
549 |
uniEditorGenUtils->UTF8Size(mTextEdit->toPlainText()) + |
|
550 |
KEstimatedMimeHeaderSize + KEstimatedMmsSmilHeaderSize; |
|
551 |
delete uniEditorGenUtils; |
|
552 |
} |
|
553 |
return bodysize; |
|
554 |
} |
|
555 |
||
556 |
int MsgUnifiedEditorBody::messageSize() |
|
557 |
{ |
|
558 |
int estimatedMediaSize = bodySize(); |
|
559 |
if(!estimatedMediaSize) |
|
560 |
{ |
|
561 |
// This is the first media content to be inserted |
|
562 |
estimatedMediaSize = KEstimatedMmsSmilHeaderSize; |
|
563 |
} |
|
564 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
565 |
return estimatedMediaSize + MsgUnifiedEditorMonitor::subjectSize() + MsgUnifiedEditorMonitor::containerSize(); |
31 | 566 |
} |
567 |
||
568 |
void MsgUnifiedEditorBody::onTextChanged() |
|
569 |
{ |
|
570 |
QString string = text(); |
|
571 |
||
572 |
if( string.size() > mPrevBuffer.size() && |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
573 |
MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Mms ) |
31 | 574 |
{ |
575 |
// reject any text input if mms size limit is reached |
|
576 |
int futureSize = bodySize() + |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
577 |
MsgUnifiedEditorMonitor::containerSize() + MsgUnifiedEditorMonitor::subjectSize(); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
578 |
if(futureSize > MsgUnifiedEditorMonitor::maxMmsSize()) |
31 | 579 |
{ |
580 |
mTextEdit->setPlainText(mPrevBuffer); |
|
581 |
HbNotificationDialog::launchDialog(LOC_UNABLE_TO_ADD_CONTENT); |
|
582 |
mTextEdit->setCursorPosition(mPrevBuffer.length()); |
|
583 |
return; |
|
584 |
} |
|
585 |
else if(!mPrevBuffer.isEmpty()) |
|
586 |
{ |
|
587 |
//Save the previous buffer |
|
588 |
mPrevBuffer = string; |
|
589 |
// emit signal to indicate change in content |
|
590 |
emit contentChanged(); |
|
591 |
return; |
|
592 |
} |
|
593 |
} |
|
594 |
||
595 |
//Check done for optimization |
|
596 |
//Only if content is deleted we need to call encodingsettings again |
|
597 |
if (mPrevBuffer.isEmpty() || string.size() <= mPrevBuffer.size()) |
|
598 |
{ |
|
599 |
mPluginInterface->setEncodingSettings(EFalse, ESmsEncodingNone, |
|
600 |
mCharSupportType); |
|
601 |
} |
|
602 |
||
603 |
TInt numOfRemainingChars; |
|
604 |
TInt numOfPDUs; |
|
605 |
TBool unicodeMode; |
|
606 |
TSmsEncoding alternativeEncodingType; |
|
607 |
mPluginInterface->getNumPDUs(string, numOfRemainingChars, numOfPDUs, |
|
608 |
unicodeMode, alternativeEncodingType); |
|
609 |
||
610 |
//Save the unicode value returned |
|
611 |
mUnicode = unicodeMode; |
|
612 |
//Save the old buffer |
|
613 |
mPrevBuffer = string; |
|
614 |
||
615 |
// emit signal to indicate change in content |
|
616 |
emit contentChanged(); |
|
617 |
||
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
618 |
if(MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Sms) |
31 | 619 |
{ |
620 |
//Set char counter value |
|
621 |
QString display = QString("%1(%2)").arg(numOfRemainingChars).arg( |
|
622 |
numOfPDUs); |
|
623 |
mCharCounter->setText(display); |
|
624 |
||
625 |
if (numOfPDUs > 1 || numOfRemainingChars <= KShowCounterLimit) |
|
626 |
{ |
|
627 |
mCharCounter->setVisible(true); |
|
628 |
mBackgroundItem->setVisible(true); |
|
629 |
} |
|
630 |
else |
|
631 |
{ |
|
632 |
mCharCounter->setVisible(false); |
|
633 |
mBackgroundItem->setVisible(false); |
|
634 |
} |
|
635 |
} |
|
636 |
} |
|
637 |
||
638 |
void MsgUnifiedEditorBody::EditorOperationEvent( |
|
639 |
TUniEditorProcessImageOperationEvent aEvent, TFileName aFileName) |
|
640 |
{ |
|
641 |
delete mImageInfo; |
|
642 |
mImageInfo = NULL; |
|
643 |
||
644 |
if (aEvent == EUniEditorProcessImageOperationComplete && |
|
645 |
aFileName.Length() > 0) |
|
646 |
{ |
|
43
35b64624a9e7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
34
diff
changeset
|
647 |
mImageFile = XQConversions::s60DescToQString(aFileName); |
31 | 648 |
} |
649 |
else |
|
650 |
{ |
|
651 |
mImageFile = mSavedImageFile; |
|
652 |
} |
|
653 |
mSavedImageFile.clear(); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
654 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
655 |
// image resize is complete. reset the image resize flag |
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
656 |
mIsImageResizing = false; |
31 | 657 |
//handle the processed image from ProcessImage Operation |
658 |
handleSetImage(); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
659 |
|
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
660 |
stopResizeAnimation(); |
31 | 661 |
} |
662 |
||
663 |
void MsgUnifiedEditorBody::startResizeAnimation() |
|
664 |
{ |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
665 |
// emit signal to indicate disable the send tool button. |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
666 |
emit enableSendButton(false); |
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
667 |
|
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
668 |
|
31 | 669 |
QGraphicsLinearLayout* processingLayout = new QGraphicsLinearLayout(Qt::Vertical); |
670 |
||
671 |
mProcessingWidget = new HbWidget(this); |
|
672 |
HbStyle::setItemName(mProcessingWidget,"pixmap"); |
|
673 |
mProcessingWidget->hide(); |
|
674 |
mProcessingWidget->setLayout(processingLayout); |
|
675 |
||
676 |
HbTextItem* processingText = new HbTextItem(LOC_PROCESSING,mProcessingWidget); |
|
677 |
processingText->setAlignment(Qt::AlignCenter); |
|
678 |
processingLayout->addItem(processingText); |
|
679 |
||
680 |
HbIconItem* animationItem = new HbIconItem(ANIMATION_ICON,mProcessingWidget); |
|
44
36f374c67aa8
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
43
diff
changeset
|
681 |
animationItem->setAlignment(Qt::AlignHCenter); |
31 | 682 |
processingLayout->addItem(animationItem); |
683 |
||
684 |
HbIconAnimator& iconAnimator = animationItem->animator(); |
|
685 |
HbIconAnimationManager* iconAnimationManager = HbIconAnimationManager::global(); |
|
686 |
iconAnimationManager->addDefinitionFile(ANIMATION_FILE); |
|
687 |
||
688 |
iconAnimator.startAnimation(); |
|
689 |
||
690 |
this->repolish(); |
|
691 |
} |
|
692 |
||
693 |
void MsgUnifiedEditorBody::stopResizeAnimation() |
|
694 |
{ |
|
695 |
if(mProcessingWidget) |
|
696 |
{ |
|
697 |
delete mProcessingWidget; |
|
698 |
mProcessingWidget = NULL; |
|
699 |
} |
|
34
84197e66a4bd
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
700 |
|
31 | 701 |
} |
702 |
||
703 |
// --------------------------------------------------------- |
|
704 |
// MsgUnifiedEditorBody::isUnicode |
|
705 |
// --------------------------------------------------------- |
|
706 |
// |
|
707 |
bool MsgUnifiedEditorBody::isUnicode() |
|
708 |
{ |
|
709 |
return mUnicode; |
|
710 |
} |
|
711 |
||
712 |
// --------------------------------------------------------- |
|
713 |
// MsgUnifiedEditorBody::disableCharCounter |
|
714 |
// --------------------------------------------------------- |
|
715 |
// |
|
716 |
void MsgUnifiedEditorBody::disableCharCounter() |
|
717 |
{ |
|
718 |
mCharCounter->setVisible(false); |
|
719 |
mBackgroundItem->setVisible(false); |
|
720 |
} |
|
721 |
||
722 |
//--------------------------------------------------------------- |
|
723 |
// MsgUnifiedEditorBody :: setFocus |
|
724 |
// @see header file |
|
725 |
//--------------------------------------------------------------- |
|
726 |
void MsgUnifiedEditorBody::setFocus() |
|
727 |
{ |
|
728 |
mTextEdit->setFocus(Qt::MouseFocusReason); |
|
729 |
} |
|
730 |
// EOF |