author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 11:52:37 +0300 | |
branch | RCL_3 |
changeset 73 | c8382f7b54ef |
parent 64 | 3533d4323edc |
child 80 | 726fba06891a |
permissions | -rw-r--r-- |
64 | 1 |
/* |
2 |
* Copyright (c) 2007 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: This file implements classes CNcsAifEntry, CNcsAifEditor. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
#include "emailtrace.h" |
|
21 |
#include <AknsDrawUtils.h> |
|
22 |
#include <s32mem.h> |
|
23 |
#include <txtrich.h> |
|
24 |
#include <baclipb.h> |
|
25 |
#include <PtiDefs.h> |
|
26 |
#include <StringLoader.h> |
|
27 |
#include <FreestyleEmailUi.rsg> |
|
28 |
||
29 |
#include "ncsaifeditor.h" |
|
30 |
#include "ncsconstants.h" |
|
31 |
#include "ncsaddressinputfield.h" |
|
32 |
#include "ncsutility.h" |
|
33 |
#include "FreestyleEmailUiUtilities.h" |
|
34 |
#include "ncsemailaddressobject.h" |
|
35 |
#include "FreestyleEmailUiLayoutData.h" |
|
36 |
#include "FSDelayedLoader.h" |
|
37 |
#include "FSEmail.pan" |
|
38 |
||
39 |
const TChar KCharAddressDelimeterSemiColon = ';'; |
|
40 |
const TChar KCharAddressDelimeterComma = ','; |
|
41 |
const TChar KCharSpace = ' '; |
|
42 |
const TChar KCharAt = '@'; |
|
43 |
||
44 |
// --------------------------------------------------------------------------- |
|
45 |
// CNcsAifEntry::NewL |
|
46 |
// --------------------------------------------------------------------------- |
|
47 |
// |
|
48 |
CNcsAifEntry* CNcsAifEntry::NewL( const CNcsEmailAddressObject& aAddr ) |
|
49 |
{ |
|
50 |
FUNC_LOG; |
|
51 |
CNcsAifEntry* self = new (ELeave) CNcsAifEntry; |
|
52 |
CleanupStack::PushL(self); |
|
53 |
self->ConstructL( aAddr ); |
|
54 |
CleanupStack::Pop(self); |
|
55 |
return self; |
|
56 |
} |
|
57 |
||
58 |
// --------------------------------------------------------------------------- |
|
59 |
// CNcsAifEntry::NewL |
|
60 |
// --------------------------------------------------------------------------- |
|
61 |
// |
|
62 |
CNcsAifEntry* CNcsAifEntry::NewL( |
|
63 |
const TDesC& aDn, |
|
64 |
const TDesC& aEml, |
|
65 |
TBool aDisplayFull ) |
|
66 |
{ |
|
67 |
FUNC_LOG; |
|
68 |
CNcsAifEntry* self = new ( ELeave ) CNcsAifEntry; |
|
69 |
CleanupStack::PushL( self ); |
|
70 |
self->ConstructL( aDn, aEml, aDisplayFull ); |
|
71 |
CleanupStack::Pop( self ); |
|
72 |
return self; |
|
73 |
} |
|
74 |
||
75 |
// --------------------------------------------------------------------------- |
|
76 |
// CNcsAifEntry::~CNcsAifEntry |
|
77 |
// --------------------------------------------------------------------------- |
|
78 |
// |
|
79 |
CNcsAifEntry::~CNcsAifEntry() |
|
80 |
{ |
|
81 |
FUNC_LOG; |
|
82 |
delete iAddress; |
|
83 |
delete iDisplayString; |
|
84 |
} |
|
85 |
||
86 |
// --------------------------------------------------------------------------- |
|
87 |
// CNcsAifEntry::CNcsAifEntry |
|
88 |
// --------------------------------------------------------------------------- |
|
89 |
// |
|
90 |
CNcsAifEntry::CNcsAifEntry() |
|
91 |
{ |
|
92 |
FUNC_LOG; |
|
93 |
} |
|
94 |
||
95 |
// --------------------------------------------------------------------------- |
|
96 |
// CNcsAifEntry::ConstructL |
|
97 |
// --------------------------------------------------------------------------- |
|
98 |
// |
|
99 |
void CNcsAifEntry::ConstructL( const TDesC& aDn, const TDesC& aEml, TBool aDisplayFull ) |
|
100 |
{ |
|
101 |
FUNC_LOG; |
|
102 |
iAddress = CNcsEmailAddressObject::NewL( aDn, aEml ); |
|
103 |
iAddress->SetDisplayFull( aDisplayFull ); |
|
104 |
ConstructL(); |
|
105 |
} |
|
106 |
||
107 |
// --------------------------------------------------------------------------- |
|
108 |
// CNcsAifEntry::ConstructL |
|
109 |
// --------------------------------------------------------------------------- |
|
110 |
// |
|
111 |
void CNcsAifEntry::ConstructL( const CNcsEmailAddressObject& aAddress ) |
|
112 |
{ |
|
113 |
FUNC_LOG; |
|
114 |
iAddress = CNcsEmailAddressObject::NewL( aAddress ); |
|
115 |
ConstructL(); |
|
116 |
} |
|
117 |
||
118 |
// --------------------------------------------------------------------------- |
|
119 |
// CNcsAifEntry::ConstructL |
|
120 |
// --------------------------------------------------------------------------- |
|
121 |
// |
|
122 |
void CNcsAifEntry::ConstructL() |
|
123 |
{ |
|
124 |
FUNC_LOG; |
|
125 |
SetDisplayStringL(); |
|
126 |
} |
|
127 |
||
128 |
// --------------------------------------------------------------------------- |
|
129 |
// CNcsAifEntry::SetDisplayStringL |
|
130 |
// --------------------------------------------------------------------------- |
|
131 |
// |
|
132 |
void CNcsAifEntry::SetDisplayStringL() |
|
133 |
{ |
|
134 |
FUNC_LOG; |
|
135 |
delete iDisplayString; |
|
136 |
iDisplayString = NULL; |
|
137 |
||
138 |
const TDesC& dname = iAddress->DisplayName(); |
|
139 |
const TDesC& email = iAddress->EmailAddress(); |
|
140 |
||
141 |
TInt dnameLength = dname.Length(); |
|
142 |
TInt emailLength = email.Length(); |
|
143 |
||
144 |
TBool displayFull = iAddress->DisplayFull() || iIsDup; |
|
145 |
||
146 |
TInt length; |
|
147 |
// Show only display name OR email address if showing both is not required |
|
148 |
// or if display name doesn't contain anything but the email address |
|
149 |
// or if the display name is empty |
|
150 |
if ( !displayFull || |
|
151 |
dname == email || |
|
152 |
!dnameLength ) |
|
153 |
{ |
|
154 |
length = dnameLength > 0 ? dnameLength : emailLength; |
|
155 |
length += KEmailAddressSeparator().Length(); // ';' |
|
156 |
||
157 |
iDisplayString = HBufC::NewL( length ); |
|
158 |
TPtr ptr = iDisplayString->Des(); |
|
159 |
||
160 |
ptr.Append( dname.Length() > 0 ? dname : email ); |
|
161 |
ptr.Append( KEmailAddressSeparator ); |
|
162 |
} |
|
163 |
||
164 |
// Otherwise, show both display name and email addresss |
|
165 |
else |
|
166 |
{ |
|
167 |
// Display, Name; |
|
168 |
length = dnameLength + emailLength + |
|
169 |
KSpace().Length() + |
|
170 |
KEmailAddressDecorationHead().Length() + |
|
171 |
KEmailAddressDecorationTail().Length() + |
|
172 |
KEmailAddressSeparator().Length(); |
|
173 |
||
174 |
iDisplayString = HBufC::NewL( length ); |
|
175 |
TPtr ptr = iDisplayString->Des(); |
|
176 |
||
177 |
ptr.Append( dname ); |
|
178 |
ptr.Append( KSpace ); |
|
179 |
ptr.Append( KEmailAddressDecorationHead ); |
|
180 |
ptr.Append( email ); |
|
181 |
ptr.Append( KEmailAddressDecorationTail ); |
|
182 |
ptr.Append( KEmailAddressSeparator ); |
|
183 |
} |
|
184 |
} |
|
185 |
||
186 |
// --------------------------------------------------------------------------- |
|
187 |
// CNcsAifEntry::SetDupL |
|
188 |
// --------------------------------------------------------------------------- |
|
189 |
// |
|
190 |
void CNcsAifEntry::SetDupL( TBool aDup ) |
|
191 |
{ |
|
192 |
FUNC_LOG; |
|
193 |
if ( iIsDup != aDup ) |
|
194 |
{ |
|
195 |
iIsDup = aDup; |
|
196 |
// Display string needs to be recreated unless there's no |
|
197 |
// meaningful display name |
|
198 |
if ( iAddress->DisplayName().Length() && |
|
199 |
iAddress->DisplayName() != iAddress->EmailAddress() ) |
|
200 |
{ |
|
201 |
SetDisplayStringL(); |
|
202 |
} |
|
203 |
} |
|
204 |
} |
|
205 |
||
206 |
// --------------------------------------------------------------------------- |
|
207 |
// CNcsAifEntry::IsSameDN |
|
208 |
// --------------------------------------------------------------------------- |
|
209 |
// |
|
210 |
TBool CNcsAifEntry::IsSameDN( const CNcsAifEntry& entry ) const |
|
211 |
{ |
|
212 |
FUNC_LOG; |
|
213 |
const TDesC& ownDn = Address().DisplayName(); |
|
214 |
const TDesC& otherDn = entry.Address().DisplayName(); |
|
215 |
return ownDn.Compare( otherDn ) == 0; |
|
216 |
} |
|
217 |
||
218 |
// --------------------------------------------------------------------------- |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
219 |
// Constructor |
64 | 220 |
// --------------------------------------------------------------------------- |
221 |
// |
|
222 |
CNcsAifEditor::CNcsAifEditor( |
|
223 |
MNcsFieldSizeObserver* aSizeObserver, const TDesC& aCaptionText ) |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
224 |
: CNcsEditor( aSizeObserver, ETrue, ENcsEditorAddress, aCaptionText ), |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
225 |
iAddressPopupList( NULL ), |
64 | 226 |
iAddLeftover( ETrue ) |
227 |
{ |
|
228 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
229 |
SetEdwinObserver( this ); |
64 | 230 |
} |
231 |
||
232 |
// --------------------------------------------------------------------------- |
|
233 |
// second phase constructor |
|
234 |
// --------------------------------------------------------------------------- |
|
235 |
// |
|
236 |
void CNcsAifEditor::ConstructL( const CCoeControl* aParent, |
|
237 |
TInt aNumberOfLines, |
|
238 |
TInt aTextLimit ) |
|
239 |
{ |
|
240 |
FUNC_LOG; |
|
241 |
CNcsEditor::ConstructL( aParent, aNumberOfLines, aTextLimit ); |
|
242 |
iAsyncCallBack = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard ); |
|
243 |
} |
|
244 |
||
245 |
// --------------------------------------------------------------------------- |
|
246 |
// destructor |
|
247 |
// --------------------------------------------------------------------------- |
|
248 |
// |
|
249 |
CNcsAifEditor::~CNcsAifEditor() |
|
250 |
{ |
|
251 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
252 |
iArray.ResetAndDestroy(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
253 |
iAddressArray.Reset(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
254 |
if ( iAsyncCallBack ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
255 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
256 |
iAsyncCallBack->Cancel(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
257 |
delete iAsyncCallBack; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
258 |
} |
64 | 259 |
} |
260 |
||
261 |
// ----------------------------------------------------------------------------- |
|
262 |
// CNcsAifEditor::CursorLineNumber() const |
|
263 |
// ----------------------------------------------------------------------------- |
|
264 |
// |
|
265 |
TInt CNcsAifEditor::CursorLineNumber() const |
|
266 |
{ |
|
267 |
FUNC_LOG; |
|
268 |
||
269 |
TInt ret = iLayout->GetLineNumber( CursorPos() ); |
|
270 |
ret++; |
|
271 |
return ret; |
|
272 |
} |
|
273 |
||
274 |
// ----------------------------------------------------------------------------- |
|
275 |
// CNcsAifEditor::LineCount() const |
|
276 |
// ----------------------------------------------------------------------------- |
|
277 |
// |
|
278 |
TInt CNcsAifEditor::LineCount() const |
|
279 |
{ |
|
280 |
FUNC_LOG; |
|
281 |
TInt lineCount = iLayout->GetLineNumber( TextLength() ); |
|
282 |
lineCount++; |
|
283 |
return lineCount; |
|
284 |
} |
|
285 |
||
286 |
// ----------------------------------------------------------------------------- |
|
287 |
// CNcsAifEditor::OfferKeyEventL() |
|
288 |
// ----------------------------------------------------------------------------- |
|
289 |
// |
|
290 |
TKeyResponse CNcsAifEditor::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
291 |
TEventCode aType ) |
|
292 |
{ |
|
293 |
FUNC_LOG; |
|
294 |
TKeyResponse ret = EKeyWasNotConsumed; |
|
295 |
||
296 |
// check if we are copying |
|
297 |
if ( ret == EKeyWasNotConsumed ) |
|
298 |
{ |
|
299 |
ret = CopyEntriesToClipboardL( aKeyEvent, aType ); |
|
300 |
} |
|
301 |
||
302 |
// Check if we need to delete a contact |
|
303 |
// This is done before select since they key off of the same key code. |
|
304 |
if ( ret == EKeyWasNotConsumed ) |
|
305 |
{ |
|
306 |
ret = HandleContactDeletionL( aKeyEvent, aType ); |
|
307 |
} |
|
308 |
||
309 |
// Check if we need to highlight a contact |
|
310 |
if ( ret == EKeyWasNotConsumed ) |
|
311 |
{ |
|
312 |
ret = SetEditorSelectionL( aKeyEvent, aType ); |
|
313 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
314 |
|
64 | 315 |
//when press a key down, record the coursor position |
316 |
if ( aType == EEventKeyDown ) |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
317 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
318 |
iLastTimeCursorPos = CursorPos(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
319 |
} |
64 | 320 |
|
321 |
if ( ret == EKeyWasNotConsumed ) |
|
322 |
{ |
|
323 |
// enter completes the address entry |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
324 |
if ( aType == EEventKey && ( aKeyEvent.iCode == EKeyEnter || |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
325 |
aKeyEvent.iScanCode == EStdKeyEnter ) ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
326 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
327 |
// make sure there is really some text inputted |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
328 |
const TInt cursorPos = CursorPos(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
329 |
TCursorSelection selection = NonEntryTextAtPos( cursorPos ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
330 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
331 |
const TInt length = selection.Length(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
332 |
if ( length > 0 ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
333 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
334 |
HBufC* text = HBufC::NewLC( length ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
335 |
TPtr ptr = text->Des(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
336 |
Text()->Extract( ptr, selection.LowerPos(), length ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
337 |
ptr.Trim(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
338 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
339 |
// complete the entry by adding a semicolon, |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
340 |
// address will be added in HandleTextUpdateL |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
341 |
if ( ptr.Length() > 0 ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
342 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
343 |
Text()->InsertL( cursorPos, KCharAddressDelimeterSemiColon ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
344 |
HandleTextChangedL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
345 |
SetCursorPosL( cursorPos + 1, EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
346 |
iLastTimeCursorPos = CursorPos(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
347 |
HandleTextUpdateL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
348 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
349 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
350 |
CleanupStack::PopAndDestroy( text ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
351 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
352 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
353 |
else if ( IsCharacterKey( aKeyEvent ) ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
354 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
355 |
PrepareForTextInputL( CursorPos() ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
356 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
357 |
iTextSelection = Selection(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
358 |
ret = CNcsEditor::OfferKeyEventL( aKeyEvent, aType ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
359 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
360 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
361 |
// for Korean we need to simulate event 'text update' as FEP |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
362 |
// doesn't send it and the MRU is not shown |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
363 |
if ( User::Language() == ELangKorean ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
364 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
365 |
if ( ret == EKeyWasNotConsumed && aType == EEventKeyUp ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
366 |
{ |
64 | 367 |
TInt cursorPos( CursorPos() ); |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
368 |
|
64 | 369 |
TCursorSelection selection = NonEntryTextAtPos( cursorPos ); |
370 |
||
371 |
TInt length( selection.Length() ); |
|
372 |
||
373 |
HBufC* text = HBufC::NewLC( length ); |
|
374 |
TPtr ptr = text->Des(); |
|
375 |
Text()->Extract( ptr, selection.LowerPos(), length ); |
|
376 |
ptr.Trim(); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
377 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
378 |
if ( TFsEmailUiUtility::IsKoreanWord( ptr ) ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
379 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
380 |
HandleTextUpdateDeferred(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
381 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
382 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
383 |
CleanupStack::PopAndDestroy( text ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
384 |
} |
64 | 385 |
} |
386 |
||
387 |
return ret; |
|
388 |
} |
|
389 |
||
390 |
// ----------------------------------------------------------------------------- |
|
391 |
// CNcsAifEditor::HandleEdwinEventL() |
|
392 |
// This function gets called if a character is entered through the FEP. |
|
393 |
// Otherwise the character entry is added through OfferKeyEvent |
|
394 |
// ----------------------------------------------------------------------------- |
|
395 |
// |
|
396 |
void CNcsAifEditor::HandleEdwinEventL( CEikEdwin* /*aEdwin*/, |
|
397 |
TEdwinEvent aEventType ) |
|
398 |
{ |
|
399 |
FUNC_LOG; |
|
400 |
if ( aEventType == MEikEdwinObserver::EEventTextUpdate ) |
|
401 |
{ |
|
402 |
// Remove any invalid entries. This is needed when entries have been marked |
|
403 |
// and have got replaced with some key event handled by FEP. |
|
404 |
CheckAndRemoveInvalidEntriesL(); |
|
405 |
||
406 |
// Make a deferred call to HandleTextUpdateL() because it may result in |
|
407 |
// changing the text field contents, and doing so directly within HandleEdwinEventL |
|
408 |
// causes problems for the FEP in some special cases. |
|
409 |
HandleTextUpdateDeferred(); |
|
410 |
} |
|
411 |
else if ( aEventType == MEikEdwinObserver::EEventNavigation ) |
|
412 |
{ |
|
413 |
iTextSelection = Selection(); |
|
414 |
HandleNavigationEventL(); |
|
415 |
} |
|
416 |
} |
|
417 |
||
418 |
// ----------------------------------------------------------------------------- |
|
419 |
// CNcsAifEditor::SetEditorSelectionL() |
|
420 |
// ----------------------------------------------------------------------------- |
|
421 |
// |
|
422 |
TKeyResponse CNcsAifEditor::SetEditorSelectionL( const TKeyEvent& aKeyEvent, |
|
423 |
TEventCode aType ) |
|
424 |
{ |
|
425 |
FUNC_LOG; |
|
426 |
TKeyResponse response = EKeyWasNotConsumed; |
|
427 |
CNcsAifEntry* entry = NULL; |
|
428 |
TCursorSelection selection = Selection(); |
|
429 |
||
430 |
// Moving to a new line is a special case. |
|
431 |
// We need to offer the key to the editor control first so it can |
|
432 |
// move the cursor for us. Then we check if it's in an entry. |
|
433 |
if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow ) |
|
434 |
{ |
|
435 |
CompleteEntryL(); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
436 |
|
64 | 437 |
response = CNcsEditor::OfferKeyEventL( aKeyEvent,aType ); |
438 |
if ( response == EKeyWasConsumed ) |
|
439 |
{ |
|
440 |
// We're moving to a new line. |
|
441 |
entry = GetEntryAt( CursorPos() ); |
|
442 |
if ( entry ) |
|
443 |
{ |
|
444 |
SetSelectionL( entry->iCursorPos, entry->iAnchorPos ); |
|
445 |
} |
|
446 |
} |
|
447 |
} |
|
448 |
// Check if the cursor is in any of the addresses |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
449 |
else if ( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyBackspace ) |
64 | 450 |
{ |
451 |
// We're moving left, but haven't yet. |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
452 |
const TInt cursorPos = CursorPos(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
453 |
entry = GetEntryAt( cursorPos, EDirectionLeft ); |
64 | 454 |
if ( entry ) |
455 |
{ |
|
456 |
if ( selection.Length() && aKeyEvent.iCode == EKeyLeftArrow) |
|
457 |
{ |
|
458 |
// Adds or removes the entry from the current selection. |
|
459 |
SetSelectionL( entry->LowerPos(), selection.iAnchorPos ); |
|
460 |
response = EKeyWasConsumed; |
|
461 |
} |
|
462 |
else if ( !selection.Length() ) |
|
463 |
{ |
|
464 |
SetSelectionL( entry->LowerPos(), entry->HigherPos() ); |
|
465 |
response = EKeyWasConsumed; |
|
466 |
} |
|
467 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
468 |
else |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
469 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
470 |
// Complete entry, if cursor is being moved to the previous row. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
471 |
TCursorSelection selection = NonEntryTextAndSpaceAtPos( cursorPos ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
472 |
if ( cursorPos > 0 && selection.LowerPos() + 1 == cursorPos ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
473 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
474 |
if ( IsDelimiter( CharAtPos( selection.LowerPos() ) ) ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
475 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
476 |
CompleteEntryL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
477 |
SetCursorPosL( cursorPos, EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
478 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
479 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
480 |
} |
64 | 481 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
482 |
else if ( aKeyEvent.iCode == EKeyRightArrow || aKeyEvent.iCode == EKeyDelete ) |
64 | 483 |
{ |
484 |
// We're moving right, but haven't yet. |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
485 |
const TInt cursorPos = CursorPos(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
486 |
entry = GetEntryAt( cursorPos, EDirectionRight ); |
64 | 487 |
if ( entry ) |
488 |
{ |
|
489 |
if ( selection.Length() && aKeyEvent.iCode == EKeyRightArrow ) |
|
490 |
{ |
|
491 |
// Adds or removes the entry form the current selection. |
|
492 |
SetSelectionL( entry->HigherPos(), selection.iAnchorPos ); |
|
493 |
response = EKeyWasConsumed; |
|
494 |
} |
|
495 |
else if ( !selection.Length() ) |
|
496 |
{ |
|
497 |
SetSelectionL( entry->HigherPos(), entry->LowerPos() ); |
|
498 |
response = EKeyWasConsumed; |
|
499 |
} |
|
500 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
501 |
else |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
502 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
503 |
// Complete entry, if cursor is being moved to the next row. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
504 |
TCursorSelection selection = NonEntryTextAndSpaceAtPos( cursorPos ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
505 |
if ( cursorPos > 0 && selection.HigherPos() - 1 == cursorPos ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
506 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
507 |
if ( IsDelimiter( CharAtPos( selection.HigherPos() - 1 ) ) ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
508 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
509 |
CompleteEntryL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
510 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
511 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
512 |
} |
64 | 513 |
} |
514 |
// to fix problems with updating CBA when hash key is pressed and hold |
|
515 |
else if ( aKeyEvent.iScanCode == EStdKeyHash ) |
|
516 |
{ |
|
517 |
iAddressPopupList->ClosePopupContactListL(); |
|
518 |
} |
|
519 |
||
520 |
// Close the address popup if we handled the event |
|
521 |
if ( response == EKeyWasConsumed ) |
|
522 |
{ |
|
523 |
iAddressPopupList->ClosePopupContactListL(); |
|
524 |
} |
|
525 |
||
526 |
return response; |
|
527 |
} |
|
528 |
||
529 |
// --------------------------------------------------------------------------- |
|
530 |
// CNcsAifEditor::HandleContactDeletionL() |
|
531 |
// --------------------------------------------------------------------------- |
|
532 |
// |
|
533 |
TKeyResponse CNcsAifEditor::HandleContactDeletionL( const TKeyEvent& aKeyEvent, |
|
534 |
TEventCode aType ) |
|
535 |
{ |
|
536 |
FUNC_LOG; |
|
537 |
TKeyResponse response = EKeyWasNotConsumed; |
|
538 |
if ( SelectionLength() && aType == EEventKey |
|
539 |
&& IsCharacterKey( aKeyEvent ) ) |
|
540 |
{ |
|
541 |
// Delete highlighted entries. |
|
542 |
TCursorSelection selection = Selection(); |
|
543 |
TBool entryDeleted = EFalse; |
|
544 |
for ( TInt ii = iArray.Count() - 1; ii >= 0; --ii ) |
|
545 |
{ |
|
546 |
if ( iArray[ii]->LowerPos() >= selection.LowerPos() && |
|
547 |
iArray[ii]->HigherPos() <= selection.HigherPos() ) |
|
548 |
{ |
|
549 |
delete iArray[ii]; |
|
550 |
iArray.Remove( ii ); |
|
551 |
entryDeleted = ETrue; |
|
552 |
} |
|
553 |
} |
|
554 |
||
555 |
if ( entryDeleted ) |
|
556 |
{ |
|
557 |
// Check that duplicate entries are correctly marked. |
|
558 |
UpdateDuplicateEntryMarkingsL(); |
|
559 |
||
560 |
// Set the cursor after the entry before the ones we just deleted |
|
561 |
CNcsAifEntry* entry = NULL; |
|
562 |
for ( TInt ii = iArray.Count() - 1; ii >= 0; --ii ) |
|
563 |
{ |
|
564 |
if ( iArray[ii]->HigherPos() <= selection.LowerPos() ) |
|
565 |
{ |
|
566 |
entry = iArray[ii]; |
|
567 |
break; |
|
568 |
} |
|
569 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
570 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
571 |
SetCursorVisible( EFalse ); |
64 | 572 |
ClearSelectionL(); |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
573 |
RepositionEntries( entry ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
574 |
SetCursorVisible( ETrue ); |
64 | 575 |
|
576 |
// The key event is set consumed only on delete and backpace |
|
577 |
// events, other events need to be forwarded to the editor. |
|
578 |
if ( aKeyEvent.iCode == EKeyDelete || |
|
579 |
aKeyEvent.iCode == EKeyBackspace ) |
|
580 |
{ |
|
581 |
response = EKeyWasConsumed; |
|
582 |
} |
|
583 |
} |
|
584 |
} |
|
585 |
return response; |
|
586 |
} |
|
587 |
||
588 |
// --------------------------------------------------------------------------- |
|
589 |
// CNcsAifEditor::DoCharChangeL |
|
590 |
// --------------------------------------------------------------------------- |
|
591 |
// |
|
592 |
void CNcsAifEditor::DoCharChangeL() |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
593 |
{ |
64 | 594 |
FUNC_LOG; |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
595 |
RecalculateEntryPositions(); |
64 | 596 |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
597 |
TChar previousChar = CharAtPos( CursorPos() - 1 ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
598 |
TBool sentinel = ( previousChar == KCharAddressDelimeterSemiColon || |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
599 |
previousChar == KCharAddressDelimeterComma ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
600 |
if ( sentinel ) |
64 | 601 |
{ |
602 |
// if comma was pressed we replace it with semicolon |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
603 |
if ( previousChar == KCharAddressDelimeterComma ) |
64 | 604 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
605 |
CPlainText* text = Text(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
606 |
text->DeleteL( CursorPos() - 1, 1 ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
607 |
text->InsertL( CursorPos() - 1, KCharAddressDelimeterSemiColon ); |
64 | 608 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
609 |
ParseNewAddressL(); |
64 | 610 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
611 |
UpdateAddressAutoCompletionL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
612 |
} |
64 | 613 |
|
614 |
// --------------------------------------------------------------------------- |
|
615 |
// CNcsAddressInputField::CharAtPos |
|
616 |
// --------------------------------------------------------------------------- |
|
617 |
// |
|
618 |
TChar CNcsAifEditor::CharAtPos( TInt aPos ) const |
|
619 |
{ |
|
620 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
621 |
if ( aPos >= 0 && aPos < TextLength() ) |
64 | 622 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
623 |
TBuf<1> buf; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
624 |
Text()->Extract( buf, aPos, 1 ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
625 |
return buf[0]; |
64 | 626 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
627 |
else |
64 | 628 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
629 |
return 0; |
64 | 630 |
} |
631 |
} |
|
632 |
||
633 |
// ----------------------------------------------------------------------------- |
|
634 |
// CNcsAifEditor::SetAddressesL() |
|
635 |
// ----------------------------------------------------------------------------- |
|
636 |
// |
|
637 |
void CNcsAifEditor::SetAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
|
638 |
{ |
|
639 |
FUNC_LOG; |
|
640 |
iArray.Reset(); |
|
641 |
AppendAddressesL( aAddresses ); |
|
642 |
} |
|
643 |
||
644 |
// ----------------------------------------------------------------------------- |
|
645 |
// CNcsAifEditor::AppendAddressesL() |
|
646 |
// ----------------------------------------------------------------------------- |
|
647 |
// |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
648 |
void CNcsAifEditor::AppendAddressesL( |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
649 |
const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
64 | 650 |
{ |
651 |
FUNC_LOG; |
|
652 |
// First, add all the addresses without updating the editor text contents |
|
653 |
for ( TInt i=0 ; i<aAddresses.Count() ; i++ ) |
|
654 |
{ |
|
655 |
AddAddressL( *aAddresses[i], EFalse ); |
|
656 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
657 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
658 |
// Update editor text content after all the items have been added. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
659 |
SetCursorVisible( EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
660 |
const TInt count = iArray.Count(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
661 |
CNcsAifEntry* lastEntry = count ? iArray[count-1] : NULL; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
662 |
RepositionEntries( lastEntry ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
663 |
SetCursorVisible( ETrue ); |
64 | 664 |
} |
665 |
||
666 |
// ----------------------------------------------------------------------------- |
|
667 |
// CNcsAifEditor::GetAddressesL() |
|
668 |
// ----------------------------------------------------------------------------- |
|
669 |
// |
|
670 |
const RPointerArray<CNcsEmailAddressObject>& CNcsAifEditor::GetAddressesL() |
|
671 |
{ |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
672 |
// Clear the existing array since it may be out of sync |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
673 |
iAddressArray.Reset(); |
64 | 674 |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
675 |
for ( TInt i=0; i<iArray.Count(); i++ ) |
64 | 676 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
677 |
iAddressArray.AppendL( &iArray[i]->Address() ); |
64 | 678 |
} |
679 |
||
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
680 |
return iAddressArray; |
64 | 681 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
682 |
|
64 | 683 |
// ----------------------------------------------------------------------------- |
684 |
// CNcsAifEditor::GetEntryAt() |
|
685 |
// ----------------------------------------------------------------------------- |
|
686 |
// |
|
687 |
CNcsAifEntry* CNcsAifEditor::GetEntryAt( |
|
688 |
TInt aPos, |
|
689 |
TEntryDirection aDirection ) const |
|
690 |
{ |
|
691 |
FUNC_LOG; |
|
692 |
const TChar KSpace( ' ' ); |
|
693 |
||
694 |
for( TInt i = 0; i < iArray.Count(); i++ ) |
|
695 |
{ |
|
696 |
CNcsAifEntry* entry = iArray[i]; |
|
697 |
if ( aDirection == EDirectionNone ) |
|
698 |
{ |
|
699 |
// no direction, check if cursor is on entry |
|
700 |
if ( entry->Includes( aPos ) ) |
|
701 |
{ |
|
702 |
return entry; |
|
703 |
} |
|
704 |
} |
|
705 |
else if ( aDirection == EDirectionRight ) |
|
706 |
{ |
|
707 |
// direction to the righ. check if cursor is on entry or |
|
708 |
// entry is immediately to the right of the cursor |
|
709 |
if ( entry->Includes( aPos ) ) |
|
710 |
{ |
|
711 |
return entry; |
|
712 |
} |
|
713 |
||
714 |
if ( entry->Start() >= aPos && entry->Start() - aPos <= 1 && |
|
715 |
CharAtPos( aPos ) == KSpace ) |
|
716 |
{ |
|
717 |
return entry; |
|
718 |
} |
|
719 |
} |
|
720 |
else if ( aDirection == EDirectionLeft ) |
|
721 |
{ |
|
722 |
// direction to the left. decrease cursor by one and check if it |
|
723 |
// is on entry or if entry is immediately to the left of the cursor |
|
724 |
if ( entry->Includes( aPos - 1 ) ) |
|
725 |
{ |
|
726 |
return entry; |
|
727 |
} |
|
728 |
||
729 |
if ( aPos >= entry->End() && aPos - entry->End() <= 1 && |
|
730 |
CharAtPos( aPos - 1 ) == KSpace ) |
|
731 |
{ |
|
732 |
return entry; |
|
733 |
} |
|
734 |
} |
|
735 |
} |
|
736 |
return NULL; |
|
737 |
} |
|
738 |
||
739 |
// ----------------------------------------------------------------------------- |
|
740 |
// CNcsAifEditor::GetPreviousEntryFrom() |
|
741 |
// ----------------------------------------------------------------------------- |
|
742 |
// |
|
743 |
CNcsAifEntry* CNcsAifEditor::GetPreviousEntryFrom( TInt aPos ) const |
|
744 |
{ |
|
745 |
FUNC_LOG; |
|
746 |
CNcsAifEntry* entry = NULL; |
|
747 |
||
748 |
for( TInt i = 0 ; i < iArray.Count() ; i++ ) |
|
749 |
{ |
|
750 |
if ( iArray[i]->End() < aPos ) |
|
751 |
{ |
|
752 |
entry = iArray[i]; |
|
753 |
} |
|
754 |
else |
|
755 |
{ |
|
756 |
break; |
|
757 |
} |
|
758 |
} |
|
759 |
||
760 |
return entry; |
|
761 |
} |
|
762 |
||
763 |
// ----------------------------------------------------------------------------- |
|
764 |
// CNcsAifEditor::CheckAddressWhenFocusLostL() |
|
765 |
// ----------------------------------------------------------------------------- |
|
766 |
// |
|
767 |
void CNcsAifEditor::CheckAddressWhenFocusLostL() |
|
768 |
{ |
|
769 |
FUNC_LOG; |
|
770 |
ParseNewAddressL(); |
|
771 |
} |
|
772 |
||
773 |
// ----------------------------------------------------------------------------- |
|
774 |
// CNcsAifEditor::ParseNewAddressL() |
|
775 |
// ----------------------------------------------------------------------------- |
|
776 |
// |
|
777 |
void CNcsAifEditor::ParseNewAddressL() |
|
778 |
{ |
|
779 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
780 |
HBufC* text = GetNonEntryTextLC(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
781 |
__ASSERT_ALWAYS( text, Panic(EFSEmailUiNullPointerException) ); |
64 | 782 |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
783 |
if ( text->Length() ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
784 |
{ |
64 | 785 |
// if changing focus leftover text is parsed to email |
786 |
// object - we don't need to add it anymore |
|
787 |
iAddLeftover = EFalse; |
|
788 |
// check if there is a name for the email address |
|
789 |
HBufC* name = CFsDelayedLoader::InstanceL()->GetContactHandlerL()->GetLastSearchNameL( *text ); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
790 |
if ( name ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
791 |
{ |
64 | 792 |
CleanupStack::PushL( name ); |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
793 |
AddAddressL( *name, *text, ETrue ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
794 |
CleanupStack::PopAndDestroy( name ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
795 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
796 |
else |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
797 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
798 |
AddAddressL( KNullDesC, *text ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
799 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
800 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
801 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
802 |
CleanupStack::PopAndDestroy(text); |
64 | 803 |
} |
804 |
||
805 |
// ----------------------------------------------------------------------------- |
|
806 |
// CNcsAifEditor::GetNonEntryTextL() |
|
807 |
// This will extract any text that was entered that is not |
|
808 |
// part of any existing entries |
|
809 |
// ----------------------------------------------------------------------------- |
|
810 |
// |
|
811 |
HBufC* CNcsAifEditor::GetNonEntryTextLC() const |
|
812 |
{ |
|
813 |
FUNC_LOG; |
|
814 |
||
815 |
// "non-entry text" starts after last "entry" |
|
816 |
TInt start( 0 ); |
|
817 |
if ( iArray.Count() > 0 ) |
|
818 |
{ |
|
819 |
start = iArray[iArray.Count() - 1]->End(); |
|
820 |
} |
|
821 |
TInt length( TextLength() - start ); |
|
822 |
||
823 |
// Allocate space and extract it |
|
824 |
HBufC* text = HBufC::NewLC( length ); |
|
825 |
TPtr ptr = text->Des(); |
|
826 |
Text()->Extract( ptr, start, length ); |
|
827 |
||
828 |
// Wipe out possible delimiter |
|
829 |
TInt pos = ptr.Locate( KCharAddressDelimeterSemiColon ); |
|
830 |
if ( pos != KErrNotFound ) |
|
831 |
{ |
|
832 |
ptr.Delete( pos, 1 ); |
|
833 |
} |
|
834 |
||
835 |
// Remove unnecessary whitespaces |
|
836 |
ptr.Trim(); |
|
837 |
||
838 |
INFO_1("non-entry text == %S", text); |
|
839 |
return text; |
|
840 |
} |
|
841 |
||
842 |
// --------------------------------------------------------------------------- |
|
843 |
// CNcsAifEditor::CopyEntriesToClipBoardL |
|
844 |
// --------------------------------------------------------------------------- |
|
845 |
// |
|
846 |
TKeyResponse CNcsAifEditor::CopyEntriesToClipboardL( |
|
847 |
const TKeyEvent& aKeyEvent, |
|
848 |
TEventCode aType ) |
|
849 |
{ |
|
850 |
FUNC_LOG; |
|
851 |
TKeyResponse ret = EKeyWasNotConsumed; |
|
852 |
// check that we are copying |
|
853 |
TBool copyKeyEvent = ( aType == EEventKey && aKeyEvent.iCode == 3 && |
|
854 |
aKeyEvent.iModifiers & EModifierCtrl && |
|
855 |
aKeyEvent.iScanCode == EPtiKeyQwertyC ); |
|
856 |
TBool cutKeyEvent = ( aType == EEventKey && aKeyEvent.iCode == 24 && |
|
857 |
aKeyEvent.iModifiers & EModifierCtrl && |
|
858 |
aKeyEvent.iScanCode == EPtiKeyQwertyX ); |
|
859 |
if ( copyKeyEvent || cutKeyEvent ) |
|
860 |
{ |
|
861 |
RPointerArray<CNcsAifEntry> entries; |
|
862 |
CleanupClosePushL( entries ); |
|
863 |
FindSelectedEntriesL( entries ); |
|
864 |
if ( entries.Count() > 0 ) |
|
865 |
{ |
|
866 |
CancelFepTransaction(); |
|
867 |
HBufC* formattedText = GetFormattedAddressListLC( entries, EFalse ); |
|
868 |
TFsEmailUiUtility::CopyToClipboardL( *formattedText ); |
|
869 |
CleanupStack::PopAndDestroy( formattedText ); |
|
870 |
||
871 |
if ( !cutKeyEvent ) |
|
872 |
{ // cutting needs more handling |
|
873 |
ret = EKeyWasConsumed; |
|
874 |
} |
|
875 |
} |
|
876 |
CleanupStack::PopAndDestroy( &entries ); |
|
877 |
} |
|
878 |
return ret; |
|
879 |
} |
|
880 |
||
881 |
// ----------------------------------------------------------------------------- |
|
882 |
// CNcsAifEditor::FindSelectedEntriesL( ) |
|
883 |
// ----------------------------------------------------------------------------- |
|
884 |
// |
|
885 |
void CNcsAifEditor::FindSelectedEntriesL( RPointerArray<CNcsAifEntry>& aEntries ) |
|
886 |
{ |
|
887 |
FUNC_LOG; |
|
888 |
TCursorSelection selection = Selection(); |
|
889 |
TInt count = iArray.Count(); |
|
890 |
for ( TInt i = 0; i < iArray.Count(); i++ ) |
|
891 |
{ |
|
892 |
CNcsAifEntry* entry = iArray[i]; |
|
893 |
if ( entry->Start() >= selection.LowerPos() && |
|
894 |
entry->End() <= selection.HigherPos() ) |
|
895 |
{ |
|
896 |
aEntries.AppendL( entry ); |
|
897 |
} |
|
898 |
} |
|
899 |
} |
|
900 |
||
901 |
// ----------------------------------------------------------------------------- |
|
902 |
// CNcsAifEditor::EmailAddressIndexNameBySelection( ) |
|
903 |
// ----------------------------------------------------------------------------- |
|
904 |
// |
|
905 |
const CNcsEmailAddressObject* CNcsAifEditor::EmailAddressObjectBySelection() const |
|
906 |
{ |
|
907 |
FUNC_LOG; |
|
908 |
// Find the contact the cursor is in |
|
909 |
const CNcsAifEntry* aEntry = GetEntryAt(CursorPos()); |
|
910 |
ASSERT(aEntry != NULL); |
|
911 |
return &aEntry->Address(); |
|
912 |
} |
|
913 |
||
914 |
// ----------------------------------------------------------------------------- |
|
915 |
// CNcsAifEditor::AddAddressL() |
|
916 |
// ----------------------------------------------------------------------------- |
|
917 |
// |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
918 |
void CNcsAifEditor::AddAddressL( const CNcsEmailAddressObject& aAddress, |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
919 |
TBool aUpdateEditorText /*= ETrue*/ ) |
64 | 920 |
{ |
921 |
FUNC_LOG; |
|
922 |
CNcsAifEntry* entry = CNcsAifEntry::NewL( aAddress ); |
|
923 |
CleanupStack::PushL( entry ); |
|
924 |
AddAddressL( entry, aUpdateEditorText ); |
|
925 |
CleanupStack::Pop( entry ); |
|
926 |
} |
|
927 |
||
928 |
void CNcsAifEditor::AddAddressL( |
|
929 |
const TDesC& aDisplayName, |
|
930 |
const TDesC& aEmail, |
|
931 |
TBool aDisplayFull /*= EFalse*/, |
|
932 |
TBool aUpdateEditorText /*= ETrue*/ ) |
|
933 |
{ |
|
934 |
FUNC_LOG; |
|
935 |
CNcsAifEntry* entry = CNcsAifEntry::NewL( aDisplayName, aEmail, aDisplayFull ); |
|
936 |
CleanupStack::PushL( entry ); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
937 |
AddAddressL( entry, aUpdateEditorText ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
938 |
CleanupStack::Pop( entry ); |
64 | 939 |
} |
940 |
||
941 |
void CNcsAifEditor::AddAddressL( CNcsAifEntry* aNewEntry, TBool aUpdateEditorText ) |
|
942 |
{ |
|
943 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
944 |
TInt idx; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
945 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
946 |
// Check for duplicate display names |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
947 |
for ( idx=0 ; idx<iArray.Count() ; idx++ ) |
64 | 948 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
949 |
if ( iArray[idx]->IsSameDN(*aNewEntry) ) |
64 | 950 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
951 |
iArray[idx]->SetDupL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
952 |
aNewEntry->SetDupL(); |
64 | 953 |
} |
954 |
} |
|
955 |
||
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
956 |
// Find the location where we need to insert the address. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
957 |
// Browse from back to forth to make last index as default index. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
958 |
// This ensures items remain in correct order when populating field from |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
959 |
// existing message. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
960 |
TInt cursorPos = CursorPos(); |
64 | 961 |
// if we are at the end of editor the address was |
962 |
// added from MRU list or separator was typed in |
|
963 |
if ( cursorPos == Text()->DocumentLength() ) |
|
964 |
{ |
|
965 |
iAddLeftover = EFalse; |
|
966 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
967 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
968 |
for ( idx = iArray.Count() ; idx > 0 ; idx-- ) |
64 | 969 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
970 |
if ( cursorPos >= iArray[idx-1]->End() ) break; |
64 | 971 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
972 |
if ( idx == iArray.Count() ) |
64 | 973 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
974 |
// Tack the address onto the end of the array |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
975 |
iArray.AppendL( aNewEntry ); |
64 | 976 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
977 |
else |
64 | 978 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
979 |
iArray.InsertL( aNewEntry, idx ); |
64 | 980 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
981 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
982 |
if ( aUpdateEditorText ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
983 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
984 |
// Trap because we must not leave after we have taken the ownership of |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
985 |
// aNewEntry. Otherwise douple deletion might happen. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
986 |
SetCursorVisible( EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
987 |
RepositionEntries( aNewEntry ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
988 |
SetCursorVisible( ETrue ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
989 |
} |
64 | 990 |
} |
991 |
||
992 |
// --------------------------------------------------------------------------- |
|
993 |
// CNcsAifEditor::RecalculateEntryPositions() |
|
994 |
// The text has changed, so recalculate the positions of the items. |
|
995 |
// --------------------------------------------------------------------------- |
|
996 |
// |
|
997 |
void CNcsAifEditor::RecalculateEntryPositions() |
|
998 |
{ |
|
999 |
FUNC_LOG; |
|
1000 |
// We only need to worry about items right of the cursor |
|
1001 |
TInt pos = CursorPos(); |
|
1002 |
TInt error = KErrNone; |
|
1003 |
||
1004 |
// Find the first item to the right of the cursor |
|
1005 |
TInt idx = 0; |
|
1006 |
for ( idx = 0; idx < iArray.Count(); idx++ ) |
|
1007 |
{ |
|
1008 |
if ( ( iArray[idx]->Includes( iLastTimeCursorPos ) ) |
|
1009 |
|| ( iArray[idx]->Start() >= iLastTimeCursorPos ) ) |
|
1010 |
{ |
|
1011 |
break; |
|
1012 |
} |
|
1013 |
} |
|
1014 |
||
1015 |
// If no entry was to the right of the cursor position |
|
1016 |
// then the new text was added at the end of the text. |
|
1017 |
// Don't do anything |
|
1018 |
if ( idx == iArray.Count() ) |
|
1019 |
{ |
|
1020 |
return; |
|
1021 |
} |
|
1022 |
||
1023 |
// Find the location of the first entry to the right |
|
1024 |
// of the cursor using a display string match |
|
1025 |
pos = Min( iArray[idx]->Start(), pos ); |
|
1026 |
TRAP( error, pos = FindTextL( &iArray[idx]->DisplayString(), pos, |
|
1027 |
CEikEdwin::EFindCaseSensitive | CEikEdwin::ENoBusyMessage ) ); |
|
1028 |
ASSERT( KErrNone == error && KErrNotFound != pos ); |
|
1029 |
||
1030 |
// Now reposition all entries to the right |
|
1031 |
for ( ; idx<iArray.Count(); idx++ ) |
|
1032 |
{ |
|
1033 |
pos = iArray[idx]->SetPos( pos ); |
|
1034 |
pos++; // for whitespace |
|
1035 |
} |
|
1036 |
} |
|
1037 |
||
1038 |
// --------------------------------------------------------------------------- |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1039 |
// CNcsAifEditor::RepositionEntries() |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1040 |
// --------------------------------------------------------------------------- |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1041 |
// |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1042 |
TInt CNcsAifEditor::RepositionEntries( const CNcsAifEntry* aPosEntry ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1043 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1044 |
FUNC_LOG; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1045 |
TRAPD( err, RepositionEntriesL( aPosEntry ) ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1046 |
return err; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1047 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1048 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1049 |
// --------------------------------------------------------------------------- |
64 | 1050 |
// CNcsAifEditor::RepositionEntriesL() |
1051 |
// --------------------------------------------------------------------------- |
|
1052 |
// |
|
1053 |
void CNcsAifEditor::RepositionEntriesL( const CNcsAifEntry* aPosEntry ) |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1054 |
{ |
64 | 1055 |
FUNC_LOG; |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1056 |
TInt pos = 0; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1057 |
CNcsAifEntry* entry; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1058 |
for ( TInt i=0 ; i<iArray.Count() ; i++ ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1059 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1060 |
entry = iArray[i]; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1061 |
pos = entry->SetPos( pos ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1062 |
pos++; // for whitespace |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1063 |
} |
64 | 1064 |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1065 |
// Reset the text |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1066 |
HBufC* text = GetFormattedAddressListLC( iArray ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1067 |
// fix for dissapearing text PWAN-82DNEJ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1068 |
//SetCursorPosL( 0, EFalse ); //In case the cursor pos is invalid |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1069 |
|
64 | 1070 |
if ( iAddLeftover ) |
1071 |
{ |
|
1072 |
TInt lengthBefore = Text()->DocumentLength(); |
|
1073 |
HBufC* textBefore = HBufC::NewLC( lengthBefore ); |
|
1074 |
TPtr ptrBefore = textBefore->Des(); |
|
1075 |
Text()->Extract( ptrBefore, 0, lengthBefore ); |
|
1076 |
ptrBefore.Trim(); |
|
1077 |
// find text after last semicolon |
|
1078 |
TInt colon = ptrBefore.LocateReverseF( |
|
1079 |
KCharAddressDelimeterSemiColon ) + 1; |
|
1080 |
TPtrC leftover = ptrBefore.Mid( colon ); |
|
1081 |
HBufC* newText = HBufC::NewLC( text->Length() + leftover.Length() ); |
|
1082 |
TPtr newTextPtr = newText->Des(); |
|
1083 |
// add all email addresses |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1084 |
newTextPtr.Append( *text ); |
64 | 1085 |
// add the text that was after last email object |
1086 |
newTextPtr.Append( leftover ); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1087 |
|
64 | 1088 |
SetTextL( newText ); |
1089 |
CleanupStack::PopAndDestroy( newText ); |
|
1090 |
CleanupStack::PopAndDestroy( textBefore ); |
|
1091 |
} |
|
1092 |
else |
|
1093 |
{ |
|
1094 |
SetTextL( text ); |
|
1095 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1096 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1097 |
if ( !aPosEntry ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1098 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1099 |
// Set cursor at the beginning of the document. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1100 |
SetCursorPosL( 0, EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1101 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1102 |
else |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1103 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1104 |
// Set the cursor at the end of the given entry |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1105 |
SetCursorPosL( aPosEntry->End(), EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1106 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1107 |
|
64 | 1108 |
CleanupStack::PopAndDestroy( text ); |
1109 |
HandleTextChangedL(); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1110 |
} |
64 | 1111 |
|
1112 |
// --------------------------------------------------------------------------- |
|
1113 |
// CNcsAifEditor::CheckAndRemoveInvalidEntriesL() |
|
1114 |
// --------------------------------------------------------------------------- |
|
1115 |
// |
|
1116 |
void CNcsAifEditor::CheckAndRemoveInvalidEntriesL() |
|
1117 |
{ |
|
1118 |
FUNC_LOG; |
|
1119 |
TInt currentCursorPos( CursorPos() ); |
|
1120 |
const TInt KNoEntryRemoved = -1; |
|
1121 |
TInt removedEntryIndex( KNoEntryRemoved ); |
|
1122 |
||
1123 |
for ( TInt i = iArray.Count() - 1 ; i >= 0 ; --i ) |
|
1124 |
{ |
|
1125 |
TInt matchesInText; |
|
1126 |
TInt matchesInArray; |
|
1127 |
TInt arrayItemLowPos( iArray[i]->LowerPos() ); |
|
1128 |
TInt arrayItemHighPos( iArray[i]->HigherPos()); |
|
1129 |
||
1130 |
GetMatchingEntryCountsL( iArray[i], matchesInText, matchesInArray ); |
|
1131 |
||
1132 |
// Entry is removed if: |
|
1133 |
// a) there's no matches for it in the text, or |
|
1134 |
// b) there're less matches for it in the text than in array (i.e., |
|
1135 |
// a duplicate ("foo(at)foo.org; foo(at)foo.org") has just been removed) |
|
1136 |
// In b) case the correct duplicate is the one that is in current |
|
1137 |
// cursor position (or one off due to possible whitespace). |
|
1138 |
if ( 0 == matchesInText || |
|
1139 |
( matchesInText < matchesInArray ) && |
|
1140 |
( currentCursorPos >= arrayItemLowPos && |
|
1141 |
currentCursorPos <= arrayItemHighPos )) |
|
1142 |
{ |
|
1143 |
delete iArray[i]; |
|
1144 |
iArray.Remove(i); |
|
1145 |
removedEntryIndex = i; |
|
1146 |
if ( iTextSelection.iAnchorPos != iTextSelection.iCursorPos && |
|
1147 |
iTextSelection.HigherPos() < arrayItemHighPos ) |
|
1148 |
{ |
|
1149 |
iPartialRemove = ETrue; |
|
1150 |
} |
|
1151 |
} |
|
1152 |
} |
|
1153 |
||
1154 |
if ( KNoEntryRemoved != removedEntryIndex ) |
|
1155 |
{ |
|
1156 |
// at least one entry has been removed => udpates duplicate markings |
|
1157 |
UpdateDuplicateEntryMarkingsL(); |
|
1158 |
} |
|
1159 |
} |
|
1160 |
||
1161 |
// --------------------------------------------------------------------------- |
|
1162 |
// CNcsAifEditor::GetLookupTextLC() |
|
1163 |
// --------------------------------------------------------------------------- |
|
1164 |
// |
|
1165 |
HBufC* CNcsAifEditor::GetLookupTextLC() const |
|
1166 |
{ |
|
1167 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1168 |
HBufC* text = GetTextInHBufL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1169 |
CleanupStack::PushL( text ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1170 |
if ( text ) |
64 | 1171 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1172 |
TPtr ptr( text->Des() ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1173 |
TInt location = ptr.LocateReverse( KCharAddressDelimeterSemiColon ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1174 |
if ( location != KErrNotFound ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1175 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1176 |
ptr = ptr.RightTPtr( ptr.Length() - location -1 ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1177 |
ptr.TrimLeft(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1178 |
} |
64 | 1179 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1180 |
return text; |
64 | 1181 |
} |
1182 |
||
1183 |
// --------------------------------------------------------------------------- |
|
1184 |
// CNcsAifEditor::GetFormattedAddressListLC() |
|
1185 |
// --------------------------------------------------------------------------- |
|
1186 |
// |
|
1187 |
HBufC* CNcsAifEditor::GetFormattedAddressListLC( |
|
1188 |
RPointerArray<CNcsAifEntry>& aEntries, |
|
1189 |
TBool aDisplayList ) const |
|
1190 |
{ |
|
1191 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1192 |
TInt length = CalculateAddressListLength( aEntries, aDisplayList ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1193 |
if ( length <= 0 ) |
64 | 1194 |
{ |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1195 |
return HBufC::NewLC(0); |
64 | 1196 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1197 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1198 |
HBufC* buf = HBufC::NewLC( length ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1199 |
TPtr ptr = buf->Des(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1200 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1201 |
TInt count = aEntries.Count(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1202 |
for ( TInt i = 0; i < count; i++ ) |
64 | 1203 |
{ |
1204 |
if ( aDisplayList ) |
|
1205 |
{ |
|
1206 |
ptr.Append( aEntries[i]->DisplayString() ); |
|
1207 |
} |
|
1208 |
else |
|
1209 |
{ |
|
1210 |
ptr.Append( aEntries[i]->Address().EmailAddress() ); |
|
1211 |
ptr.Append( KEmailAddressSeparator ); |
|
1212 |
} |
|
1213 |
||
1214 |
// append whitespace, if not in the last entry |
|
1215 |
if ( i < count - 1 ) |
|
1216 |
{ |
|
1217 |
ptr.Append( KLineFeed ); |
|
1218 |
} |
|
1219 |
} |
|
1220 |
||
1221 |
return buf; |
|
1222 |
} |
|
1223 |
||
1224 |
// --------------------------------------------------------------------------- |
|
1225 |
// CNcsAifEditor::GetFormattedAddressListL() |
|
1226 |
// --------------------------------------------------------------------------- |
|
1227 |
// |
|
1228 |
HBufC* CNcsAifEditor::GetFormattedAddressListL( |
|
1229 |
RPointerArray<CNcsAifEntry>& aEntries, |
|
1230 |
TBool aDisplayList ) const |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1231 |
{ |
64 | 1232 |
FUNC_LOG; |
1233 |
HBufC* buf = GetFormattedAddressListLC( aEntries, aDisplayList ); |
|
1234 |
CleanupStack::Pop( buf ); |
|
1235 |
return buf; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1236 |
} |
64 | 1237 |
|
1238 |
// --------------------------------------------------------------------------- |
|
1239 |
// CNcsAifEditor::CalculateAddressListLength() |
|
1240 |
// --------------------------------------------------------------------------- |
|
1241 |
// |
|
1242 |
TInt CNcsAifEditor::CalculateAddressListLength( |
|
1243 |
RPointerArray<CNcsAifEntry>& aEntries, |
|
1244 |
TBool aDisplayList ) const |
|
1245 |
{ |
|
1246 |
FUNC_LOG; |
|
1247 |
TInt length = 0; |
|
1248 |
TInt count = aEntries.Count(); |
|
1249 |
for ( TInt i = 0; i < count; i++ ) |
|
1250 |
{ |
|
1251 |
CNcsAifEntry* entry = aEntries[ i ]; |
|
1252 |
if ( !entry ) continue; |
|
1253 |
if ( aDisplayList ) |
|
1254 |
{ |
|
1255 |
length += entry->Length(); |
|
1256 |
} |
|
1257 |
else |
|
1258 |
{ |
|
1259 |
// +1 is for semicolon |
|
1260 |
length += entry->Address().EmailAddress().Length() + 1; |
|
1261 |
} |
|
1262 |
} |
|
1263 |
||
1264 |
// add one white space after that so the format is |
|
1265 |
// aamiumaubb.com; ccmiumaudd.com; eemiumauff.com |
|
1266 |
if ( count > 1 ) |
|
1267 |
{ |
|
1268 |
// ( count - 1 ) we do need white space after the last address |
|
1269 |
length += count - 1 ; |
|
1270 |
} |
|
1271 |
||
1272 |
if ( aEntries.Count() > 0 ) |
|
1273 |
{ |
|
1274 |
length += 2; |
|
1275 |
} |
|
1276 |
||
1277 |
return length; |
|
1278 |
} |
|
1279 |
||
1280 |
// --------------------------------------------------------------------------- |
|
1281 |
// CNcsAifEditor::UpdateAddressAutoCompletionL() |
|
1282 |
// --------------------------------------------------------------------------- |
|
1283 |
// |
|
1284 |
void CNcsAifEditor::UpdateAddressAutoCompletionL() |
|
1285 |
{ |
|
1286 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1287 |
HBufC* text = GetNonEntryTextLC(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1288 |
__ASSERT_ALWAYS( text, Panic(EFSEmailUiNullPointerException) ); |
64 | 1289 |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1290 |
iAddressPopupList->UpdatePopupContactListL( *text, EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1291 |
CleanupStack::PopAndDestroy( text ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1292 |
} |
64 | 1293 |
|
1294 |
// --------------------------------------------------------------------------- |
|
1295 |
// CNcsAifEditor::UpdateAddressAutoCompletionL() |
|
1296 |
// --------------------------------------------------------------------------- |
|
1297 |
// |
|
1298 |
void CNcsAifEditor::UpdateAddressAutoCompletionL( |
|
1299 |
const TCursorSelection& aSelection ) |
|
1300 |
{ |
|
1301 |
FUNC_LOG; |
|
1302 |
TInt length = aSelection.Length(); |
|
1303 |
HBufC* text = HBufC::NewLC( length ); |
|
1304 |
TPtr ptr = text->Des(); |
|
1305 |
Text()->Extract( ptr, aSelection.LowerPos(), length ); |
|
1306 |
ptr.Trim(); |
|
1307 |
if ( text->Length() ) |
|
1308 |
{ |
|
1309 |
iAddressPopupList->UpdatePopupContactListL( *text, EFalse ); |
|
1310 |
} |
|
1311 |
else |
|
1312 |
{ |
|
1313 |
iAddressPopupList->ClosePopupContactListL(); |
|
1314 |
} |
|
1315 |
CleanupStack::PopAndDestroy( text ); |
|
1316 |
} |
|
1317 |
||
1318 |
// --------------------------------------------------------------------------- |
|
1319 |
// CNcsAifEditor::UpdateAddressListAllL() |
|
1320 |
// --------------------------------------------------------------------------- |
|
1321 |
// |
|
1322 |
void CNcsAifEditor::UpdateAddressListAllL() |
|
1323 |
{ |
|
1324 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1325 |
iAddressPopupList->UpdatePopupContactListL( KNullDesC, ETrue ); |
64 | 1326 |
} |
1327 |
||
1328 |
// --------------------------------------------------------------------------- |
|
1329 |
// Updates the duplicate markings in the entry array. |
|
1330 |
// --------------------------------------------------------------------------- |
|
1331 |
// |
|
1332 |
void CNcsAifEditor::UpdateDuplicateEntryMarkingsL() |
|
1333 |
{ |
|
1334 |
FUNC_LOG; |
|
1335 |
const TInt entryCount = iArray.Count(); |
|
1336 |
for ( TInt ii = entryCount - 1; ii >= 0; --ii ) |
|
1337 |
{ |
|
1338 |
if ( ii > 0 ) |
|
1339 |
{ |
|
1340 |
TBool duplicateFound = EFalse; |
|
1341 |
for ( TInt jj = ii - 1; jj >= 0; --jj ) |
|
1342 |
{ |
|
1343 |
if ( iArray[ii]->IsSameDN( *iArray[jj] ) ) |
|
1344 |
{ |
|
1345 |
duplicateFound = ETrue; |
|
1346 |
iArray[jj]->SetDupL( ETrue ); |
|
1347 |
} |
|
1348 |
} |
|
1349 |
iArray[ii]->SetDupL( duplicateFound ); |
|
1350 |
} |
|
1351 |
} |
|
1352 |
} |
|
1353 |
||
1354 |
// --------------------------------------------------------------------------- |
|
1355 |
// Makes a deferred call to HandleTextUpdateL |
|
1356 |
// --------------------------------------------------------------------------- |
|
1357 |
// |
|
1358 |
void CNcsAifEditor::HandleTextUpdateDeferred() |
|
1359 |
{ |
|
1360 |
FUNC_LOG; |
|
1361 |
if ( iAsyncCallBack ) |
|
1362 |
{ |
|
1363 |
iAsyncCallBack->Cancel(); |
|
1364 |
iAsyncCallBack->Set( TCallBack( DoHandleTextUpdate, this ) ); |
|
1365 |
iAsyncCallBack->CallBack(); |
|
1366 |
} |
|
1367 |
} |
|
1368 |
||
1369 |
// --------------------------------------------------------------------------- |
|
1370 |
// Static wrapper function for HandleTextUpdateL() |
|
1371 |
// --------------------------------------------------------------------------- |
|
1372 |
// |
|
1373 |
TInt CNcsAifEditor::DoHandleTextUpdate( TAny* aSelf ) |
|
1374 |
{ |
|
1375 |
FUNC_LOG; |
|
1376 |
CNcsAifEditor* self = static_cast<CNcsAifEditor*>( aSelf ); |
|
1377 |
TRAPD( err, self->HandleTextUpdateL() ); |
|
1378 |
return err; |
|
1379 |
} |
|
1380 |
||
1381 |
// --------------------------------------------------------------------------- |
|
1382 |
// Handles text update. |
|
1383 |
// --------------------------------------------------------------------------- |
|
1384 |
// |
|
1385 |
void CNcsAifEditor::HandleTextUpdateL() |
|
1386 |
{ |
|
1387 |
FUNC_LOG; |
|
1388 |
RecalculateEntryPositions(); |
|
1389 |
TCursorSelection textSelection = NonEntryTextAtPos( CursorPos() ); |
|
1390 |
if ( textSelection.Length() ) |
|
1391 |
{ |
|
1392 |
// Check non-entry text for complete entries. |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1393 |
const TBool newEntriesAdded = HandleTextUpdateL( textSelection ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1394 |
if ( newEntriesAdded ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1395 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1396 |
iAddressPopupList->ClosePopupContactListL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1397 |
iSizeObserver->UpdateFieldSizeL( ETrue ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1398 |
iPartialRemove = EFalse; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1399 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1400 |
else |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1401 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1402 |
MoveNonEntryTextToDedicatedRowsL( CursorPos() ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1403 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1404 |
textSelection = NonEntryTextAtPos( CursorPos() ); |
64 | 1405 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1406 |
UpdateAddressAutoCompletionL( textSelection ); |
64 | 1407 |
} |
1408 |
||
1409 |
// --------------------------------------------------------------------------- |
|
1410 |
// CNcsAifEditor::HandleTextUpdateL() |
|
1411 |
// --------------------------------------------------------------------------- |
|
1412 |
// |
|
1413 |
TBool CNcsAifEditor::HandleTextUpdateL( const TCursorSelection& aSelection ) |
|
1414 |
{ |
|
1415 |
FUNC_LOG; |
|
1416 |
iAddLeftover = ETrue; |
|
1417 |
TInt firstCharacter = aSelection.LowerPos(); |
|
1418 |
TInt lastCharacter = aSelection.HigherPos(); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1419 |
|
64 | 1420 |
// get the inputted text |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1421 |
const TInt length = lastCharacter - firstCharacter; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1422 |
|
64 | 1423 |
HBufC* text = HBufC::NewLC( length ); |
1424 |
TPtr ptr = text->Des(); |
|
1425 |
Text()->Extract( ptr, firstCharacter, length ); |
|
1426 |
ptr.Trim(); |
|
1427 |
||
1428 |
TBool entriesFound( EFalse ); |
|
1429 |
||
1430 |
// start looking for entries separated with semicolon |
|
1431 |
TInt start( 0 ); |
|
1432 |
TInt end( ptr.Length() ); |
|
1433 |
TInt lastSentinel = KErrNotFound; |
|
1434 |
||
1435 |
for ( TInt ii = 0; ii < end; ++ii ) |
|
1436 |
{ |
|
1437 |
TChar character = ptr[ii]; |
|
1438 |
TBool addAddress = EFalse; |
|
1439 |
||
1440 |
if ( IsSentinel( character ) ) |
|
1441 |
{ |
|
1442 |
if ( character == KCharSpace ) |
|
1443 |
{ |
|
1444 |
if ( ptr.Mid( start, ii-start ).Locate( KCharAt ) |
|
1445 |
!= KErrNotFound ) |
|
1446 |
{ |
|
1447 |
ptr[ii] = KCharAddressDelimeterSemiColon; |
|
1448 |
lastSentinel = ii; |
|
1449 |
addAddress = ETrue; |
|
1450 |
} |
|
1451 |
} |
|
1452 |
else if ( character == KCharAddressDelimeterComma ) |
|
1453 |
{ |
|
1454 |
// Replace comma with semicolon |
|
1455 |
ptr[ii] = KCharAddressDelimeterSemiColon; |
|
1456 |
lastSentinel = ii; |
|
1457 |
addAddress = ETrue; |
|
1458 |
} |
|
1459 |
else if ( character == KCharAddressDelimeterSemiColon ) |
|
1460 |
{ |
|
1461 |
lastSentinel = ii; |
|
1462 |
addAddress = ETrue; |
|
1463 |
} |
|
1464 |
||
1465 |
// Create new entry. |
|
1466 |
if ( addAddress && start < end ) |
|
1467 |
{ |
|
1468 |
// only if longer than 0, if not we'll get |
|
1469 |
// "empty" email address |
|
1470 |
if ( ii-start ) |
|
1471 |
{ |
|
1472 |
AddAddressL( KNullDesC(), ptr.Mid(start, ii-start) ); |
|
1473 |
start = Min( ii + 1, end ); |
|
1474 |
entriesFound = ETrue; |
|
1475 |
} |
|
1476 |
addAddress = EFalse; |
|
1477 |
} |
|
1478 |
} |
|
1479 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1480 |
|
64 | 1481 |
// add email that wasn't ended with semicolon |
1482 |
if ( lastSentinel != KErrNotFound ) |
|
1483 |
{ |
|
1484 |
if ( lastSentinel < end && start < end ) |
|
1485 |
{ |
|
1486 |
AddAddressL( KNullDesC(), ptr.Mid(start, end-start) ); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1487 |
entriesFound = ETrue; |
64 | 1488 |
} |
1489 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1490 |
|
64 | 1491 |
CleanupStack::PopAndDestroy( text ); |
1492 |
return entriesFound; |
|
1493 |
} |
|
1494 |
||
1495 |
// --------------------------------------------------------------------------- |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1496 |
// Moves inputted non-entry text to separate row |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1497 |
// --------------------------------------------------------------------------- |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1498 |
// |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1499 |
void CNcsAifEditor::MoveNonEntryTextToDedicatedRowsL( TUint aPosition ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1500 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1501 |
// Get the non-entry text and whitespace at given location |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1502 |
TCursorSelection textSelection = NonEntryTextAndSpaceAtPos( aPosition ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1503 |
const TInt start = textSelection.LowerPos(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1504 |
const TInt end = textSelection.HigherPos(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1505 |
const TInt length = end - start; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1506 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1507 |
const TChar lineBreak = TChar( CEditableText::ELineBreak ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1508 |
const TChar paragraphDelimiter = |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1509 |
TChar( CEditableText::EParagraphDelimiter ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1510 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1511 |
// Make sure that the inputted non-entry text is not on the same lines |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1512 |
// with existing entries. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1513 |
if ( length ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1514 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1515 |
HBufC* text = HBufC::NewLC( length ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1516 |
TPtr ptr = text->Des(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1517 |
Text()->Extract( ptr, start, length ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1518 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1519 |
const TChar firstCharacter = TChar( ptr[0] ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1520 |
const TChar lastCharacter = TChar( ptr[length-1] ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1521 |
const TInt documentLength = Text()->DocumentLength(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1522 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1523 |
TBool textChanged = EFalse; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1524 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1525 |
if ( end < documentLength && |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1526 |
lastCharacter != paragraphDelimiter && |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1527 |
lastCharacter != lineBreak ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1528 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1529 |
Text()->InsertL( end, lineBreak ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1530 |
HandleTextChangedL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1531 |
textChanged = ETrue; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1532 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1533 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1534 |
if ( start > 0 && start < end && |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1535 |
firstCharacter != paragraphDelimiter && |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1536 |
firstCharacter != lineBreak ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1537 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1538 |
Text()->InsertL( start, lineBreak ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1539 |
SetCursorVisible( EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1540 |
HandleTextChangedL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1541 |
SetCursorPosL( CursorPos() + 1, EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1542 |
SetCursorVisible( ETrue ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1543 |
textChanged = ETrue; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1544 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1545 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1546 |
if ( textChanged ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1547 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1548 |
RecalculateEntryPositions(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1549 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1550 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1551 |
CleanupStack::PopAndDestroy( text ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1552 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1553 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1554 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1555 |
// --------------------------------------------------------------------------- |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1556 |
// Prepares for text entry to given cursor position making sure that the |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1557 |
// new text will not be entered on same row with existing |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1558 |
// --------------------------------------------------------------------------- |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1559 |
// |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1560 |
void CNcsAifEditor::PrepareForTextInputL( TUint aPosition ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1561 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1562 |
FUNC_LOG; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1563 |
// Get the non-entry text and whitespace at given position. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1564 |
TCursorSelection textSelection = NonEntryTextAndSpaceAtPos( aPosition ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1565 |
const TInt start = textSelection.LowerPos(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1566 |
const TInt end = textSelection.HigherPos(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1567 |
const TInt length = end - start; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1568 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1569 |
const TChar lineBreak = TChar( CEditableText::ELineBreak ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1570 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1571 |
if ( start > 0 && ( !length || aPosition == start ) ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1572 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1573 |
Text()->InsertL( start, lineBreak ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1574 |
HandleTextChangedL(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1575 |
SetCursorPosL( start + 1, EFalse ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1576 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1577 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1578 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1579 |
// --------------------------------------------------------------------------- |
64 | 1580 |
// Handles navigation event. |
1581 |
// --------------------------------------------------------------------------- |
|
1582 |
// |
|
1583 |
void CNcsAifEditor::HandleNavigationEventL() |
|
1584 |
{ |
|
1585 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1586 |
// Close the contact popup when cursor is moved withing the field to make |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1587 |
// it less distracting. It's reopened when user types something. |
64 | 1588 |
iAddressPopupList->ClosePopupContactListL(); |
1589 |
} |
|
1590 |
||
1591 |
// --------------------------------------------------------------------------- |
|
1592 |
// Gets the range of non-entry text at the given position. |
|
1593 |
// --------------------------------------------------------------------------- |
|
1594 |
// |
|
1595 |
TCursorSelection CNcsAifEditor::NonEntryTextAtPos( TUint aPosition ) const |
|
1596 |
{ |
|
1597 |
FUNC_LOG; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1598 |
// Get the range of non-entry text and whitespace at given position. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1599 |
TCursorSelection text = NonEntryTextAndSpaceAtPos( aPosition ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1600 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1601 |
// Get the selected text to remove whitespace |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1602 |
const TInt length = text.Length(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1603 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1604 |
HBufC* selectedText = NULL; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1605 |
TRAPD( err, selectedText = HBufC::NewL( length ) ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1606 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1607 |
if( err == KErrNone ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1608 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1609 |
TPtr ptr = selectedText->Des(); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1610 |
Text()->Extract( ptr, text.LowerPos(), length ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1611 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1612 |
// trim from end |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1613 |
TInt index( length - 1 ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1614 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1615 |
while( index >= 0 && IsWhitespace( ptr[index--] ) ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1616 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1617 |
text.iCursorPos--; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1618 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1619 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1620 |
// trim from begin |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1621 |
index = 0; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1622 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1623 |
while( index < length && IsWhitespace( ptr[index++] ) ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1624 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1625 |
text.iAnchorPos++; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1626 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1627 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1628 |
delete selectedText; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1629 |
selectedText = NULL; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1630 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1631 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1632 |
return text; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1633 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1634 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1635 |
// --------------------------------------------------------------------------- |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1636 |
// Gets non-entry text including surrounding whitespace at given position. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1637 |
// --------------------------------------------------------------------------- |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1638 |
// |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1639 |
TCursorSelection CNcsAifEditor::NonEntryTextAndSpaceAtPos( |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1640 |
TUint aPosition ) const |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1641 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1642 |
FUNC_LOG; |
64 | 1643 |
TCursorSelection text( TextLength(), 0 ); |
1644 |
for ( TInt ii = iArray.Count() - 1; ii >= 0; --ii ) |
|
1645 |
{ |
|
1646 |
if ( iArray[ii]->Includes( aPosition - 1) ) |
|
1647 |
{ |
|
1648 |
// Given position is included in existing entry |
|
1649 |
text.SetSelection( 0, 0 ); |
|
1650 |
break; |
|
1651 |
} |
|
1652 |
else if ( iArray[ii]->LowerPos() >= aPosition ) |
|
1653 |
{ |
|
1654 |
// Found entry after the given position |
|
1655 |
text.iCursorPos = iArray[ii]->LowerPos(); |
|
1656 |
} |
|
1657 |
else if ( iArray[ii]->HigherPos() < aPosition ) |
|
1658 |
{ |
|
1659 |
// Found first entry before given position |
|
1660 |
text.iAnchorPos = iArray[ii]->HigherPos(); |
|
1661 |
break; |
|
1662 |
} |
|
1663 |
} |
|
1664 |
||
1665 |
return text; |
|
1666 |
} |
|
1667 |
||
1668 |
// --------------------------------------------------------------------------- |
|
1669 |
// Gets the range of text immediatelly before given position that does not |
|
1670 |
// belong to any entry. |
|
1671 |
// --------------------------------------------------------------------------- |
|
1672 |
// |
|
1673 |
TCursorSelection CNcsAifEditor::NonEntryTextBeforePos( TUint aPosition ) const |
|
1674 |
{ |
|
1675 |
FUNC_LOG; |
|
1676 |
TCursorSelection text( aPosition, 0 ); |
|
1677 |
for ( TInt ii = iArray.Count() - 1; ii >= 0; --ii ) |
|
1678 |
{ |
|
1679 |
if ( iArray[ii]->Includes( aPosition - 1 ) ) |
|
1680 |
{ |
|
1681 |
// Given position is included in existing entry |
|
1682 |
text.SetSelection( 0, 0 ); |
|
1683 |
break; |
|
1684 |
} |
|
1685 |
else if ( iArray[ii]->HigherPos() < aPosition ) |
|
1686 |
{ |
|
1687 |
// Found first existing entry before given position |
|
1688 |
text.SetSelection( aPosition, iArray[ii]->HigherPos() ); |
|
1689 |
break; |
|
1690 |
} |
|
1691 |
} |
|
1692 |
return text; |
|
1693 |
} |
|
1694 |
||
1695 |
// --------------------------------------------------------------------------- |
|
1696 |
// Checks whether given character is considered as sentinel. |
|
1697 |
// --------------------------------------------------------------------------- |
|
1698 |
// |
|
1699 |
TBool CNcsAifEditor::IsSentinel( TChar aCharacter ) const |
|
1700 |
{ |
|
1701 |
FUNC_LOG; |
|
1702 |
return ( aCharacter == KCharAddressDelimeterSemiColon || |
|
1703 |
aCharacter == KCharAddressDelimeterComma || aCharacter == KCharSpace ); |
|
1704 |
} |
|
1705 |
||
1706 |
// --------------------------------------------------------------------------- |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1707 |
// Checks whether given character is considered as line delimiter. |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1708 |
// --------------------------------------------------------------------------- |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1709 |
// |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1710 |
// |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1711 |
TBool CNcsAifEditor::IsDelimiter( TChar aCharacter ) const |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1712 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1713 |
FUNC_LOG; |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1714 |
return ( aCharacter == TChar( CEditableText::ELineBreak) || |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1715 |
aCharacter == TChar( CEditableText::EParagraphDelimiter) ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1716 |
} |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1717 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1718 |
// --------------------------------------------------------------------------- |
64 | 1719 |
// Checks whether given character is considered as whitespace. |
1720 |
// --------------------------------------------------------------------------- |
|
1721 |
// |
|
1722 |
TBool CNcsAifEditor::IsWhitespace( TChar aCharacter ) const |
|
1723 |
{ |
|
1724 |
FUNC_LOG; |
|
1725 |
return ( aCharacter == KCharSpace || |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1726 |
aCharacter == TChar(CEditableText::ELineBreak) || |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1727 |
aCharacter == TChar(CEditableText::EParagraphDelimiter) ); |
64 | 1728 |
} |
1729 |
||
1730 |
// --------------------------------------------------------------------------- |
|
1731 |
// Checks whether given event is considered as navigation event. |
|
1732 |
// --------------------------------------------------------------------------- |
|
1733 |
// |
|
1734 |
TBool CNcsAifEditor::IsNavigationKey( const TKeyEvent& aKeyEvent ) const |
|
1735 |
{ |
|
1736 |
FUNC_LOG; |
|
1737 |
return ( aKeyEvent.iCode == EKeyLeftArrow || |
|
1738 |
aKeyEvent.iCode == EKeyRightArrow || |
|
1739 |
aKeyEvent.iCode == EKeyUpArrow || |
|
1740 |
aKeyEvent.iCode == EKeyDownArrow || |
|
1741 |
aKeyEvent.iScanCode == EStdKeyLeftArrow || |
|
1742 |
aKeyEvent.iScanCode == EStdKeyRightArrow || |
|
1743 |
aKeyEvent.iScanCode == EStdKeyUpArrow || |
|
1744 |
aKeyEvent.iScanCode == EStdKeyDownArrow ); |
|
1745 |
} |
|
1746 |
||
1747 |
// --------------------------------------------------------------------------- |
|
1748 |
// Checks whether given event is one which generates visible character |
|
1749 |
// --------------------------------------------------------------------------- |
|
1750 |
// |
|
1751 |
TBool CNcsAifEditor::IsCharacterKey( const TKeyEvent& aKeyEvent ) const |
|
1752 |
{ |
|
1753 |
FUNC_LOG; |
|
1754 |
TUint ctrlModifiers = EModifierLeftCtrl | EModifierRightCtrl | EModifierCtrl; |
|
1755 |
TBool ctrlEvent = aKeyEvent.iModifiers & ctrlModifiers; |
|
1756 |
TBool isAppKey = ( aKeyEvent.iScanCode >= EStdKeyApplication0) && (aKeyEvent.iScanCode <= EStdKeyKeyboardExtend); |
|
1757 |
return ( !ctrlEvent && !IsNavigationKey(aKeyEvent) && !isAppKey ); |
|
1758 |
} |
|
1759 |
||
1760 |
// --------------------------------------------------------------------------- |
|
1761 |
// Gets the count of substrings (in current text field) matching the aEntry's |
|
1762 |
// DisplayName (DN) and the count of matching (same DN) items in iArray. |
|
1763 |
// --------------------------------------------------------------------------- |
|
1764 |
// |
|
1765 |
void CNcsAifEditor::GetMatchingEntryCountsL( const CNcsAifEntry* aEntry, |
|
1766 |
TInt& aNrOfMatchesInText, |
|
1767 |
TInt& aNrOfMatchesInEntryArray ) |
|
1768 |
{ |
|
1769 |
aNrOfMatchesInText = 0; |
|
1770 |
aNrOfMatchesInEntryArray = 0; |
|
1771 |
TInt pos( 0 ); |
|
1772 |
const TInt end_pos( TextLength() ); |
|
1773 |
||
1774 |
// First a checking loop for finding the number of matching substrings |
|
1775 |
// (i.e., substrings that match the entry's displaystring) in current text |
|
1776 |
while ( pos < end_pos ) |
|
1777 |
{ |
|
1778 |
pos = FindTextL( &aEntry->DisplayString(), pos, |
|
1779 |
CEikEdwin::EFindCaseSensitive | |
|
1780 |
CEikEdwin::ENoBusyMessage ); |
|
1781 |
||
1782 |
// No more matches for entry found => checking finished for this one |
|
1783 |
if ( pos < 0 ) |
|
1784 |
{ |
|
1785 |
pos = end_pos; // ends the loop |
|
1786 |
} |
|
1787 |
// Match found => update counter |
|
1788 |
else |
|
1789 |
{ |
|
1790 |
++aNrOfMatchesInText; |
|
1791 |
// Move to next word |
|
1792 |
TInt len; |
|
1793 |
TInt startPos; |
|
1794 |
GetWordInfo( pos, startPos, len ); |
|
1795 |
pos = startPos+len; |
|
1796 |
} |
|
1797 |
} |
|
1798 |
||
1799 |
// Secondly check the number of entries in entry array that match |
|
1800 |
// the given entry's displayname. |
|
1801 |
for ( TInt i = iArray.Count()-1; i >= 0; --i ) |
|
1802 |
{ |
|
1803 |
if ( !aEntry->DisplayString().Compare( iArray[i]->DisplayString() ) ) |
|
1804 |
{ |
|
1805 |
++aNrOfMatchesInEntryArray; |
|
1806 |
} |
|
1807 |
} |
|
1808 |
} |
|
1809 |
||
1810 |
// ----------------------------------------------------------------------------- |
|
1811 |
// CNcsAifEditor::HandlePointerEventL() |
|
1812 |
// Handles pointer events |
|
1813 |
// ----------------------------------------------------------------------------- |
|
1814 |
// |
|
1815 |
void CNcsAifEditor::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
1816 |
{ |
|
1817 |
FUNC_LOG; |
|
1818 |
||
1819 |
if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
1820 |
{ |
|
1821 |
CTextLayout* textLayout = TextLayout(); |
|
1822 |
TInt cursorPos = CursorPos(); |
|
1823 |
TPoint touchPoint( aPointerEvent.iPosition ); |
|
1824 |
||
1825 |
//adjust touch point to mach editor coordinates |
|
1826 |
touchPoint.iX -= Position().iX; |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1827 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1828 |
TInt pointerLineNbr = textLayout->GetLineNumber( |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1829 |
textLayout->XyPosToDocPosL( touchPoint ) ); |
64 | 1830 |
TInt cursorLineNbr = textLayout->GetLineNumber( cursorPos ); |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1831 |
|
64 | 1832 |
if ( pointerLineNbr != cursorLineNbr ) |
1833 |
{ |
|
1834 |
CompleteEntryL(); |
|
1835 |
||
1836 |
// We're moving to a new line. |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1837 |
CNcsAifEntry* entry = GetEntryAt( CursorPos() ); |
64 | 1838 |
if ( entry ) |
1839 |
{ |
|
1840 |
SetSelectionL( entry->iCursorPos, entry->iAnchorPos ); |
|
1841 |
} |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1842 |
} |
64 | 1843 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1844 |
|
64 | 1845 |
CEikEdwin::HandlePointerEventL( aPointerEvent ); |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1846 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1847 |
// Do not allow to insert cursor into the middle of some entry |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1848 |
CNcsAifEntry* entry = GetEntryAt( CursorPos() ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1849 |
if ( entry ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1850 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1851 |
SetSelectionL( entry->iCursorPos, entry->iAnchorPos ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1852 |
} |
64 | 1853 |
} |
1854 |
||
1855 |
||
1856 |
// ----------------------------------------------------------------------------- |
|
1857 |
// CNcsAifEditor::CompleteEntryL() |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1858 |
// Adds semicolon to the end of the entry. |
64 | 1859 |
// ----------------------------------------------------------------------------- |
1860 |
// |
|
1861 |
void CNcsAifEditor::CompleteEntryL() |
|
1862 |
{ |
|
1863 |
// make sure there is really some text inputted |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1864 |
const TInt cursorPos = CursorPos(); |
64 | 1865 |
|
1866 |
TCursorSelection selection = NonEntryTextAtPos( cursorPos ); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1867 |
const TInt length = selection.Length(); |
64 | 1868 |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1869 |
if ( length > 0 && selection.LowerPos() >= 0 ) |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1870 |
{ |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1871 |
HBufC* text = HBufC::NewLC( length ); |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1872 |
TPtr ptr = text->Des(); |
64 | 1873 |
|
1874 |
Text()->Extract( ptr, selection.LowerPos(), length ); |
|
1875 |
ptr.Trim(); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1876 |
|
64 | 1877 |
// complete the entry |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1878 |
if ( ptr.Length() > 0 ) |
64 | 1879 |
{ |
1880 |
Text()->InsertL( selection.HigherPos(), KCharAddressDelimeterSemiColon ); |
|
1881 |
HandleTextChangedL(); |
|
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1882 |
HandleTextUpdateL( TCursorSelection( selection.LowerPos(), |
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1883 |
selection.HigherPos() + 1 ) ); |
64 | 1884 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1885 |
|
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1886 |
CleanupStack::PopAndDestroy( text ); |
64 | 1887 |
} |
73
c8382f7b54ef
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
1888 |
} |
64 | 1889 |
|
1890 |
// End of File |
|
1891 |