|
1 /* |
|
2 * Copyright (c) 2002 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: Container base class of Calendar application. |
|
15 * This class is the derivation origin of Calendar container. |
|
16 * |
|
17 */ |
|
18 |
|
19 // system includes |
|
20 #include <AknsFrameBackgroundControlContext.h> |
|
21 #include <AknsDrawUtils.h> |
|
22 #include <calinstance.h> |
|
23 #include <eiklabel.h> |
|
24 #include <aknlayoutscalable_apps.cdl.h> // AknLayoutScalable_Apps |
|
25 #include <AknUtils.h> // AknLayoutUtils |
|
26 #include <calenagendautils.h> |
|
27 #include <calalarm.h> |
|
28 #include <AknIconArray.h> |
|
29 #include <calencommands.hrh> // Calendar commands |
|
30 #include <layoutmetadata.cdl.h> |
|
31 #include <calentoolbar.h> |
|
32 #include <akntoolbar.h> |
|
33 |
|
34 // user includes |
|
35 #include "calendarui_debug.h" |
|
36 #include "calencontainer.h" |
|
37 #include "calencontainerlayoutmanager.h" |
|
38 #include "calencontroller.h" |
|
39 #include <calendateutils.h> |
|
40 #include "calendar.hrh" |
|
41 #include "calennativeview.h" |
|
42 #include "CalenUid.h" |
|
43 #include <calencontext.h> |
|
44 #include "caleninstanceid.h" |
|
45 #include "calenpreview.h" |
|
46 #include <caleninstanceid.h> // TCalenInstanceId |
|
47 |
|
48 // ================= MEMBER FUNCTIONS ======================= |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CCalenContainer::CCalenContainer |
|
52 // C++ constructor can NOT contain any code, that might leave. |
|
53 // (other items were commented in a header). |
|
54 // ---------------------------------------------------------------------------- |
|
55 // |
|
56 CCalenContainer::CCalenContainer( CCalenNativeView* aView, |
|
57 MCalenServices& aServices ) |
|
58 : iView( aView ), iServices( aServices ) |
|
59 { |
|
60 TRACE_ENTRY_POINT; |
|
61 |
|
62 TRACE_EXIT_POINT; |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CCalenContainer::ConstructL |
|
67 // Symbian OS default constructor can leave. |
|
68 // (other items were commented in a header). |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 void CCalenContainer::ConstructL() |
|
72 { |
|
73 TRACE_ENTRY_POINT; |
|
74 |
|
75 CreateWindowL(); |
|
76 CreateIconIndicesL( iIconIndices ); |
|
77 ConstructImplL(); |
|
78 |
|
79 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, |
|
80 TRect(0,0,0,0), |
|
81 EFalse ); |
|
82 |
|
83 iLayoutManager = CCalenContainerLayoutManager::NewL( iServices, *this ); |
|
84 iLayoutManager->SetToolbarVisibility( ETrue ); |
|
85 |
|
86 TRACE_EXIT_POINT; |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CCalenContainer::~CCalenContainer |
|
91 // Destructor |
|
92 // (other items were commented in a header). |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 CCalenContainer::~CCalenContainer() |
|
96 { |
|
97 TRACE_ENTRY_POINT; |
|
98 |
|
99 delete iLayoutManager; |
|
100 |
|
101 delete iHeadingBgContext; |
|
102 delete iSideBgContext; |
|
103 delete iBgContext; |
|
104 iIconIndices.Close(); |
|
105 |
|
106 |
|
107 if(iLongTapDetector) |
|
108 { |
|
109 delete iLongTapDetector; |
|
110 } |
|
111 |
|
112 |
|
113 TRACE_EXIT_POINT; |
|
114 } |
|
115 |
|
116 // ---------------------------------------------------------------------------- |
|
117 // CCalenContainer::NotifyChangeDateL |
|
118 // Notify that Active date is changed. Each contianer will redraw. |
|
119 // (other items were commented in a header). |
|
120 // ---------------------------------------------------------------------------- |
|
121 // |
|
122 void CCalenContainer::NotifyChangeDateL() |
|
123 { |
|
124 TRACE_ENTRY_POINT; |
|
125 TRACE_EXIT_POINT; |
|
126 } |
|
127 |
|
128 // ---------------------------------------------------------------------------- |
|
129 // CCalenContainer::RemoveFromStackAndMakeInvisible |
|
130 // Remove from Control stack and Make in-visible |
|
131 // (other items were commented in a header). |
|
132 // ---------------------------------------------------------------------------- |
|
133 // |
|
134 void CCalenContainer::RemoveFromStackAndMakeInvisible(TBool /*aMakeInvisible*/) |
|
135 { |
|
136 TRACE_ENTRY_POINT; |
|
137 |
|
138 CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); |
|
139 appui->RemoveFromStack( this ); |
|
140 MakeVisible(EFalse); |
|
141 |
|
142 TRACE_EXIT_POINT; |
|
143 } |
|
144 |
|
145 // ---------------------------------------------------------------------------- |
|
146 // CCalenContainer::AddToStackAndMakeVisibleL |
|
147 // Add to Control stack |
|
148 // (other items were commented in a header). |
|
149 // ---------------------------------------------------------------------------- |
|
150 // |
|
151 void CCalenContainer::AddToStackAndMakeVisibleL() |
|
152 { |
|
153 TRACE_ENTRY_POINT; |
|
154 |
|
155 if( iView->IsCommandHandlingInProgress() ) |
|
156 { |
|
157 iView->SetCommandHandlingInProgress( EFalse ); |
|
158 } |
|
159 |
|
160 if (!IsVisible()) |
|
161 { |
|
162 MakeVisible(ETrue); |
|
163 } |
|
164 |
|
165 { |
|
166 CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); |
|
167 appui->AddToStackL( this ); |
|
168 iView->NotifyFocusChanged(); |
|
169 } |
|
170 |
|
171 TRACE_EXIT_POINT; |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------- |
|
175 // CCalenContainer::IsOnStack |
|
176 // Is this control exist on stack? |
|
177 // (other items were commented in a header). |
|
178 // --------------------------------------------------------- |
|
179 // |
|
180 TBool CCalenContainer::IsOnStack() |
|
181 { |
|
182 TRACE_ENTRY_POINT; |
|
183 |
|
184 TRACE_EXIT_POINT; |
|
185 //return iFlags[EAddedControlStack]; |
|
186 return ETrue; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // CCalenContainer::SetIgnoreDocuChange |
|
191 // Ignore Agenda server notifier |
|
192 // (other items were commented in a header). |
|
193 // --------------------------------------------------------- |
|
194 // |
|
195 void CCalenContainer::SetIgnoreDocuChange() |
|
196 { |
|
197 TRACE_ENTRY_POINT; |
|
198 |
|
199 //iFlags.Set(EIgnoreDocChange); |
|
200 |
|
201 TRACE_EXIT_POINT; |
|
202 } |
|
203 |
|
204 // ---------------------------------------------------------------------------- |
|
205 // CCalenContainer::OfferKeyEventL |
|
206 // Key handling that is common to all calendar views. |
|
207 // Note! This has to be called before custom key handling |
|
208 // in views, so that state handling of view-cycling works |
|
209 // correcly. |
|
210 // (other items were commented in a header). |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 TKeyResponse CCalenContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
214 TEventCode aType) |
|
215 { |
|
216 TRACE_ENTRY_POINT; |
|
217 |
|
218 TKeyResponse exitCode(EKeyWasNotConsumed); |
|
219 TBool startEditor(EFalse); |
|
220 |
|
221 |
|
222 TBool mirrored( AknLayoutUtils::LayoutMirrored() ); |
|
223 |
|
224 |
|
225 if (aType == EEventKey) |
|
226 { |
|
227 switch (aKeyEvent.iCode) |
|
228 { |
|
229 |
|
230 case CALEN_VIEW_CYCLING_NEXT: // HASH # |
|
231 // if(AknLayoutUtils::PenEnabled()) |
|
232 // { |
|
233 // iServices.IssueCommandL( mirrored ? ECalenPrevView : ECalenNextView ); |
|
234 // } |
|
235 // else |
|
236 // { |
|
237 iView->HandleCommandL( ECalenGotoToday ); |
|
238 // } |
|
239 exitCode = EKeyWasConsumed; |
|
240 break; |
|
241 case CALEN_VIEW_CYCLING_PREV: // STAR * |
|
242 { |
|
243 if(AknLayoutUtils::PenEnabled()) |
|
244 { |
|
245 iServices.IssueCommandL( mirrored ? ECalenPrevView : ECalenNextView ); |
|
246 } |
|
247 else |
|
248 { |
|
249 iServices.IssueCommandL( ECalenNextView ); |
|
250 } |
|
251 exitCode = EKeyWasConsumed; |
|
252 break; |
|
253 } |
|
254 |
|
255 default: |
|
256 break; |
|
257 } |
|
258 } |
|
259 |
|
260 if( exitCode == EKeyWasNotConsumed ) |
|
261 { |
|
262 /* If printable key was pressed while editors are not being opened and |
|
263 * Delete note is not shown editor will be lauched. |
|
264 */ |
|
265 if( aType == EEventKey && TChar(aKeyEvent.iCode).IsPrint()) |
|
266 { |
|
267 startEditor = ETrue; |
|
268 } |
|
269 |
|
270 /* If editor is being opened or is about to be opened |
|
271 * put event (any event) into queue. |
|
272 */ |
|
273 if(startEditor) |
|
274 { |
|
275 iServices.QueueKeyEvent(aKeyEvent, aType); |
|
276 exitCode = EKeyWasConsumed; |
|
277 } |
|
278 /* Launch editor |
|
279 */ |
|
280 if(startEditor) |
|
281 { |
|
282 TInt cmd = |
|
283 iView->Id() == KUidCalenTodoView ? |
|
284 ECalenNewTodo : ECalenNewMeeting; |
|
285 iView->HandleCommandL( cmd ); |
|
286 } |
|
287 } |
|
288 |
|
289 |
|
290 TRACE_EXIT_POINT; |
|
291 return exitCode; |
|
292 } |
|
293 |
|
294 // ---------------------------------------------------------------------------- |
|
295 // CCalenContainer::SizeChanged |
|
296 // (other items were commented in a header). |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 void CCalenContainer::SizeChanged(const TRect& aParent) |
|
300 { |
|
301 TRACE_ENTRY_POINT; |
|
302 |
|
303 if( iBgContext ) |
|
304 { |
|
305 iBgContext->SetRect(aParent); |
|
306 iBgContext->SetParentContext( AknsDrawUtils::ControlContextOfParent( this ) ); |
|
307 } |
|
308 |
|
309 // iServices.IssueCommandL( ECalenUpdateToolbar ); |
|
310 |
|
311 TRACE_EXIT_POINT; |
|
312 } |
|
313 |
|
314 // ---------------------------------------------------------------------------- |
|
315 // CCalenContainer::FocusChanged |
|
316 // Handler of changing focus |
|
317 // (other items were commented in a header). |
|
318 // ---------------------------------------------------------------------------- |
|
319 // |
|
320 void CCalenContainer::FocusChanged(TDrawNow /*aDrawNow*/) |
|
321 { |
|
322 TRACE_ENTRY_POINT; |
|
323 |
|
324 iView->NotifyFocusChanged(); |
|
325 |
|
326 TRACE_EXIT_POINT; |
|
327 } |
|
328 |
|
329 // ---------------------------------------------------------------------------- |
|
330 // CCalenContainer::HandleResourceChange |
|
331 // Handles a resource relative event |
|
332 // (other items were commented in a header). |
|
333 // ---------------------------------------------------------------------------- |
|
334 // |
|
335 void CCalenContainer::HandleResourceChange(TInt aType) |
|
336 { |
|
337 TRACE_ENTRY_POINT; |
|
338 |
|
339 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
340 { |
|
341 SetRect( iView->ClientRect() ); |
|
342 } |
|
343 |
|
344 if(KEikMessageUnfadeWindows == aType) |
|
345 { |
|
346 iView->SetFasterAppActive( EFalse ); |
|
347 } |
|
348 |
|
349 TRACE_EXIT_POINT; |
|
350 } |
|
351 |
|
352 // ---------------------------------------------------------------------------- |
|
353 // ?classname::?member_function |
|
354 // ?implementation_description |
|
355 // (other items were commented in a header). |
|
356 // ---------------------------------------------------------------------------- |
|
357 // |
|
358 void CCalenContainer::UpdateStatusPaneAndExtensionsL() |
|
359 { |
|
360 TRACE_ENTRY_POINT; |
|
361 |
|
362 iView->SetStatusPaneFromActiveContextL(); |
|
363 |
|
364 // Control is either infobar, preview pane or null. |
|
365 CCoeControl* control = iLayoutManager->ControlOrNull(); |
|
366 if ( control ) |
|
367 { |
|
368 control->DrawDeferred(); |
|
369 } |
|
370 |
|
371 TRACE_EXIT_POINT; |
|
372 } |
|
373 |
|
374 // ---------------------------------------------------------------------------- |
|
375 // CCalenContainer::DateFromContextL |
|
376 // Calculates the time from the context. If the context is a todo in the past, |
|
377 // returns today. |
|
378 // ---------------------------------------------------------------------------- |
|
379 // |
|
380 TTime CCalenContainer::DateFromContextL( const MCalenContext& aContext ) |
|
381 { |
|
382 TRACE_ENTRY_POINT; |
|
383 |
|
384 TTime ret; |
|
385 |
|
386 if ( aContext.InstanceId().iType == CCalEntry::ETodo ) |
|
387 { |
|
388 TTime today = CalenDateUtils::Today(); |
|
389 if ( aContext.FocusDateAndTimeL().TimeLocalL() < today ) |
|
390 { |
|
391 ret = today; |
|
392 } |
|
393 else |
|
394 { |
|
395 ret = aContext.FocusDateAndTimeL().TimeLocalL(); |
|
396 } |
|
397 } |
|
398 else |
|
399 { |
|
400 ret = aContext.FocusDateAndTimeL().TimeLocalL(); |
|
401 } |
|
402 |
|
403 TRACE_EXIT_POINT; |
|
404 return ret; |
|
405 } |
|
406 |
|
407 |
|
408 // --------------------------------------------------------- |
|
409 // CCalenNativeView::HandleNaviLabelEventL |
|
410 // Handles navigation label events |
|
411 // (other items were commented in a header). |
|
412 // --------------------------------------------------------- |
|
413 // |
|
414 void CCalenContainer::HandleNaviLabelEventL( TInt aEventID ) |
|
415 { |
|
416 TRACE_ENTRY_POINT; |
|
417 |
|
418 if ( AknLayoutUtils::PenEnabled() ) |
|
419 { |
|
420 switch ( aEventID ) |
|
421 { |
|
422 case ECCalenNaviLabelEventRight: |
|
423 HandleNaviDecoratorEventL(EAknNaviDecoratorEventRightTabArrow); |
|
424 break; |
|
425 case ECCalenNaviLabelEventLeft: |
|
426 HandleNaviDecoratorEventL(EAknNaviDecoratorEventLeftTabArrow); |
|
427 break; |
|
428 case ECCalenNaviLabelGo: |
|
429 iView->HandleCommandL( ECalenGotoDate ); |
|
430 break; |
|
431 } |
|
432 } |
|
433 |
|
434 TRACE_EXIT_POINT; |
|
435 } |
|
436 |
|
437 |
|
438 // ---------------------------------------------------------------------------- |
|
439 // CCalenContainer::InfoBarRectL |
|
440 // Returns an empty rect. Derived classes should return their info bar rect |
|
441 // from the LAF |
|
442 // ---------------------------------------------------------------------------- |
|
443 TRect CCalenContainer::InfoBarRectL( TBool /*aToolbarAvailable*/ ) |
|
444 { |
|
445 TRACE_ENTRY_POINT; |
|
446 |
|
447 TRect rect; |
|
448 |
|
449 TRACE_EXIT_POINT; |
|
450 return rect; |
|
451 } |
|
452 |
|
453 // ---------------------------------------------------------------------------- |
|
454 // CCalenContainer::PreviewRectL |
|
455 // Returns the preview pane rect from the LAF |
|
456 // ---------------------------------------------------------------------------- |
|
457 TRect CCalenContainer::PreviewRectL() |
|
458 { |
|
459 TRACE_ENTRY_POINT; |
|
460 |
|
461 // Get the screen rect |
|
462 TRect screenRect; |
|
463 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
464 |
|
465 // Get the application window rect |
|
466 TAknLayoutRect application_window; |
|
467 application_window.LayoutRect( |
|
468 screenRect, |
|
469 AknLayoutScalable_Apps::application_window().LayoutLine() ); |
|
470 |
|
471 |
|
472 // Get the preview pane rect |
|
473 TAknLayoutRect popup_fixed_preview_cale_window; |
|
474 popup_fixed_preview_cale_window.LayoutRect( |
|
475 screenRect, |
|
476 AknLayoutScalable_Apps::popup_fixed_preview_cale_window( |
|
477 Layout_Meta_Data::IsLandscapeOrientation()).LayoutLine() ); |
|
478 |
|
479 return popup_fixed_preview_cale_window.Rect(); |
|
480 |
|
481 TRACE_EXIT_POINT; |
|
482 } |
|
483 |
|
484 // ---------------------------------------------------------------------------- |
|
485 // ?classname::?member_function |
|
486 // ?implementation_description |
|
487 // (other items were commented in a header). |
|
488 // ---------------------------------------------------------------------------- |
|
489 // |
|
490 void CCalenContainer::NotifyLongTapDetectorL(const TPointerEvent& aPointerEvent) |
|
491 { |
|
492 TRACE_ENTRY_POINT; |
|
493 |
|
494 if(AknLayoutUtils::PenEnabled()) |
|
495 { |
|
496 if(iLongTapDetector == NULL) |
|
497 { |
|
498 iLongTapDetector = CAknLongTapDetector::NewL( this ); |
|
499 if(iLongTapDetector) |
|
500 { |
|
501 iLongTapDetector->EnableLongTapAnimation(ETrue); |
|
502 iLongTapDetector->PointerEventL( aPointerEvent ); |
|
503 } |
|
504 } |
|
505 else |
|
506 { |
|
507 iLongTapDetector->PointerEventL( aPointerEvent ); |
|
508 } |
|
509 } |
|
510 |
|
511 TRACE_EXIT_POINT; |
|
512 } |
|
513 |
|
514 // ---------------------------------------------------------------------------- |
|
515 // ?classname::?member_function |
|
516 // ?implementation_description |
|
517 // (other items were commented in a header). |
|
518 // ---------------------------------------------------------------------------- |
|
519 // |
|
520 CAknIconArray* CCalenContainer::CreateIconsL( const RArray<MCalenServices::TCalenIcons>& aIndexArray ) |
|
521 { |
|
522 TRACE_ENTRY_POINT; |
|
523 const TInt iconCount( aIndexArray.Count() ); |
|
524 CAknIconArray* icons = new(ELeave) CAknIconArray( iconCount ); |
|
525 CleanupStack::PushL( icons ); |
|
526 icons->SetReserveL( iconCount ); |
|
527 |
|
528 for( TInt i=0; i<iconCount; ++i ) |
|
529 { |
|
530 icons->AppendL( iServices.GetIconL( static_cast<MCalenServices::TCalenIcons>(aIndexArray[i] ) )); |
|
531 } |
|
532 CleanupStack::Pop( icons ); |
|
533 TRACE_EXIT_POINT; |
|
534 return icons; |
|
535 } |
|
536 |
|
537 // ---------------------------------------------------------------------------- |
|
538 // CCalenContainer::IconIndex |
|
539 // Get icon index in the icon array |
|
540 // ---------------------------------------------------------------------------- |
|
541 // |
|
542 TInt CCalenContainer::IconIndex( MCalenServices::TCalenIcons aType ) const |
|
543 { |
|
544 TRACE_ENTRY_POINT; |
|
545 TInt index( iIconIndices.Find( aType ) ); |
|
546 // User::LeaveIfError( index == KErrNotFound ); |
|
547 TRACE_EXIT_POINT; |
|
548 return index; |
|
549 } |
|
550 |
|
551 // ---------------------------------------------------------------------------- |
|
552 // CCalenContainer::IconIndex |
|
553 // Get icon index in the icon array |
|
554 // ---------------------------------------------------------------------------- |
|
555 // |
|
556 TInt CCalenContainer::IconIndexFromEntryL( CCalEntry& aEntry, TBool aIsAllDayEvent ) const |
|
557 { |
|
558 TRACE_ENTRY_POINT; |
|
559 TInt index( KErrNotFound ); |
|
560 |
|
561 //Irrespective of entry type alldayevent has to be shown |
|
562 //wiht differnt icon |
|
563 if( aIsAllDayEvent ) |
|
564 { |
|
565 //Fix me - temopararily meeting icon is used,unitl allday |
|
566 //icon is available |
|
567 index = IconIndex( MCalenServices::ECalenMeetingIcon ); |
|
568 User::LeaveIfError( index == KErrNotFound ); |
|
569 } |
|
570 else |
|
571 { |
|
572 switch(aEntry.EntryTypeL()) |
|
573 { |
|
574 case CCalEntry::EAnniv: |
|
575 index = IconIndex( MCalenServices::ECalenBirthdayIcon ); |
|
576 User::LeaveIfError( index == KErrNotFound ); |
|
577 break; |
|
578 case CCalEntry::EEvent: |
|
579 index = IconIndex( MCalenServices::ECalenDaynoteIcon ); |
|
580 User::LeaveIfError( index == KErrNotFound ); |
|
581 break; |
|
582 case CCalEntry::EAppt: |
|
583 index = IconIndex( MCalenServices::ECalenMeetingIcon ); |
|
584 User::LeaveIfError( index == KErrNotFound ); |
|
585 break; |
|
586 case CCalEntry::ETodo: |
|
587 index = IconIndex( MCalenServices::ECalenToDoIcon ); |
|
588 User::LeaveIfError( index == KErrNotFound ); |
|
589 break; |
|
590 default: |
|
591 ASSERT( EFalse ); |
|
592 break; |
|
593 } |
|
594 } |
|
595 return index; |
|
596 } |
|
597 // ---------------------------------------------------------------------------- |
|
598 // CalenViewUtils::InsertAdditionalIconsL |
|
599 // (other items were commented in a header). |
|
600 // ---------------------------------------------------------------------------- |
|
601 // |
|
602 void CCalenContainer::InsertAdditionalIconsL( const CCalEntry& aEntry, |
|
603 const TDesC& aIconFormatDes, |
|
604 TPtr& aTargetDes, |
|
605 const TBool aPushSingleIconToRight, |
|
606 const TBool aRevertOrder ) const |
|
607 { |
|
608 TRACE_ENTRY_POINT; |
|
609 |
|
610 const TInt maxIconStrLength = 50; |
|
611 TInt free = aTargetDes.MaxLength() - aTargetDes.Length(); |
|
612 free -= (2*aIconFormatDes.Length()); // up to 2 icons |
|
613 if(free < 0) |
|
614 { |
|
615 User::Leave(KErrBadDescriptor); |
|
616 } |
|
617 |
|
618 _LIT(KPercentD, "%d"); |
|
619 TInt pos = aIconFormatDes.Find( KPercentD ); |
|
620 if(( pos == KErrNotFound ) || ( maxIconStrLength < aIconFormatDes.Length() )) |
|
621 { |
|
622 User::Leave(KErrArgument); |
|
623 } |
|
624 |
|
625 TBool alarm ( EFalse ), repeat( EFalse ); |
|
626 TBool priLow( EFalse ), priHigh( EFalse ), exception( EFalse ); |
|
627 CCalEntry::TType type( aEntry.EntryTypeL() ); |
|
628 |
|
629 // check alarm |
|
630 { |
|
631 CCalAlarm* alarmObj = aEntry.AlarmL(); |
|
632 alarm = alarmObj ? ETrue : EFalse; |
|
633 delete alarmObj; |
|
634 } |
|
635 |
|
636 // child entries (repeat exceptions) have recurrence ID |
|
637 exception = (aEntry.RecurrenceIdL().TimeUtcL() != Time::NullTTime()); |
|
638 // exceptions can(?) also be repeating |
|
639 // but we can't have both icons... |
|
640 if( !exception ) |
|
641 { |
|
642 // check repeating rule (except for Anniv, we dont put repeating icons) |
|
643 repeat = CalenAgendaUtils::IsRepeatingL( aEntry ); |
|
644 } |
|
645 |
|
646 // check priority (only for to-dos) |
|
647 TBool hasPriority = NeedsPriorityIconL( aEntry, priHigh, priLow ); |
|
648 |
|
649 // used to push the only icon to the right |
|
650 TInt numOfIcons = NumberOfIcons(exception, repeat, alarm, hasPriority); |
|
651 |
|
652 // ToDo view needs length 4 for 1 icon |
|
653 // Day & week view need 3 for 1 icon |
|
654 _LIT(KEmptyString, ""); |
|
655 TBuf<maxIconStrLength> alarmIcon(KEmptyString); |
|
656 TBuf<maxIconStrLength> priorityIcon(KEmptyString); |
|
657 TBuf<maxIconStrLength> recurrenceIcon(KEmptyString); |
|
658 |
|
659 // handle repeating icon for meeting & todo's |
|
660 if( repeat ) |
|
661 { |
|
662 recurrenceIcon.Format(aIconFormatDes, IconIndex( MCalenServices::ECalenRepeatIcon )); |
|
663 } |
|
664 else if( exception ) // exception EFalse for ToDo, safe |
|
665 { |
|
666 recurrenceIcon.Format(aIconFormatDes, IconIndex( MCalenServices::ECalenRepeatExceptionIcon)); |
|
667 } |
|
668 TBuf<maxIconStrLength> mapIcon(KEmptyString); |
|
669 CCalGeoValue* geovalue = aEntry.GeoValueL(); |
|
670 if(geovalue) |
|
671 { |
|
672 numOfIcons++; |
|
673 mapIcon.Format(aIconFormatDes, IconIndex( MCalenServices::ECalenMapIcon )); |
|
674 delete geovalue; |
|
675 } |
|
676 // Master UI spec v43: In case there are three icons |
|
677 // and only two can be shown "Priority" icon is not shown. |
|
678 // We can only have 2 icons, though LAF days 3. |
|
679 if (hasPriority && (numOfIcons != 3)) |
|
680 { |
|
681 // handle priority icon |
|
682 if( priLow ) |
|
683 { |
|
684 priorityIcon.Format( aIconFormatDes, IconIndex( MCalenServices::ECalenNotePriorityLow )); |
|
685 } |
|
686 else if( priHigh ) |
|
687 { |
|
688 priorityIcon.Format( aIconFormatDes, IconIndex( MCalenServices::ECalenNotePriorityHigh )); |
|
689 } |
|
690 } |
|
691 |
|
692 // two icons are active then, the alarm icon is closer |
|
693 // the border. |
|
694 if( alarm ) |
|
695 { |
|
696 alarmIcon.Format( aIconFormatDes, IconIndex( MCalenServices::ECalenAlarmIcon )); |
|
697 } |
|
698 |
|
699 if( aPushSingleIconToRight && ( numOfIcons == 1 ) ) |
|
700 { |
|
701 // Strip %d part away |
|
702 TBuf<5> push( aIconFormatDes ); |
|
703 push.Delete( pos, 2 ); // "%d" deleted |
|
704 |
|
705 // push the only icon to the right |
|
706 aTargetDes.Append( push ); |
|
707 } |
|
708 |
|
709 if(aRevertOrder) |
|
710 { |
|
711 // ToDo view needs this order |
|
712 aTargetDes.Append( alarmIcon ); |
|
713 aTargetDes.Append( priorityIcon ); |
|
714 aTargetDes.Append( recurrenceIcon ); |
|
715 } |
|
716 else |
|
717 { |
|
718 // Day & Week view |
|
719 // Add map icon if entry has geo value |
|
720 aTargetDes.Append(mapIcon); |
|
721 aTargetDes.Append( recurrenceIcon ); |
|
722 aTargetDes.Append( priorityIcon ); |
|
723 aTargetDes.Append( alarmIcon ); |
|
724 } |
|
725 |
|
726 TRACE_EXIT_POINT; |
|
727 } |
|
728 |
|
729 // ---------------------------------------------------------------------------- |
|
730 // CalenViewUtils::NumberOfIcons |
|
731 // (other items were commented in a header). |
|
732 // ---------------------------------------------------------------------------- |
|
733 // |
|
734 TInt CCalenContainer::NumberOfIcons( const TBool aException, |
|
735 const TBool aRepeat, |
|
736 const TBool aAlarm, |
|
737 const TBool aHasPriority ) const |
|
738 { |
|
739 TRACE_ENTRY_POINT; |
|
740 TInt count = 0; |
|
741 |
|
742 if(aException || aRepeat) |
|
743 { |
|
744 ++count; |
|
745 } |
|
746 |
|
747 if(aAlarm) |
|
748 { |
|
749 ++count; |
|
750 } |
|
751 |
|
752 if(aHasPriority) |
|
753 { |
|
754 ++count; |
|
755 } |
|
756 |
|
757 TRACE_EXIT_POINT; |
|
758 return count; |
|
759 } |
|
760 |
|
761 // ---------------------------------------------------------------------------- |
|
762 // CalenViewUtils::NeedsPriorityIconL |
|
763 // (other items were commented in a header). |
|
764 // ---------------------------------------------------------------------------- |
|
765 // |
|
766 TBool CCalenContainer::NeedsPriorityIconL( const CCalEntry& aEntry, |
|
767 TBool& aPriHigh, |
|
768 TBool& aPriLow ) const |
|
769 { |
|
770 TRACE_ENTRY_POINT; |
|
771 |
|
772 if( aEntry.EntryTypeL() == CCalEntry::ETodo ) |
|
773 { |
|
774 TUint priority( aEntry.PriorityL() ); |
|
775 |
|
776 if( priority <= ETodoPriorityHigh ) |
|
777 { |
|
778 aPriHigh = ETrue; |
|
779 } |
|
780 else if( priority >= ETodoPriorityLow ) |
|
781 { |
|
782 aPriLow = ETrue; |
|
783 } |
|
784 } |
|
785 |
|
786 TRACE_EXIT_POINT; |
|
787 return (aPriHigh||aPriLow); |
|
788 } |
|
789 |
|
790 // ---------------------------------------------------------------------------- |
|
791 // |
|
792 // ---------------------------------------------------------------------------- |
|
793 // |
|
794 TBool CCalenContainer::UseInfobar() const |
|
795 { |
|
796 TRACE_ENTRY_POINT; |
|
797 |
|
798 TBitFlags layoutFlags = iLayoutManager->LayoutFlags(); |
|
799 |
|
800 TRACE_EXIT_POINT; |
|
801 return layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerInfobar ); |
|
802 } |
|
803 |
|
804 |
|
805 TBool CCalenContainer::UseToolbar() const |
|
806 { |
|
807 TRACE_ENTRY_POINT; |
|
808 |
|
809 TBitFlags layoutFlags = iLayoutManager->LayoutFlags(); |
|
810 |
|
811 TRACE_EXIT_POINT; |
|
812 return layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerToolbar ); |
|
813 } |
|
814 |
|
815 TBool CCalenContainer::UsePreview() const |
|
816 { |
|
817 TRACE_ENTRY_POINT; |
|
818 |
|
819 TBitFlags layoutFlags = iLayoutManager->LayoutFlags(); |
|
820 |
|
821 TRACE_EXIT_POINT; |
|
822 return layoutFlags.IsSet( CCalenContainerLayoutManager::ECalenContainerPreview ); |
|
823 } |
|
824 |
|
825 |
|
826 TRect CCalenContainer::ReducePreview( TRect aRect ) const |
|
827 { |
|
828 TRACE_ENTRY_POINT; |
|
829 if (UsePreview() ) |
|
830 { |
|
831 // Find the application window |
|
832 TRect screenRect; |
|
833 TAknLayoutRect application_window; |
|
834 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, |
|
835 screenRect ); |
|
836 application_window.LayoutRect( |
|
837 screenRect, |
|
838 AknLayoutScalable_Apps::application_window().LayoutLine() ); |
|
839 |
|
840 // Find the size of the main pane when the preview is valid. |
|
841 TAknLayoutRect main_pane; |
|
842 |
|
843 TInt orientation = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
844 |
|
845 main_pane.LayoutRect( |
|
846 application_window.Rect(), |
|
847 AknLayoutScalable_Apps::main_pane( orientation + 10 ).LayoutLine() ); |
|
848 |
|
849 aRect.SetWidth( main_pane.Rect().Width() ); |
|
850 aRect.SetHeight( main_pane.Rect().Height() ); |
|
851 } |
|
852 |
|
853 TRACE_EXIT_POINT; |
|
854 return aRect; |
|
855 } |
|
856 |
|
857 // ---------------------------------------------------------------------------- |
|
858 // CCalenContainer::UpdateTodayToolbarItemL |
|
859 // Hide/Unhide "today" toolbar item based on the focused day |
|
860 // ---------------------------------------------------------------------------- |
|
861 void CCalenContainer::UpdateTodayToolbarItemL() |
|
862 { |
|
863 TRACE_ENTRY_POINT; |
|
864 |
|
865 TDateTime currentFocusedDayTime = |
|
866 iServices.Context().FocusDateAndTimeL().TimeLocalL().DateTime(); |
|
867 TTime today = CalenDateUtils::Today(); |
|
868 TDateTime todayDateTime = today.DateTime(); |
|
869 TBool hideItem(EFalse); |
|
870 if( currentFocusedDayTime.Day() == todayDateTime.Day() |
|
871 && currentFocusedDayTime.Month() == todayDateTime.Month() |
|
872 && currentFocusedDayTime.Year() == todayDateTime.Year() ) |
|
873 { |
|
874 hideItem = ETrue; |
|
875 } |
|
876 MCalenToolbar* toolbar = iServices.ToolbarOrNull(); |
|
877 if(toolbar) |
|
878 { |
|
879 toolbar->Toolbar().SetItemDimmed( ECalenGotoToday, hideItem, ETrue ); |
|
880 } |
|
881 TRACE_EXIT_POINT; |
|
882 } |
|
883 |
|
884 // End of File |