|
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 iListBox->SetListBoxObserver( this ); // single click changes MK |
|
143 // set the model array |
|
144 iListBox->Model()->SetItemTextArray(iListBoxItemArray); |
|
145 |
|
146 // set icon array |
|
147 CAknIconArray* iconArray = CreateIconsL( iIconIndices, KCalenMissedAlarmsViewUidValue ); |
|
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 //Set toolbar visibility to false, bcoz this view is not using the ToolBar |
|
157 MCalenToolbar* toolbar = iServices.ToolbarOrNull(); |
|
158 if(toolbar) |
|
159 { |
|
160 toolbar->SetToolbarVisibilityL(EFalse); |
|
161 } |
|
162 |
|
163 TRACE_EXIT_POINT; |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------------------------------- |
|
167 // CCalenMissedAlarmsContainer::UpdateSize |
|
168 // Do layout changes after calendar settings are |
|
169 // changed. No necessary actions for this view. |
|
170 // ---------------------------------------------------------------------------- |
|
171 // |
|
172 void CCalenMissedAlarmsContainer::UpdateSize() |
|
173 { |
|
174 TRACE_ENTRY_POINT; |
|
175 TRACE_EXIT_POINT; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CCalenMissedAlarmsContainer::IconIndexForEntryL |
|
180 // Gets the Icon Index for the missed alarm entry |
|
181 // (other items were commented in a header). |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 TInt CCalenMissedAlarmsContainer::IconIndexForEntryL(CCalEntry& aEntry, |
|
185 TInt aSeenMissedAlarm) |
|
186 { |
|
187 TRACE_ENTRY_POINT; |
|
188 TInt iconIndex(0); |
|
189 |
|
190 if(aSeenMissedAlarm) |
|
191 { |
|
192 switch(aEntry.EntryTypeL()) |
|
193 { |
|
194 case CCalEntry::EAnniv: |
|
195 iconIndex = IconIndex(MCalenServices::ECalenBirthdayIcon); |
|
196 break; |
|
197 case CCalEntry::EEvent: |
|
198 iconIndex = IconIndex(MCalenServices::ECalenDaynoteIcon); |
|
199 break; |
|
200 case CCalEntry::EAppt: |
|
201 iconIndex = IconIndex(MCalenServices::ECalenMeetingIcon); |
|
202 break; |
|
203 case CCalEntry::ETodo: |
|
204 iconIndex = IconIndex(MCalenServices::ECalenTodoIconUndone); |
|
205 break; |
|
206 default: |
|
207 ASSERT( EFalse ); |
|
208 break; |
|
209 } |
|
210 } |
|
211 else |
|
212 { |
|
213 switch(aEntry.EntryTypeL()) |
|
214 { |
|
215 case CCalEntry::EAnniv: |
|
216 iconIndex = IconIndex(MCalenServices::ECalenBirthdayIconMissed); |
|
217 break; |
|
218 case CCalEntry::EEvent: |
|
219 iconIndex = IconIndex(MCalenServices::ECalenDaynoteIconMissed); |
|
220 break; |
|
221 case CCalEntry::EAppt: |
|
222 iconIndex = IconIndex(MCalenServices::ECalenMeetingIconMissed); |
|
223 break; |
|
224 case CCalEntry::ETodo: |
|
225 iconIndex = IconIndex(MCalenServices::ECalenToDoIconMissed); |
|
226 break; |
|
227 default: |
|
228 ASSERT( EFalse ); |
|
229 break; |
|
230 } |
|
231 } |
|
232 return iconIndex; |
|
233 TRACE_EXIT_POINT; |
|
234 } |
|
235 |
|
236 // ---------------------------------------------------------------------------- |
|
237 // CCalenMissedAlarmsContainer::CreateIconIndicesL |
|
238 // Fill the list of icons used by the MAV |
|
239 // (other items were commented in a header). |
|
240 // ---------------------------------------------------------------------------- |
|
241 // |
|
242 void CCalenMissedAlarmsContainer::CreateIconIndicesL( |
|
243 RArray<MCalenServices::TCalenIcons>& aIndexArray) |
|
244 { |
|
245 TRACE_ENTRY_POINT; |
|
246 |
|
247 aIndexArray.Reset(); |
|
248 aIndexArray.AppendL( MCalenServices::ECalenBirthdayIcon ); |
|
249 aIndexArray.AppendL( MCalenServices::ECalenDaynoteIcon ); |
|
250 aIndexArray.AppendL( MCalenServices::ECalenMeetingIcon ); |
|
251 aIndexArray.AppendL( MCalenServices::ECalenTodoIconUndone ); |
|
252 aIndexArray.AppendL( MCalenServices::ECalenBirthdayIconMissed ); |
|
253 aIndexArray.AppendL( MCalenServices::ECalenDaynoteIconMissed ); |
|
254 aIndexArray.AppendL( MCalenServices::ECalenMeetingIconMissed ); |
|
255 aIndexArray.AppendL( MCalenServices::ECalenToDoIconMissed ); |
|
256 aIndexArray.AppendL( MCalenServices::ECalenClearMissedAlarms ); |
|
257 aIndexArray.AppendL( MCalenServices::ECalenClearAllMissedAlarms ) |
|
258 |
|
259 TRACE_EXIT_POINT; |
|
260 } |
|
261 |
|
262 // ---------------------------------------------------------------------------- |
|
263 // CCalenMissedAlarmsContainer::GetHelpContext |
|
264 // Get help context. |
|
265 // (other items were commented in a header). |
|
266 // ---------------------------------------------------------------------------- |
|
267 // |
|
268 void CCalenMissedAlarmsContainer::GetHelpContext(TCoeHelpContext& aContext) const |
|
269 { |
|
270 TRACE_ENTRY_POINT; |
|
271 |
|
272 aContext.iMajor = KUidCalendar; |
|
273 aContext.iContext = KCALE_HLP_MONTH_VIEW; // need to change |
|
274 |
|
275 TRACE_EXIT_POINT; |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CCalenMissedAlarmsContainer::MopSupplyObject |
|
280 // Pass the skin information |
|
281 // (other items were commented in a header). |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 TTypeUid::Ptr CCalenMissedAlarmsContainer::MopSupplyObject(TTypeUid aId) |
|
285 { |
|
286 TRACE_ENTRY_POINT; |
|
287 TRACE_EXIT_POINT; |
|
288 |
|
289 return MAknsControlContext::SupplyMopObject(aId, iBgContext); |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CCalenMissedAlarmsContainer::ListBox |
|
294 // Returns the listbox |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 CAknDoubleGraphicStyleListBox* CCalenMissedAlarmsContainer::ListBox() const |
|
298 { |
|
299 TRACE_ENTRY_POINT; |
|
300 TRACE_EXIT_POINT; |
|
301 |
|
302 return iListBox; |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CCalenMissedAlarmsContainer::SizeChanged |
|
307 // Called by the framework when the view size is changed. |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void CCalenMissedAlarmsContainer::SizeChanged() |
|
311 { |
|
312 TRACE_ENTRY_POINT; |
|
313 TRect main_pane( Rect() ); |
|
314 CCalenContainer::SizeChanged( main_pane ); |
|
315 |
|
316 if(iListBox) |
|
317 { |
|
318 iListBox->SetRect( main_pane ); |
|
319 } |
|
320 |
|
321 TRACE_EXIT_POINT; |
|
322 } |
|
323 |
|
324 // ----------------------------------------------------------------------------- |
|
325 // CCalenMissedAlarmsContainer::CountComponentControls |
|
326 // Gets the number of controls contained in a compound control. |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 TInt CCalenMissedAlarmsContainer::CountComponentControls() const |
|
330 { |
|
331 TRACE_ENTRY_POINT; |
|
332 TRACE_EXIT_POINT; |
|
333 |
|
334 return 1; |
|
335 } |
|
336 |
|
337 // ----------------------------------------------------------------------------- |
|
338 // CCalenMissedAlarmsContainer::ComponentControl |
|
339 // Gets the specified component of a compound control. |
|
340 // ----------------------------------------------------------------------------- |
|
341 // |
|
342 CCoeControl* CCalenMissedAlarmsContainer::ComponentControl(TInt aIndex) const |
|
343 { |
|
344 TRACE_ENTRY_POINT; |
|
345 TRACE_EXIT_POINT; |
|
346 switch (aIndex) |
|
347 { |
|
348 case 0: |
|
349 return iListBox; |
|
350 default: |
|
351 return NULL; |
|
352 } |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // CCalenMissedAlarmsContainer::OfferKeyEventL |
|
357 // Called by the framework when a key event needs to be processed. |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 TKeyResponse CCalenMissedAlarmsContainer::OfferKeyEventL( |
|
361 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
362 { |
|
363 TRACE_ENTRY_POINT; |
|
364 |
|
365 TKeyResponse ret(EKeyWasNotConsumed); |
|
366 |
|
367 if (EEventKey == aType) |
|
368 { |
|
369 switch (aKeyEvent.iCode) |
|
370 { |
|
371 case EKeyBackspace: |
|
372 case EKeyDelete: |
|
373 { |
|
374 iView->HandleCommandL(ECalenCmdClear); |
|
375 ret = EKeyWasConsumed; |
|
376 } |
|
377 break; |
|
378 default: |
|
379 break; |
|
380 } |
|
381 } |
|
382 |
|
383 if(ret == EKeyWasNotConsumed) |
|
384 { |
|
385 TInt oldCursor = iListBox->View()->CurrentItemIndex(); |
|
386 ret = iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
387 TInt newCursor = iListBox->View()->CurrentItemIndex(); |
|
388 if(oldCursor != newCursor) |
|
389 { |
|
390 iHighlightedRowNumber = newCursor; |
|
391 SetContextFromMissedAlarmEntryL(newCursor); |
|
392 } |
|
393 } |
|
394 TRACE_EXIT_POINT; |
|
395 return ret; |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CCalenMissedAlarmsContainer::HandleResourceChange |
|
400 // Handles a change to the application's resources which are shared across the environment. |
|
401 // ----------------------------------------------------------------------------- |
|
402 // |
|
403 void CCalenMissedAlarmsContainer::HandleResourceChange(TInt aType) |
|
404 { |
|
405 TRACE_ENTRY_POINT; |
|
406 |
|
407 CCalenContainer::HandleResourceChange( aType ); |
|
408 |
|
409 if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch ) |
|
410 { |
|
411 SizeChanged(); |
|
412 /*TRect main_pane; |
|
413 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, main_pane ); |
|
414 SetRect( main_pane ); |
|
415 if(iListBox) |
|
416 { |
|
417 TRect mainPane; |
|
418 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
419 TRect bgContextRect( TPoint(0, 0), mainPane.Size() ); |
|
420 iListBox->SetRect( bgContextRect ); |
|
421 }*/ |
|
422 |
|
423 // refresh |
|
424 TRAPD(error,iView->BeginRepopulationL()); |
|
425 if(error!=KErrNone) |
|
426 { |
|
427 // do avoid warning |
|
428 } |
|
429 } |
|
430 |
|
431 CCoeControl::HandleResourceChange( aType ); |
|
432 |
|
433 TRACE_EXIT_POINT; |
|
434 } |
|
435 |
|
436 // ----------------------------------------------------------------------------- |
|
437 // CCalenMissedAlarmsContainer::Draw |
|
438 // Draws the control |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 void CCalenMissedAlarmsContainer::Draw(const TRect& aRect) const |
|
442 { |
|
443 TRACE_ENTRY_POINT; |
|
444 |
|
445 CWindowGc& gc = SystemGc(); |
|
446 TRect main_pane( Rect() ); |
|
447 |
|
448 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
449 MAknsControlContext* cc = AknsDrawUtils::ControlContext(this); |
|
450 |
|
451 AknsDrawUtils::Background(skin, cc, this, gc, aRect); |
|
452 |
|
453 TRACE_EXIT_POINT; |
|
454 } |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // CCalenMissedAlarmsContainer::HandlePointerEventL |
|
458 // Handles the pointer events in touch resolutions |
|
459 // ----------------------------------------------------------------------------- |
|
460 // |
|
461 void CCalenMissedAlarmsContainer::HandlePointerEventL( |
|
462 const TPointerEvent& aPointerEvent) |
|
463 { |
|
464 TRACE_ENTRY_POINT; |
|
465 |
|
466 TInt pointerIndex(-1); |
|
467 TBool isItem (iListBox->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointerIndex)); |
|
468 |
|
469 if(isItem == EFalse) |
|
470 { |
|
471 iListBox->HandlePointerEventL(aPointerEvent); |
|
472 return; |
|
473 } |
|
474 |
|
475 TInt index = iListBox->CurrentItemIndex(); |
|
476 |
|
477 switch (aPointerEvent.iType) |
|
478 { |
|
479 case TPointerEvent::EButton1Down: |
|
480 { |
|
481 TBool isItem (iListBox->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointerIndex)); |
|
482 |
|
483 if(isItem && MissedAlarmsCount() > 0) |
|
484 { |
|
485 iHighlightedRowNumber = iListBox->View()->CurrentItemIndex(); |
|
486 SetContextFromMissedAlarmEntryL(iListBox->View()->CurrentItemIndex()); |
|
487 } |
|
488 |
|
489 break; |
|
490 } |
|
491 case TPointerEvent::EDrag: |
|
492 { |
|
493 /*iListBox->HandlePointerEventL(aPointerEvent); |
|
494 if (iFirstTap && index != iListBox->CurrentItemIndex()) |
|
495 { |
|
496 iFirstTap = EFalse; |
|
497 }*/ |
|
498 break; |
|
499 } |
|
500 |
|
501 case TPointerEvent::EButton1Up: |
|
502 { |
|
503 // if (iFirstTap) |
|
504 { |
|
505 // iView->HandleCommandL(ECalenMissedEventView); |
|
506 } |
|
507 break; |
|
508 } |
|
509 default: |
|
510 break; |
|
511 } |
|
512 |
|
513 if ( aPointerEvent.iType != TPointerEvent::EButtonRepeat ) |
|
514 { |
|
515 iListBox->HandlePointerEventL( aPointerEvent ); |
|
516 } |
|
517 |
|
518 TRACE_EXIT_POINT; |
|
519 } |
|
520 |
|
521 // ---------------------------------------------------------------------------- |
|
522 // CCalenMissedAlarmsContainer::HandleNaviDecoratorEventL |
|
523 // ?implementation_description |
|
524 // (other items were commented in a header). |
|
525 // ---------------------------------------------------------------------------- |
|
526 // |
|
527 void CCalenMissedAlarmsContainer::HandleNaviDecoratorEventL( TInt /*aEventID*/ ) |
|
528 { |
|
529 TRACE_ENTRY_POINT; |
|
530 |
|
531 TRACE_EXIT_POINT; |
|
532 } |
|
533 |
|
534 // ---------------------------------------------------------------------------- |
|
535 // CCalenMissedAlarmsContainer::HandleLongTapEventL |
|
536 // processing of a long tap event |
|
537 // (other items were commented in a header). |
|
538 // ---------------------------------------------------------------------------- |
|
539 // |
|
540 void CCalenMissedAlarmsContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/, |
|
541 const TPoint& /*aPenEventScreenLocation*/ ) |
|
542 { |
|
543 TRACE_ENTRY_POINT; |
|
544 |
|
545 TRACE_EXIT_POINT; |
|
546 } |
|
547 |
|
548 |
|
549 // ----------------------------------------------------------------------------- |
|
550 // CCalenMissedAlarmsContainer::CurrentItemIndex |
|
551 // Returns the current/highlighted listbox index |
|
552 // ----------------------------------------------------------------------------- |
|
553 // |
|
554 TInt CCalenMissedAlarmsContainer::CurrentItemIndex() |
|
555 { |
|
556 TRACE_ENTRY_POINT; |
|
557 TRACE_EXIT_POINT; |
|
558 |
|
559 return iListBox->CurrentItemIndex(); |
|
560 } |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // CCalenMissedAlarmsContainer::SetEmptyListTextL |
|
564 // Sets the empty list box text (no events) |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 void CCalenMissedAlarmsContainer::SetEmptyListTextL() |
|
568 { |
|
569 TRACE_ENTRY_POINT; |
|
570 |
|
571 HBufC* noEvents = StringLoader::LoadLC(R_CALEN_QTN_CALE_NO_EVENTS); |
|
572 iListBox->View()->SetListEmptyTextL(noEvents->Des()); |
|
573 CleanupStack::PopAndDestroy(noEvents); |
|
574 |
|
575 TRACE_EXIT_POINT; |
|
576 } |
|
577 |
|
578 // ----------------------------------------------------------------------------- |
|
579 // CCalenMissedAlarmsContainer::MissedAlarmsCount |
|
580 // Returns the missed alarms count. |
|
581 // ----------------------------------------------------------------------------- |
|
582 // |
|
583 TInt CCalenMissedAlarmsContainer::MissedAlarmsCount() |
|
584 { |
|
585 TRACE_ENTRY_POINT; |
|
586 TRACE_EXIT_POINT; |
|
587 |
|
588 return iMissedAlarmsArray.Count(); |
|
589 } |
|
590 |
|
591 // ---------------------------------------------------------------------------- |
|
592 // CCalenMissedAlarmsContainer::SetHighlightingL |
|
593 // Sets the highlighting |
|
594 // ---------------------------------------------------------------------------- |
|
595 // |
|
596 void CCalenMissedAlarmsContainer::SetHighlightingL() |
|
597 { |
|
598 TRACE_ENTRY_POINT; |
|
599 |
|
600 TInt focusIx = KErrNotFound; |
|
601 |
|
602 if ( iHighlightedRowNumber != KErrNotFound ) |
|
603 { |
|
604 focusIx = iHighlightedRowNumber; |
|
605 } |
|
606 else |
|
607 { |
|
608 MCalenContext& context = iServices.Context(); |
|
609 if ( !(context.InstanceId() == TCalenInstanceId::NullInstanceId()) ) |
|
610 { |
|
611 iHighlightedRowNumber = focusIx = FindMissedAlarmEntryIndexL(context.InstanceId()); |
|
612 } |
|
613 } |
|
614 |
|
615 // If everything else fails, focus on first item |
|
616 if ( focusIx == KErrNotFound ) |
|
617 { |
|
618 focusIx = 0; |
|
619 } |
|
620 |
|
621 // Set iHighlightedRowNumber as the current focus |
|
622 SetCurrentItemIndex( focusIx ); |
|
623 // Draw listbox with this new iHighlightedRowNumber value. |
|
624 // otherwise we won't get updated focus |
|
625 SetCurrentItemIndexAndDraw(); |
|
626 |
|
627 TRACE_EXIT_POINT; |
|
628 } |
|
629 |
|
630 // ---------------------------------------------------------------------------- |
|
631 // CCalenTodoContainer::SetCurrentItemIndex |
|
632 // Set current item index. |
|
633 // (other items were commented in a header). |
|
634 // ---------------------------------------------------------------------------- |
|
635 // |
|
636 void CCalenMissedAlarmsContainer::SetCurrentItemIndex(TInt aIndex) |
|
637 { |
|
638 TRACE_ENTRY_POINT; |
|
639 |
|
640 TInt count(iMissedAlarmsArray.Count()); |
|
641 if( aIndex < count ) |
|
642 { |
|
643 iHighlightedRowNumber = aIndex; |
|
644 } |
|
645 else |
|
646 { |
|
647 iHighlightedRowNumber = count-1; |
|
648 } |
|
649 |
|
650 TRACE_EXIT_POINT; |
|
651 } |
|
652 |
|
653 // ---------------------------------------------------------------------------- |
|
654 // CCalenMissedAlarmsContainer::SetCurrentItemIndexAndDraw |
|
655 // Set current item index and draw list. |
|
656 // ---------------------------------------------------------------------------- |
|
657 // |
|
658 void CCalenMissedAlarmsContainer::SetCurrentItemIndexAndDraw() |
|
659 { |
|
660 TRACE_ENTRY_POINT; |
|
661 |
|
662 if( iHighlightedRowNumber != KErrNotFound && |
|
663 iHighlightedRowNumber < iListBox->Model()->NumberOfItems() ) |
|
664 { |
|
665 iListBox->SetCurrentItemIndexAndDraw( iHighlightedRowNumber ); |
|
666 } |
|
667 |
|
668 TRACE_EXIT_POINT; |
|
669 } |
|
670 |
|
671 // ----------------------------------------------------------------------------- |
|
672 // CCalenMissedAlarmsContainer::UpdateMissedAlarmsArray |
|
673 // Update Missed Alarms Array |
|
674 // ----------------------------------------------------------------------------- |
|
675 // |
|
676 void CCalenMissedAlarmsContainer::UpdateMissedAlarmsArrayL() |
|
677 { |
|
678 TRACE_ENTRY_POINT; |
|
679 |
|
680 if(iMissedAlarmsArray.Count()) |
|
681 { |
|
682 iMissedAlarmsArray.Reset(); |
|
683 } |
|
684 |
|
685 // get missed alarms list from services |
|
686 iServices.GetMissedAlarmsList(iMissedAlarmsArray); |
|
687 |
|
688 // Get the missed alarms count |
|
689 iMissedAlarmStore->CountL(iMissedAlarmsCount); |
|
690 |
|
691 TRACE_EXIT_POINT; |
|
692 } |
|
693 |
|
694 // ---------------------------------------------------------------------------- |
|
695 // CCalenMissedAlarmsContainer::PopulateWithMissedAlarmsL |
|
696 // Populate Missed alarms view |
|
697 // ---------------------------------------------------------------------------- |
|
698 // |
|
699 void CCalenMissedAlarmsContainer::PopulateWithMissedAlarmsL() |
|
700 { |
|
701 TRACE_ENTRY_POINT; |
|
702 |
|
703 // resets list box item array |
|
704 if(iListBoxItemArray) |
|
705 { |
|
706 delete iListBoxItemArray; |
|
707 iListBoxItemArray = NULL; |
|
708 } |
|
709 |
|
710 iListBoxItemArray = new(ELeave) CDesCArrayFlat(KMissedAlarmListBoxItems); |
|
711 |
|
712 if(iMissedAlarmsArray.Count()) |
|
713 { |
|
714 for(TInt index = 0;index < iMissedAlarmsArray.Count(); index++ ) |
|
715 { |
|
716 CreateListBoxDataL(index); |
|
717 } |
|
718 iListBox->Model()->SetItemTextArray(iListBoxItemArray); |
|
719 |
|
720 if(!iHighlightedRowNumber || iHighlightedRowNumber == KErrNotFound ) |
|
721 { |
|
722 //set first missed alarm entry to the context |
|
723 SetContextFromMissedAlarmEntryL(0); |
|
724 } |
|
725 iListBox->HandleItemAdditionL(); |
|
726 } |
|
727 else |
|
728 { |
|
729 iListBox->Model()->SetItemTextArray(iListBoxItemArray); |
|
730 SetEmptyListTextL(); |
|
731 } |
|
732 |
|
733 TRACE_EXIT_POINT; |
|
734 } |
|
735 |
|
736 // ----------------------------------------------------------------------------- |
|
737 // CCalenMissedAlarmsContainer::CreateListBoxDataL |
|
738 // Creates the list box items and appends in to listrbox item array |
|
739 // ----------------------------------------------------------------------------- |
|
740 // |
|
741 void CCalenMissedAlarmsContainer::CreateListBoxDataL(TInt aIndex) |
|
742 { |
|
743 TRACE_ENTRY_POINT; |
|
744 |
|
745 // temporary buffer |
|
746 HBufC* buffer = HBufC::NewLC( KListDataLength ); |
|
747 CleanupStack::Pop(buffer); |
|
748 |
|
749 // initialise the item to construct a new listbox entry |
|
750 buffer->Des().Zero(); |
|
751 |
|
752 // double graphic style "0\tText\tText2\t1 |
|
753 TPtr ptr( buffer->Des() ); |
|
754 |
|
755 CCalEntry* entry = NULL; |
|
756 TTime instanceTime; |
|
757 TInt isEventViewed; |
|
758 |
|
759 // Get the missed alarm entry |
|
760 entry = GetMissedAlarmEntryL(aIndex); |
|
761 |
|
762 // Get the instance time |
|
763 instanceTime = GetInstanceTime(aIndex); |
|
764 |
|
765 // Get the viewed event info |
|
766 isEventViewed = GetViewedEventInfo(aIndex); |
|
767 |
|
768 if(entry) |
|
769 { |
|
770 // get the icon from the entry |
|
771 TBuf<10> icon; |
|
772 TInt iconIndex(0); |
|
773 iconIndex =IconIndexForEntryL( *entry , isEventViewed); |
|
774 icon.Format(KIconFormat,iconIndex); |
|
775 |
|
776 ptr.Append(icon); |
|
777 ptr.Append(KListSeparator); |
|
778 |
|
779 // get the subject from the entry |
|
780 // Set summary |
|
781 // Create temporary buffer for summary |
|
782 |
|
783 HBufC* summary = HBufC::NewLC( KMissedAlarmListMaxLength ); |
|
784 TPtr summaryPtr = summary->Des(); |
|
785 TInt maxLength = summary->Length()- KMissedAlarmListMaxLength; |
|
786 CalenViewUtils::GetSummaryLocationTextL( *entry, summaryPtr, KMissedAlarmListMaxLength ); |
|
787 |
|
788 AknBidiTextUtils::ConvertToVisualAndClipL( summaryPtr, |
|
789 *iEikonEnv->NormalFont(), |
|
790 KListDataLength, |
|
791 KListDataLength ); |
|
792 ptr.Append(summary->Des()); |
|
793 ptr.Append(KListSeparator); |
|
794 |
|
795 CleanupStack::PopAndDestroy( summary ); |
|
796 |
|
797 // get the start time and date |
|
798 // for timed display both start time and date |
|
799 // append start time of the instance |
|
800 TBuf<10> timeString; |
|
801 |
|
802 if(entry->EntryTypeL() == CCalEntry::EAppt ) |
|
803 { |
|
804 HBufC* timeFormat = StringLoader::LoadLC(R_QTN_TIME_USUAL_WITH_ZERO); |
|
805 instanceTime.FormatL(timeString, *timeFormat); |
|
806 // convert the date numbers into Arabic-Indic numbers |
|
807 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeString ); |
|
808 CleanupStack::PopAndDestroy(timeFormat); |
|
809 } |
|
810 |
|
811 //append date |
|
812 TBuf<20> dateString; |
|
813 HBufC* dateFormat = StringLoader::LoadLC(R_QTN_DATE_USUAL_WITH_ZERO); |
|
814 instanceTime.FormatL(dateString, *dateFormat); |
|
815 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( dateString ); |
|
816 CleanupStack::PopAndDestroy(dateFormat); |
|
817 |
|
818 CDesCArrayFlat* strings = new (ELeave) CDesCArrayFlat(2); |
|
819 CleanupStack::PushL( strings ); |
|
820 |
|
821 strings->AppendL(timeString); |
|
822 strings->AppendL(dateString); |
|
823 |
|
824 HBufC* timeDateFormat = StringLoader::LoadL(R_CALE_MAV_START_TIME,*strings); |
|
825 CleanupStack::PushL( timeDateFormat ); |
|
826 ptr.Append(timeDateFormat->Des()); |
|
827 CleanupStack::PopAndDestroy(timeDateFormat); |
|
828 CleanupStack::PopAndDestroy(strings);// strings |
|
829 |
|
830 CleanupStack::PopAndDestroy(entry); |
|
831 |
|
832 ptr.Append( KListSeparator ); |
|
833 |
|
834 iListBoxItemArray->AppendL(ptr); |
|
835 } |
|
836 |
|
837 delete buffer; |
|
838 |
|
839 TRACE_EXIT_POINT; |
|
840 } |
|
841 |
|
842 // ----------------------------------------------------------------------------- |
|
843 // CCalenMissedAlarmsContainer::GetMissedAlarmEntryL |
|
844 // Get a Missed Alarm entry based on the index |
|
845 // ----------------------------------------------------------------------------- |
|
846 // |
|
847 CCalEntry* CCalenMissedAlarmsContainer::GetMissedAlarmEntryL(TInt aIndex) const |
|
848 { |
|
849 TRACE_ENTRY_POINT; |
|
850 |
|
851 TInt localUid; |
|
852 TTime instanceTime; |
|
853 TCalenInstanceId missedAlarm = iMissedAlarmsArray[aIndex]; |
|
854 |
|
855 // get the local uid and instancetime |
|
856 localUid = missedAlarm.iEntryLocalUid; |
|
857 instanceTime = missedAlarm.iInstanceTime; |
|
858 |
|
859 CCalEntry* entry=NULL; |
|
860 // Get the entry using the localUid |
|
861 TRAP_IGNORE(entry=iServices.EntryViewL(missedAlarm.iColId)->FetchL(localUid)); |
|
862 |
|
863 CleanupStack::PushL(entry); |
|
864 |
|
865 TRACE_EXIT_POINT; |
|
866 return entry; |
|
867 } |
|
868 |
|
869 // ----------------------------------------------------------------------------- |
|
870 // CCalenMissedAlarmsContainer::GetInstanceTime |
|
871 // Get the instance time |
|
872 // ----------------------------------------------------------------------------- |
|
873 // |
|
874 TTime CCalenMissedAlarmsContainer::GetInstanceTime(TInt aIndex) const |
|
875 { |
|
876 TRACE_ENTRY_POINT; |
|
877 |
|
878 TCalenInstanceId missedAlarm = iMissedAlarmsArray[aIndex]; |
|
879 |
|
880 TRACE_EXIT_POINT; |
|
881 return missedAlarm.iInstanceTime; |
|
882 } |
|
883 |
|
884 // ----------------------------------------------------------------------------- |
|
885 // CCalenMissedAlarmsContainer::GetViewedEventInfo |
|
886 // Get the viewed event information |
|
887 // ----------------------------------------------------------------------------- |
|
888 // |
|
889 TInt CCalenMissedAlarmsContainer::GetViewedEventInfo(TInt aIndex) |
|
890 { |
|
891 TRACE_ENTRY_POINT; |
|
892 |
|
893 TCalenInstanceId missedAlarm= iMissedAlarmsArray[aIndex]; |
|
894 |
|
895 TRACE_EXIT_POINT; |
|
896 return missedAlarm.iInstanceViewed; |
|
897 } |
|
898 |
|
899 // ---------------------------------------------------------------------------- |
|
900 // CCalenMissedAlarmsContainer::CompletePopulationL |
|
901 // Complete population |
|
902 // ---------------------------------------------------------------------------- |
|
903 // |
|
904 void CCalenMissedAlarmsContainer::CompletePopulationL() |
|
905 { |
|
906 TRACE_ENTRY_POINT; |
|
907 |
|
908 AddToStackAndMakeVisibleL(); |
|
909 SetHighlightingL(); |
|
910 DrawDeferred(); |
|
911 |
|
912 TRACE_EXIT_POINT; |
|
913 } |
|
914 |
|
915 // ----------------------------------------------------------------------------- |
|
916 // CCalenMissedAlarmsContainer::SetContextFromMissedAlarmEntryL |
|
917 // Sets the context from the current focused missed alarm entry |
|
918 // ----------------------------------------------------------------------------- |
|
919 // |
|
920 void CCalenMissedAlarmsContainer::SetContextFromMissedAlarmEntryL(TInt aIndex) |
|
921 { |
|
922 TRACE_ENTRY_POINT; |
|
923 |
|
924 TCalenInstanceId missedAlarm = iMissedAlarmsArray[aIndex]; |
|
925 |
|
926 CCalEntry* entry = iServices.EntryViewL(missedAlarm.iColId)->FetchL( missedAlarm.iEntryLocalUid ); |
|
927 //User::LeaveIfNull( entry ); |
|
928 if (entry) |
|
929 { |
|
930 CleanupStack::PushL( entry ); |
|
931 |
|
932 TTime instanceTime; |
|
933 TCalTime inscaltime; |
|
934 |
|
935 instanceTime = CalenAgendaUtils::EntryTimeL( *entry ); |
|
936 inscaltime.SetTimeLocalL( instanceTime ); |
|
937 |
|
938 // set the context |
|
939 MCalenContext &context = iServices.Context(); |
|
940 TCalenInstanceId id = TCalenInstanceId::CreateL( *entry, inscaltime ); |
|
941 id.iColId = missedAlarm.iColId; |
|
942 context.SetInstanceIdL( id, context.ViewId() ); |
|
943 |
|
944 CleanupStack::PopAndDestroy( entry ); |
|
945 } |
|
946 |
|
947 TRACE_EXIT_POINT; |
|
948 } |
|
949 |
|
950 // ----------------------------------------------------------------------------- |
|
951 // CCalenMissedAlarmsContainer::FindMissedAlarmEntryIndexL |
|
952 // Find missed alarm entry's index |
|
953 // ----------------------------------------------------------------------------- |
|
954 // |
|
955 TInt CCalenMissedAlarmsContainer::FindMissedAlarmEntryIndexL( |
|
956 const TCalenInstanceId& aId) |
|
957 { |
|
958 TRACE_ENTRY_POINT; |
|
959 |
|
960 for(TInt index(0); index < iMissedAlarmsArray.Count(); ++index) |
|
961 { |
|
962 if( iMissedAlarmsArray[index].iEntryLocalUid == aId.iEntryLocalUid ) |
|
963 { |
|
964 TRACE_EXIT_POINT; |
|
965 return index; |
|
966 } |
|
967 } |
|
968 |
|
969 TRACE_EXIT_POINT; |
|
970 return KErrNotFound; |
|
971 } |
|
972 |
|
973 |
|
974 void CCalenMissedAlarmsContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
975 TListBoxEvent aEventType) |
|
976 { |
|
977 TRACE_ENTRY_POINT; |
|
978 switch( aEventType ) |
|
979 { |
|
980 // Single click integration |
|
981 case EEventItemSingleClicked: |
|
982 { |
|
983 iHighlightedRowNumber = iListBox->View()->CurrentItemIndex(); |
|
984 |
|
985 SetContextFromMissedAlarmEntryL(iListBox->View()->CurrentItemIndex()); |
|
986 //Handle listbox item selection event |
|
987 // iListBox->HandlePointerEventL(aPointerEvent); |
|
988 if(iView->MenuBar()->IsDisplayed() == EFalse) |
|
989 { |
|
990 iView->HandleCommandL( ECalenMissedEventView ); |
|
991 } |
|
992 break; |
|
993 } |
|
994 |
|
995 // Single click integration |
|
996 case EEventEnterKeyPressed: |
|
997 { |
|
998 iHighlightedRowNumber = iListBox->View()->CurrentItemIndex(); |
|
999 |
|
1000 SetContextFromMissedAlarmEntryL(iListBox->View()->CurrentItemIndex()); |
|
1001 iView->HandleCommandL( ECalenMissedEventView ); |
|
1002 break; |
|
1003 } |
|
1004 default: |
|
1005 break; |
|
1006 }; |
|
1007 TRACE_EXIT_POINT; |
|
1008 } |
|
1009 |
|
1010 |
|
1011 |
|
1012 // End of File |