|
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 : email header container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "emailtrace.h" |
|
21 #include <StringLoader.h> |
|
22 #include <aknViewAppUi.h> |
|
23 #include <aknnotewrappers.h> //CAknInformationNote |
|
24 #include <FreestyleEmailUi.rsg> |
|
25 //<cmail> |
|
26 #include "CFSMailBox.h" |
|
27 #include <FreestyleEmailUi.rsg> |
|
28 |
|
29 #include "cpbkxremotecontactlookupserviceuicontext.h" |
|
30 //</cmail> |
|
31 |
|
32 #include "FSEmailBuildFlags.h" |
|
33 #include "ncsheadercontainer.h" |
|
34 #include "ncscomposeviewcontainer.h" |
|
35 #include "ncsemailaddressobject.h" |
|
36 #include "ncsutility.h" |
|
37 #include "FreestyleEmailUiUtilities.h" |
|
38 #include "FreestyleEmailUiAppui.h" |
|
39 #include "FSEmail.pan" |
|
40 #include "ncsattachmentfield.h" |
|
41 #include "ncssubjectfield.h" |
|
42 #include "ncspopuplistbox.h" |
|
43 |
|
44 _LIT( KAddressDelimeterSemiColon, ";" ); |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // ToNcsControl |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 static MNcsControl* ToNcsControl( CCoeControlArray::TCursor cur ) |
|
52 { |
|
53 FUNC_LOG; |
|
54 CCoeControl* coe = cur.Control<CCoeControl>(); |
|
55 return dynamic_cast<MNcsControl*>(coe); |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CNcsHeaderContainer::NewL |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CNcsHeaderContainer* CNcsHeaderContainer::NewL( CCoeControl& aParent, |
|
63 CFSMailBox& aMailBox, TInt aFlags ) |
|
64 { |
|
65 FUNC_LOG; |
|
66 CNcsHeaderContainer* self = new ( ELeave ) CNcsHeaderContainer( aParent, aMailBox ); |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL( aFlags ); |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CNcsHeaderContainer::CNcsHeaderContainer |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CNcsHeaderContainer::CNcsHeaderContainer( |
|
78 CCoeControl& aParent, |
|
79 CFSMailBox& aMailBox ): |
|
80 iParent(aParent), |
|
81 // <cmail> Platform layout change |
|
82 iFieldSizeObserver( static_cast< CNcsComposeViewContainer& >( aParent ) ), |
|
83 // </cmail> Platform layout change |
|
84 iMailBox( aMailBox ), |
|
85 iLongTapEventConsumed(EFalse) |
|
86 { |
|
87 FUNC_LOG; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CNcsHeaderContainer::ConstructL |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CNcsHeaderContainer::ConstructL( TInt aFlags ) |
|
95 { |
|
96 FUNC_LOG; |
|
97 |
|
98 SetContainerWindowL(iParent); |
|
99 |
|
100 CFreestyleEmailUiAppUi* fsAppUi = static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() ); |
|
101 // <cmail> |
|
102 //fsAppUi->FsTextureManager()->ProvideBitmapL( EViewerTextureHeaderBackGround, iBackgroundBitmap, iBackgroundMask ); |
|
103 // </cmail> |
|
104 |
|
105 // <cmail> Platform layout change |
|
106 // Create 'To' field |
|
107 iToField = CNcsAddressInputField::NewL( |
|
108 R_NCS_TO_FIELD_TEXT, |
|
109 CNcsAddressInputField::EInputFieldTo, |
|
110 &iFieldSizeObserver, |
|
111 this, this ); |
|
112 |
|
113 // Create 'Cc' field |
|
114 iCcField = CNcsAddressInputField::NewL( |
|
115 R_NCS_CC_FIELD_TEXT, |
|
116 CNcsAddressInputField::EInputFieldCc, |
|
117 &iFieldSizeObserver, |
|
118 this, this ); |
|
119 iCcField->MakeVisible( aFlags&ECcFieldVisible ); |
|
120 |
|
121 // Create 'Bcc' field |
|
122 iBccField = CNcsAddressInputField::NewL( |
|
123 R_NCS_BCC_FIELD_TEXT, |
|
124 CNcsAddressInputField::EInputFieldBcc, |
|
125 &iFieldSizeObserver, |
|
126 this, this ); |
|
127 iBccField->MakeVisible( aFlags&EBccFieldVisible ); |
|
128 |
|
129 // Create 'subject' field |
|
130 iSubjectField = CNcsSubjectField::NewL( R_FSE_EDITOR_HEADER_SUBJECT, |
|
131 &iFieldSizeObserver, this ); |
|
132 |
|
133 iAttachmentField = CNcsAttachmentField::NewL( R_NCS_ATTACHMENT_LABEL_TEXT, |
|
134 &iFieldSizeObserver, this ); |
|
135 // </cmail> Platform layout change |
|
136 |
|
137 // Setup the control array |
|
138 // Add all of them now so the container and parent is set correctly |
|
139 InitComponentArrayL(); |
|
140 CCoeControlArray& controls = Components(); |
|
141 controls.SetControlsOwnedExternally( ETrue ); |
|
142 |
|
143 controls.AppendLC( iToField ); |
|
144 CleanupStack::Pop( iToField ); |
|
145 controls.AppendLC( iCcField ); |
|
146 CleanupStack::Pop( iCcField ); |
|
147 controls.AppendLC( iBccField ); |
|
148 CleanupStack::Pop( iBccField ); |
|
149 controls.AppendLC( iSubjectField ); |
|
150 CleanupStack::Pop( iSubjectField ); |
|
151 controls.AppendLC( iAttachmentField ); |
|
152 CleanupStack::Pop( iAttachmentField ); |
|
153 |
|
154 iToField->SetFocus( ETrue ); |
|
155 |
|
156 if ( !(aFlags&ECcFieldVisible) ) |
|
157 { |
|
158 controls.Remove( iCcField ); |
|
159 } |
|
160 |
|
161 if ( !(aFlags&EBccFieldVisible) ) |
|
162 { |
|
163 controls.Remove( iBccField ); |
|
164 } |
|
165 |
|
166 // initially attachments field is hidden |
|
167 iAttachmentField->MakeVisible( EFalse ); |
|
168 controls.Remove( iAttachmentField ); |
|
169 |
|
170 // test whether mailbox supports remote lookup |
|
171 TBool remoteLookupSupported = TFsEmailUiUtility::IsRemoteLookupSupported( iMailBox ); |
|
172 |
|
173 iAacListBox = CNcsPopupListBox::NewL( this, iMailBox, *this, remoteLookupSupported ); |
|
174 iAacListBox->MakeVisible( EFalse ); |
|
175 |
|
176 // <cmail> |
|
177 iBgContext = CAknsBasicBackgroundControlContext::NewL( |
|
178 KAknsIIDQsnBgAreaMain, Rect(), EFalse ); |
|
179 // </cmail> |
|
180 iRALInProgress = EFalse; |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------------- |
|
184 // CNcsHeaderContainer::~CNcsHeaderContainer |
|
185 // --------------------------------------------------------------------------- |
|
186 CNcsHeaderContainer::~CNcsHeaderContainer() |
|
187 { |
|
188 FUNC_LOG; |
|
189 delete iToField; |
|
190 delete iCcField; |
|
191 delete iBccField; |
|
192 delete iSubjectField; |
|
193 delete iAttachmentField; |
|
194 delete iAacListBox; |
|
195 // <cmail> |
|
196 //delete iBackgroundBitmap; |
|
197 //delete iBackgroundMask; |
|
198 delete iLongTapDetector; |
|
199 delete iBgContext; |
|
200 // </cmail> |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // CNcsHeaderContainer::FocusChanged |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 void CNcsHeaderContainer::FocusChanged( TDrawNow aDrawNow ) |
|
208 { |
|
209 FUNC_LOG; |
|
210 |
|
211 CCoeControl* focused = FindFocused(); |
|
212 if ( !IsFocused() ) |
|
213 { |
|
214 if ( focused ) |
|
215 { |
|
216 // We're loosing focus (probably going to message body) |
|
217 // Commit changes and make sure no controls are focused. |
|
218 TRAP_IGNORE( CommitFieldL( focused ) ); |
|
219 focused->SetFocus( EFalse, aDrawNow ); |
|
220 } |
|
221 |
|
222 // Remove MSK label when header loses focus |
|
223 TRAP_IGNORE( SetMskL() ); |
|
224 } |
|
225 else if ( IsFocused() && !focused ) |
|
226 { |
|
227 // We're gaining focus from the message body |
|
228 // Set the focus to the last control in the control array |
|
229 // (either attachment line or subject field) |
|
230 CCoeControlArray::TCursor cur = Components().End(); |
|
231 cur.Prev(); |
|
232 cur.Control<CCoeControl>()->SetFocus( ETrue, aDrawNow ); |
|
233 } |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CNcsHeaderContainer::Draw() const |
|
238 // Draws the display |
|
239 // ----------------------------------------------------------------------------- |
|
240 void CNcsHeaderContainer::Draw( const TRect& /*aRect*/ ) const |
|
241 { |
|
242 FUNC_LOG; |
|
243 // <cmail> S60 Skin support |
|
244 // Get the standard graphics context |
|
245 //CWindowGc& gc = SystemGc(); |
|
246 |
|
247 //gc.Clear(); |
|
248 |
|
249 // Redraw the background |
|
250 //gc.BitBlt( iBackgroundPos, iBackgroundBitmap, iBackgroundBitmap->SizeInPixels() ); |
|
251 if ( iBgContext ) |
|
252 { |
|
253 CWindowGc& gc = SystemGc(); |
|
254 |
|
255 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
256 |
|
257 if ( skin ) |
|
258 { |
|
259 AknsDrawUtils::Background( skin, iBgContext, this, gc, Rect() ); |
|
260 } |
|
261 } |
|
262 // </cmail> |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CNcsHeaderContainer::DrawAttachmentFocusNow() const |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 void CNcsHeaderContainer::DrawAttachmentFocusNow() |
|
270 { |
|
271 FUNC_LOG; |
|
272 iAttachmentField->DrawDeferred(); |
|
273 } |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // CNcsHeaderContainer::HandleControlArrayEventL() |
|
277 // Handles removal or additons of controls to the header. |
|
278 // ----------------------------------------------------------------------------- |
|
279 void CNcsHeaderContainer::HandleControlArrayEventL( |
|
280 CCoeControlArray::TEvent aEvent, |
|
281 const CCoeControlArray* /*aArray*/, |
|
282 CCoeControl* aControl, |
|
283 TInt /*aControlId*/ ) |
|
284 { |
|
285 FUNC_LOG; |
|
286 if (aEvent == CCoeControlArray::EControlAdded) |
|
287 { |
|
288 aControl->SetContainerWindowL( iParent ); |
|
289 aControl->MakeVisible( ETrue ); |
|
290 aControl->ActivateL(); |
|
291 } |
|
292 else if ( aEvent == CCoeControlArray::EControlRemoved ) |
|
293 { |
|
294 aControl->MakeVisible( EFalse ); |
|
295 } |
|
296 // Tell the parent to recalculate everything |
|
297 // <cmail> Platform layout change |
|
298 iFieldSizeObserver.UpdateFieldPosition(NULL); |
|
299 // </cmail> Platform layout change |
|
300 } |
|
301 |
|
302 void CNcsHeaderContainer::SetMskL() |
|
303 { |
|
304 FUNC_LOG; |
|
305 CCoeControl* focused = FindFocused(); |
|
306 if ( focused == iToField || focused == iCcField || focused == iBccField ) |
|
307 { |
|
308 // <cmail> additional check if we can change MSK label |
|
309 if(iSwitchChangeMskOff == EFalse) |
|
310 { |
|
311 // </cmail> |
|
312 ChangeMskCommandL( R_FSE_QTN_MSK_ADD ); |
|
313 } |
|
314 } |
|
315 else if ( focused == iAttachmentField ) |
|
316 { |
|
317 if ( GetAttachmentCount() > 1 ) |
|
318 { |
|
319 ChangeMskCommandL( R_FSE_QTN_MSK_VIEWATTACHMENTS ); |
|
320 } |
|
321 else if ( !HasRemoteAttachments() ) |
|
322 { |
|
323 ChangeMskCommandL( R_FSE_QTN_MSK_VIEWATTACHMENT ); |
|
324 } |
|
325 else // message has single remote attachment => no MSK function |
|
326 { |
|
327 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
328 } |
|
329 } |
|
330 // <cmail> msk context menu added into composer |
|
331 else if ( focused == iSubjectField ) |
|
332 { |
|
333 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
334 } |
|
335 else |
|
336 { |
|
337 ChangeMskCommandL( R_FSE_QTN_MSK_BODY_MENU ); |
|
338 } |
|
339 // </cmail> |
|
340 } |
|
341 |
|
342 //<cmail> |
|
343 // ----------------------------------------------------------------------------- |
|
344 // CNcsHeaderContainer::HandlePointerEventL() |
|
345 // |
|
346 // ----------------------------------------------------------------------------- |
|
347 void CNcsHeaderContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
348 { |
|
349 FUNC_LOG; |
|
350 CCoeControl* clicked = 0; |
|
351 for (TInt i=0; i < Components().Count(); ++i) |
|
352 { |
|
353 TRect rc = Components().At(i).iControl->Rect(); |
|
354 if (rc.Contains(aPointerEvent.iPosition)) |
|
355 { |
|
356 clicked = Components().At(i).iControl; |
|
357 } |
|
358 } |
|
359 if (clicked) |
|
360 { |
|
361 if (aPointerEvent.iType == TPointerEvent::EButton1Up) |
|
362 { |
|
363 CCoeControl* pOldCtrl = FindFocused(); |
|
364 CCoeControl* pNewCtrl= clicked; |
|
365 |
|
366 if (pOldCtrl != pNewCtrl) |
|
367 { |
|
368 // Unfocus the control |
|
369 if ( pOldCtrl ) |
|
370 { |
|
371 CommitFieldL( pOldCtrl ); |
|
372 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
373 } |
|
374 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
375 |
|
376 // If the attachments label has changed focus |
|
377 if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField ) |
|
378 { |
|
379 DrawAttachmentFocusNow(); |
|
380 } |
|
381 |
|
382 CNcsComposeViewContainer* container = |
|
383 static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
384 container->UpdateScrollBarL(); |
|
385 } |
|
386 |
|
387 if( iLongTapEventConsumed ) |
|
388 { |
|
389 iLongTapEventConsumed = EFalse; |
|
390 return; |
|
391 } |
|
392 |
|
393 if( pNewCtrl == iAttachmentField ) |
|
394 { |
|
395 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
396 parent.HandleAttachmentsOpenCommandL(); |
|
397 } |
|
398 } |
|
399 } |
|
400 for (TInt i=0; i < Components().Count(); ++i) |
|
401 { |
|
402 Components().At(i).iControl->HandlePointerEventL(aPointerEvent); |
|
403 } |
|
404 } |
|
405 |
|
406 // ----------------------------------------------------------------------------- |
|
407 // CNcsHeaderContainer::HandleLongTapL() |
|
408 // |
|
409 // ----------------------------------------------------------------------------- |
|
410 void CNcsHeaderContainer::HandleLongTapL( const TPoint& aPenEventLocation ) |
|
411 { |
|
412 FUNC_LOG; |
|
413 iLongTapEventConsumed = EFalse; |
|
414 |
|
415 CCoeControl* control = FindFocused(); |
|
416 TRect rect = iAttachmentField->Rect(); |
|
417 if( iAttachmentField->IsVisible() && rect.Contains( aPenEventLocation ) ) |
|
418 { |
|
419 iLongTapEventConsumed = ETrue; |
|
420 |
|
421 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
422 parent.LaunchAttachmentActionMenuL(); |
|
423 } |
|
424 } |
|
425 |
|
426 TBool CNcsHeaderContainer::NeedsLongTapL( const TPoint& aPenEventLocation ) |
|
427 { |
|
428 FUNC_LOG; |
|
429 |
|
430 CCoeControl* control = FindFocused(); |
|
431 TRect rect = iAttachmentField->Rect(); |
|
432 TBool result(EFalse); |
|
433 if( iAttachmentField->IsVisible() && rect.Contains( aPenEventLocation ) ) |
|
434 { |
|
435 result = ETrue; |
|
436 } |
|
437 return result; |
|
438 } |
|
439 //</cmail> |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CNcsHeaderContainer::OfferKeyEventL() |
|
443 // Handles key events |
|
444 // ----------------------------------------------------------------------------- |
|
445 TKeyResponse CNcsHeaderContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
446 { |
|
447 FUNC_LOG; |
|
448 TKeyResponse ret( EKeyWasNotConsumed ); |
|
449 |
|
450 TBool doScroll( EFalse ); |
|
451 |
|
452 if( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow ) |
|
453 { |
|
454 if ( iAacListBox && iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() ) |
|
455 { |
|
456 return iAacListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
457 } |
|
458 else |
|
459 { |
|
460 ret = FindFocused()->OfferKeyEventL( aKeyEvent, aType ); |
|
461 |
|
462 doScroll = (ret == EKeyWasConsumed); |
|
463 } |
|
464 |
|
465 if ( ret == EKeyWasNotConsumed ) |
|
466 { |
|
467 ret = ChangeFocusL( aKeyEvent ); |
|
468 DrawDeferred(); |
|
469 } |
|
470 } |
|
471 else |
|
472 { |
|
473 if ( FindFocused() == iAttachmentField ) |
|
474 { |
|
475 if ( aType == EEventKey ) |
|
476 { |
|
477 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
478 |
|
479 if ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter || |
|
480 aKeyEvent.iCode == EKeyOK || aKeyEvent.iScanCode == EStdKeyDevice3 ) |
|
481 { |
|
482 // open list or attachment |
|
483 parent.HandleAttachmentsOpenCommandL(); |
|
484 ret = EKeyWasConsumed; |
|
485 } |
|
486 else if ( (AknLayoutUtils::LayoutMirrored() && aKeyEvent.iCode == EKeyLeftArrow) || |
|
487 (!AknLayoutUtils::LayoutMirrored() && aKeyEvent.iCode == EKeyRightArrow) ) |
|
488 { |
|
489 parent.LaunchAttachmentActionMenuL(); |
|
490 ret = EKeyWasConsumed; |
|
491 } |
|
492 } |
|
493 } |
|
494 else if ( IsPopupActive() && aType == EEventKey ) |
|
495 { |
|
496 // select current |
|
497 if( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyDevice4 || |
|
498 aKeyEvent.iCode == EKeyOK ) |
|
499 { |
|
500 DoPopupSelectL(); |
|
501 ret = EKeyWasConsumed; |
|
502 } |
|
503 } |
|
504 else |
|
505 { |
|
506 // Don't allow line feeds in header fields. |
|
507 // Could be nice if enter committed the field and moved the focus to next one |
|
508 if ( aType == EEventKey && (aKeyEvent.iCode == EKeyEnter || aKeyEvent.iScanCode == EStdKeyEnter) ) |
|
509 { |
|
510 ret = FindFocused()->OfferKeyEventL( aKeyEvent, aType ); |
|
511 return EKeyWasConsumed; |
|
512 } |
|
513 } |
|
514 } |
|
515 if ( ret == EKeyWasNotConsumed ) |
|
516 { |
|
517 CCoeControl* focused = FindFocused(); |
|
518 if ( focused ) |
|
519 { |
|
520 ret = focused->OfferKeyEventL( aKeyEvent, aType ); |
|
521 |
|
522 doScroll = (ret == EKeyWasConsumed); |
|
523 } |
|
524 } |
|
525 |
|
526 if( doScroll ) |
|
527 { |
|
528 // scroll the screen if the cursor goes beyond the screen |
|
529 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
530 |
|
531 TInt screenPos( -Position().iY ); |
|
532 TInt cursorPos( CursorPosition() ); |
|
533 TInt lineHeight( Rect().Height() / LineCount() ); |
|
534 TInt screenHeight( parent.Rect().Height() ); |
|
535 |
|
536 if( cursorPos - lineHeight < screenPos ) |
|
537 { |
|
538 screenPos = cursorPos - lineHeight; |
|
539 } |
|
540 else |
|
541 if( cursorPos + lineHeight > screenPos + screenHeight ) |
|
542 { |
|
543 screenPos = cursorPos + lineHeight - screenHeight; |
|
544 } |
|
545 |
|
546 parent.ScrollL( screenPos ); |
|
547 PositionChanged(); |
|
548 } |
|
549 |
|
550 return ret; |
|
551 } |
|
552 |
|
553 // --------------------------------------------------------------------------- |
|
554 // CNcsHeaderContainer::FindFocused |
|
555 // --------------------------------------------------------------------------- |
|
556 // |
|
557 CCoeControl* CNcsHeaderContainer::FindFocused() const |
|
558 { |
|
559 FUNC_LOG; |
|
560 CCoeControlArray::TCursor cur = Components().Begin(); |
|
561 do |
|
562 { |
|
563 if ( cur.Control<CCoeControl>()->IsFocused() ) |
|
564 { |
|
565 return cur.Control<CCoeControl>(); |
|
566 } |
|
567 } |
|
568 while ( cur.Next() ); |
|
569 return NULL; |
|
570 } |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CNcsHeaderContainer::ChangeFocusL() |
|
574 // Handles key events |
|
575 // ----------------------------------------------------------------------------- |
|
576 TKeyResponse CNcsHeaderContainer::ChangeFocusL( const TKeyEvent& aKeyEvent ) |
|
577 { |
|
578 FUNC_LOG; |
|
579 ASSERT( aKeyEvent.iCode == EKeyDownArrow || aKeyEvent.iCode == EKeyUpArrow ); |
|
580 TKeyResponse ret( EKeyWasNotConsumed ); |
|
581 |
|
582 CCoeControl* pOldCtrl = FindFocused(); |
|
583 |
|
584 // If nothing is focused we return |
|
585 if ( !pOldCtrl ) return ret; |
|
586 |
|
587 //If this is the first control in the list, don't change focus |
|
588 CCoeControlArray::TCursor cur = Components().Find(pOldCtrl); |
|
589 if ( aKeyEvent.iCode == EKeyUpArrow && cur == Components().Begin() ) |
|
590 { |
|
591 return ret; |
|
592 } |
|
593 |
|
594 // Unfocus the control |
|
595 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
596 |
|
597 CCoeControl* pNewCtrl= NULL; |
|
598 if ( aKeyEvent.iCode == EKeyDownArrow && cur.Next() ) |
|
599 { |
|
600 pNewCtrl = cur.Control<CCoeControl>(); |
|
601 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
602 ret = EKeyWasConsumed; |
|
603 } |
|
604 else if ( aKeyEvent.iCode == EKeyUpArrow && cur.Prev() ) |
|
605 { |
|
606 pNewCtrl = cur.Control<CCoeControl>(); |
|
607 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
608 ret = EKeyWasConsumed; |
|
609 } |
|
610 |
|
611 CNcsComposeViewContainer* container = |
|
612 static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
613 if ( pOldCtrl == iToField ) |
|
614 { |
|
615 container->CommitL(EToField); |
|
616 } |
|
617 else if ( pOldCtrl == iCcField) |
|
618 { |
|
619 container->CommitL(ECcField); |
|
620 } |
|
621 else if ( pOldCtrl == iBccField) |
|
622 { |
|
623 container->CommitL(EBccField); |
|
624 } |
|
625 else if ( pOldCtrl == iSubjectField) |
|
626 { |
|
627 container->CommitL(ESubjectField); |
|
628 } |
|
629 |
|
630 // If the attachments label has changed focus |
|
631 if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField ) |
|
632 { |
|
633 DrawAttachmentFocusNow(); |
|
634 } |
|
635 |
|
636 // if focus was changed, update scroll bar |
|
637 if ( ret == EKeyWasConsumed ) |
|
638 { |
|
639 container->UpdateScrollBarL(); |
|
640 } |
|
641 |
|
642 // NOTE: If we're leaving the header (down was pushed on last control) |
|
643 // then we return EKeyWasNotConsumed to make sure the |
|
644 // parent moves the focus to the control below this container |
|
645 return ret; |
|
646 } |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // CNcsHeaderContainer::UpdateFieldPosition() |
|
650 // One of the controls want me to readjust myself to a new position,' |
|
651 // anchoring arround the given control |
|
652 // ----------------------------------------------------------------------------- |
|
653 void CNcsHeaderContainer::UpdateFieldPosition( CCoeControl* aAnchor ) |
|
654 { |
|
655 FUNC_LOG; |
|
656 // if the anchor is NULL just call SizeChanged |
|
657 if ( !aAnchor ) |
|
658 { |
|
659 SizeChanged(); |
|
660 return; |
|
661 } |
|
662 |
|
663 CCoeControlArray::TCursor cur = Components().Find( aAnchor ); |
|
664 ASSERT( cur.IsValid() ); |
|
665 |
|
666 // figure out the new top position of the container |
|
667 TInt top = aAnchor->Rect().iTl.iY; |
|
668 while ( cur.Prev() ) |
|
669 { |
|
670 CCoeControl* ctrl = cur.Control<CCoeControl>(); |
|
671 top -= ctrl->Rect().Height(); |
|
672 } |
|
673 |
|
674 // Then check we didn't move too much and composer still fills the whole |
|
675 // visible area on the screen (i.e. don't scroll below the bottom of the body field) |
|
676 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
677 TInt composerHeight = parent.ContentTotalHeight(); |
|
678 TInt screenHeight = parent.Rect().Height(); |
|
679 if ( composerHeight <= screenHeight ) |
|
680 { // no scrolling is needed at all since everything fits on screen |
|
681 top = 0; |
|
682 } |
|
683 else |
|
684 { |
|
685 top = Max( top, screenHeight - composerHeight ); |
|
686 } |
|
687 |
|
688 // The top edge of the header should never be lower than on the top edge of the screen. |
|
689 // For some reason, the calculation above leads to such situation if recipient and subject |
|
690 // fields are scrollable. If that happens, increase the top value to 0 to prevent empty |
|
691 // space showing up above the header area. |
|
692 top = Min( top, 0 ); |
|
693 |
|
694 // set the new position of the container |
|
695 SetExtent( TPoint( Rect().iTl.iX, top ), Size() ); |
|
696 } |
|
697 |
|
698 // <cmail> Platform layout change |
|
699 // ----------------------------------------------------------------------------- |
|
700 // CNcsHeaderContainer::SizeChanged() |
|
701 // set size |
|
702 // ----------------------------------------------------------------------------- |
|
703 void CNcsHeaderContainer::SizeChanged() |
|
704 { |
|
705 FUNC_LOG; |
|
706 |
|
707 const TRect rect( Rect() ); |
|
708 |
|
709 TInt currentLine( 0 ); |
|
710 CCoeControlArray::TCursor cur = Components().Begin(); |
|
711 do |
|
712 { |
|
713 const TInt lineCount( ToNcsControl( cur )->LayoutLineCount() ); |
|
714 if ( lineCount > 0 ) |
|
715 { |
|
716 NcsUtility::LayoutHeaderControl( cur.Control<CCoeControl>(), rect, currentLine, lineCount ); |
|
717 // <cmail> |
|
718 // Do not use stored value lineCount because count may change |
|
719 // during layout (e.g. when orientation is changed => edit field |
|
720 // length may change => it grows or shrinks) |
|
721 currentLine += ToNcsControl( cur )->LayoutLineCount(); |
|
722 // </cmail> |
|
723 } |
|
724 } while ( cur.Next() ); |
|
725 |
|
726 if( iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() ) |
|
727 { |
|
728 iAacListBox->SetPopupMaxRect( CalculatePopupRect() ); |
|
729 } |
|
730 } |
|
731 // </cmail> Platform layout change |
|
732 |
|
733 // ----------------------------------------------------------------------------- |
|
734 // CNcsHeaderContainer::PositionChanged() |
|
735 // set size |
|
736 // ----------------------------------------------------------------------------- |
|
737 void CNcsHeaderContainer::PositionChanged() |
|
738 { |
|
739 FUNC_LOG; |
|
740 DrawDeferred(); |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CNcsHeaderContainer::ChangePositions() |
|
745 // set positions |
|
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 void CNcsHeaderContainer::ChangePositions() |
|
749 { |
|
750 FUNC_LOG; |
|
751 TPoint nextPoint(Rect().iTl); |
|
752 |
|
753 CCoeControl* ctrl; |
|
754 CCoeControlArray::TCursor cur = Components().Begin(); |
|
755 do |
|
756 { |
|
757 ctrl = cur.Control<CCoeControl>(); |
|
758 ctrl->SetPosition(nextPoint); |
|
759 nextPoint.iY += ctrl->Size().iHeight; |
|
760 } |
|
761 while ( cur.Next() ); |
|
762 } |
|
763 |
|
764 |
|
765 // --------------------------------------------------------------------------- |
|
766 // CNcsHeaderContainer::NeedsAifMenu |
|
767 // --------------------------------------------------------------------------- |
|
768 // |
|
769 TBool CNcsHeaderContainer::NeedsAifMenu() const |
|
770 { |
|
771 FUNC_LOG; |
|
772 // <cmail> |
|
773 CCoeControl* focused = FindFocused(); |
|
774 |
|
775 // Has to be an AIF field |
|
776 TBool ret = EFalse; |
|
777 |
|
778 if ( IsAddressInputField( focused ) ) |
|
779 { |
|
780 CNcsAddressInputField* aifFocused = NULL; |
|
781 aifFocused = static_cast<CNcsAddressInputField*>( focused ); |
|
782 ret = ( aifFocused->TextEditor()->SelectionLength() > 1 ); |
|
783 } |
|
784 |
|
785 return ret; |
|
786 // </cmail> |
|
787 } |
|
788 |
|
789 // --------------------------------------------------------------------------- |
|
790 // CNcsHeaderContainer::GetTotalHeight |
|
791 // --------------------------------------------------------------------------- |
|
792 // |
|
793 TInt CNcsHeaderContainer::GetTotalHeight() const |
|
794 { |
|
795 FUNC_LOG; |
|
796 TInt ret = 0; |
|
797 CCoeControlArray::TCursor cur = Components().Begin(); |
|
798 do |
|
799 { |
|
800 CCoeControl* ctrl = cur.Control<CCoeControl>(); |
|
801 ret += ctrl->Size().iHeight; |
|
802 } |
|
803 while (cur.Next()); |
|
804 return ret; |
|
805 } |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // CNcsHeaderContainer::SetAttachmentLabelTextL() |
|
809 // ----------------------------------------------------------------------------- |
|
810 void CNcsHeaderContainer::SetAttachmentLabelTextL( const TDesC& aText ) |
|
811 { |
|
812 FUNC_LOG; |
|
813 if ( aText.Length() >= 1 ) |
|
814 { |
|
815 iAttachmentField->SetTextL( aText ); |
|
816 ShowAttachmentLabelL(); |
|
817 } |
|
818 DrawAttachmentFocusNow(); |
|
819 } |
|
820 |
|
821 // ----------------------------------------------------------------------------- |
|
822 // CNcsHeaderContainer::SetAttachmentLabelTextL() |
|
823 // ----------------------------------------------------------------------------- |
|
824 void CNcsHeaderContainer::SetAttachmentLabelTextL( const TDesC& aAttachmentName, |
|
825 const TDesC& aAttachmentSizeDesc ) |
|
826 { |
|
827 FUNC_LOG; |
|
828 iAttachmentField->SetTextL( aAttachmentName, aAttachmentSizeDesc ); |
|
829 ShowAttachmentLabelL(); |
|
830 DrawAttachmentFocusNow(); |
|
831 } |
|
832 |
|
833 // ----------------------------------------------------------------------------- |
|
834 // CNcsHeaderContainer::ShowAttachmentLabel() |
|
835 // ----------------------------------------------------------------------------- |
|
836 // |
|
837 void CNcsHeaderContainer::ShowAttachmentLabelL() |
|
838 { |
|
839 FUNC_LOG; |
|
840 if ( !iAttachmentField->IsVisible() ) |
|
841 { |
|
842 CCoeControlArray::TCursor cur = Components().End(); |
|
843 Components().InsertLC( cur, iAttachmentField ); |
|
844 CleanupStack::Pop( iAttachmentField ); |
|
845 |
|
846 // <cmail> Platform layout change |
|
847 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
|
848 // </cmail> Platform layout change |
|
849 |
|
850 CCoeControl* pOldCtrl = FindFocused(); |
|
851 if ( pOldCtrl ) |
|
852 { |
|
853 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
854 } |
|
855 |
|
856 iAttachmentField->SetFocus( ETrue, ENoDrawNow ); |
|
857 // <cmail> Platform layout change |
|
858 //CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
859 iFieldSizeObserver.UpdateFieldPosition( iAttachmentField ); |
|
860 // </cmail> Platform layout change |
|
861 } |
|
862 } |
|
863 |
|
864 // ----------------------------------------------------------------------------- |
|
865 // CNcsHeaderContainer::HideAttachmentLabel() |
|
866 // ----------------------------------------------------------------------------- |
|
867 // |
|
868 void CNcsHeaderContainer::HideAttachmentLabel() |
|
869 { |
|
870 FUNC_LOG; |
|
871 // check if we are focused and in that case |
|
872 // unfocus attachment filed and focus previous control |
|
873 CCoeControl* pOldCtrl = FindFocused(); |
|
874 CCoeControl* pNewCtrl = NULL; |
|
875 |
|
876 if ( pOldCtrl == iAttachmentField ) |
|
877 { |
|
878 CCoeControlArray::TCursor cur = Components().Find( pOldCtrl ); |
|
879 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
880 |
|
881 if ( cur.Prev() ) |
|
882 { |
|
883 pNewCtrl = cur.Control<CCoeControl>(); |
|
884 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
885 } |
|
886 } |
|
887 else |
|
888 { |
|
889 pNewCtrl = pOldCtrl; // no need to move focus |
|
890 } |
|
891 |
|
892 if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField ) |
|
893 { |
|
894 DrawAttachmentFocusNow(); |
|
895 } |
|
896 |
|
897 iAttachmentField->MakeVisible( EFalse ); |
|
898 Components().Remove( iAttachmentField ); |
|
899 |
|
900 // <cmail> Platform layout change |
|
901 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
|
902 // </cmail> Platform layout change |
|
903 |
|
904 // Scroll to currently focused field |
|
905 if ( pNewCtrl ) |
|
906 { |
|
907 // <cmail> Platform layout change |
|
908 //CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
909 iFieldSizeObserver.UpdateFieldPosition( pNewCtrl ); |
|
910 // </cmail> Platform layout change |
|
911 } |
|
912 |
|
913 } |
|
914 |
|
915 // ----------------------------------------------------------------------------- |
|
916 // CNcsHeaderContainer::SetBccFieldVisibleL() |
|
917 // ----------------------------------------------------------------------------- |
|
918 // |
|
919 void CNcsHeaderContainer::SetBccFieldVisibleL( TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) |
|
920 { |
|
921 FUNC_LOG; |
|
922 if (iBccField->IsVisible() == aVisible) |
|
923 { |
|
924 return; |
|
925 } |
|
926 |
|
927 if ( aVisible ) |
|
928 { |
|
929 CCoeControlArray::TCursor cur = Components().Find(iSubjectField); |
|
930 Components().InsertLC(cur,iBccField); |
|
931 CleanupStack::Pop( iBccField ); |
|
932 |
|
933 if ( aFocus ) |
|
934 { |
|
935 CCoeControl* focused = FindFocused(); |
|
936 |
|
937 if ( focused ) |
|
938 { |
|
939 focused->SetFocus( EFalse ); |
|
940 } |
|
941 iBccField->SetFocus( ETrue ); |
|
942 iBccField->SelectAllTextL(); |
|
943 } |
|
944 } |
|
945 else |
|
946 { |
|
947 if ( iBccField->IsFocused() ) |
|
948 { |
|
949 CCoeControlArray::TCursor cur = Components().Find(iBccField); |
|
950 ASSERT(cur.IsValid()); |
|
951 |
|
952 iBccField->SetFocus(EFalse); |
|
953 |
|
954 cur.Prev(); //Get the control before this field |
|
955 cur.Control<CCoeControl>()->SetFocus(ETrue); |
|
956 } |
|
957 Components().Remove( iBccField ); |
|
958 } |
|
959 |
|
960 // <cmail> Platform layout change |
|
961 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
|
962 // </cmail> Platform layout change |
|
963 |
|
964 if ( aDrawNow == EDrawNow ) |
|
965 { |
|
966 DrawDeferred(); |
|
967 } |
|
968 } |
|
969 |
|
970 // ----------------------------------------------------------------------------- |
|
971 // CNcsHeaderContainer::SetCcFieldVisibleL() |
|
972 // ----------------------------------------------------------------------------- |
|
973 void CNcsHeaderContainer::SetCcFieldVisibleL( TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) |
|
974 { |
|
975 FUNC_LOG; |
|
976 if ( iCcField->IsVisible() == aVisible ) |
|
977 { |
|
978 return; |
|
979 } |
|
980 |
|
981 if ( aVisible ) |
|
982 { |
|
983 Components().InsertAfterLC( Components().Id(*iToField), iCcField ); |
|
984 CleanupStack::Pop( iCcField ); |
|
985 |
|
986 if ( aFocus ) |
|
987 { |
|
988 CCoeControl* focused = FindFocused(); |
|
989 if ( focused ) |
|
990 { |
|
991 focused->SetFocus( EFalse ); |
|
992 } |
|
993 iCcField->SetFocus( ETrue ); |
|
994 iCcField->SelectAllTextL(); |
|
995 } |
|
996 } |
|
997 else |
|
998 { |
|
999 if( iCcField->IsFocused() ) |
|
1000 { |
|
1001 iCcField->SetFocus(EFalse); |
|
1002 iToField->SetFocus(ETrue); |
|
1003 } |
|
1004 Components().Remove(iCcField); |
|
1005 } |
|
1006 |
|
1007 // <cmail> Platform layout change |
|
1008 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
|
1009 // </cmail> Platform layout change |
|
1010 |
|
1011 if ( aDrawNow == EDrawNow ) |
|
1012 { |
|
1013 DrawDeferred(); |
|
1014 } |
|
1015 } |
|
1016 |
|
1017 // ----------------------------------------------------------------------------- |
|
1018 // CNcsHeaderContainer::MopSupplyObject |
|
1019 // From CCoeControl. |
|
1020 // ----------------------------------------------------------------------------- |
|
1021 TTypeUid::Ptr CNcsHeaderContainer::MopSupplyObject( TTypeUid aId ) |
|
1022 { |
|
1023 FUNC_LOG; |
|
1024 return CCoeControl::MopSupplyObject( aId ); |
|
1025 } |
|
1026 |
|
1027 // --------------------------------------------------------------------------- |
|
1028 // CNcsHeaderContainer::LineCount |
|
1029 // --------------------------------------------------------------------------- |
|
1030 // |
|
1031 TInt CNcsHeaderContainer::LineCount() const |
|
1032 { |
|
1033 FUNC_LOG; |
|
1034 TInt cnt = 0; |
|
1035 CCoeControlArray::TCursor cur = Components().Begin(); |
|
1036 do |
|
1037 { |
|
1038 MNcsControl* ctrl = ToNcsControl(cur); |
|
1039 cnt += ctrl->LineCount(); |
|
1040 } |
|
1041 while ( cur.Next() ); |
|
1042 return cnt; |
|
1043 } |
|
1044 |
|
1045 // --------------------------------------------------------------------------- |
|
1046 // CNcsHeaderContainer::ScrollableLines |
|
1047 // --------------------------------------------------------------------------- |
|
1048 // |
|
1049 TInt CNcsHeaderContainer::ScrollableLines() const |
|
1050 { |
|
1051 FUNC_LOG; |
|
1052 TInt cnt = 0; |
|
1053 CCoeControlArray::TCursor cur = Components().Begin(); |
|
1054 do |
|
1055 { |
|
1056 MNcsControl* ctrl = ToNcsControl(cur); |
|
1057 cnt += ctrl->ScrollableLines(); |
|
1058 } |
|
1059 while ( cur.Next() ); |
|
1060 return cnt; |
|
1061 } |
|
1062 |
|
1063 // --------------------------------------------------------------------------- |
|
1064 // CNcsHeaderContainer::CursorPosition |
|
1065 // --------------------------------------------------------------------------- |
|
1066 // |
|
1067 TInt CNcsHeaderContainer::CursorPosition() const |
|
1068 { |
|
1069 FUNC_LOG; |
|
1070 CCoeControl* coe = FindFocused(); |
|
1071 if ( !coe ) |
|
1072 { |
|
1073 return 0; |
|
1074 } |
|
1075 |
|
1076 MNcsControl* ncsCtrl = dynamic_cast<MNcsControl*>( coe ); |
|
1077 // This will give the the position relative to the top of the control |
|
1078 TInt pos = ncsCtrl->CursorPosition(); |
|
1079 // add the location of the top of the control relative to the top of the header. |
|
1080 pos += coe->Rect().iTl.iY - Rect().iTl.iY; |
|
1081 return pos; |
|
1082 } |
|
1083 |
|
1084 // --------------------------------------------------------------------------- |
|
1085 // CNcsHeaderContainer::CursorLineNumber |
|
1086 // --------------------------------------------------------------------------- |
|
1087 // |
|
1088 TInt CNcsHeaderContainer::CursorLineNumber() const |
|
1089 { |
|
1090 FUNC_LOG; |
|
1091 TInt cnt = 0; |
|
1092 CCoeControlArray::TCursor cur = Components().Begin(); |
|
1093 do |
|
1094 { |
|
1095 CCoeControl* coe = cur.Control<CCoeControl>(); |
|
1096 MNcsControl* ctrl = ToNcsControl(cur); |
|
1097 if ( !coe->IsFocused() ) |
|
1098 { |
|
1099 cnt += ctrl->LineCount(); |
|
1100 } |
|
1101 else |
|
1102 { |
|
1103 cnt += ctrl->CursorLineNumber(); |
|
1104 break; |
|
1105 } |
|
1106 } |
|
1107 while ( cur.Next() ); |
|
1108 return cnt; |
|
1109 } |
|
1110 |
|
1111 // --------------------------------------------------------------------------- |
|
1112 // CNcsHeaderContainer::GetNumChars |
|
1113 // --------------------------------------------------------------------------- |
|
1114 // |
|
1115 TInt CNcsHeaderContainer::GetNumChars() const |
|
1116 { |
|
1117 FUNC_LOG; |
|
1118 TInt cnt = iToField->GetNumChars() + |
|
1119 iCcField->GetNumChars() + |
|
1120 iBccField->GetNumChars() + |
|
1121 iSubjectField->GetNumChars(); |
|
1122 |
|
1123 return cnt; |
|
1124 } |
|
1125 |
|
1126 // ----------------------------------------------------------------------------- |
|
1127 // CNcsHeaderContainer::UpdatePopupContactListL() |
|
1128 // ----------------------------------------------------------------------------- |
|
1129 // |
|
1130 void CNcsHeaderContainer::UpdatePopupContactListL( const TDesC& aMatchString, TBool /*aListAll*/ ) |
|
1131 { |
|
1132 FUNC_LOG; |
|
1133 |
|
1134 // <cmail> do update only for address fields |
|
1135 CCoeControl* focused = FindFocused(); |
|
1136 |
|
1137 if ( !IsAddressInputField( focused ) ) |
|
1138 { |
|
1139 return; |
|
1140 } |
|
1141 // </cmail> |
|
1142 |
|
1143 if ( aMatchString.CompareC( KNullDesC ) == 0 || |
|
1144 aMatchString.Compare( KAddressDelimeterSemiColon ) == 0 ) |
|
1145 { |
|
1146 ClosePopupContactListL(); |
|
1147 return; |
|
1148 } |
|
1149 |
|
1150 if( !iAacListBox->IsVisible() ) |
|
1151 { |
|
1152 iAacListBox->SetPopupMaxRect( CalculatePopupRect() ); |
|
1153 iAacListBox->InitAndSearchL( aMatchString ); |
|
1154 iAacListBox->ActivateL(); |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 iAacListBox->SetSearchTextL( aMatchString ); |
|
1159 } |
|
1160 } |
|
1161 |
|
1162 // ----------------------------------------------------------------------------- |
|
1163 // CNcsHeaderContainer::ClosePopupContactListL() |
|
1164 // ----------------------------------------------------------------------------- |
|
1165 // |
|
1166 void CNcsHeaderContainer::ClosePopupContactListL() |
|
1167 { |
|
1168 FUNC_LOG; |
|
1169 // <cmail> |
|
1170 if ( iAacListBox->IsVisible() ) |
|
1171 { |
|
1172 // </cmail> |
|
1173 iAacListBox->MakeVisible( EFalse ); |
|
1174 ShowPopupMenuBarL( EFalse ); |
|
1175 |
|
1176 // The focused address field should be redrawn after the popup is closed to fix |
|
1177 // the field border. |
|
1178 if ( iToField->IsFocused() ) |
|
1179 { |
|
1180 iToField->DrawDeferred(); |
|
1181 } |
|
1182 else if ( iCcField->IsFocused() ) |
|
1183 { |
|
1184 iCcField->DrawDeferred(); |
|
1185 } |
|
1186 else if ( iBccField->IsFocused() ) |
|
1187 { |
|
1188 iBccField->DrawDeferred(); |
|
1189 } |
|
1190 // <cmail> |
|
1191 } |
|
1192 // </cmail> |
|
1193 } |
|
1194 |
|
1195 // --------------------------------------------------------------------------- |
|
1196 // CNcsHeaderContainer::ShowPopupMenuBarL |
|
1197 // --------------------------------------------------------------------------- |
|
1198 // |
|
1199 void CNcsHeaderContainer::ShowPopupMenuBarL( TBool aShow ) |
|
1200 { |
|
1201 FUNC_LOG; |
|
1202 if ( iMenuBar ) |
|
1203 { |
|
1204 if( aShow ) |
|
1205 { |
|
1206 iMenuBar->SetCommandSetL( R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT ); |
|
1207 } |
|
1208 else |
|
1209 { |
|
1210 iMenuBar->SetCommandSetL( R_FSE_EDITOR_SOFTKEYS_OPTIONS_CLOSE ); |
|
1211 SetMskL(); |
|
1212 } |
|
1213 iMenuBar->DrawDeferred(); |
|
1214 } |
|
1215 } |
|
1216 |
|
1217 // --------------------------------------------------------------------------- |
|
1218 // CNcsHeaderContainer::DeleteSelectionL |
|
1219 // --------------------------------------------------------------------------- |
|
1220 // |
|
1221 void CNcsHeaderContainer::DeleteSelectionL() |
|
1222 { |
|
1223 FUNC_LOG; |
|
1224 |
|
1225 // <cmail> |
|
1226 CCoeControl* focused = FindFocused(); |
|
1227 |
|
1228 if ( IsAddressInputField( focused ) ) |
|
1229 { |
|
1230 CNcsAddressInputField* field = NULL; |
|
1231 field = static_cast<CNcsAddressInputField*>( focused ); |
|
1232 TKeyEvent event; // This mimics c -button pressing |
|
1233 event.iCode = EKeyBackspace; |
|
1234 event.iScanCode = EStdKeyBackspace; |
|
1235 event.iModifiers = EModifierAutorepeatable|EModifierNumLock; |
|
1236 event.iRepeats = 0; |
|
1237 TEventCode code = EEventKey; |
|
1238 field->OfferKeyEventL( event, code ); |
|
1239 } |
|
1240 // </cmail> |
|
1241 |
|
1242 } |
|
1243 |
|
1244 // --------------------------------------------------------------------------- |
|
1245 // CNcsHeaderContainer::SelectAllToFieldTextL |
|
1246 // --------------------------------------------------------------------------- |
|
1247 // |
|
1248 void CNcsHeaderContainer::SelectAllToFieldTextL() |
|
1249 { |
|
1250 FUNC_LOG; |
|
1251 iToField->SelectAllTextL(); |
|
1252 } |
|
1253 |
|
1254 // --------------------------------------------------------------------------- |
|
1255 // CNcsHeaderContainer::SelectAllCcFieldTextL |
|
1256 // --------------------------------------------------------------------------- |
|
1257 // |
|
1258 void CNcsHeaderContainer::SelectAllCcFieldTextL() |
|
1259 { |
|
1260 FUNC_LOG; |
|
1261 iCcField->SelectAllTextL(); |
|
1262 } |
|
1263 |
|
1264 // --------------------------------------------------------------------------- |
|
1265 // CNcsHeaderContainer::SelectAllBccFieldTextL |
|
1266 // --------------------------------------------------------------------------- |
|
1267 // |
|
1268 void CNcsHeaderContainer::SelectAllBccFieldTextL() |
|
1269 { |
|
1270 FUNC_LOG; |
|
1271 iBccField->SelectAllTextL(); |
|
1272 } |
|
1273 |
|
1274 // --------------------------------------------------------------------------- |
|
1275 // CNcsHeaderContainer::SelectAllSubjectFieldTextL |
|
1276 // --------------------------------------------------------------------------- |
|
1277 // |
|
1278 void CNcsHeaderContainer::SelectAllSubjectFieldTextL() |
|
1279 { |
|
1280 FUNC_LOG; |
|
1281 iSubjectField->SelectAllTextL(); |
|
1282 } |
|
1283 |
|
1284 // ----------------------------------------------------------------------------- |
|
1285 // CNcsHeaderContainer::CalculatePopupRect |
|
1286 // ----------------------------------------------------------------------------- |
|
1287 TRect CNcsHeaderContainer::CalculatePopupRect() |
|
1288 { |
|
1289 FUNC_LOG; |
|
1290 // get focused control rect |
|
1291 //<cmail> Added a NULL check for FindFocused(). |
|
1292 // Find out why we end up here in S60 5.0 if there is no focused |
|
1293 // item. In S60 3.2.3 this kind of situation seems not to be possible. |
|
1294 TRect popupRect; |
|
1295 |
|
1296 CCoeControl* focused = FindFocused(); |
|
1297 if ( IsAddressInputField( focused ) ) |
|
1298 { |
|
1299 CNcsAddressInputField* aifEditor = |
|
1300 static_cast<CNcsAddressInputField*>( focused ); |
|
1301 |
|
1302 TRect editorRect = aifEditor->Editor()->Rect(); |
|
1303 |
|
1304 popupRect.iTl = TPoint( editorRect.iTl.iX - 1, editorRect.iTl.iY + aifEditor->CursorPosition() + 1 ); |
|
1305 |
|
1306 popupRect.iBr = TPoint( editorRect.iBr.iX + 1, iParent.Rect().iBr.iY ); |
|
1307 } |
|
1308 //</cmail> |
|
1309 |
|
1310 return popupRect; |
|
1311 } |
|
1312 |
|
1313 // ----------------------------------------------------------------------------- |
|
1314 // CNcsHeaderContainer::DoPopupSelect |
|
1315 // ----------------------------------------------------------------------------- |
|
1316 void CNcsHeaderContainer::DoPopupSelectL() |
|
1317 { |
|
1318 FUNC_LOG; |
|
1319 __ASSERT_DEBUG( iAacListBox, Panic( ENcsBasicUi ) ); |
|
1320 __ASSERT_DEBUG( &iMailBox, Panic( ENcsBasicUi ) ); |
|
1321 |
|
1322 if( iAacListBox->IsRemoteLookupItemSelected() ) |
|
1323 { |
|
1324 // <cmail> |
|
1325 CCoeControl* focused = FindFocused(); |
|
1326 |
|
1327 if ( IsAddressInputField( focused ) ) |
|
1328 { |
|
1329 // Launch remote lookup |
|
1330 iRALInProgress = ETrue; |
|
1331 CNcsAddressInputField* addressField = NULL; |
|
1332 addressField = static_cast<CNcsAddressInputField*>( focused ); |
|
1333 HBufC* lookupText = addressField->GetLookupTextLC(); |
|
1334 CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason ex; |
|
1335 CNcsEmailAddressObject* address = ExecuteRemoteSearchL( |
|
1336 ex, *lookupText ); |
|
1337 iRALInProgress = EFalse; |
|
1338 if ( address ) |
|
1339 { |
|
1340 CleanupStack::PushL( address ); |
|
1341 IncludeAddressL( *address ); |
|
1342 CleanupStack::PopAndDestroy( address ); |
|
1343 } |
|
1344 CleanupStack::PopAndDestroy( lookupText ); |
|
1345 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
1346 parent.FocusChanged(EDrawNow); |
|
1347 } |
|
1348 // </cmail> |
|
1349 } |
|
1350 else if( !iAacListBox->IsPopupEmpty() ) |
|
1351 { |
|
1352 CNcsEmailAddressObject* emailAddress = iAacListBox->ReturnCurrentEmailAddressLC(); |
|
1353 if( emailAddress ) |
|
1354 { |
|
1355 if ( emailAddress->EmailAddress().Compare( KNullDesC ) != 0 ) |
|
1356 { |
|
1357 IncludeAddressL( *emailAddress ); |
|
1358 } |
|
1359 else |
|
1360 { |
|
1361 // selected contact doesn't have email address, launch remote contact lookup |
|
1362 // rcl must be usable, since otherwise there couldn't be any items |
|
1363 // without email addresses |
|
1364 CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason exitReason; |
|
1365 CNcsEmailAddressObject* remAddress = ExecuteRemoteSearchL( |
|
1366 exitReason, |
|
1367 emailAddress->DisplayName() ); |
|
1368 if ( remAddress ) |
|
1369 { |
|
1370 CleanupStack::PushL( remAddress ); |
|
1371 IncludeAddressL( *remAddress ); |
|
1372 CleanupStack::PopAndDestroy( remAddress ); |
|
1373 } |
|
1374 } |
|
1375 CleanupStack::PopAndDestroy( emailAddress ); |
|
1376 } |
|
1377 } |
|
1378 ClosePopupContactListL(); |
|
1379 } |
|
1380 |
|
1381 // ----------------------------------------------------------------------------- |
|
1382 // CNcsHeaderContainer::IsPopupActive |
|
1383 // ----------------------------------------------------------------------------- |
|
1384 TBool CNcsHeaderContainer::IsPopupActive() const |
|
1385 { |
|
1386 FUNC_LOG; |
|
1387 if ( iAacListBox && iAacListBox->IsVisible() ) |
|
1388 { |
|
1389 return ETrue; |
|
1390 } |
|
1391 else |
|
1392 { |
|
1393 return EFalse; |
|
1394 } |
|
1395 } |
|
1396 |
|
1397 // --------------------------------------------------------------------------- |
|
1398 // CNcsHeaderContainer::IsToFieldEmpty |
|
1399 // --------------------------------------------------------------------------- |
|
1400 // |
|
1401 TBool CNcsHeaderContainer::IsToFieldEmpty() const |
|
1402 { |
|
1403 FUNC_LOG; |
|
1404 return ( GetToFieldLength() < 1 ); |
|
1405 } |
|
1406 |
|
1407 // --------------------------------------------------------------------------- |
|
1408 // CNcsHeaderContainer::IsCcFieldEmpty |
|
1409 // --------------------------------------------------------------------------- |
|
1410 // |
|
1411 TBool CNcsHeaderContainer::IsCcFieldEmpty() const |
|
1412 { |
|
1413 FUNC_LOG; |
|
1414 return ( !IsCcFieldVisible() || GetCcFieldLength() < 1 ); |
|
1415 } |
|
1416 |
|
1417 // --------------------------------------------------------------------------- |
|
1418 // CNcsHeaderContainer::IsBccFieldEmpty |
|
1419 // --------------------------------------------------------------------------- |
|
1420 // |
|
1421 TBool CNcsHeaderContainer::IsBccFieldEmpty() const |
|
1422 { |
|
1423 FUNC_LOG; |
|
1424 return ( !IsBccFieldVisible() || GetBccFieldLength() < 1 ); |
|
1425 } |
|
1426 |
|
1427 // --------------------------------------------------------------------------- |
|
1428 // CNcsHeaderContainer::IsSubjectFieldEmpty |
|
1429 // --------------------------------------------------------------------------- |
|
1430 // |
|
1431 TBool CNcsHeaderContainer::IsSubjectFieldEmpty() const |
|
1432 { |
|
1433 FUNC_LOG; |
|
1434 return ( GetSubjectFieldLength() < 1 ); |
|
1435 } |
|
1436 |
|
1437 // --------------------------------------------------------------------------- |
|
1438 // CNcsHeaderContainer::GetToFieldAddressesL |
|
1439 // --------------------------------------------------------------------------- |
|
1440 // |
|
1441 const RPointerArray<CNcsEmailAddressObject>& CNcsHeaderContainer::GetToFieldAddressesL( TBool aParseNow ) |
|
1442 { |
|
1443 return iToField->GetAddressesL( aParseNow ); |
|
1444 } |
|
1445 |
|
1446 // --------------------------------------------------------------------------- |
|
1447 // CNcsHeaderContainer::GetCcFieldAddressesL |
|
1448 // --------------------------------------------------------------------------- |
|
1449 // |
|
1450 const RPointerArray<CNcsEmailAddressObject>& CNcsHeaderContainer::GetCcFieldAddressesL( TBool aParseNow ) |
|
1451 { |
|
1452 return iCcField->GetAddressesL( aParseNow ); |
|
1453 } |
|
1454 |
|
1455 // --------------------------------------------------------------------------- |
|
1456 // CNcsHeaderContainer::GetBccFieldAddressesL |
|
1457 // --------------------------------------------------------------------------- |
|
1458 // |
|
1459 const RPointerArray<CNcsEmailAddressObject>& CNcsHeaderContainer::GetBccFieldAddressesL( TBool aParseNow ) |
|
1460 { |
|
1461 return iBccField->GetAddressesL( aParseNow ); |
|
1462 } |
|
1463 |
|
1464 // --------------------------------------------------------------------------- |
|
1465 // CNcsHeaderContainer::GetSubjectLC |
|
1466 // --------------------------------------------------------------------------- |
|
1467 // |
|
1468 HBufC* CNcsHeaderContainer::GetSubjectLC() const |
|
1469 { |
|
1470 FUNC_LOG; |
|
1471 HBufC* subject = HBufC::NewLC(iSubjectField->Editor()->TextLength() + 2); |
|
1472 TPtr des = subject->Des(); |
|
1473 iSubjectField->Editor()->GetText(des); |
|
1474 return subject; |
|
1475 } |
|
1476 |
|
1477 // --------------------------------------------------------------------------- |
|
1478 // CNcsHeaderContainer::IsBccFieldVisible |
|
1479 // --------------------------------------------------------------------------- |
|
1480 // |
|
1481 TBool CNcsHeaderContainer::IsBccFieldVisible() const |
|
1482 { |
|
1483 FUNC_LOG; |
|
1484 return iBccField->IsVisible(); |
|
1485 } |
|
1486 |
|
1487 // --------------------------------------------------------------------------- |
|
1488 // CNcsHeaderContainer::IsCcFieldVisible |
|
1489 // --------------------------------------------------------------------------- |
|
1490 // |
|
1491 TBool CNcsHeaderContainer::IsCcFieldVisible() const |
|
1492 { |
|
1493 FUNC_LOG; |
|
1494 return iCcField->IsVisible(); |
|
1495 } |
|
1496 |
|
1497 // <cmail> Unneeded IsFocusAif removed |
|
1498 // </cmail> |
|
1499 |
|
1500 // --------------------------------------------------------------------------- |
|
1501 // CNcsHeaderContainer::IsFocusAttachments |
|
1502 // --------------------------------------------------------------------------- |
|
1503 // |
|
1504 TBool CNcsHeaderContainer::IsFocusAttachments() const |
|
1505 { |
|
1506 FUNC_LOG; |
|
1507 return ( FindFocused() == iAttachmentField ); |
|
1508 } |
|
1509 |
|
1510 // --------------------------------------------------------------------------- |
|
1511 // CNcsHeaderContainer::IsFocusTo |
|
1512 // --------------------------------------------------------------------------- |
|
1513 // |
|
1514 TBool CNcsHeaderContainer::IsFocusTo() const |
|
1515 { |
|
1516 FUNC_LOG; |
|
1517 return ( FindFocused() == iToField ); |
|
1518 } |
|
1519 |
|
1520 // --------------------------------------------------------------------------- |
|
1521 // CNcsHeaderContainer::IsFocusCc |
|
1522 // --------------------------------------------------------------------------- |
|
1523 // |
|
1524 TBool CNcsHeaderContainer::IsFocusCc() const |
|
1525 { |
|
1526 FUNC_LOG; |
|
1527 return ( FindFocused() == iCcField ); |
|
1528 } |
|
1529 |
|
1530 // --------------------------------------------------------------------------- |
|
1531 // CNcsHeaderContainer::IsFocusBcc |
|
1532 // --------------------------------------------------------------------------- |
|
1533 // |
|
1534 TBool CNcsHeaderContainer::IsFocusBcc() const |
|
1535 { |
|
1536 FUNC_LOG; |
|
1537 return ( FindFocused() == iBccField ); |
|
1538 } |
|
1539 |
|
1540 // --------------------------------------------------------------------------- |
|
1541 // CNcsHeaderContainer::GetCcFieldLength |
|
1542 // --------------------------------------------------------------------------- |
|
1543 // |
|
1544 TInt CNcsHeaderContainer::GetCcFieldLength() const |
|
1545 { |
|
1546 FUNC_LOG; |
|
1547 return iCcField->Editor()->TrimmedTextLength(); |
|
1548 } |
|
1549 |
|
1550 // --------------------------------------------------------------------------- |
|
1551 // CNcsHeaderContainer::GetBccFieldLength |
|
1552 // --------------------------------------------------------------------------- |
|
1553 // |
|
1554 TInt CNcsHeaderContainer::GetBccFieldLength() const |
|
1555 { |
|
1556 FUNC_LOG; |
|
1557 return iBccField->Editor()->TrimmedTextLength(); |
|
1558 } |
|
1559 |
|
1560 // --------------------------------------------------------------------------- |
|
1561 // CNcsHeaderContainer::GetToFieldLength |
|
1562 // --------------------------------------------------------------------------- |
|
1563 // |
|
1564 TInt CNcsHeaderContainer::GetToFieldLength() const |
|
1565 { |
|
1566 FUNC_LOG; |
|
1567 return iToField->Editor()->TrimmedTextLength(); |
|
1568 } |
|
1569 |
|
1570 // --------------------------------------------------------------------------- |
|
1571 // CNcsHeaderContainer::GetSubjectFieldLength |
|
1572 // --------------------------------------------------------------------------- |
|
1573 // |
|
1574 TInt CNcsHeaderContainer::GetSubjectFieldLength() const |
|
1575 { |
|
1576 FUNC_LOG; |
|
1577 return iSubjectField->Editor()->TrimmedTextLength(); |
|
1578 } |
|
1579 |
|
1580 // --------------------------------------------------------------------------- |
|
1581 // CNcsHeaderContainer::GetAttachmentCount |
|
1582 // --------------------------------------------------------------------------- |
|
1583 // |
|
1584 TInt CNcsHeaderContainer::GetAttachmentCount() const |
|
1585 { |
|
1586 FUNC_LOG; |
|
1587 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
1588 return parent.GetAttachmentCount(); |
|
1589 } |
|
1590 |
|
1591 // --------------------------------------------------------------------------- |
|
1592 // CNcsHeaderContainer::HasRemoteAttachments |
|
1593 // --------------------------------------------------------------------------- |
|
1594 // |
|
1595 TInt CNcsHeaderContainer::HasRemoteAttachments() const |
|
1596 { |
|
1597 FUNC_LOG; |
|
1598 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
1599 return parent.HasRemoteAttachments(); |
|
1600 } |
|
1601 |
|
1602 // --------------------------------------------------------------------------- |
|
1603 // CNcsHeaderContainer::GetToFieldSelectionLength |
|
1604 // --------------------------------------------------------------------------- |
|
1605 // |
|
1606 TInt CNcsHeaderContainer::GetToFieldSelectionLength() const |
|
1607 { |
|
1608 FUNC_LOG; |
|
1609 return iToField->TextEditor()->SelectionLength(); |
|
1610 } |
|
1611 |
|
1612 // --------------------------------------------------------------------------- |
|
1613 // CNcsHeaderContainer::GetCcFieldSelectionLength |
|
1614 // --------------------------------------------------------------------------- |
|
1615 // |
|
1616 TInt CNcsHeaderContainer::GetCcFieldSelectionLength() const |
|
1617 { |
|
1618 FUNC_LOG; |
|
1619 return iCcField->TextEditor()->SelectionLength(); |
|
1620 } |
|
1621 |
|
1622 // --------------------------------------------------------------------------- |
|
1623 // CNcsHeaderContainer::GetBccFieldSelectionLength |
|
1624 // --------------------------------------------------------------------------- |
|
1625 // |
|
1626 TInt CNcsHeaderContainer::GetBccFieldSelectionLength() const |
|
1627 { |
|
1628 FUNC_LOG; |
|
1629 return iBccField->TextEditor()->SelectionLength(); |
|
1630 } |
|
1631 |
|
1632 // --------------------------------------------------------------------------- |
|
1633 // CNcsHeaderContainer::GetLookupTextLC |
|
1634 // --------------------------------------------------------------------------- |
|
1635 // |
|
1636 HBufC* CNcsHeaderContainer::GetLookupTextLC() const |
|
1637 { |
|
1638 FUNC_LOG; |
|
1639 CCoeControl* focused = FindFocused(); |
|
1640 if ( !focused ) return NULL; |
|
1641 |
|
1642 CNcsAddressInputField* aif = dynamic_cast<CNcsAddressInputField*>(focused); |
|
1643 if ( !aif ) return NULL; |
|
1644 return aif->GetLookupTextLC(); |
|
1645 } |
|
1646 |
|
1647 // --------------------------------------------------------------------------- |
|
1648 // CNcsHeaderContainer::SetToFieldAddressesL |
|
1649 // --------------------------------------------------------------------------- |
|
1650 // |
|
1651 void CNcsHeaderContainer::SetToFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress ) |
|
1652 { |
|
1653 FUNC_LOG; |
|
1654 iToField->SetAddressesL( aAddress ); |
|
1655 } |
|
1656 |
|
1657 // --------------------------------------------------------------------------- |
|
1658 // CNcsHeaderContainer::SetCcFieldAddressesL |
|
1659 // --------------------------------------------------------------------------- |
|
1660 // |
|
1661 void CNcsHeaderContainer::SetCcFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress ) |
|
1662 { |
|
1663 FUNC_LOG; |
|
1664 iCcField->SetAddressesL( aAddress ); |
|
1665 if (!iCcField->IsEmpty()) |
|
1666 SetCcFieldVisibleL(ETrue, ENoDrawNow); |
|
1667 } |
|
1668 |
|
1669 // --------------------------------------------------------------------------- |
|
1670 // CNcsHeaderContainer::SetBccFieldAddressesL |
|
1671 // --------------------------------------------------------------------------- |
|
1672 // |
|
1673 void CNcsHeaderContainer::SetBccFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress ) |
|
1674 { |
|
1675 FUNC_LOG; |
|
1676 iBccField->SetAddressesL( aAddress ); |
|
1677 if (!iBccField->IsEmpty()) |
|
1678 SetBccFieldVisibleL(ETrue, ENoDrawNow); |
|
1679 } |
|
1680 |
|
1681 // --------------------------------------------------------------------------- |
|
1682 // CNcsHeaderContainer::AppendToFieldAddressesL |
|
1683 // --------------------------------------------------------------------------- |
|
1684 // |
|
1685 void CNcsHeaderContainer::AppendToFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
|
1686 { |
|
1687 FUNC_LOG; |
|
1688 iToField->AppendAddressesL( aAddresses ); |
|
1689 } |
|
1690 |
|
1691 // --------------------------------------------------------------------------- |
|
1692 // CNcsHeaderContainer::AppendCcFieldAddressesL |
|
1693 // --------------------------------------------------------------------------- |
|
1694 // |
|
1695 void CNcsHeaderContainer::AppendCcFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
|
1696 { |
|
1697 FUNC_LOG; |
|
1698 iCcField->AppendAddressesL( aAddresses ); |
|
1699 } |
|
1700 |
|
1701 // --------------------------------------------------------------------------- |
|
1702 // CNcsHeaderContainer::AppendBccFieldAddressesL |
|
1703 // --------------------------------------------------------------------------- |
|
1704 // |
|
1705 void CNcsHeaderContainer::AppendBccFieldAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
|
1706 { |
|
1707 FUNC_LOG; |
|
1708 iBccField->AppendAddressesL( aAddresses ); |
|
1709 } |
|
1710 |
|
1711 // --------------------------------------------------------------------------- |
|
1712 // CNcsHeaderContainer::SetSubjectL |
|
1713 // --------------------------------------------------------------------------- |
|
1714 // |
|
1715 void CNcsHeaderContainer::SetSubjectL( const TDesC& aSubject ) |
|
1716 { |
|
1717 FUNC_LOG; |
|
1718 iSubjectField->SetSubjectL( aSubject ); |
|
1719 } |
|
1720 |
|
1721 // --------------------------------------------------------------------------- |
|
1722 // CNcsHeaderContainer::SetMenuBar |
|
1723 // --------------------------------------------------------------------------- |
|
1724 // |
|
1725 void CNcsHeaderContainer::SetMenuBar( CEikButtonGroupContainer* aMenuBar ) |
|
1726 { |
|
1727 FUNC_LOG; |
|
1728 iMenuBar = aMenuBar; |
|
1729 } |
|
1730 |
|
1731 // --------------------------------------------------------------------------- |
|
1732 // CNcsHeaderContainer::IncludeAddressL |
|
1733 // --------------------------------------------------------------------------- |
|
1734 // |
|
1735 void CNcsHeaderContainer::IncludeAddressL(const CNcsEmailAddressObject& aEml ) |
|
1736 { |
|
1737 FUNC_LOG; |
|
1738 // <cmail> |
|
1739 CCoeControl* focused = FindFocused(); |
|
1740 if ( IsAddressInputField( focused ) ) |
|
1741 { |
|
1742 CNcsAddressInputField* aifFocused = NULL; |
|
1743 aifFocused = static_cast<CNcsAddressInputField*>( focused ); |
|
1744 aifFocused->AddAddressL( aEml ); |
|
1745 } |
|
1746 // </cmail> |
|
1747 } |
|
1748 |
|
1749 // --------------------------------------------------------------------------- |
|
1750 // CNcsHeaderContainer::IncludeAddressL |
|
1751 // --------------------------------------------------------------------------- |
|
1752 // |
|
1753 void CNcsHeaderContainer::IncludeAddressL() |
|
1754 { |
|
1755 FUNC_LOG; |
|
1756 // is this methods needed at all? |
|
1757 // get the curren selection from popup list if there is any? |
|
1758 } |
|
1759 |
|
1760 // --------------------------------------------------------------------------- |
|
1761 // CNcsHeaderContainer::FocusToField |
|
1762 // --------------------------------------------------------------------------- |
|
1763 // |
|
1764 void CNcsHeaderContainer::FocusToField() |
|
1765 { |
|
1766 FUNC_LOG; |
|
1767 CCoeControl* oldCtrl = FindFocused(); |
|
1768 if ( !oldCtrl ) |
|
1769 { |
|
1770 return; |
|
1771 } |
|
1772 oldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
1773 iToField->SetFocus( ETrue, ENoDrawNow ); |
|
1774 } |
|
1775 |
|
1776 // --------------------------------------------------------------------------- |
|
1777 // CNcsHeaderContainer::FocusAttachmentField |
|
1778 // --------------------------------------------------------------------------- |
|
1779 // |
|
1780 void CNcsHeaderContainer::FocusAttachmentField() |
|
1781 { |
|
1782 FUNC_LOG; |
|
1783 CCoeControl* oldCtrl = FindFocused(); |
|
1784 if ( !oldCtrl ) |
|
1785 { |
|
1786 return; |
|
1787 } |
|
1788 oldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
1789 iAttachmentField->SetFocus( ETrue, ENoDrawNow ); |
|
1790 } |
|
1791 |
|
1792 // --------------------------------------------------------------------------- |
|
1793 // CNcsHeaderContainer::AreAddressFieldsEmpty |
|
1794 // --------------------------------------------------------------------------- |
|
1795 // |
|
1796 TBool CNcsHeaderContainer::AreAddressFieldsEmpty() const |
|
1797 { |
|
1798 FUNC_LOG; |
|
1799 return (IsToFieldEmpty() && IsCcFieldEmpty() && IsBccFieldEmpty()) || iRALInProgress; |
|
1800 } |
|
1801 |
|
1802 // --------------------------------------------------------------------------- |
|
1803 // CNcsHeaderContainer::HandleDynamicVariantSwitchL |
|
1804 // --------------------------------------------------------------------------- |
|
1805 // |
|
1806 void CNcsHeaderContainer::HandleDynamicVariantSwitchL() |
|
1807 { |
|
1808 FUNC_LOG; |
|
1809 } |
|
1810 |
|
1811 // <cmail> Platform layout change |
|
1812 // --------------------------------------------------------------------------- |
|
1813 // CNcsHeaderContainer::LayoutLineCount |
|
1814 // --------------------------------------------------------------------------- |
|
1815 // |
|
1816 TInt CNcsHeaderContainer::LayoutLineCount() const |
|
1817 { |
|
1818 FUNC_LOG; |
|
1819 TInt totalLineCount( 0 ); |
|
1820 CCoeControlArray::TCursor cur = Components().Begin(); |
|
1821 do |
|
1822 { |
|
1823 totalLineCount += ToNcsControl( cur )->LayoutLineCount(); |
|
1824 } while ( cur.Next() ); |
|
1825 return totalLineCount; |
|
1826 } |
|
1827 // </cmail> Platform layout change |
|
1828 |
|
1829 // <cmail> |
|
1830 // --------------------------------------------------------------------------- |
|
1831 // CNcsHeaderContainer::IsAddressInputField |
|
1832 // --------------------------------------------------------------------------- |
|
1833 // |
|
1834 TBool CNcsHeaderContainer::IsAddressInputField( |
|
1835 const CCoeControl* aControl ) const |
|
1836 { |
|
1837 FUNC_LOG; |
|
1838 |
|
1839 TBool ret = EFalse; |
|
1840 |
|
1841 if ( aControl != NULL && |
|
1842 ( aControl == iToField || |
|
1843 aControl == iCcField || |
|
1844 aControl == iBccField ) ) |
|
1845 { |
|
1846 ret = ETrue; |
|
1847 } |
|
1848 |
|
1849 return ret; |
|
1850 } |
|
1851 // </cmail> |
|
1852 |
|
1853 // --------------------------------------------------------------------------- |
|
1854 // CNcsHeaderContainer::ExecuteRemoteSearchL |
|
1855 // --------------------------------------------------------------------------- |
|
1856 // |
|
1857 CNcsEmailAddressObject* CNcsHeaderContainer::ExecuteRemoteSearchL( |
|
1858 CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason& /*aExitReason*/, |
|
1859 const TDesC& aSearchText ) |
|
1860 { |
|
1861 FUNC_LOG; |
|
1862 const TInt KMaxLength = 255; |
|
1863 RBuf displayname; |
|
1864 displayname.CreateL( KMaxLength ); |
|
1865 CleanupClosePushL( displayname ); |
|
1866 |
|
1867 RBuf emailAddress; |
|
1868 emailAddress.CreateL( KMaxLength ); |
|
1869 CleanupClosePushL( emailAddress ); |
|
1870 |
|
1871 TBool contactSelected = CFsDelayedLoader::InstanceL()->GetContactHandlerL()->GetNameAndEmailFromRemoteLookupL( |
|
1872 iMailBox, aSearchText, displayname, emailAddress ); |
|
1873 |
|
1874 CNcsEmailAddressObject* address = NULL; |
|
1875 if ( contactSelected ) |
|
1876 { |
|
1877 if ( !displayname.Length() ) |
|
1878 { |
|
1879 address = CNcsEmailAddressObject::NewL( emailAddress, emailAddress ); |
|
1880 } |
|
1881 else |
|
1882 { |
|
1883 address = CNcsEmailAddressObject::NewL( displayname, emailAddress ); |
|
1884 } |
|
1885 } |
|
1886 |
|
1887 CleanupStack::PopAndDestroy( &emailAddress ); |
|
1888 CleanupStack::PopAndDestroy( &displayname ); |
|
1889 |
|
1890 return address; |
|
1891 } |
|
1892 |
|
1893 // ----------------------------------------------------------------------------- |
|
1894 // CNcsHeaderContainer::ChangeMskCommandL |
|
1895 // Utility function to change the command ID and label on the middle soft key |
|
1896 // ----------------------------------------------------------------------------- |
|
1897 void CNcsHeaderContainer::ChangeMskCommandL( TInt aLabelResourceId ) |
|
1898 { |
|
1899 FUNC_LOG; |
|
1900 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
1901 if ( cba ) |
|
1902 { |
|
1903 cba->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
|
1904 aLabelResourceId ); |
|
1905 cba->DrawDeferred(); |
|
1906 } |
|
1907 } |
|
1908 |
|
1909 //<cmail> |
|
1910 // ----------------------------------------------------------------------------- |
|
1911 // CNcsHeaderContainer::SwitchChangeMskOff |
|
1912 // sets up iSwitchChangeMskOff falg |
|
1913 // ----------------------------------------------------------------------------- |
|
1914 void CNcsHeaderContainer::SwitchChangeMskOff(TBool aTag) |
|
1915 { |
|
1916 iSwitchChangeMskOff = aTag; |
|
1917 } |
|
1918 // </cmail> |
|
1919 |
|
1920 // ----------------------------------------------------------------------------- |
|
1921 // CNcsHeaderContainer::OpenPhonebookL |
|
1922 // |
|
1923 // ----------------------------------------------------------------------------- |
|
1924 void CNcsHeaderContainer::OpenPhonebookL() |
|
1925 { |
|
1926 CNcsComposeViewContainer* container = static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
1927 container->AppendAddressesL(); |
|
1928 } |
|
1929 |
|
1930 void CNcsHeaderContainer::FixSemicolonInAddressFieldsL() |
|
1931 { |
|
1932 iToField->FixSemicolonAtTheEndL(); |
|
1933 iCcField->FixSemicolonAtTheEndL(); |
|
1934 iBccField->FixSemicolonAtTheEndL(); |
|
1935 } |
|
1936 |
|
1937 TBool CNcsHeaderContainer::IsRemoteSearchInprogress() const |
|
1938 { |
|
1939 return iRALInProgress; |
|
1940 } |
|
1941 |
|
1942 // --------------------------------------------------------------------------- |
|
1943 // Commits changes made to given input field. |
|
1944 // --------------------------------------------------------------------------- |
|
1945 // |
|
1946 void CNcsHeaderContainer::CommitFieldL( CCoeControl* aField ) |
|
1947 { |
|
1948 FUNC_LOG; |
|
1949 CNcsComposeViewContainer* container = |
|
1950 static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
1951 if ( container && aField ) |
|
1952 { |
|
1953 if ( aField == iToField ) |
|
1954 { |
|
1955 container->CommitL( EToField ); |
|
1956 } |
|
1957 else if ( aField == iCcField ) |
|
1958 { |
|
1959 container->CommitL( ECcField ); |
|
1960 } |
|
1961 else if ( aField == iBccField ) |
|
1962 { |
|
1963 container->CommitL( EBccField ); |
|
1964 } |
|
1965 else if ( aField == iSubjectField ) |
|
1966 { |
|
1967 container->CommitL( ESubjectField ); |
|
1968 } |
|
1969 } |
|
1970 } |
|
1971 |