|
1 /* |
|
2 * Copyright (c) 2008 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 for missed alarm view's controls. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // System Includes |
|
21 #include <StringLoader.h> |
|
22 #include <eikdef.h> |
|
23 #include <eikenv.h> |
|
24 #include <avkon.rsg> |
|
25 #include <AknUtils.h> |
|
26 #include <aknlists.h> |
|
27 #include <AknsUtils.h> |
|
28 #include <AknIconArray.h> |
|
29 #include <avkon.hrh> |
|
30 #include <aknconsts.h> |
|
31 #include <data_caging_path_literals.hrh> |
|
32 #include <AknIconArray.h> |
|
33 #include <AknsDrawUtils.h> |
|
34 #include <avkon.mbg> |
|
35 #include <gulicon.h> |
|
36 #include <aknenv.h> |
|
37 #include <eikapp.h> |
|
38 #include <AknBidiTextUtils.h> |
|
39 #include <aknlayoutscalable_apps.cdl.h> |
|
40 #include <AknsFrameBackgroundControlContext.h> |
|
41 #include <csxhelp/cale.hlp.hrh> |
|
42 #include <calentryview.h> |
|
43 #include <calsession.h> |
|
44 #include <calinstanceview.h> |
|
45 #include <calinstance.h> |
|
46 #include <missedalarmstore.h> |
|
47 #include <missedalarm.h> |
|
48 #include <calenagendautils.h> |
|
49 #include <calenglobaldata.h> |
|
50 #include <calendar.mbg> |
|
51 #include <Calendar.rsg> |
|
52 #include <calencommands.hrh> // Calendar commands |
|
53 #include <calencontext.h> |
|
54 #include <caleninstanceid.h> // TCalenInstanceId |
|
55 #include <calenservices.h> |
|
56 #include <calentoolbar.h> |
|
57 #include <calenviewutils.h> |
|
58 |
|
59 // User Includes |
|
60 #include "calendarui_debug.h" |
|
61 #include "calenmissedalarmscontainer.h" |
|
62 #include "calendar.hrh" |
|
63 #include "calencontainer.h" |
|
64 #include "calenicons.h" |
|
65 #include "calenicons.h" |
|
66 #include "CalenUid.h" |
|
67 |
|
68 // Constants |
|
69 const TInt KMissedAlarmListMaxLength = 25; |
|
70 const TInt KMissedAlarmListBoxItems = 10; |
|
71 const TInt KListDataLength = 256; |
|
72 _LIT( KListSeparator, "\t" ); |
|
73 _LIT( KIconFormat,"%d"); |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CCalenMissedAlarmsContainer::CCalenMissedAlarmsContainer |
|
77 // Performs the first phase of two phase construction. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CCalenMissedAlarmsContainer::CCalenMissedAlarmsContainer(CCalenNativeView* aView, |
|
81 MCalenServices& aServices,TInt& aHighlightedRowNumber) : |
|
82 CCalenContainer(aView, aServices), |
|
83 iHighlightedRowNumber(aHighlightedRowNumber) |
|
84 { |
|
85 TRACE_ENTRY_POINT; |
|
86 TRACE_EXIT_POINT; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CCalenMissedAlarmsContainer::~CCalenMissedAlarmsContainer |
|
91 // Destructor |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 CCalenMissedAlarmsContainer::~CCalenMissedAlarmsContainer() |
|
95 { |
|
96 TRACE_ENTRY_POINT; |
|
97 |
|
98 if(iListBoxItemArray) |
|
99 { |
|
100 delete iListBoxItemArray; |
|
101 } |
|
102 if(iMissedAlarmsArray.Count()) |
|
103 { |
|
104 iMissedAlarmsArray.Reset(); |
|
105 iMissedAlarmsArray.Close(); |
|
106 } |
|
107 if (iListBox) |
|
108 { |
|
109 delete iListBox; |
|
110 iListBox = NULL; |
|
111 } |
|
112 |
|
113 TRACE_EXIT_POINT; |
|
114 } |
|
115 |
|
116 // ---------------------------------------------------------------------------- |
|
117 // CCalenMissedAlarmsContainer::ConstructImplL |
|
118 // Third phase constructor. |
|
119 // This function was called CCalenNativeView::ConstructL(). |
|
120 // (other items were commented in a header). |
|
121 // ---------------------------------------------------------------------------- |
|
122 // |
|
123 void CCalenMissedAlarmsContainer::ConstructImplL() |
|
124 { |
|
125 TRACE_ENTRY_POINT; |
|
126 |
|
127 iListBoxItemArray = new(ELeave) CDesCArrayFlat(KMissedAlarmListBoxItems); |
|
128 |
|
129 iMissedAlarmStore = iServices.MissedAlarmStore(); |
|
130 |
|
131 // Get the missed alarms count |
|
132 iMissedAlarmStore->CountL(iMissedAlarmsCount); |
|
133 |
|
134 iListBox = new( ELeave ) CAknDoubleGraphicStyleListBox; |
|
135 iListBox->ConstructL( this, 0); |
|
136 iListBox->SetContainerWindowL( *this); |
|
137 |
|
138 // Create scroll bar |
|
139 iListBox->CreateScrollBarFrameL(ETrue); |
|
140 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, |
|
141 CEikScrollBarFrame::EAuto); |
|
142 |
|
143 // set the model array |
|
144 iListBox->Model()->SetItemTextArray(iListBoxItemArray); |
|
145 |
|
146 // set icon array |
|
147 CAknIconArray* iconArray = CreateIconsL( iIconIndices ); |
|
148 CleanupStack::PushL(iconArray); |
|
149 iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(iconArray); |
|
150 CleanupStack::Pop(); |
|
151 |
|
152 iListBox->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
153 iListBox->View()->SetListEmptyTextL( KNullDesC ); |
|
154 iFirstTap = EFalse; |
|
155 |
|
156 TRACE_EXIT_POINT; |
|
157 } |
|
158 |
|
159 // ---------------------------------------------------------------------------- |
|
160 // CCalenMissedAlarmsContainer::UpdateSize |
|
161 // Do layout changes after calendar settings are |
|
162 // changed. No necessary actions for this view. |
|
163 // ---------------------------------------------------------------------------- |
|
164 // |
|
165 void CCalenMissedAlarmsContainer::UpdateSize() |
|
166 { |
|
167 TRACE_ENTRY_POINT; |
|
168 TRACE_EXIT_POINT; |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // CCalenMissedAlarmsContainer::IconIndexForEntryL |
|
173 // Gets the Icon Index for the missed alarm entry |
|
174 // (other items were commented in a header). |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TInt CCalenMissedAlarmsContainer::IconIndexForEntryL(CCalEntry& aEntry, |
|
178 TInt aSeenMissedAlarm) |
|
179 { |
|
180 TRACE_ENTRY_POINT; |
|
181 TInt iconIndex(0); |
|
182 |
|
183 if(aSeenMissedAlarm) |
|
184 { |
|
185 switch(aEntry.EntryTypeL()) |
|
186 { |
|
187 case CCalEntry::EAnniv: |
|
188 iconIndex = IconIndex(MCalenServices::ECalenBirthdayIcon); |
|
189 break; |
|
190 case CCalEntry::EEvent: |
|
191 iconIndex = IconIndex(MCalenServices::ECalenDaynoteIcon); |
|
192 break; |
|
193 case CCalEntry::EAppt: |
|
194 iconIndex = IconIndex(MCalenServices::ECalenMeetingIcon); |
|
195 break; |
|
196 case CCalEntry::ETodo: |
|
197 iconIndex = IconIndex(MCalenServices::ECalenTodoIconUndone); |
|
198 break; |
|
199 default: |
|
200 ASSERT( EFalse ); |
|
201 break; |
|
202 } |
|
203 } |
|
204 else |
|
205 { |
|
206 switch(aEntry.EntryTypeL()) |
|
207 { |
|
208 case CCalEntry::EAnniv: |
|
209 iconIndex = IconIndex(MCalenServices::ECalenBirthdayIconMissed); |
|
210 break; |
|
211 case CCalEntry::EEvent: |
|
212 iconIndex = IconIndex(MCalenServices::ECalenDaynoteIconMissed); |
|
213 break; |
|
214 case CCalEntry::EAppt: |
|
215 iconIndex = IconIndex(MCalenServices::ECalenMeetingIconMissed); |
|
216 break; |
|
217 case CCalEntry::ETodo: |
|
218 iconIndex = IconIndex(MCalenServices::ECalenToDoIconMissed); |
|
219 break; |
|
220 default: |
|
221 ASSERT( EFalse ); |
|
222 break; |
|
223 } |
|
224 } |
|
225 return iconIndex; |
|
226 TRACE_EXIT_POINT; |
|
227 } |
|
228 |
|
229 // ---------------------------------------------------------------------------- |
|
230 // CCalenMissedAlarmsContainer::CreateIconIndicesL |
|
231 // Fill the list of icons used by the MAV |
|
232 // (other items were commented in a header). |
|
233 // ---------------------------------------------------------------------------- |
|
234 // |
|
235 void CCalenMissedAlarmsContainer::CreateIconIndicesL( |
|
236 RArray<MCalenServices::TCalenIcons>& aIndexArray) |
|
237 { |
|
238 TRACE_ENTRY_POINT; |
|
239 |
|
240 aIndexArray.Reset(); |
|
241 aIndexArray.AppendL( MCalenServices::ECalenBirthdayIcon ); |
|
242 aIndexArray.AppendL( MCalenServices::ECalenDaynoteIcon ); |
|
243 aIndexArray.AppendL( MCalenServices::ECalenMeetingIcon ); |
|
244 aIndexArray.AppendL( MCalenServices::ECalenTodoIconUndone ); |
|
245 aIndexArray.AppendL( MCalenServices::ECalenBirthdayIconMissed ); |
|
246 aIndexArray.AppendL( MCalenServices::ECalenDaynoteIconMissed ); |
|
247 aIndexArray.AppendL( MCalenServices::ECalenMeetingIconMissed ); |
|
248 aIndexArray.AppendL( MCalenServices::ECalenToDoIconMissed ); |
|
249 aIndexArray.AppendL( MCalenServices::ECalenClearMissedAlarms ); |
|
250 aIndexArray.AppendL( MCalenServices::ECalenClearAllMissedAlarms ) |
|
251 |
|
252 TRACE_EXIT_POINT; |
|
253 } |
|
254 |
|
255 // ---------------------------------------------------------------------------- |
|
256 // CCalenMissedAlarmsContainer::GetHelpContext |
|
257 // Get help context. |
|
258 // (other items were commented in a header). |
|
259 // ---------------------------------------------------------------------------- |
|
260 // |
|
261 void CCalenMissedAlarmsContainer::GetHelpContext(TCoeHelpContext& aContext) const |
|
262 { |
|
263 TRACE_ENTRY_POINT; |
|
264 |
|
265 aContext.iMajor = KUidCalendar; |
|
266 aContext.iContext = KCALE_HLP_MONTH_VIEW; // need to change |
|
267 |
|
268 TRACE_EXIT_POINT; |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CCalenMissedAlarmsContainer::MopSupplyObject |
|
273 // Pass the skin information |
|
274 // (other items were commented in a header). |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 TTypeUid::Ptr CCalenMissedAlarmsContainer::MopSupplyObject(TTypeUid aId) |
|
278 { |
|
279 TRACE_ENTRY_POINT; |
|
280 TRACE_EXIT_POINT; |
|
281 |
|
282 return MAknsControlContext::SupplyMopObject(aId, iBgContext); |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // CCalenMissedAlarmsContainer::ListBox |
|
287 // Returns the listbox |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 CAknDoubleGraphicStyleListBox* CCalenMissedAlarmsContainer::ListBox() const |
|
291 { |
|
292 TRACE_ENTRY_POINT; |
|
293 TRACE_EXIT_POINT; |
|
294 |
|
295 return iListBox; |
|
296 } |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // CCalenMissedAlarmsContainer::SizeChanged |
|
300 // Called by the framework when the view size is changed. |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 void CCalenMissedAlarmsContainer::SizeChanged() |
|
304 { |
|
305 TRACE_ENTRY_POINT; |
|
306 TRect main_pane( Rect() ); |
|
307 CCalenContainer::SizeChanged( main_pane ); |
|
308 |
|
309 if(iListBox) |
|
310 { |
|
311 iListBox->SetRect( main_pane ); |
|
312 } |
|
313 |
|
314 TRACE_EXIT_POINT; |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CCalenMissedAlarmsContainer::CountComponentControls |
|
319 // Gets the number of controls contained in a compound control. |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 TInt CCalenMissedAlarmsContainer::CountComponentControls() const |
|
323 { |
|
324 TRACE_ENTRY_POINT; |
|
325 TRACE_EXIT_POINT; |
|
326 |
|
327 return 1; |
|
328 } |
|
329 |
|
330 // ----------------------------------------------------------------------------- |
|
331 // CCalenMissedAlarmsContainer::ComponentControl |
|
332 // Gets the specified component of a compound control. |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 CCoeControl* CCalenMissedAlarmsContainer::ComponentControl(TInt aIndex) const |
|
336 { |
|
337 TRACE_ENTRY_POINT; |
|
338 TRACE_EXIT_POINT; |
|
339 switch (aIndex) |
|
340 { |
|
341 case 0: |
|
342 return iListBox; |
|
343 default: |
|
344 return NULL; |
|
345 } |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // CCalenMissedAlarmsContainer::OfferKeyEventL |
|
350 // Called by the framework when a key event needs to be processed. |
|
351 // ----------------------------------------------------------------------------- |
|
352 // |
|
353 TKeyResponse CCalenMissedAlarmsContainer::OfferKeyEventL( |
|
354 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
355 { |
|
356 TRACE_ENTRY_POINT; |
|
357 |
|
358 TKeyResponse ret(EKeyWasNotConsumed); |
|
359 |
|
360 if (EEventKey == aType) |
|
361 { |
|
362 switch (aKeyEvent.iCode) |
|
363 { |
|
364 case EKeyBackspace: |
|
365 case EKeyDelete: |
|
366 { |
|
367 iView->HandleCommandL(ECalenCmdClear); |
|
368 ret = EKeyWasConsumed; |
|
369 } |
|
370 break; |
|
371 default: |
|
372 break; |
|
373 } |
|
374 } |
|
375 |
|
376 if(ret == EKeyWasNotConsumed) |
|
377 { |
|
378 TInt oldCursor = iListBox->View()->CurrentItemIndex(); |
|
379 ret = iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
380 TInt newCursor = iListBox->View()->CurrentItemIndex(); |
|
381 if(oldCursor != newCursor) |
|
382 { |
|
383 iHighlightedRowNumber = newCursor; |
|
384 SetContextFromMissedAlarmEntryL(newCursor); |
|
385 } |
|
386 } |
|
387 TRACE_EXIT_POINT; |
|
388 return ret; |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // CCalenMissedAlarmsContainer::HandleResourceChange |
|
393 // Handles a change to the application's resources which are shared across the environment. |
|
394 // ----------------------------------------------------------------------------- |
|
395 // |
|
396 void CCalenMissedAlarmsContainer::HandleResourceChange(TInt aType) |
|
397 { |
|
398 TRACE_ENTRY_POINT; |
|
399 |
|
400 CCalenContainer::HandleResourceChange( aType ); |
|
401 |
|
402 if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch ) |
|
403 { |
|
404 SizeChanged(); |
|
405 |
|
406 // refresh |
|
407 TRAPD(error,iView->BeginRepopulationL()); |
|
408 if(error!=KErrNone) |
|
409 { |
|
410 // do avoid warning |
|
411 } |
|
412 } |
|
413 |
|
414 CCoeControl::HandleResourceChange( aType ); |
|
415 |
|
416 TRACE_EXIT_POINT; |
|
417 } |
|
418 |
|
419 // ----------------------------------------------------------------------------- |
|
420 // CCalenMissedAlarmsContainer::Draw |
|
421 // Draws the control |
|
422 // ----------------------------------------------------------------------------- |
|
423 // |
|
424 void CCalenMissedAlarmsContainer::Draw(const TRect& aRect) const |
|
425 { |
|
426 TRACE_ENTRY_POINT; |
|
427 |
|
428 CWindowGc& gc = SystemGc(); |
|
429 TRect main_pane( Rect() ); |
|
430 |
|
431 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
432 MAknsControlContext* cc = AknsDrawUtils::ControlContext(this); |
|
433 |
|
434 AknsDrawUtils::Background(skin, cc, this, gc, aRect); |
|
435 |
|
436 TRACE_EXIT_POINT; |
|
437 } |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // CCalenMissedAlarmsContainer::HandlePointerEventL |
|
441 // Handles the pointer events in touch resolutions |
|
442 // ----------------------------------------------------------------------------- |
|
443 // |
|
444 void CCalenMissedAlarmsContainer::HandlePointerEventL( |
|
445 const TPointerEvent& aPointerEvent) |
|
446 { |
|
447 TRACE_ENTRY_POINT; |
|
448 |
|
449 TInt pointerIndex(-1); |
|
450 TBool isItem (iListBox->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointerIndex)); |
|
451 |
|
452 if(isItem == EFalse) |
|
453 { |
|
454 iListBox->HandlePointerEventL(aPointerEvent); |
|
455 return; |
|
456 } |
|
457 |
|
458 TInt index = iListBox->CurrentItemIndex(); |
|
459 |
|
460 switch (aPointerEvent.iType) |
|
461 { |
|
462 case TPointerEvent::EButton1Down: |
|
463 { |
|
464 TInt oldCursor = iListBox->View()->CurrentItemIndex(); |
|
465 iListBox->HandlePointerEventL(aPointerEvent); |
|
466 TInt newCursor = iListBox->View()->CurrentItemIndex(); |
|
467 |
|
468 if (oldCursor != newCursor) |
|
469 { |
|
470 // set the context |
|
471 iHighlightedRowNumber = newCursor; |
|
472 SetContextFromMissedAlarmEntryL(newCursor); |
|
473 iFirstTap = EFalse; |
|
474 } |
|
475 else |
|
476 { |
|
477 iFirstTap = ETrue; |
|
478 } |
|
479 break; |
|
480 } |
|
481 case TPointerEvent::EDrag: |
|
482 { |
|
483 iListBox->HandlePointerEventL(aPointerEvent); |
|
484 if (iFirstTap && index != iListBox->CurrentItemIndex()) |
|
485 { |
|
486 iFirstTap = EFalse; |
|
487 } |
|
488 break; |
|
489 } |
|
490 |
|
491 case TPointerEvent::EButton1Up: |
|
492 { |
|
493 if (iFirstTap) |
|
494 { |
|
495 iView->HandleCommandL(ECalenMissedEventView); |
|
496 } |
|
497 break; |
|
498 } |
|
499 default: |
|
500 break; |
|
501 } |
|
502 |
|
503 TRACE_EXIT_POINT; |
|
504 } |
|
505 |
|
506 // ---------------------------------------------------------------------------- |
|
507 // CCalenMissedAlarmsContainer::HandleNaviDecoratorEventL |
|
508 // ?implementation_description |
|
509 // (other items were commented in a header). |
|
510 // ---------------------------------------------------------------------------- |
|
511 // |
|
512 void CCalenMissedAlarmsContainer::HandleNaviDecoratorEventL( TInt /*aEventID*/ ) |
|
513 { |
|
514 TRACE_ENTRY_POINT; |
|
515 |
|
516 TRACE_EXIT_POINT; |
|
517 } |
|
518 |
|
519 // ---------------------------------------------------------------------------- |
|
520 // CCalenMissedAlarmsContainer::HandleLongTapEventL |
|
521 // processing of a long tap event |
|
522 // (other items were commented in a header). |
|
523 // ---------------------------------------------------------------------------- |
|
524 // |
|
525 void CCalenMissedAlarmsContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/, |
|
526 const TPoint& /*aPenEventScreenLocation*/ ) |
|
527 { |
|
528 TRACE_ENTRY_POINT; |
|
529 |
|
530 TRACE_EXIT_POINT; |
|
531 } |
|
532 |
|
533 |
|
534 // ----------------------------------------------------------------------------- |
|
535 // CCalenMissedAlarmsContainer::CurrentItemIndex |
|
536 // Returns the current/highlighted listbox index |
|
537 // ----------------------------------------------------------------------------- |
|
538 // |
|
539 TInt CCalenMissedAlarmsContainer::CurrentItemIndex() |
|
540 { |
|
541 TRACE_ENTRY_POINT; |
|
542 TRACE_EXIT_POINT; |
|
543 |
|
544 return iListBox->CurrentItemIndex(); |
|
545 } |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // CCalenMissedAlarmsContainer::SetEmptyListTextL |
|
549 // Sets the empty list box text (no events) |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 void CCalenMissedAlarmsContainer::SetEmptyListTextL() |
|
553 { |
|
554 TRACE_ENTRY_POINT; |
|
555 |
|
556 HBufC* noEvents = StringLoader::LoadLC(R_CALEN_QTN_CALE_NO_EVENTS); |
|
557 iListBox->View()->SetListEmptyTextL(noEvents->Des()); |
|
558 CleanupStack::PopAndDestroy(noEvents); |
|
559 |
|
560 TRACE_EXIT_POINT; |
|
561 } |
|
562 |
|
563 // ----------------------------------------------------------------------------- |
|
564 // CCalenMissedAlarmsContainer::MissedAlarmsCount |
|
565 // Returns the missed alarms count. |
|
566 // ----------------------------------------------------------------------------- |
|
567 // |
|
568 TInt CCalenMissedAlarmsContainer::MissedAlarmsCount() |
|
569 { |
|
570 TRACE_ENTRY_POINT; |
|
571 TRACE_EXIT_POINT; |
|
572 |
|
573 return iMissedAlarmsArray.Count(); |
|
574 } |
|
575 |
|
576 // ---------------------------------------------------------------------------- |
|
577 // CCalenMissedAlarmsContainer::SetHighlightingL |
|
578 // Sets the highlighting |
|
579 // ---------------------------------------------------------------------------- |
|
580 // |
|
581 void CCalenMissedAlarmsContainer::SetHighlightingL() |
|
582 { |
|
583 TRACE_ENTRY_POINT; |
|
584 |
|
585 TInt focusIx = KErrNotFound; |
|
586 |
|
587 if ( iHighlightedRowNumber != KErrNotFound ) |
|
588 { |
|
589 focusIx = iHighlightedRowNumber; |
|
590 } |
|
591 else |
|
592 { |
|
593 MCalenContext& context = iServices.Context(); |
|
594 if ( !(context.InstanceId() == TCalenInstanceId::NullInstanceId()) ) |
|
595 { |
|
596 iHighlightedRowNumber = focusIx = FindMissedAlarmEntryIndexL(context.InstanceId()); |
|
597 } |
|
598 } |
|
599 |
|
600 // If everything else fails, focus on first item |
|
601 if ( focusIx == KErrNotFound ) |
|
602 { |
|
603 focusIx = 0; |
|
604 } |
|
605 |
|
606 // Set iHighlightedRowNumber as the current focus |
|
607 SetCurrentItemIndex( focusIx ); |
|
608 // Draw listbox with this new iHighlightedRowNumber value. |
|
609 // otherwise we won't get updated focus |
|
610 SetCurrentItemIndexAndDraw(); |
|
611 |
|
612 TRACE_EXIT_POINT; |
|
613 } |
|
614 |
|
615 // ---------------------------------------------------------------------------- |
|
616 // CCalenTodoContainer::SetCurrentItemIndex |
|
617 // Set current item index. |
|
618 // (other items were commented in a header). |
|
619 // ---------------------------------------------------------------------------- |
|
620 // |
|
621 void CCalenMissedAlarmsContainer::SetCurrentItemIndex(TInt aIndex) |
|
622 { |
|
623 TRACE_ENTRY_POINT; |
|
624 |
|
625 TInt count(iMissedAlarmsArray.Count()); |
|
626 if( aIndex < count ) |
|
627 { |
|
628 iHighlightedRowNumber = aIndex; |
|
629 } |
|
630 else |
|
631 { |
|
632 iHighlightedRowNumber = count-1; |
|
633 } |
|
634 |
|
635 TRACE_EXIT_POINT; |
|
636 } |
|
637 |
|
638 // ---------------------------------------------------------------------------- |
|
639 // CCalenMissedAlarmsContainer::SetCurrentItemIndexAndDraw |
|
640 // Set current item index and draw list. |
|
641 // ---------------------------------------------------------------------------- |
|
642 // |
|
643 void CCalenMissedAlarmsContainer::SetCurrentItemIndexAndDraw() |
|
644 { |
|
645 TRACE_ENTRY_POINT; |
|
646 |
|
647 if( iHighlightedRowNumber != KErrNotFound && |
|
648 iHighlightedRowNumber < iListBox->Model()->NumberOfItems() ) |
|
649 { |
|
650 iListBox->SetCurrentItemIndexAndDraw( iHighlightedRowNumber ); |
|
651 } |
|
652 |
|
653 TRACE_EXIT_POINT; |
|
654 } |
|
655 |
|
656 // ----------------------------------------------------------------------------- |
|
657 // CCalenMissedAlarmsContainer::UpdateMissedAlarmsArray |
|
658 // Update Missed Alarms Array |
|
659 // ----------------------------------------------------------------------------- |
|
660 // |
|
661 void CCalenMissedAlarmsContainer::UpdateMissedAlarmsArrayL() |
|
662 { |
|
663 TRACE_ENTRY_POINT; |
|
664 |
|
665 if(iMissedAlarmsArray.Count()) |
|
666 { |
|
667 iMissedAlarmsArray.Reset(); |
|
668 } |
|
669 |
|
670 // get missed alarms list from services |
|
671 iServices.GetMissedAlarmsList(iMissedAlarmsArray); |
|
672 |
|
673 // Get the missed alarms count |
|
674 iMissedAlarmStore->CountL(iMissedAlarmsCount); |
|
675 |
|
676 TRACE_EXIT_POINT; |
|
677 } |
|
678 |
|
679 // ---------------------------------------------------------------------------- |
|
680 // CCalenMissedAlarmsContainer::PopulateWithMissedAlarmsL |
|
681 // Populate Missed alarms view |
|
682 // ---------------------------------------------------------------------------- |
|
683 // |
|
684 void CCalenMissedAlarmsContainer::PopulateWithMissedAlarmsL() |
|
685 { |
|
686 TRACE_ENTRY_POINT; |
|
687 |
|
688 // resets list box item array |
|
689 if(iListBoxItemArray) |
|
690 { |
|
691 delete iListBoxItemArray; |
|
692 iListBoxItemArray = NULL; |
|
693 } |
|
694 |
|
695 iListBoxItemArray = new(ELeave) CDesCArrayFlat(KMissedAlarmListBoxItems); |
|
696 |
|
697 if(iMissedAlarmsArray.Count()) |
|
698 { |
|
699 for(TInt index = 0;index < iMissedAlarmsArray.Count(); index++ ) |
|
700 { |
|
701 CreateListBoxDataL(index); |
|
702 } |
|
703 iListBox->Model()->SetItemTextArray(iListBoxItemArray); |
|
704 |
|
705 if(!iHighlightedRowNumber || iHighlightedRowNumber == KErrNotFound ) |
|
706 { |
|
707 //set first missed alarm entry to the context |
|
708 SetContextFromMissedAlarmEntryL(0); |
|
709 } |
|
710 iListBox->HandleItemAdditionL(); |
|
711 } |
|
712 else |
|
713 { |
|
714 iListBox->Model()->SetItemTextArray(iListBoxItemArray); |
|
715 SetEmptyListTextL(); |
|
716 } |
|
717 |
|
718 TRACE_EXIT_POINT; |
|
719 } |
|
720 |
|
721 // ----------------------------------------------------------------------------- |
|
722 // CCalenMissedAlarmsContainer::CreateListBoxDataL |
|
723 // Creates the list box items and appends in to listrbox item array |
|
724 // ----------------------------------------------------------------------------- |
|
725 // |
|
726 void CCalenMissedAlarmsContainer::CreateListBoxDataL(TInt aIndex) |
|
727 { |
|
728 TRACE_ENTRY_POINT; |
|
729 |
|
730 // temporary buffer |
|
731 HBufC* buffer = HBufC::NewLC( KListDataLength ); |
|
732 CleanupStack::Pop(buffer); |
|
733 |
|
734 // initialise the item to construct a new listbox entry |
|
735 buffer->Des().Zero(); |
|
736 |
|
737 // double graphic style "0\tText\tText2\t1 |
|
738 TPtr ptr( buffer->Des() ); |
|
739 |
|
740 CCalEntry* entry = NULL; |
|
741 TTime instanceTime; |
|
742 TInt isEventViewed; |
|
743 |
|
744 // Get the missed alarm entry |
|
745 entry = GetMissedAlarmEntryL(aIndex); |
|
746 |
|
747 // Get the instance time |
|
748 instanceTime = GetInstanceTime(aIndex); |
|
749 |
|
750 // Get the viewed event info |
|
751 isEventViewed = GetViewedEventInfo(aIndex); |
|
752 |
|
753 if(entry) |
|
754 { |
|
755 // get the icon from the entry |
|
756 TBuf<10> icon; |
|
757 TInt iconIndex(0); |
|
758 iconIndex =IconIndexForEntryL( *entry , isEventViewed); |
|
759 icon.Format(KIconFormat,iconIndex); |
|
760 |
|
761 ptr.Append(icon); |
|
762 ptr.Append(KListSeparator); |
|
763 |
|
764 // get the subject from the entry |
|
765 // Set summary |
|
766 // Create temporary buffer for summary |
|
767 |
|
768 HBufC* summary = HBufC::NewLC( KMissedAlarmListMaxLength ); |
|
769 TPtr summaryPtr = summary->Des(); |
|
770 TInt maxLength = summary->Length()- KMissedAlarmListMaxLength; |
|
771 CalenViewUtils::GetSummaryLocationTextL( *entry, summaryPtr, KMissedAlarmListMaxLength ); |
|
772 |
|
773 AknBidiTextUtils::ConvertToVisualAndClipL( summaryPtr, |
|
774 *iEikonEnv->NormalFont(), |
|
775 KListDataLength, |
|
776 KListDataLength ); |
|
777 ptr.Append(summary->Des()); |
|
778 ptr.Append(KListSeparator); |
|
779 |
|
780 CleanupStack::PopAndDestroy( summary ); |
|
781 |
|
782 // get the start time and date |
|
783 // for timed display both start time and date |
|
784 // append start time of the instance |
|
785 TBuf<10> timeString; |
|
786 |
|
787 if(entry->EntryTypeL() == CCalEntry::EAppt ) |
|
788 { |
|
789 HBufC* timeFormat = StringLoader::LoadLC(R_QTN_TIME_USUAL_WITH_ZERO); |
|
790 instanceTime.FormatL(timeString, *timeFormat); |
|
791 // convert the date numbers into Arabic-Indic numbers |
|
792 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeString ); |
|
793 CleanupStack::PopAndDestroy(timeFormat); |
|
794 } |
|
795 |
|
796 //append date |
|
797 TBuf<20> dateString; |
|
798 HBufC* dateFormat = StringLoader::LoadLC(R_QTN_DATE_USUAL_WITH_ZERO); |
|
799 instanceTime.FormatL(dateString, *dateFormat); |
|
800 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dateString ); |
|
801 CleanupStack::PopAndDestroy(dateFormat); |
|
802 |
|
803 CDesCArrayFlat* strings = new (ELeave) CDesCArrayFlat(2); |
|
804 CleanupStack::PushL( strings ); |
|
805 |
|
806 strings->AppendL(timeString); |
|
807 strings->AppendL(dateString); |
|
808 |
|
809 HBufC* timeDateFormat = StringLoader::LoadL(R_CALE_MAV_START_TIME,*strings); |
|
810 CleanupStack::PushL( timeDateFormat ); |
|
811 ptr.Append(timeDateFormat->Des()); |
|
812 CleanupStack::PopAndDestroy(timeDateFormat); |
|
813 CleanupStack::PopAndDestroy(strings);// strings |
|
814 |
|
815 CleanupStack::PopAndDestroy(entry); |
|
816 |
|
817 ptr.Append( KListSeparator ); |
|
818 |
|
819 iListBoxItemArray->AppendL(ptr); |
|
820 } |
|
821 |
|
822 delete buffer; |
|
823 |
|
824 TRACE_EXIT_POINT; |
|
825 } |
|
826 |
|
827 // ----------------------------------------------------------------------------- |
|
828 // CCalenMissedAlarmsContainer::GetMissedAlarmEntryL |
|
829 // Get a Missed Alarm entry based on the index |
|
830 // ----------------------------------------------------------------------------- |
|
831 // |
|
832 CCalEntry* CCalenMissedAlarmsContainer::GetMissedAlarmEntryL(TInt aIndex) const |
|
833 { |
|
834 TRACE_ENTRY_POINT; |
|
835 |
|
836 TInt localUid; |
|
837 TTime instanceTime; |
|
838 TCalenInstanceId missedAlarm = iMissedAlarmsArray[aIndex]; |
|
839 |
|
840 // get the local uid and instancetime |
|
841 localUid = missedAlarm.iEntryLocalUid; |
|
842 instanceTime = missedAlarm.iInstanceTime; |
|
843 |
|
844 CCalEntry* entry=NULL; |
|
845 // Get the entry using the localUid |
|
846 TRAP_IGNORE(entry=iServices.EntryViewL(missedAlarm.iColId)->FetchL(localUid)); |
|
847 |
|
848 CleanupStack::PushL(entry); |
|
849 |
|
850 TRACE_EXIT_POINT; |
|
851 return entry; |
|
852 } |
|
853 |
|
854 // ----------------------------------------------------------------------------- |
|
855 // CCalenMissedAlarmsContainer::GetInstanceTime |
|
856 // Get the instance time |
|
857 // ----------------------------------------------------------------------------- |
|
858 // |
|
859 TTime CCalenMissedAlarmsContainer::GetInstanceTime(TInt aIndex) const |
|
860 { |
|
861 TRACE_ENTRY_POINT; |
|
862 |
|
863 TCalenInstanceId missedAlarm = iMissedAlarmsArray[aIndex]; |
|
864 |
|
865 TRACE_EXIT_POINT; |
|
866 return missedAlarm.iInstanceTime; |
|
867 } |
|
868 |
|
869 // ----------------------------------------------------------------------------- |
|
870 // CCalenMissedAlarmsContainer::GetViewedEventInfo |
|
871 // Get the viewed event information |
|
872 // ----------------------------------------------------------------------------- |
|
873 // |
|
874 TInt CCalenMissedAlarmsContainer::GetViewedEventInfo(TInt aIndex) |
|
875 { |
|
876 TRACE_ENTRY_POINT; |
|
877 |
|
878 TCalenInstanceId missedAlarm= iMissedAlarmsArray[aIndex]; |
|
879 |
|
880 TRACE_EXIT_POINT; |
|
881 return missedAlarm.iInstanceViewed; |
|
882 } |
|
883 |
|
884 // ---------------------------------------------------------------------------- |
|
885 // CCalenMissedAlarmsContainer::CompletePopulationL |
|
886 // Complete population |
|
887 // ---------------------------------------------------------------------------- |
|
888 // |
|
889 void CCalenMissedAlarmsContainer::CompletePopulationL() |
|
890 { |
|
891 TRACE_ENTRY_POINT; |
|
892 |
|
893 AddToStackAndMakeVisibleL(); |
|
894 SetHighlightingL(); |
|
895 DrawDeferred(); |
|
896 |
|
897 TRACE_EXIT_POINT; |
|
898 } |
|
899 |
|
900 // ----------------------------------------------------------------------------- |
|
901 // CCalenMissedAlarmsContainer::SetContextFromMissedAlarmEntryL |
|
902 // Sets the context from the current focused missed alarm entry |
|
903 // ----------------------------------------------------------------------------- |
|
904 // |
|
905 void CCalenMissedAlarmsContainer::SetContextFromMissedAlarmEntryL(TInt aIndex) |
|
906 { |
|
907 TRACE_ENTRY_POINT; |
|
908 |
|
909 TCalenInstanceId missedAlarm = iMissedAlarmsArray[aIndex]; |
|
910 |
|
911 CCalEntry* entry = iServices.EntryViewL(missedAlarm.iColId)->FetchL( missedAlarm.iEntryLocalUid ); |
|
912 User::LeaveIfNull( entry ); |
|
913 CleanupStack::PushL( entry ); |
|
914 |
|
915 TTime instanceTime; |
|
916 TCalTime inscaltime; |
|
917 |
|
918 instanceTime = CalenAgendaUtils::EntryTimeL( *entry ); |
|
919 inscaltime.SetTimeLocalL( instanceTime ); |
|
920 |
|
921 // set the context |
|
922 MCalenContext &context = iServices.Context(); |
|
923 TCalenInstanceId id = TCalenInstanceId::CreateL( *entry, inscaltime ); |
|
924 id.iColId = missedAlarm.iColId; |
|
925 context.SetInstanceIdL( id, context.ViewId() ); |
|
926 |
|
927 CleanupStack::PopAndDestroy( entry ); |
|
928 |
|
929 TRACE_EXIT_POINT; |
|
930 } |
|
931 |
|
932 // ----------------------------------------------------------------------------- |
|
933 // CCalenMissedAlarmsContainer::FindMissedAlarmEntryIndexL |
|
934 // Find missed alarm entry's index |
|
935 // ----------------------------------------------------------------------------- |
|
936 // |
|
937 TInt CCalenMissedAlarmsContainer::FindMissedAlarmEntryIndexL( |
|
938 const TCalenInstanceId& aId) |
|
939 { |
|
940 TRACE_ENTRY_POINT; |
|
941 |
|
942 for(TInt index(0); index < iMissedAlarmsArray.Count(); ++index) |
|
943 { |
|
944 if( iMissedAlarmsArray[index].iEntryLocalUid == aId.iEntryLocalUid ) |
|
945 { |
|
946 TRACE_EXIT_POINT; |
|
947 return index; |
|
948 } |
|
949 } |
|
950 |
|
951 TRACE_EXIT_POINT; |
|
952 return KErrNotFound; |
|
953 } |
|
954 |
|
955 // End of File |