|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ESMR time (start-end) field implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "emailtrace.h" |
|
19 #include "cesmrtimefield.h" |
|
20 |
|
21 #include <eikmfne.h> |
|
22 #include <avkon.hrh> |
|
23 #include <eiklabel.h> |
|
24 #include <AknUtils.h> |
|
25 #include <AknsFrameBackgroundControlContext.h> |
|
26 #include <AknsDrawUtils.h> |
|
27 |
|
28 #include "mesmrfieldvalidator.h" |
|
29 #include "cesmrglobalnote.h" |
|
30 //<cmail> |
|
31 #include "esmrdef.h" |
|
32 //</cmail> |
|
33 #include "esmrfieldbuilderdef.h" |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CESMRTimeField::CESMRTimeField |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CESMRTimeField::CESMRTimeField( ) |
|
42 { |
|
43 FUNC_LOG; |
|
44 // do nothing |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CESMRTimeField::~CESMRTimeField |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CESMRTimeField::~CESMRTimeField( ) |
|
52 { |
|
53 FUNC_LOG; |
|
54 // iContainer is deleted by framework |
|
55 // do nothing |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CESMRTimeField::NewL |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CESMRTimeField* CESMRTimeField::NewL( |
|
63 MESMRFieldValidator* aValidator ) |
|
64 { |
|
65 FUNC_LOG; |
|
66 CESMRTimeField* self = new (ELeave) CESMRTimeField; |
|
67 CleanupStack::PushL ( self ); |
|
68 self->ConstructL ( aValidator ); |
|
69 CleanupStack::Pop ( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CESMRTimeField::ConstructL |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void CESMRTimeField::ConstructL( |
|
78 MESMRFieldValidator* aValidator ) |
|
79 { |
|
80 FUNC_LOG; |
|
81 SetFieldId ( EESMRFieldMeetingTime ); |
|
82 iContainer = |
|
83 CTimeContainer::NewL( |
|
84 aValidator, |
|
85 this, |
|
86 EESMRFieldMeetingTime ); |
|
87 |
|
88 CESMRIconField::ConstructL( |
|
89 KAknsIIDQgnMeetReqIndiClock, |
|
90 iContainer ); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CESMRTimeField::SetContainerWindowL |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CESMRTimeField::SetContainerWindowL( |
|
98 const CCoeControl& aControl ) |
|
99 { |
|
100 FUNC_LOG; |
|
101 CCoeControl::SetContainerWindowL ( aControl ); |
|
102 if ( iContainer ) |
|
103 { |
|
104 iContainer->SetContainerWindowL ( aControl ); |
|
105 } |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CESMRTimeField::OfferKeyEventL |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 TKeyResponse CESMRTimeField::OfferKeyEventL( |
|
113 const TKeyEvent& aEvent, |
|
114 TEventCode aType ) |
|
115 { |
|
116 FUNC_LOG; |
|
117 TKeyResponse response( EKeyWasNotConsumed); |
|
118 if ( iContainer ) |
|
119 { |
|
120 response = iContainer->OfferKeyEventL ( aEvent, aType ); |
|
121 } |
|
122 return response; |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CESMRTimeField::InitializeL |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CESMRTimeField::InitializeL() |
|
130 { |
|
131 FUNC_LOG; |
|
132 if ( iContainer ) |
|
133 { |
|
134 iContainer->SetFontL( iLayout->Font ( iCoeEnv, iFieldId ), iLayout ); |
|
135 } |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CESMRTimeField::OkToLoseFocusL |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 TBool CESMRTimeField::OkToLoseFocusL( |
|
143 TESMREntryFieldId aNext ) |
|
144 { |
|
145 FUNC_LOG; |
|
146 if ( iContainer ) |
|
147 { |
|
148 return iContainer->OkToLoseFocusL ( FieldId ( ), aNext ); |
|
149 } |
|
150 return EFalse; |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CESMRTimeField::SetOutlineFocusL |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CESMRTimeField::SetOutlineFocusL( TBool aFocus ) |
|
158 { |
|
159 FUNC_LOG; |
|
160 CESMRField::SetOutlineFocusL ( aFocus ); |
|
161 if ( aFocus ) |
|
162 { |
|
163 ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE); |
|
164 } |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CTimeContainer::CTimeContainer |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 CTimeContainer::CTimeContainer( |
|
172 MESMRFieldValidator* aValidator, |
|
173 TESMREntryFieldId aFieldId ) : |
|
174 iValidator(aValidator), |
|
175 iFieldId( aFieldId ) |
|
176 { |
|
177 FUNC_LOG; |
|
178 // do nothing |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CTimeContainer::~CTimeContainer |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 CTimeContainer::~CTimeContainer( ) |
|
186 { |
|
187 FUNC_LOG; |
|
188 delete iStartTime; |
|
189 delete iEndTime; |
|
190 delete iSeparator; |
|
191 delete iStartTimeBgContext; |
|
192 delete iEndTimeBgContext; |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // CTimeContainer::NewL |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 CTimeContainer* CTimeContainer::NewL( |
|
200 MESMRFieldValidator* aValidator, |
|
201 CCoeControl* aParent, |
|
202 TESMREntryFieldId aFieldId ) |
|
203 { |
|
204 FUNC_LOG; |
|
205 CTimeContainer* self = |
|
206 new (ELeave) CTimeContainer( aValidator, aFieldId ); |
|
207 CleanupStack::PushL ( self ); |
|
208 self->ConstructL ( aParent ); |
|
209 CleanupStack::Pop ( self ); |
|
210 return self; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // CTimeContainer::ConstructL |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 void CTimeContainer::ConstructL( |
|
218 CCoeControl* /*aParent*/) |
|
219 { |
|
220 FUNC_LOG; |
|
221 TTime startTime; |
|
222 startTime.UniversalTime ( ); |
|
223 |
|
224 iStartTime = new (ELeave) CEikTimeEditor; |
|
225 iEndTime = new (ELeave) CEikTimeEditor; |
|
226 iSeparator = new (ELeave) CEikLabel; |
|
227 |
|
228 iStartTime->ConstructL ( TTIME_TIMEFIELDMINIMUMDATE, |
|
229 TTIME_TIMEFIELDMAXIMUMDATE, |
|
230 startTime, |
|
231 EEikTimeWithoutSecondsField ); |
|
232 |
|
233 iEndTime->ConstructL ( TTIME_TIMEFIELDMINIMUMDATE, |
|
234 TTIME_TIMEFIELDMAXIMUMDATE, |
|
235 startTime, |
|
236 EEikTimeWithoutSecondsField ); |
|
237 |
|
238 iBackground = AknsDrawUtils::ControlContext( this ); |
|
239 |
|
240 TInt align = CESMRLayoutManager::IsMirrored ( ) ? EAknEditorAlignRight |
|
241 : EAknEditorAlignLeft; |
|
242 iStartTime->SetMfneAlignment ( align ); |
|
243 iEndTime->SetMfneAlignment ( align ); |
|
244 |
|
245 iSeparator->SetTextL ( KTimeFieldSeparator ); |
|
246 |
|
247 if ( iValidator ) |
|
248 { |
|
249 iValidator->SetStartTimeFieldL( *iStartTime ); |
|
250 iValidator->SetEndTimeFieldL( *iEndTime ); |
|
251 } |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // CTimeContainer::SetContainerWindowL |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 void CTimeContainer::SetContainerWindowL( |
|
259 const CCoeControl& aControl ) |
|
260 { |
|
261 FUNC_LOG; |
|
262 CCoeControl::SetContainerWindowL ( aControl ); |
|
263 iStartTime->SetContainerWindowL ( aControl ); |
|
264 iEndTime->SetContainerWindowL ( aControl ); |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // CTimeContainer::CountComponentControls |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 TInt CTimeContainer::CountComponentControls() const |
|
272 { |
|
273 FUNC_LOG; |
|
274 TInt count( 0); |
|
275 |
|
276 if ( iStartTime ) |
|
277 { |
|
278 ++count; |
|
279 } |
|
280 |
|
281 if ( iSeparator ) |
|
282 { |
|
283 ++count; |
|
284 } |
|
285 |
|
286 if ( iEndTime ) |
|
287 { |
|
288 ++count; |
|
289 } |
|
290 |
|
291 return count; |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // CTimeContainer::ComponentControl |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 CCoeControl* CTimeContainer::ComponentControl( |
|
299 TInt aInd ) const |
|
300 { |
|
301 FUNC_LOG; |
|
302 switch ( aInd ) |
|
303 { |
|
304 case 0: |
|
305 return iStartTime; |
|
306 case 1: |
|
307 return iSeparator; |
|
308 case 2: |
|
309 return iEndTime; |
|
310 default: |
|
311 return NULL; |
|
312 } |
|
313 } |
|
314 |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // CTimeContainer::PositionChanged() |
|
318 // --------------------------------------------------------------------------- |
|
319 // |
|
320 void CTimeContainer::PositionChanged() |
|
321 { |
|
322 FUNC_LOG; |
|
323 CCoeControl::PositionChanged(); |
|
324 if( iStartTimeBgContext ) |
|
325 { |
|
326 iStartTimeBgContext->SetFrameRects( |
|
327 iStartTime->Rect(), |
|
328 iStartTime->Rect() ); |
|
329 } |
|
330 |
|
331 if( iEndTimeBgContext ) |
|
332 { |
|
333 iEndTimeBgContext->SetFrameRects( |
|
334 iEndTime->Rect(), |
|
335 iEndTime->Rect() ); |
|
336 } |
|
337 } |
|
338 |
|
339 // --------------------------------------------------------------------------- |
|
340 // CTimeContainer::SizeChanged |
|
341 // --------------------------------------------------------------------------- |
|
342 // |
|
343 void CTimeContainer::SizeChanged() |
|
344 { |
|
345 FUNC_LOG; |
|
346 TInt x = CESMRLayoutManager::IsMirrored ( ) ? Rect().iBr.iX : Rect().iTl.iX; |
|
347 TPoint p( x, Rect().iTl.iY); |
|
348 |
|
349 TSize editorSize; |
|
350 TSize separatorSize; |
|
351 |
|
352 editorSize = iStartTime->MinimumSize(); |
|
353 editorSize.iHeight = Rect().Height(); |
|
354 |
|
355 separatorSize = iSeparator->MinimumSize(); |
|
356 separatorSize.iHeight = Rect().Height(); |
|
357 |
|
358 iStartTime->SetBorder( TGulBorder::ENone ); |
|
359 iEndTime->SetBorder( TGulBorder::ENone ); |
|
360 |
|
361 if ( CESMRLayoutManager::IsMirrored ( ) ) |
|
362 { |
|
363 p.iX -= editorSize.iWidth; |
|
364 iStartTime->SetExtent ( p, editorSize ); |
|
365 |
|
366 p.iX -= separatorSize.iWidth; |
|
367 iSeparator->SetExtent ( p, separatorSize ); |
|
368 |
|
369 p.iX -= editorSize.iWidth; |
|
370 iEndTime->SetExtent ( p, editorSize ); |
|
371 } |
|
372 else |
|
373 { |
|
374 iStartTime->SetExtent ( p, editorSize ); |
|
375 p.iX += editorSize.iWidth; |
|
376 |
|
377 iSeparator->SetExtent ( p, separatorSize ); |
|
378 p.iX += separatorSize.iWidth; |
|
379 |
|
380 iEndTime->SetExtent ( p, editorSize ); |
|
381 } |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // CTimeContainer::OfferKeyEventL |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 TKeyResponse CTimeContainer::OfferKeyEventL( |
|
389 const TKeyEvent& aEvent, |
|
390 TEventCode aType ) |
|
391 { |
|
392 FUNC_LOG; |
|
393 TBool startFocusedBefore( iStartTime->IsFocused() ); |
|
394 TInt startIndex( iStartTime->CurrentField() ); |
|
395 |
|
396 TBool endFocusedBefore( iEndTime->IsFocused() ); |
|
397 TInt endIndex( iEndTime->CurrentField() ); |
|
398 |
|
399 TKeyResponse response = EKeyWasNotConsumed; |
|
400 if ( aType == EEventKey ) |
|
401 { |
|
402 switch ( aEvent.iScanCode ) |
|
403 { |
|
404 case EStdKeyLeftArrow: |
|
405 response = ChangeFocusLeftL( aEvent, aType ); |
|
406 break; |
|
407 |
|
408 case EStdKeyRightArrow: |
|
409 response = ChangeFocusRightL( aEvent, aType ); |
|
410 break; |
|
411 |
|
412 default: // other events than left/right arrows |
|
413 { |
|
414 response = FocusedEditor()->OfferKeyEventL( aEvent, aType ); |
|
415 } |
|
416 break; |
|
417 } |
|
418 } |
|
419 |
|
420 if ( EKeyWasConsumed == response ) |
|
421 { |
|
422 CheckIfValidatingNeededL( |
|
423 startFocusedBefore, |
|
424 startIndex, |
|
425 endFocusedBefore, |
|
426 endIndex ); |
|
427 } |
|
428 |
|
429 return response; |
|
430 } |
|
431 |
|
432 // --------------------------------------------------------------------------- |
|
433 // CTimeContainer::FocusChanged |
|
434 // --------------------------------------------------------------------------- |
|
435 // |
|
436 void CTimeContainer::FocusChanged( |
|
437 TDrawNow /*aDrawNow*/) |
|
438 { |
|
439 FUNC_LOG; |
|
440 if ( IsFocused ( ) ) // if focus is gained |
|
441 { |
|
442 iStartTime->SetFocus ( ETrue ); |
|
443 } |
|
444 else |
|
445 { |
|
446 if ( iStartTime->IsFocused() ) |
|
447 { |
|
448 iStartTime->SetFocus( EFalse, EDrawNow ); |
|
449 } |
|
450 |
|
451 if ( iEndTime->IsFocused() ) |
|
452 { |
|
453 iEndTime->SetFocus( EFalse, EDrawNow ); |
|
454 } |
|
455 } |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // CTimeContainer::SetFont |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 void CTimeContainer::SetFontL( |
|
463 const CFont* aFont, |
|
464 CESMRLayoutManager* aLayout ) |
|
465 { |
|
466 FUNC_LOG; |
|
467 iLayout = aLayout; |
|
468 |
|
469 iStartTime->SetFont ( aFont ); |
|
470 iSeparator->SetFont ( aFont ); |
|
471 iEndTime->SetFont ( aFont ); |
|
472 |
|
473 iStartTime->SetSkinTextColorL( aLayout->NormalTextColorID() ); |
|
474 iEndTime->SetSkinTextColorL( aLayout->NormalTextColorID() ); |
|
475 |
|
476 AknLayoutUtils::OverrideControlColorL ( *iSeparator, EColorLabelText, |
|
477 aLayout->NormalTextColor() ); |
|
478 } |
|
479 |
|
480 // --------------------------------------------------------------------------- |
|
481 // CTimeContainer::FocusedEditor |
|
482 // --------------------------------------------------------------------------- |
|
483 // |
|
484 CEikTimeEditor* CTimeContainer::FocusedEditor( ) |
|
485 { |
|
486 FUNC_LOG; |
|
487 return iStartTime->IsFocused ( ) ? iStartTime : iEndTime; |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 // CTimeContainer::OkToLoseFocusL |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 TBool CTimeContainer::OkToLoseFocusL( |
|
495 TESMREntryFieldId /*aFrom*/, |
|
496 TESMREntryFieldId /*aTo*/ ) |
|
497 { |
|
498 FUNC_LOG; |
|
499 // validate the current time |
|
500 FocusedEditor()->PrepareForFocusLossL(); |
|
501 |
|
502 if ( iStartTime->IsFocused() ) |
|
503 { |
|
504 TriggerStartTimeChangedL(); |
|
505 } |
|
506 else |
|
507 { |
|
508 TriggerEndTimeChangedL(); |
|
509 } |
|
510 |
|
511 return ETrue; |
|
512 } |
|
513 |
|
514 // --------------------------------------------------------------------------- |
|
515 // CTimeContainer::ActivateL |
|
516 // --------------------------------------------------------------------------- |
|
517 // |
|
518 void CTimeContainer::ActivateL() |
|
519 { |
|
520 FUNC_LOG; |
|
521 CCoeControl::ActivateL(); |
|
522 TRect rect(TPoint(iStartTime->Position()), iStartTime->Size()); |
|
523 TRect inner(rect); |
|
524 TRect outer(rect); |
|
525 |
|
526 delete iStartTimeBgContext; |
|
527 delete iEndTimeBgContext; |
|
528 iStartTimeBgContext = NULL; |
|
529 iEndTimeBgContext = NULL; |
|
530 |
|
531 iStartTimeBgContext = |
|
532 CAknsFrameBackgroundControlContext::NewL( |
|
533 KAknsIIDQsnFrInput, |
|
534 outer, |
|
535 inner, |
|
536 EFalse ) ; |
|
537 |
|
538 rect.SetRect( iEndTime->Position(), iEndTime->Size()); |
|
539 inner = rect; |
|
540 iEndTimeBgContext = |
|
541 CAknsFrameBackgroundControlContext::NewL( |
|
542 KAknsIIDQsnFrInput, |
|
543 outer, |
|
544 inner, |
|
545 EFalse ) ; |
|
546 |
|
547 iStartTimeBgContext->SetParentContext( iBackground ); |
|
548 iEndTimeBgContext->SetParentContext( iBackground ); |
|
549 iStartTime->SetSkinBackgroundControlContextL(iStartTimeBgContext); |
|
550 iEndTime->SetSkinBackgroundControlContextL(iEndTimeBgContext); |
|
551 } |
|
552 |
|
553 // --------------------------------------------------------------------------- |
|
554 // CTimeContainer::ChangeFocusRightL |
|
555 // --------------------------------------------------------------------------- |
|
556 // |
|
557 TKeyResponse CTimeContainer::ChangeFocusRightL(const TKeyEvent& aEvent, |
|
558 TEventCode aType ) |
|
559 { |
|
560 FUNC_LOG; |
|
561 TKeyResponse response = EKeyWasNotConsumed; |
|
562 |
|
563 if ( iStartTime->IsFocused ( ) ) |
|
564 { |
|
565 // if the focus is in the last field of start time, move focus |
|
566 // to end times first field. |
|
567 TInt current = iStartTime->CurrentField(); |
|
568 TInt count = iStartTime->NumFields(); |
|
569 if ( current == (count - 1) ) |
|
570 { |
|
571 iStartTime->SetFocus( EFalse, EDrawNow ); |
|
572 iEndTime->SetFocus( ETrue, EDrawNow ); |
|
573 response = EKeyWasConsumed; |
|
574 } |
|
575 else |
|
576 { |
|
577 response = iStartTime->OfferKeyEventL ( aEvent, aType ); |
|
578 } |
|
579 TriggerStartTimeChangedL(); |
|
580 } |
|
581 |
|
582 else if ( iEndTime->IsFocused ( ) ) |
|
583 { |
|
584 if ( iEndTime->CurrentField() == (iEndTime->NumFields() - 1) ) |
|
585 { |
|
586 iEndTime->SetFocus ( EFalse, EDrawNow ); |
|
587 iStartTime->SetFocus ( ETrue, EDrawNow ); |
|
588 response = EKeyWasConsumed; |
|
589 } |
|
590 else |
|
591 { |
|
592 response = iEndTime->OfferKeyEventL ( aEvent, aType ); |
|
593 } |
|
594 TriggerEndTimeChangedL(); |
|
595 } |
|
596 return response; |
|
597 } |
|
598 |
|
599 // --------------------------------------------------------------------------- |
|
600 // CTimeContainer::ChangeFocusLeftL |
|
601 // --------------------------------------------------------------------------- |
|
602 // |
|
603 TKeyResponse CTimeContainer::ChangeFocusLeftL( |
|
604 const TKeyEvent& aEvent, |
|
605 TEventCode aType ) |
|
606 { |
|
607 FUNC_LOG; |
|
608 TKeyResponse response = EKeyWasNotConsumed; |
|
609 if ( iStartTime->IsFocused ( ) ) |
|
610 { |
|
611 // if the focus is in the first field of start time, move focus |
|
612 // to end times last field. |
|
613 if ( iStartTime->CurrentField ( )== 0 ) |
|
614 { |
|
615 iStartTime->SetFocus ( EFalse, EDrawNow ); |
|
616 iEndTime->SetFocus ( ETrue, EDrawNow ); |
|
617 // last item should highlighted, API does not export the highlight |
|
618 // function, so emulate key presses |
|
619 response = iEndTime->OfferKeyEventL ( aEvent, aType ); |
|
620 } |
|
621 else |
|
622 { |
|
623 response = iStartTime->OfferKeyEventL ( aEvent, aType ); |
|
624 } |
|
625 TriggerStartTimeChangedL(); |
|
626 } |
|
627 |
|
628 else if ( iEndTime->IsFocused ( ) ) |
|
629 { |
|
630 if ( iEndTime->CurrentField ( )== 0 ) |
|
631 { |
|
632 iEndTime->SetFocus ( EFalse, EDrawNow ); |
|
633 iStartTime->SetFocus ( ETrue, EDrawNow ); |
|
634 // last item should highlighted, API does not export the highlight |
|
635 // function, so emulate key presses |
|
636 response = iStartTime->OfferKeyEventL ( aEvent, aType ); |
|
637 } |
|
638 else |
|
639 { |
|
640 response = iEndTime->OfferKeyEventL ( aEvent, aType ); |
|
641 } |
|
642 |
|
643 TriggerEndTimeChangedL(); |
|
644 } |
|
645 return response; |
|
646 } |
|
647 |
|
648 // --------------------------------------------------------------------------- |
|
649 // CTimeContainer::CheckIfValidatingNeededL |
|
650 // --------------------------------------------------------------------------- |
|
651 // |
|
652 void CTimeContainer::CheckIfValidatingNeededL( |
|
653 TBool aStartFocusedBefore, |
|
654 TInt aStartFieldIndex, |
|
655 TBool aEndFocusedBefore, |
|
656 TInt aEndFieldIndex ) |
|
657 { |
|
658 FUNC_LOG; |
|
659 TBool startFocusedAfter( iStartTime->IsFocused() ); |
|
660 TBool endFocusedAfter( iEndTime->IsFocused() ); |
|
661 |
|
662 if ( aStartFocusedBefore != startFocusedAfter ) |
|
663 { |
|
664 if ( startFocusedAfter ) |
|
665 { |
|
666 TriggerEndTimeChangedL(); |
|
667 } |
|
668 else |
|
669 { |
|
670 TriggerStartTimeChangedL(); |
|
671 } |
|
672 } |
|
673 |
|
674 else if ( startFocusedAfter && |
|
675 aStartFocusedBefore == startFocusedAfter ) |
|
676 { |
|
677 TInt fieldIndex( iStartTime->CurrentField() ); |
|
678 if ( fieldIndex != aStartFieldIndex ) |
|
679 { |
|
680 TriggerStartTimeChangedL(); |
|
681 } |
|
682 } |
|
683 |
|
684 else if ( endFocusedAfter && |
|
685 aEndFocusedBefore == endFocusedAfter ) |
|
686 { |
|
687 TInt fieldIndex( iEndTime->CurrentField() ); |
|
688 if ( fieldIndex != aEndFieldIndex ) |
|
689 { |
|
690 TriggerEndTimeChangedL(); |
|
691 } |
|
692 } |
|
693 } |
|
694 |
|
695 // --------------------------------------------------------------------------- |
|
696 // CTimeContainer::TriggerStartTimeChangedL |
|
697 // --------------------------------------------------------------------------- |
|
698 // |
|
699 void CTimeContainer::TriggerStartTimeChangedL() |
|
700 { |
|
701 FUNC_LOG; |
|
702 if ( iValidator ) |
|
703 { |
|
704 TRAPD( err, iValidator->StartTimeChangedL() ); |
|
705 if ( err != KErrNone ) |
|
706 { |
|
707 switch ( err ) |
|
708 { |
|
709 case KErrOverflow: |
|
710 CESMRGlobalNote::ExecuteL( |
|
711 CESMRGlobalNote::EESMRRepeatReSchedule ); |
|
712 break; |
|
713 } |
|
714 } |
|
715 } |
|
716 } |
|
717 |
|
718 // --------------------------------------------------------------------------- |
|
719 // CTimeContainer::TriggerEndTimeChangedL |
|
720 // --------------------------------------------------------------------------- |
|
721 // |
|
722 void CTimeContainer::TriggerEndTimeChangedL() |
|
723 { |
|
724 FUNC_LOG; |
|
725 if ( iValidator ) |
|
726 { |
|
727 TRAPD( err, iValidator->EndTimeChangedL() ); |
|
728 if ( err != KErrNone ) |
|
729 { |
|
730 switch ( err ) |
|
731 { |
|
732 case KErrArgument: |
|
733 // Assuming that end date is different |
|
734 // and this is repeating entry |
|
735 CESMRGlobalNote::ExecuteL( |
|
736 CESMRGlobalNote::EESMRRepeatDifferentStartAndEndDate ); |
|
737 break; |
|
738 case KErrOverflow: |
|
739 CESMRGlobalNote::ExecuteL( |
|
740 CESMRGlobalNote::EESMRRepeatReSchedule ); |
|
741 break; |
|
742 } |
|
743 } |
|
744 } |
|
745 } |
|
746 |
|
747 // EOF |
|
748 |