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