|
1 /* |
|
2 * Copyright (c) 2002-2006 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: MsgAddressControl implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ========== INCLUDE FILES ================================ |
|
21 |
|
22 #include <eikenv.h> // for CEikonEnv |
|
23 #include <eikappui.h> // for CEikAppUi |
|
24 #include <barsread.h> // for TResourceReader |
|
25 #include <eikedwin.h> // for TClipboardFunc |
|
26 #include <txtrich.h> // for CRichText |
|
27 #include <AknUtils.h> // for AknUtils |
|
28 #include <aknbutton.h> // for CAknButton |
|
29 #include <eiklabel.h> // for CEikLabel |
|
30 |
|
31 #include "MsgAddressControl.h" // for CMsgAddressControl |
|
32 #include "MsgAddressControlEditor.h" // for CMsgAddressControlEditor |
|
33 #include "MsgAddressControlEditorField.h" // for CMsgAddressControlEditorField |
|
34 #include "MsgBaseControlObserver.h" // for MMsgBaseControlObserver |
|
35 #include "MsgRecipientItem.h" // for CMsgRecipientItem |
|
36 #include "MsgEditorPanic.h" // for CMsgEditor panics |
|
37 #include "MsgEditorCommon.h" // for KArabicSemicolon |
|
38 |
|
39 // ========== EXTERNAL DATA STRUCTURES ===================== |
|
40 |
|
41 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
|
42 |
|
43 // ========== CONSTANTS ==================================== |
|
44 |
|
45 // ========== MACROS ======================================= |
|
46 |
|
47 // ========== LOCAL CONSTANTS AND MACROS =================== |
|
48 |
|
49 const TInt KRecipientArrayGranularity = 10; |
|
50 const TInt KMaxEntryLength = 256; |
|
51 const TUint KMsgListSeparator = ';'; // List separator |
|
52 |
|
53 // Unicode sign for S60 "enter" symbol |
|
54 const TInt KDownwardsArrowWithTipLeftwards = 0x21B2; |
|
55 const TInt KDownwardsArrowWithTipRightwards = 0x21B3; |
|
56 |
|
57 |
|
58 // ========== MODULE DATA STRUCTURES ======================= |
|
59 |
|
60 // ========== LOCAL FUNCTION PROTOTYPES ==================== |
|
61 |
|
62 // ========== LOCAL FUNCTIONS ============================== |
|
63 |
|
64 // ========== MEMBER FUNCTIONS ============================= |
|
65 |
|
66 |
|
67 // --------------------------------------------------------- |
|
68 // CMsgAddressControl::CMsgAddressControl |
|
69 // |
|
70 // Constructor. |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 CMsgAddressControl::CMsgAddressControl( MMsgBaseControlObserver& aBaseControlObserver ) : |
|
74 CMsgExpandableControl( aBaseControlObserver ) |
|
75 { |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CMsgAddressControl::~CMsgAddressControl |
|
80 // |
|
81 // Destructor. |
|
82 // --------------------------------------------------------- |
|
83 // |
|
84 CMsgAddressControl::~CMsgAddressControl() |
|
85 { |
|
86 if ( iRecipientArray ) |
|
87 { |
|
88 iRecipientArray->ResetAndDestroy(); |
|
89 } |
|
90 |
|
91 delete iRecipientArray; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CMsgAddressControl::AddRecipientL |
|
96 // |
|
97 // |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C void CMsgAddressControl::AddRecipientL( const TDesC& aName, |
|
101 const TDesC& aAddress, |
|
102 TBool aVerified, |
|
103 MVPbkContactLink* aContactLink ) |
|
104 { |
|
105 TInt count = 0; |
|
106 TInt size = 0; |
|
107 TInt entries = iAddressControlEditor->EntryCount(); |
|
108 |
|
109 GetSizeOfAddresses( count, size ); |
|
110 |
|
111 // when field is empty, count == 0 but entries == 1. |
|
112 // when count > 0, this inserts at the end of the field. |
|
113 if ( entries > 1 ) |
|
114 { |
|
115 count = entries; |
|
116 } |
|
117 |
|
118 iAddressControlEditor->SetCursorPosAndCancelSelectionL( |
|
119 iAddressControlEditor->TextLength() ); |
|
120 iAddressControlEditor->CheckHighlightingL(); |
|
121 iAddressControlEditor->InsertEntryL( |
|
122 count, |
|
123 aName, |
|
124 aAddress, |
|
125 aVerified, |
|
126 ETrue, |
|
127 aContactLink |
|
128 ); |
|
129 |
|
130 FormatAndSetCursorPosL( iAddressControlEditor->TextLength() ); |
|
131 DrawDeferred(); |
|
132 iControlModeFlags |= EMsgControlModeModified; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------- |
|
136 // CMsgAddressControl::AddRecipientsL |
|
137 // |
|
138 // |
|
139 // --------------------------------------------------------- |
|
140 // |
|
141 EXPORT_C void CMsgAddressControl::AddRecipientsL( |
|
142 const CMsgRecipientList& aRecipients ) |
|
143 { |
|
144 CMsgRecipientArray* recipients = GetRecipientsL(); |
|
145 RefreshL( *recipients ); |
|
146 |
|
147 TInt count = 0; |
|
148 TInt size = 0; |
|
149 TInt entries = iAddressControlEditor->EntryCount(); |
|
150 |
|
151 GetSizeOfAddresses( count, size ); |
|
152 |
|
153 // when field is empty, count == 0 but entries == 1. |
|
154 // when count > 0, this inserts at the end of the field. |
|
155 if ( entries > 1 ) |
|
156 { |
|
157 count = entries; |
|
158 } |
|
159 |
|
160 TInt cc = aRecipients.Count(); |
|
161 CMsgRecipientItem* item = NULL; |
|
162 |
|
163 iAddressControlEditor->SetCursorPosAndCancelSelectionL( |
|
164 iAddressControlEditor->TextLength() ); |
|
165 iAddressControlEditor->CheckHighlightingL(); |
|
166 |
|
167 TBool bandFormatting( EFalse ); |
|
168 if ( iAddressControlEditor->TextLayout()->IsFormattingBand() ) |
|
169 { |
|
170 bandFormatting = ETrue; |
|
171 } |
|
172 |
|
173 for ( TInt i = 0; i < cc; i++ ) |
|
174 { |
|
175 item = aRecipients.At( i ); |
|
176 iAddressControlEditor->InsertEntryL( |
|
177 count, |
|
178 *item->Name(), |
|
179 *item->Address(), |
|
180 item->IsVerified(), |
|
181 item->IsValidated(), |
|
182 item->ContactLink() ); |
|
183 count++; |
|
184 } |
|
185 |
|
186 TInt pos = iAddressControlEditor->TextLength(); |
|
187 |
|
188 iAddressControlEditor->TextView()->SetDocPosL( pos, EFalse ); |
|
189 |
|
190 FormatAndSetCursorPosL( pos ); |
|
191 |
|
192 // Editor changed to band formatting due to address addition. |
|
193 // Set the editor height to maximum as text was added directly to |
|
194 // richtext and height is not updated correctly because of partial format. |
|
195 if ( !bandFormatting && |
|
196 iAddressControlEditor->TextLayout()->IsFormattingBand() ) |
|
197 { |
|
198 // Set newSize to current width and maximum body height and |
|
199 // force CMsgExpandableControl::HandleEdwinSizeChangeEventL to |
|
200 // update the control size. |
|
201 iControlModeFlags |= EMsgControlModeForceSizeUpdate; |
|
202 |
|
203 TSize newSize( iAddressControlEditor->Size().iWidth, |
|
204 iMaxBodyHeight - 1 ); |
|
205 |
|
206 iAddressControlEditor->SetSize( newSize ); |
|
207 |
|
208 iControlModeFlags &= ~EMsgControlModeForceSizeUpdate; |
|
209 } |
|
210 |
|
211 DrawDeferred(); |
|
212 iControlModeFlags |= EMsgControlModeModified; |
|
213 } |
|
214 |
|
215 |
|
216 // --------------------------------------------------------- |
|
217 // CMsgAddressControl::GetRecipientsL |
|
218 // |
|
219 // |
|
220 // --------------------------------------------------------- |
|
221 // |
|
222 EXPORT_C CMsgRecipientArray* CMsgAddressControl::GetRecipientsL() |
|
223 { |
|
224 TInt entryNumber( iAddressControlEditor->EntryCount() ); |
|
225 const CMsgAddressControlEditorField* field = NULL; |
|
226 TBuf<KMaxEntryLength> entryBuf; |
|
227 TInt ret( KErrNotFound ); |
|
228 |
|
229 if ( iRecipientArray == NULL ) |
|
230 { |
|
231 iRecipientArray = new ( ELeave ) |
|
232 CMsgRecipientArray( KRecipientArrayGranularity ); |
|
233 } |
|
234 else |
|
235 { |
|
236 iRecipientArray->ResetAndDestroy(); |
|
237 } |
|
238 |
|
239 for ( TInt ii = 0; ii < entryNumber; ii++ ) |
|
240 { |
|
241 field = iAddressControlEditor->Field( ii ); |
|
242 |
|
243 if ( field && field->IsVerified() ) |
|
244 { |
|
245 HBufC* addressCopy = field->Address()->AllocLC(); |
|
246 TPtr addrTPtr = addressCopy->Des(); |
|
247 AknTextUtils::ConvertDigitsTo( addrTPtr, EDigitTypeWestern ); |
|
248 |
|
249 CMsgRecipientItem* item = |
|
250 CMsgRecipientItem::NewLC( *field->Name(), *addressCopy ); |
|
251 |
|
252 const MVPbkContactLink* contactLink = field->ContactLink(); |
|
253 if ( contactLink ) |
|
254 { |
|
255 item->SetContactLink( contactLink ); |
|
256 } |
|
257 |
|
258 item->SetVerified( field->IsVerified() ); |
|
259 item->SetValidated( field->IsValidated() ); |
|
260 iRecipientArray->AppendL( item ); |
|
261 |
|
262 CleanupStack::Pop(); // item |
|
263 CleanupStack::PopAndDestroy(); // addressCopy |
|
264 } |
|
265 else |
|
266 { |
|
267 SetParsingInfo( ii, 0, 0 ); |
|
268 ret = KErrNone; |
|
269 while ( ret == KErrNone ) |
|
270 { |
|
271 ret = GetNextItemOnEntry( entryBuf ); |
|
272 if ( ( ret == KErrNone ) && ( entryBuf.Length() > 0 ) ) |
|
273 { |
|
274 AknTextUtils::ConvertDigitsTo( entryBuf, EDigitTypeWestern ); |
|
275 // unverified entries are treated as addresses. |
|
276 CMsgRecipientItem* item = |
|
277 CMsgRecipientItem::NewLC( KNullDesC, entryBuf ); |
|
278 |
|
279 iRecipientArray->AppendL( item ); |
|
280 |
|
281 CleanupStack::Pop(); // item |
|
282 entryBuf.Zero(); |
|
283 } |
|
284 } |
|
285 } |
|
286 } |
|
287 |
|
288 ResetParsingInfo(); |
|
289 return iRecipientArray; |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------- |
|
293 // CMsgAddressControl::ResetL |
|
294 // |
|
295 // Clears content of the address control. |
|
296 // --------------------------------------------------------- |
|
297 // |
|
298 EXPORT_C TInt CMsgAddressControl::ResetL() |
|
299 { |
|
300 ResetParsingInfo(); |
|
301 TInt entryCount( iAddressControlEditor->EntryCount() ); |
|
302 |
|
303 iAddressControlEditor->TurnHighlightingOffL(); |
|
304 iAddressControlEditor->DeleteAllL(); |
|
305 iControlModeFlags |= EMsgControlModeModified; |
|
306 |
|
307 return entryCount; |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------- |
|
311 // CMsgAddressControl::Reset |
|
312 // |
|
313 // from CMsgBaseControl. |
|
314 // Same as above but non-leaving version. |
|
315 // --------------------------------------------------------- |
|
316 // |
|
317 EXPORT_C void CMsgAddressControl::Reset() |
|
318 { |
|
319 TRAP_IGNORE( ResetL() ); |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------- |
|
323 // CMsgAddressControl::GetFirstUnverifiedStringL |
|
324 // |
|
325 // Finds the first unverified string and updates also the iParserInfo |
|
326 // correspondingly. |
|
327 // --------------------------------------------------------- |
|
328 // |
|
329 EXPORT_C TInt CMsgAddressControl::GetFirstUnverifiedStringL( HBufC*& aString ) |
|
330 { |
|
331 __ASSERT_DEBUG( IsFocused(), Panic( EMsgControlNotFocused ) ); |
|
332 |
|
333 ResetParsingInfo(); |
|
334 return GetNextUnverifiedStringL( aString ); |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------- |
|
338 // CMsgAddressControl::GetNextUnverifiedStringL |
|
339 // |
|
340 // Finds the next unverified string. |
|
341 // --------------------------------------------------------- |
|
342 // |
|
343 EXPORT_C TInt CMsgAddressControl::GetNextUnverifiedStringL( HBufC*& aString ) |
|
344 { |
|
345 __ASSERT_DEBUG( IsFocused(), Panic( EMsgControlNotFocused ) ); |
|
346 |
|
347 if ( aString != NULL ) |
|
348 { |
|
349 delete aString; |
|
350 aString = NULL; |
|
351 } |
|
352 |
|
353 iAddressControlEditor->TurnHighlightingOffL(); |
|
354 |
|
355 TInt entryCount = iAddressControlEditor->EntryCount(); |
|
356 TInt entryNumber( iParsingInfo.iEntryNum ); |
|
357 TBuf<KMaxEntryLength> entryBuf; |
|
358 TInt ret( KErrNotFound ); |
|
359 HBufC* string = NULL; |
|
360 |
|
361 while ( entryNumber < entryCount ) |
|
362 { |
|
363 entryBuf.Zero(); |
|
364 if ( iAddressControlEditor->IsEntryVerified( entryNumber ) ) |
|
365 { |
|
366 entryNumber++; |
|
367 SetParsingInfo( entryNumber, 0, 0 ); |
|
368 } |
|
369 else |
|
370 { |
|
371 ret = GetNextItemOnEntry( entryBuf ); |
|
372 if ( ( ret == KErrNone ) && ( entryBuf.Length() > 0 ) ) |
|
373 { |
|
374 string = entryBuf.AllocLC(); |
|
375 TInt firstPos = iAddressControlEditor->EntryStartPos( |
|
376 iParsingInfo.iEntryNum ); |
|
377 FormatAndSetCursorPosL( firstPos + iParsingInfo.iEndPos ); |
|
378 break; |
|
379 } |
|
380 else if ( iParsingInfo.iEndPos > iParsingInfo.iStartPos ) |
|
381 { |
|
382 // a string could not be found but there seems to be white |
|
383 // spaces on an entry which may be also followed by the list |
|
384 // separator, hence clean them up |
|
385 iAddressControlEditor->DeleteEntryCharsL( |
|
386 iParsingInfo.iEntryNum, |
|
387 iParsingInfo.iStartPos, |
|
388 iParsingInfo.iEndPos ); |
|
389 |
|
390 SetParsingInfo( |
|
391 entryNumber, |
|
392 iParsingInfo.iStartPos, |
|
393 iParsingInfo.iStartPos ); |
|
394 } |
|
395 else if ( ( iParsingInfo.iEndPos == 0 ) && |
|
396 ( iParsingInfo.iEntryNum < entryCount - 1 ) ) |
|
397 { |
|
398 // there is just an EParagraphDelimiter on the entry |
|
399 iAddressControlEditor->DeleteEntryL( iParsingInfo.iEntryNum ); |
|
400 SetParsingInfo( entryNumber, 0, 0 ); |
|
401 entryCount--; |
|
402 } |
|
403 else |
|
404 { |
|
405 // there are no strings left on the current entry |
|
406 entryNumber++; |
|
407 SetParsingInfo( entryNumber, 0, 0 ); |
|
408 } |
|
409 } |
|
410 } |
|
411 |
|
412 if ( entryNumber >= entryCount ) |
|
413 { |
|
414 FormatAndSetCursorPosL( iAddressControlEditor->TextLength() ); |
|
415 } |
|
416 |
|
417 aString = string; |
|
418 |
|
419 if ( string ) |
|
420 { |
|
421 CleanupStack::Pop(); // string |
|
422 } |
|
423 |
|
424 return ret; |
|
425 } |
|
426 |
|
427 |
|
428 // --------------------------------------------------------- |
|
429 // CMsgAddressControl::ReplaceUnverifiedStringL |
|
430 // |
|
431 // Replaces a string with contents of the recipient array aArray. |
|
432 // The string is replaced according to the iParsingInfo. |
|
433 // |
|
434 // This function cannot undelete a string if it leaves after/while removing it. |
|
435 // --------------------------------------------------------- |
|
436 // |
|
437 EXPORT_C TInt CMsgAddressControl::ReplaceUnverifiedStringL( |
|
438 CMsgRecipientArray& aArray ) |
|
439 { |
|
440 __ASSERT_DEBUG( IsFocused(), Panic( EMsgControlNotFocused ) ); |
|
441 |
|
442 if ( ( iParsingInfo.iEndPos <= iParsingInfo.iStartPos ) || |
|
443 ( iParsingInfo.iEntryNum >= iAddressControlEditor->EntryCount() ) ) |
|
444 { |
|
445 return KErrNotFound; |
|
446 } |
|
447 |
|
448 iAddressControlEditor->TurnHighlightingOffL(); |
|
449 |
|
450 TInt entryLength = iAddressControlEditor->EntryLength( iParsingInfo.iEntryNum ); |
|
451 iAddressControlEditor->DeleteEntryCharsL( |
|
452 iParsingInfo.iEntryNum, |
|
453 iParsingInfo.iStartPos, |
|
454 iParsingInfo.iEndPos ); |
|
455 |
|
456 if ( ( iParsingInfo.iStartPos > 0 ) && ( iParsingInfo.iEndPos < entryLength ) ) |
|
457 { |
|
458 iAddressControlEditor->InsertEntryBreakL( |
|
459 iParsingInfo.iEntryNum, |
|
460 iParsingInfo.iStartPos ); |
|
461 iParsingInfo.iEntryNum++; |
|
462 } |
|
463 |
|
464 TInt entryNumber( iParsingInfo.iEntryNum ); |
|
465 TInt contactCount = aArray.Count(); |
|
466 CMsgRecipientItem* recipientItem = NULL; |
|
467 |
|
468 for ( TInt i = 0; i < contactCount; i++ ) |
|
469 { |
|
470 recipientItem = aArray.At( i ); |
|
471 iAddressControlEditor->InsertEntryL( |
|
472 entryNumber, |
|
473 *recipientItem->Name(), |
|
474 *recipientItem->Address(), |
|
475 recipientItem->IsVerified(), |
|
476 recipientItem->IsValidated(), |
|
477 recipientItem->ContactLink() ); |
|
478 |
|
479 entryNumber++; |
|
480 } |
|
481 |
|
482 SetParsingInfo( iParsingInfo.iEntryNum, 0, 0 ); |
|
483 TInt firstPos = iAddressControlEditor->EntryStartPos( iParsingInfo.iEntryNum ); |
|
484 entryLength = iAddressControlEditor->EntryLength( iParsingInfo.iEntryNum ); |
|
485 TInt endPos = firstPos + entryLength - 1; |
|
486 SetParsingInfo( iParsingInfo.iEntryNum, endPos, endPos ); |
|
487 FormatAndSetCursorPosL( endPos ); |
|
488 iControlModeFlags |= EMsgControlModeModified; |
|
489 return KErrNone; |
|
490 } |
|
491 |
|
492 // --------------------------------------------------------- |
|
493 // CMsgAddressControl::RefreshL |
|
494 // |
|
495 // Refreshes the contents of address control. |
|
496 // --------------------------------------------------------- |
|
497 // |
|
498 EXPORT_C TInt CMsgAddressControl::RefreshL( const CMsgRecipientArray& aArray ) |
|
499 { |
|
500 iEditor->SetEdwinSizeObserver( NULL ); |
|
501 |
|
502 TRAPD( error, ResetL() ); // Clears the control and turns highlighting off |
|
503 |
|
504 iEditor->SetEdwinSizeObserver( this ); |
|
505 |
|
506 if ( error != KErrNone ) |
|
507 { |
|
508 User::Leave( error ); |
|
509 } |
|
510 |
|
511 TInt entryNumber = 0; |
|
512 TInt contactCount = aArray.Count(); |
|
513 CMsgRecipientItem* item = NULL; |
|
514 |
|
515 for ( TInt i = 0; i < contactCount; i++ ) |
|
516 { |
|
517 item = aArray.At( i ); |
|
518 iAddressControlEditor->InsertEntryL( |
|
519 entryNumber, |
|
520 *item->Name(), |
|
521 *item->Address(), |
|
522 item->IsVerified(), |
|
523 item->IsValidated(), |
|
524 item->ContactLink() ); |
|
525 entryNumber++; |
|
526 } |
|
527 |
|
528 ResetParsingInfo(); |
|
529 FormatAndSetCursorPosL( iAddressControlEditor->TextLength() ); |
|
530 iControlModeFlags |= EMsgControlModeModified; |
|
531 |
|
532 return KErrNone; |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------- |
|
536 // CMsgAddressControl::HighlightUnverifiedStringL |
|
537 // |
|
538 // Highlights the found unverified entry. |
|
539 // --------------------------------------------------------- |
|
540 // |
|
541 EXPORT_C TInt CMsgAddressControl::HighlightUnverifiedStringL() |
|
542 { |
|
543 __ASSERT_DEBUG( IsFocused(), Panic( EMsgControlNotFocused ) ); |
|
544 |
|
545 TInt ret = iParsingInfo.iEndPos - iParsingInfo.iStartPos > 0 |
|
546 ? KErrNone |
|
547 : KErrNotFound; |
|
548 |
|
549 if ( IsActivated() && ( ret == KErrNone ) && IsFocused() ) |
|
550 { |
|
551 TInt entryLength( 0 ); // not really needed |
|
552 TInt entryStart( iAddressControlEditor->RichText()->CharPosOfParagraph( |
|
553 entryLength, iParsingInfo.iEntryNum ) ); |
|
554 FormatAndSetCursorPosL( entryStart + iParsingInfo.iEndPos ); |
|
555 iAddressControlEditor->SetSelectionL( |
|
556 entryStart + iParsingInfo.iEndPos, |
|
557 entryStart + iParsingInfo.iStartPos ); |
|
558 } |
|
559 |
|
560 return ret; |
|
561 } |
|
562 |
|
563 // --------------------------------------------------------- |
|
564 // CMsgAddressControl::SizeOfAddresses |
|
565 // |
|
566 // Returns size of addresses. |
|
567 // --------------------------------------------------------- |
|
568 // |
|
569 EXPORT_C void CMsgAddressControl::GetSizeOfAddresses( |
|
570 TInt& aEntryCount, TInt& aSizeOfAddresses ) |
|
571 { |
|
572 const CMsgAddressControlEditorField* field = NULL; |
|
573 TBuf<KMaxEntryLength> entryBuf; |
|
574 TInt ret( KErrNotFound ); |
|
575 |
|
576 aEntryCount = 0; |
|
577 aSizeOfAddresses = 0; |
|
578 |
|
579 for ( TInt entryNumber = iAddressControlEditor->EntryCount() - 1; |
|
580 entryNumber >= 0; |
|
581 entryNumber-- ) |
|
582 { |
|
583 if ( iAddressControlEditor->IsEntryVerified( entryNumber ) ) |
|
584 { |
|
585 field = iAddressControlEditor->Field( entryNumber ); |
|
586 |
|
587 aSizeOfAddresses += field->Address()->Length(); |
|
588 aEntryCount++; |
|
589 } |
|
590 else |
|
591 { |
|
592 SetParsingInfo( entryNumber, 0, 0 ); |
|
593 ret = KErrNone; |
|
594 while ( ret == KErrNone ) |
|
595 { |
|
596 ret = GetNextItemOnEntry( entryBuf ); |
|
597 if ( ( ret == KErrNone ) && ( entryBuf.Length() > 0 ) ) |
|
598 { |
|
599 aSizeOfAddresses += entryBuf.Length(); |
|
600 aEntryCount++; |
|
601 entryBuf.Zero(); |
|
602 } |
|
603 } |
|
604 } |
|
605 } |
|
606 |
|
607 ResetParsingInfo(); |
|
608 } |
|
609 |
|
610 // --------------------------------------------------------- |
|
611 // CMsgAddressControl::HighlightUnvalidatedStringL |
|
612 // |
|
613 // Highlights the found unvvalidated entry. |
|
614 // --------------------------------------------------------- |
|
615 // |
|
616 EXPORT_C TInt CMsgAddressControl::HighlightUnvalidatedStringL() |
|
617 { |
|
618 ResetParsingInfo(); |
|
619 |
|
620 iAddressControlEditor->TurnHighlightingOffL(); |
|
621 |
|
622 TInt entryCount = iAddressControlEditor->EntryCount(); |
|
623 TInt entryNumber( iParsingInfo.iEntryNum ); |
|
624 TBuf<KMaxEntryLength> entryBuf; |
|
625 TInt ret( KErrNotFound ); |
|
626 |
|
627 while ( entryNumber < entryCount ) |
|
628 { |
|
629 entryBuf.Zero(); |
|
630 if ( iAddressControlEditor->IsEntryValidated( entryNumber ) ) |
|
631 { |
|
632 entryNumber++; |
|
633 SetParsingInfo( entryNumber, 0, 0 ); |
|
634 } |
|
635 else |
|
636 { |
|
637 ret = GetNextItemOnEntry( entryBuf ); |
|
638 if ( ( ret == KErrNone ) && ( entryBuf.Length() > 0 ) ) |
|
639 { |
|
640 TInt firstPos = iAddressControlEditor->EntryStartPos( |
|
641 iParsingInfo.iEntryNum ); |
|
642 FormatAndSetCursorPosL( firstPos + iParsingInfo.iEndPos ); |
|
643 break; |
|
644 } |
|
645 else if ( iParsingInfo.iEndPos > iParsingInfo.iStartPos ) |
|
646 { |
|
647 // a string could not be found but there seems to be white |
|
648 // spaces on an entry which may be also followed by the list |
|
649 // separator, hence clean them up |
|
650 iAddressControlEditor->DeleteEntryCharsL( |
|
651 iParsingInfo.iEntryNum, |
|
652 iParsingInfo.iStartPos, |
|
653 iParsingInfo.iEndPos ); |
|
654 |
|
655 SetParsingInfo( |
|
656 entryNumber, |
|
657 iParsingInfo.iStartPos, |
|
658 iParsingInfo.iStartPos ); |
|
659 } |
|
660 else if ( ( iParsingInfo.iEndPos == 0 ) && |
|
661 ( iParsingInfo.iEntryNum < entryCount - 1 ) ) |
|
662 { |
|
663 // there is just an EParagraphDelimiter on the entry |
|
664 iAddressControlEditor->DeleteEntryL( iParsingInfo.iEntryNum ); |
|
665 SetParsingInfo( entryNumber, 0, 0 ); |
|
666 entryCount--; |
|
667 } |
|
668 else |
|
669 { |
|
670 // there are no strings left on the current entry |
|
671 entryNumber++; |
|
672 SetParsingInfo( entryNumber, 0, 0 ); |
|
673 } |
|
674 } |
|
675 } |
|
676 |
|
677 if ( entryNumber >= entryCount ) |
|
678 { |
|
679 FormatAndSetCursorPosL( iAddressControlEditor->TextLength() ); |
|
680 } |
|
681 |
|
682 ret = iParsingInfo.iEndPos - iParsingInfo.iStartPos > 0 |
|
683 ? KErrNone |
|
684 : KErrNotFound; |
|
685 |
|
686 if ( IsActivated() && ( ret == KErrNone ) && IsFocused() ) |
|
687 { |
|
688 TInt entryLength( 0 ); // not really needed |
|
689 TInt entryStart( iAddressControlEditor->RichText()->CharPosOfParagraph( |
|
690 entryLength, iParsingInfo.iEntryNum ) ); |
|
691 FormatAndSetCursorPosL( entryStart + iParsingInfo.iEndPos ); |
|
692 iAddressControlEditor->SetSelectionL( |
|
693 entryStart + iParsingInfo.iEndPos, |
|
694 entryStart + iParsingInfo.iStartPos ); |
|
695 } |
|
696 return ret; |
|
697 } |
|
698 |
|
699 // --------------------------------------------------------- |
|
700 // CMsgAddressControl::IsPriorCharSemicolonL() |
|
701 // |
|
702 // Checks whether prior character is semicolon. Needed to variable |
|
703 // selection key functionality in editors. |
|
704 // --------------------------------------------------------- |
|
705 // |
|
706 EXPORT_C TBool CMsgAddressControl::IsPriorCharSemicolonL() const |
|
707 { |
|
708 TInt cursorPos = Editor().CursorPos(); |
|
709 HBufC* buf = Editor().GetTextInHBufL(); |
|
710 CleanupStack::PushL( buf ); |
|
711 |
|
712 TBool semicolonFound = EFalse; |
|
713 TUint character; |
|
714 while ( cursorPos > 1 && !semicolonFound ) |
|
715 { |
|
716 cursorPos--; |
|
717 character = TUint( (*buf)[cursorPos] ); |
|
718 |
|
719 if ( character == KMsgListSeparator || character == KArabicSemicolon ) |
|
720 { |
|
721 semicolonFound = ETrue; |
|
722 } |
|
723 else if ( character != CEditableText::ESpace && |
|
724 character != CEditableText::EParagraphDelimiter ) |
|
725 { |
|
726 break; |
|
727 } |
|
728 } |
|
729 |
|
730 CleanupStack::PopAndDestroy(); // buf |
|
731 return semicolonFound; |
|
732 } |
|
733 |
|
734 // --------------------------------------------------------- |
|
735 // CMsgAddressControl::SetAddressFieldAutoHighlight() |
|
736 // |
|
737 // Turns on or off automatic recipient highlight on this address |
|
738 // field. Focus must stop to this control if highlight is enabled. |
|
739 // Updates also the highlight accordingly. |
|
740 // --------------------------------------------------------- |
|
741 // |
|
742 EXPORT_C void CMsgAddressControl::SetAddressFieldAutoHighlight( TBool aValidHighlightable ) |
|
743 { |
|
744 iAddressControlEditor->SetAddressFieldAutoHighlight( aValidHighlightable ); |
|
745 DrawDeferred(); |
|
746 } |
|
747 |
|
748 // --------------------------------------------------------- |
|
749 // CMsgAddressControl::AddressFieldAutoHighlight() |
|
750 // |
|
751 // --------------------------------------------------------- |
|
752 // |
|
753 EXPORT_C TBool CMsgAddressControl::AddressFieldAutoHighlight() |
|
754 { |
|
755 return iAddressControlEditor->AddressFieldAutoHighlight(); |
|
756 } |
|
757 |
|
758 // --------------------------------------------------------- |
|
759 // CMsgAddressControl::ConstructFromResourceL |
|
760 // |
|
761 // Creates this control from resource. |
|
762 // --------------------------------------------------------- |
|
763 // |
|
764 void CMsgAddressControl::ConstructFromResourceL( TInt aResourceId ) |
|
765 { |
|
766 BaseConstructL(); // Sets margins only. |
|
767 |
|
768 TResourceReader reader; |
|
769 iCoeEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
770 |
|
771 // Create caption. |
|
772 iCaption = CreateCaptionFromResourceL( reader ); |
|
773 |
|
774 // Read some information about control from resource. |
|
775 ReadControlPropertiesFromResourceL( reader ); |
|
776 |
|
777 // Create editor. |
|
778 iEditor = CreateEditorFromResourceL( reader ); |
|
779 |
|
780 iEditor->SetControlType(EMsgAddressControl); |
|
781 iEditor->SetObserver( this ); |
|
782 iEditor->SetEdwinSizeObserver( this ); |
|
783 iEditor->AddEdwinObserverL( this ); |
|
784 |
|
785 SetPlainTextMode( ETrue ); |
|
786 |
|
787 #ifdef RD_SCALABLE_UI_V2 |
|
788 if ( AknLayoutUtils::PenEnabled() ) |
|
789 { |
|
790 CreateButtonL(); |
|
791 } |
|
792 #endif // RD_SCALABLE_UI_V2 |
|
793 |
|
794 ResolveLayoutsL(); |
|
795 |
|
796 iControlModeFlags |= EMsgControlModeForceFocusStop; |
|
797 //Set the flag for Enabling Partial Screen |
|
798 TInt flags = iEditor->AknEditorFlags(); |
|
799 flags |= EAknEditorFlagEnablePartialScreen; |
|
800 iEditor->SetAknEditorFlags( flags ); |
|
801 |
|
802 CleanupStack::PopAndDestroy(); // reader |
|
803 } |
|
804 |
|
805 // --------------------------------------------------------- |
|
806 // CMsgAddressControl::NotifyViewEvent |
|
807 // |
|
808 // Builds up text fields for the control i.e. reads verified recipients and |
|
809 // creates corresponding text fields for them. |
|
810 // --------------------------------------------------------- |
|
811 // |
|
812 void CMsgAddressControl::NotifyViewEvent( TMsgViewEvent aEvent, TInt aParam ) |
|
813 { |
|
814 if ( iAddressControlEditor->AddressFieldAutoHighlight() ) |
|
815 { |
|
816 aParam |= EMsgViewEventAutoHighlight; |
|
817 } |
|
818 |
|
819 CMsgExpandableControl::NotifyViewEvent( aEvent, aParam ); |
|
820 |
|
821 if ( aEvent == EMsgViewEventPrepareForViewing ) |
|
822 { |
|
823 if ( iAddressControlEditor->TextLength() && IsFocused() ) |
|
824 { |
|
825 iAddressControlEditor->PrepareForViewing(); |
|
826 |
|
827 } |
|
828 } |
|
829 } |
|
830 |
|
831 // --------------------------------------------------------- |
|
832 // ReadControlPropertiesFromResourceL |
|
833 // |
|
834 // Reads control properties from resource. |
|
835 // --------------------------------------------------------- |
|
836 // |
|
837 void CMsgAddressControl::ReadControlPropertiesFromResourceL( |
|
838 TResourceReader& aReader ) |
|
839 { |
|
840 CMsgExpandableControl::ReadControlPropertiesFromResourceL( aReader ); |
|
841 } |
|
842 |
|
843 // --------------------------------------------------------- |
|
844 // CMsgAddressControl::CreateEditorFromResourceL |
|
845 // |
|
846 // Creates editor (CEikRichTextEditor) for the control from resource and |
|
847 // returns pointer to it. |
|
848 // --------------------------------------------------------- |
|
849 // |
|
850 CMsgExpandableControlEditor* CMsgAddressControl::CreateEditorFromResourceL( |
|
851 TResourceReader& aReader ) |
|
852 { |
|
853 // Create an editor. |
|
854 CMsgExpandableControlEditor* editor = |
|
855 new ( ELeave ) CMsgAddressControlEditor( |
|
856 this, iControlModeFlags, iBaseControlObserver ); |
|
857 |
|
858 CleanupStack::PushL( editor ); |
|
859 editor->ConstructFromResourceL( aReader ); |
|
860 CleanupStack::Pop(); // editor |
|
861 |
|
862 return editor; |
|
863 } |
|
864 |
|
865 // --------------------------------------------------------- |
|
866 // CMsgAddressControl::EditPermission |
|
867 // |
|
868 // Checks and returns control's edit permissions. Edit permissions are needed |
|
869 // to check in order to know whether some key press is allowed to pass |
|
870 // to the control or not. |
|
871 // --------------------------------------------------------- |
|
872 // |
|
873 TUint32 CMsgAddressControl::EditPermission() const |
|
874 { |
|
875 return iAddressControlEditor->CheckEditPermission(); |
|
876 } |
|
877 |
|
878 |
|
879 // --------------------------------------------------------- |
|
880 // CMsgAddressControl::OfferKeyEventL |
|
881 // |
|
882 // Handles key events. The most of the keys are passed to the control editor. |
|
883 // --------------------------------------------------------- |
|
884 // |
|
885 TKeyResponse CMsgAddressControl::OfferKeyEventL( |
|
886 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
887 { |
|
888 // reset "trap" for extraneous multi-tap TextUpdate edwin events as we are |
|
889 // now working on another input |
|
890 iDuplicateEvent = EFalse; |
|
891 |
|
892 TKeyResponse keyResp = EKeyWasNotConsumed; |
|
893 ResetParsingInfo(); |
|
894 TInt cursorPos = iAddressControlEditor->CursorPos(); |
|
895 |
|
896 if ( aKeyEvent.iModifiers & EModifierShift ) |
|
897 { |
|
898 iControlModeFlags |= EMsgControlModeShiftPressed; |
|
899 } |
|
900 else |
|
901 { |
|
902 iControlModeFlags &= ~EMsgControlModeShiftPressed; |
|
903 } |
|
904 |
|
905 switch ( aKeyEvent.iCode ) |
|
906 { |
|
907 case EKeyHome: |
|
908 case EKeyEnd: |
|
909 case EKeyPageUp: |
|
910 case EKeyPageDown: |
|
911 { |
|
912 break; |
|
913 } |
|
914 case EKeyUpArrow: |
|
915 case EKeyDownArrow: |
|
916 { |
|
917 /*TInt fldpos = iAddressControlEditor->FirstFieldPos( cursorPos ); |
|
918 TInt entryNumber = iAddressControlEditor->EntryNumber( cursorPos ); |
|
919 |
|
920 if ( cursorPos != fldpos ) |
|
921 { |
|
922 iAddressControlEditor->MoveCursorToEntryPosL( entryNumber, 0 ); |
|
923 }*/ |
|
924 break; |
|
925 } |
|
926 case EKeyLeftArrow: |
|
927 { |
|
928 if ( iAddressControlEditor->IsPosAtEntryBeginning( cursorPos ) ) |
|
929 { |
|
930 TInt entryNumber = iAddressControlEditor->EntryNumber( cursorPos ); |
|
931 if ( iAddressControlEditor->IsEntryVerified( entryNumber ) ) |
|
932 { |
|
933 if ( iAddressControlEditor->IsEntryRightToLeft( entryNumber ) ) |
|
934 { |
|
935 iAddressControlEditor->MoveCursorToEntryPosL( |
|
936 entryNumber, |
|
937 iAddressControlEditor->EntryLength( entryNumber ) ); |
|
938 iAddressControlEditor->CheckHighlightingL(); |
|
939 return EKeyWasConsumed; |
|
940 } |
|
941 } |
|
942 } |
|
943 |
|
944 if ( !iAddressControlEditor->IsPosAtEntryBeginning( cursorPos ) ) |
|
945 { |
|
946 TInt entryNumber = iAddressControlEditor->EntryNumber( cursorPos ); |
|
947 if (iAddressControlEditor->IsEntryVerified( entryNumber ) ) |
|
948 { |
|
949 if ( !iAddressControlEditor->IsEntryRightToLeft( entryNumber ) ) |
|
950 { |
|
951 iAddressControlEditor->MoveCursorToEntryPosL( entryNumber, 0 ); |
|
952 iAddressControlEditor->CheckHighlightingL(); |
|
953 return EKeyWasConsumed; |
|
954 } |
|
955 } |
|
956 } |
|
957 |
|
958 break; |
|
959 } |
|
960 case EKeyRightArrow: |
|
961 { |
|
962 if ( iAddressControlEditor->IsPosAtEntryBeginning( cursorPos ) ) |
|
963 { |
|
964 TInt entryNumber = iAddressControlEditor->EntryNumber( cursorPos ); |
|
965 if (iAddressControlEditor->IsEntryVerified( entryNumber ) ) |
|
966 { |
|
967 if( !iAddressControlEditor->IsEntryRightToLeft( entryNumber ) ) |
|
968 { |
|
969 iAddressControlEditor->MoveCursorToEntryPosL( |
|
970 entryNumber, |
|
971 iAddressControlEditor->EntryLength( entryNumber ) ); |
|
972 iAddressControlEditor->CheckHighlightingL(); |
|
973 return EKeyWasConsumed; |
|
974 } |
|
975 } |
|
976 } |
|
977 if ( !iAddressControlEditor->IsPosAtEntryBeginning( cursorPos ) ) |
|
978 { |
|
979 TInt entryNumber = iAddressControlEditor->EntryNumber( cursorPos ); |
|
980 if (iAddressControlEditor->IsEntryVerified( entryNumber ) ) |
|
981 { |
|
982 if( iAddressControlEditor->IsEntryRightToLeft( entryNumber ) ) |
|
983 { |
|
984 iAddressControlEditor->MoveCursorToEntryPosL( entryNumber, 0 ); |
|
985 iAddressControlEditor->CheckHighlightingL(); |
|
986 return EKeyWasConsumed; |
|
987 } |
|
988 } |
|
989 } |
|
990 break; |
|
991 } |
|
992 case EKeyTab: |
|
993 case EKeyInsert: |
|
994 { |
|
995 return EKeyWasConsumed; |
|
996 } |
|
997 case EKeyEnter: |
|
998 { |
|
999 TUint32 editPermission = iAddressControlEditor->CheckEditPermission(); |
|
1000 if ( !( editPermission & EMsgEditParagraphDelimiter ) || |
|
1001 ( aKeyEvent.iModifiers & EModifierShift ) ) |
|
1002 { |
|
1003 return EKeyWasConsumed; |
|
1004 } |
|
1005 |
|
1006 iAddressControlEditor->TurnHighlightingOffL( iAddressControlEditor->Selection() ); |
|
1007 |
|
1008 break; |
|
1009 } |
|
1010 case EKeyDelete: |
|
1011 { |
|
1012 TUint32 editPermission = iAddressControlEditor->CheckEditPermission(); |
|
1013 if ( editPermission & EMsgEditRemoveEntry && |
|
1014 iAddressControlEditor->IsPosAtEntryBeginning( cursorPos ) ) |
|
1015 { |
|
1016 RemoveHighlightedEntryL(); |
|
1017 return EKeyWasConsumed; |
|
1018 } |
|
1019 else if ( !( editPermission & EMsgEditDelete ) ) |
|
1020 { |
|
1021 return EKeyWasConsumed; |
|
1022 } |
|
1023 |
|
1024 iAddressControlEditor->TurnHighlightingOffL( iAddressControlEditor->Selection() ); |
|
1025 break; |
|
1026 } |
|
1027 case EKeyBackspace: |
|
1028 { |
|
1029 TUint32 editPermission = iAddressControlEditor->CheckEditPermission(); |
|
1030 |
|
1031 if ( editPermission & EMsgEditRemoveEntry ) |
|
1032 { |
|
1033 RemoveHighlightedEntryL(); |
|
1034 return EKeyWasConsumed; |
|
1035 } |
|
1036 else if ( editPermission & EMsgEditBackspaceMove ) |
|
1037 { |
|
1038 TInt entryNumber = iAddressControlEditor->EntryNumber( cursorPos ) - 1; |
|
1039 iAddressControlEditor->MoveCursorToEntryPosL( |
|
1040 entryNumber, |
|
1041 iAddressControlEditor->EntryLength( entryNumber ) ); |
|
1042 return EKeyWasConsumed; |
|
1043 } |
|
1044 else if ( !( editPermission & EMsgEditBackspace ) ) |
|
1045 { |
|
1046 return EKeyWasConsumed; |
|
1047 } |
|
1048 |
|
1049 iAddressControlEditor->TurnHighlightingOffL( iAddressControlEditor->Selection() ); |
|
1050 |
|
1051 // This is for disabling paragraph adding when removing line feed after |
|
1052 // semicolon. OfferKeyEventL below will trigger EEventTextUpdate event. |
|
1053 iDuplicateEvent = ETrue; |
|
1054 |
|
1055 break; |
|
1056 } |
|
1057 default: |
|
1058 { |
|
1059 if ( !iAddressControlEditor->IsHandleEditEvent() ) |
|
1060 { |
|
1061 TUint32 editPermission = iAddressControlEditor->CheckEditPermission(); |
|
1062 if ( !( editPermission & EMsgEditCharInsert ) ) |
|
1063 { |
|
1064 return EKeyWasConsumed; |
|
1065 } |
|
1066 } |
|
1067 iAddressControlEditor->TurnHighlightingOffL( iAddressControlEditor->Selection() ); |
|
1068 break; |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 keyResp = iAddressControlEditor->OfferKeyEventL( aKeyEvent, aType ); |
|
1073 |
|
1074 return keyResp; |
|
1075 } |
|
1076 |
|
1077 // --------------------------------------------------------- |
|
1078 // CMsgAddressControl::HandleEdwinEventL |
|
1079 // |
|
1080 // |
|
1081 // --------------------------------------------------------- |
|
1082 // |
|
1083 void CMsgAddressControl::HandleEdwinEventL( |
|
1084 CEikEdwin* aEdwin, TEdwinEvent aEventType ) |
|
1085 { |
|
1086 CMsgExpandableControl::HandleEdwinEventL( aEdwin, aEventType ); |
|
1087 |
|
1088 if ( aEventType == MEikEdwinObserver::EEventNavigation ) |
|
1089 { |
|
1090 if ( iAddressControlEditor->CursorPos() == |
|
1091 iAddressControlEditor->TextLength() ) |
|
1092 { |
|
1093 iAddressControlEditor->TurnHighlightingOffFromPosL( 0 ); |
|
1094 } |
|
1095 iAddressControlEditor->CheckHighlightingL(); |
|
1096 } |
|
1097 if ( aEventType == MEikEdwinObserver::EEventTextUpdate ) |
|
1098 { |
|
1099 iAddressControlEditor->PostInsertEditorFormattingL( iDuplicateEvent ); |
|
1100 |
|
1101 // Reset duplicate event flag. |
|
1102 iDuplicateEvent = EFalse; |
|
1103 } |
|
1104 } |
|
1105 |
|
1106 // --------------------------------------------------------- |
|
1107 // CMsgAddressControl::PrepareForReadOnly |
|
1108 // |
|
1109 // Prepares read only or non read only state. |
|
1110 // --------------------------------------------------------- |
|
1111 // |
|
1112 void CMsgAddressControl::PrepareForReadOnly( TBool aReadOnly ) |
|
1113 { |
|
1114 CMsgExpandableControl::PrepareForReadOnly( aReadOnly ); |
|
1115 |
|
1116 #ifdef RD_SCALABLE_UI_V2 |
|
1117 if ( !aReadOnly && |
|
1118 AknLayoutUtils::PenEnabled() ) |
|
1119 { |
|
1120 if ( !iButton ) |
|
1121 { |
|
1122 TRAPD( error, CreateButtonL() ); |
|
1123 if ( error == KErrNone ) |
|
1124 { |
|
1125 LayoutButton(); |
|
1126 } |
|
1127 else |
|
1128 { |
|
1129 delete iButton; |
|
1130 iButton = NULL; |
|
1131 } |
|
1132 } |
|
1133 } |
|
1134 else |
|
1135 { |
|
1136 // No button is created at the read only state or when pen is disabled |
|
1137 delete iButton; |
|
1138 iButton = NULL; |
|
1139 } |
|
1140 #endif |
|
1141 } |
|
1142 |
|
1143 // --------------------------------------------------------- |
|
1144 // CMsgAddressControl::FocusChanged |
|
1145 // |
|
1146 // This is called when the focus of the control is changed. |
|
1147 // --------------------------------------------------------- |
|
1148 // |
|
1149 void CMsgAddressControl::FocusChanged( TDrawNow aDrawNow ) |
|
1150 { |
|
1151 CMsgExpandableControl::FocusChanged( aDrawNow ); |
|
1152 |
|
1153 } |
|
1154 |
|
1155 // --------------------------------------------------------- |
|
1156 // CMsgAddressControl::HandleResourceChange |
|
1157 // |
|
1158 // This is called when the focus of the control is changed. |
|
1159 // --------------------------------------------------------- |
|
1160 // |
|
1161 void CMsgAddressControl::HandleResourceChange( TInt aType ) |
|
1162 { |
|
1163 |
|
1164 CMsgExpandableControl::HandleResourceChange( aType ); |
|
1165 } |
|
1166 |
|
1167 // --------------------------------------------------------- |
|
1168 // CMsgAddressControl::GetNextItemOnEntry |
|
1169 // |
|
1170 // Finds the next unverified string on entry and updates parsing info |
|
1171 // correspondingly. Returns ETrue if found. |
|
1172 // --------------------------------------------------------- |
|
1173 // |
|
1174 TInt CMsgAddressControl::GetNextItemOnEntry( TDes& aEntryBuf ) |
|
1175 { |
|
1176 TInt entryNumber = iParsingInfo.iEntryNum; |
|
1177 TInt startPos = iParsingInfo.iEndPos; |
|
1178 TInt endPos = iParsingInfo.iEndPos; |
|
1179 |
|
1180 TPtrC entryString( iAddressControlEditor->ReadEntry( entryNumber ) ); |
|
1181 TInt ret = ParseString( aEntryBuf, entryString, startPos, endPos ); |
|
1182 SetParsingInfo( entryNumber, startPos, endPos ); |
|
1183 |
|
1184 return ret; |
|
1185 } |
|
1186 |
|
1187 // --------------------------------------------------------- |
|
1188 // CMsgAddressControl::ParseString |
|
1189 // |
|
1190 // Finds and returns an unverified string aEntryItem from aString starting at |
|
1191 // position aStartPos. Returns a start position aStartPos and an end position |
|
1192 // aEndPos of the searched range. Returns KErrNotFound if the string cannot be |
|
1193 // found or KErrOverflow if a sting was too long. |
|
1194 // --------------------------------------------------------- |
|
1195 // |
|
1196 TInt CMsgAddressControl::ParseString( |
|
1197 TDes& aEntryItem, const TPtrC& aString, TInt& aStartPos, TInt& aEndPos ) |
|
1198 { |
|
1199 __ASSERT_DEBUG( aStartPos >= 0, Panic( EMsgInvalidStartPos ) ); |
|
1200 |
|
1201 aEntryItem.Zero(); |
|
1202 aEndPos = aStartPos; |
|
1203 TInt stringLength = aString.Length(); |
|
1204 TInt ret( KErrNone ); |
|
1205 |
|
1206 while ( aEndPos < stringLength ) |
|
1207 { |
|
1208 // finds suitable strings e.g. kalle;^ kalle^ ______;^ |
|
1209 if ( ( ( aString[aEndPos] == KMsgListSeparator ) || |
|
1210 ( aString[aEndPos] == KArabicSemicolon ) || |
|
1211 ( aString[aEndPos] == CEditableText::ELineBreak ) || |
|
1212 ( aString[aEndPos] == KDownwardsArrowWithTipLeftwards ) || |
|
1213 ( aString[aEndPos] == KDownwardsArrowWithTipRightwards ) ) |
|
1214 // SJK 25.04.2005: Fixing "HNUN-6BPAVU": |
|
1215 /*&& ( aStartPos != aEndPos )*/ ) |
|
1216 { |
|
1217 aEndPos++; |
|
1218 break; |
|
1219 } |
|
1220 else if ( ( ( aString[aEndPos] != KMsgListSeparator ) || |
|
1221 ( aString[aEndPos] != KArabicSemicolon ) ) && |
|
1222 ( aEntryItem.Length() < aEntryItem.MaxLength() ) ) |
|
1223 { |
|
1224 aEntryItem.Append( aString[aEndPos] ); |
|
1225 } |
|
1226 else if ( aString[aEndPos] != CEditableText::ESpace ) |
|
1227 { |
|
1228 // Do we ever get here? Even in theory!? |
|
1229 // What is this branch for?! |
|
1230 aEndPos++; |
|
1231 break; |
|
1232 } |
|
1233 aEndPos++; |
|
1234 } |
|
1235 |
|
1236 aEntryItem.TrimAll(); |
|
1237 |
|
1238 if ( ( aEntryItem.Length() == 0 ) && ( aStartPos == aEndPos ) ) |
|
1239 { |
|
1240 ret = KErrNotFound; |
|
1241 } |
|
1242 |
|
1243 return ret; |
|
1244 } |
|
1245 |
|
1246 // --------------------------------------------------------- |
|
1247 // CMsgAddressControl::FormatAndSetCursorPosL |
|
1248 // |
|
1249 // Formats and sets the cursor to the beginning of the formatted band. |
|
1250 // --------------------------------------------------------- |
|
1251 // |
|
1252 void CMsgAddressControl::FormatAndSetCursorPosL( TInt aPos ) |
|
1253 { |
|
1254 if ( iControlModeFlags & EMsgControlModeInitialized ) |
|
1255 { |
|
1256 iAddressControlEditor->SetAmountToFormatL( ETrue ); |
|
1257 iAddressControlEditor->CheckHighlightingL(); |
|
1258 } |
|
1259 |
|
1260 // Formats and draws the content |
|
1261 iAddressControlEditor->SetCursorPosAndCancelSelectionL( aPos ); |
|
1262 if ( iControlModeFlags & EMsgControlModeInitialized ) |
|
1263 { |
|
1264 iAddressControlEditor->CheckHighlightingL(); |
|
1265 iBaseControlObserver->HandleBaseControlEventRequestL( |
|
1266 this, EMsgEnsureCorrectFormPosition ); |
|
1267 } |
|
1268 } |
|
1269 |
|
1270 // --------------------------------------------------------- |
|
1271 // CMsgAddressControl::RemoveHightlightedEntryL |
|
1272 // --------------------------------------------------------- |
|
1273 // |
|
1274 void CMsgAddressControl::RemoveHighlightedEntryL( ) |
|
1275 { |
|
1276 iAddressControlEditor->TurnHighlightingOffL(); |
|
1277 TInt cursorPos( iAddressControlEditor->CursorPos() ); |
|
1278 TInt entryNumber = iAddressControlEditor->EntryNumber( iAddressControlEditor->CursorPos() ); |
|
1279 //Count the paragraph delimiter while capturing length |
|
1280 TInt entryLength = iAddressControlEditor->EntryLength( entryNumber )+1; |
|
1281 //Clear the entry |
|
1282 iAddressControlEditor->DeleteEntryCharsL( entryNumber, 0, entryLength ); |
|
1283 iAddressControlEditor->DeleteEntryL( entryNumber ); |
|
1284 FormatAndSetCursorPosL(iAddressControlEditor->CursorPos()); |
|
1285 |
|
1286 iControlModeFlags |= EMsgControlModeModified; |
|
1287 } |
|
1288 |
|
1289 // --------------------------------------------------------- |
|
1290 // CMsgAddressControl::CreateButtonL |
|
1291 // --------------------------------------------------------- |
|
1292 // |
|
1293 void CMsgAddressControl::CreateButtonL() |
|
1294 { |
|
1295 #ifdef RD_SCALABLE_UI_V2 |
|
1296 delete iButton; |
|
1297 iButton = NULL; |
|
1298 |
|
1299 iButton = CAknButton::NewL( NULL, |
|
1300 NULL, |
|
1301 NULL, |
|
1302 NULL, |
|
1303 *iCaption->Text(), |
|
1304 KNullDesC, |
|
1305 KAknButtonSizeFitText | KAknButtonTextLeft, |
|
1306 0 ); |
|
1307 |
|
1308 iButton->SetTextColorIds( KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG63 ); |
|
1309 iButton->SetObserver( this ); |
|
1310 |
|
1311 if ( Parent() ) |
|
1312 { |
|
1313 iButton->SetContainerWindowL( *Parent() ); |
|
1314 iButton->ActivateL(); |
|
1315 } |
|
1316 #endif // RD_SCALABLE_UI_V2 |
|
1317 } |
|
1318 |
|
1319 // --------------------------------------------------------- |
|
1320 // CMsgAddressControl::LayoutButton |
|
1321 // --------------------------------------------------------- |
|
1322 // |
|
1323 void CMsgAddressControl::LayoutButton() |
|
1324 { |
|
1325 #ifdef RD_SCALABLE_UI_V2 |
|
1326 CMsgExpandableControl::LayoutButton(); |
|
1327 |
|
1328 if ( iButton ) |
|
1329 { |
|
1330 TMargins8 margins; |
|
1331 TRect buttonRect = iButtonLayout.Rect(); |
|
1332 TRect textRect = iCaptionLayout.TextRect(); |
|
1333 margins.iTop = textRect.iTl.iY - buttonRect.iTl.iY; |
|
1334 margins.iBottom = buttonRect.iBr.iY - textRect.iBr.iY; |
|
1335 margins.iLeft = textRect.iTl.iX - buttonRect.iTl.iX; |
|
1336 margins.iRight = buttonRect.iBr.iX - textRect.iBr.iX; |
|
1337 |
|
1338 iButton->SetMargins( margins ); |
|
1339 } |
|
1340 #endif // RD_SCALABLE_UI_V2 |
|
1341 } |
|
1342 |
|
1343 // End of File |