|
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: This is the source file for the CClockMainView class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <clock.rsg> |
|
20 #include <avkon.hrh> |
|
21 #include <aknViewAppUi.h> |
|
22 #include <aknnotewrappers.h> |
|
23 #include <aknlists.h> |
|
24 #include <StringLoader.h> |
|
25 #include <tz.h> |
|
26 #include <vtzrules.h> |
|
27 #include <clockalarmeditor.h> |
|
28 #include <hlplch.h> |
|
29 |
|
30 // User includes |
|
31 #include "clockmainview.h" |
|
32 #include "clockmaincontainer.h" |
|
33 #include "clockalarmarray.h" |
|
34 #include "clockappui.h" |
|
35 #include "clockdocument.h" |
|
36 #include "clock.h" |
|
37 #include "clock.hrh" |
|
38 #include "clkuialarmmodel.h" |
|
39 #include "clkuialarmidleobserver.h" |
|
40 #include "clkcommon.h" |
|
41 #include "clock_debug.h" |
|
42 |
|
43 // Constants |
|
44 |
|
45 // Literals |
|
46 |
|
47 // --------------------------------------------------------- |
|
48 // CClockMainView::NewL |
|
49 // rest of the details are commented in the header |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 CClockMainView* CClockMainView::NewL( CClkUiAlarmModel* aAlarmModel ) |
|
53 { |
|
54 __PRINTS( "CClockMainView::NewL - Entry" ); |
|
55 |
|
56 CClockMainView* self = new ( ELeave ) CClockMainView; |
|
57 CleanupStack::PushL( self ); |
|
58 |
|
59 self->ConstructL( aAlarmModel ); |
|
60 |
|
61 CleanupStack::Pop( self ); |
|
62 |
|
63 __PRINTS( "CClockMainView::NewL - Exit" ); |
|
64 |
|
65 return self; |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------- |
|
69 // CClockMainView::ConstructL |
|
70 // rest of the details are commented in the header |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CClockMainView::ConstructL( CClkUiAlarmModel* aAlarmModel ) |
|
74 { |
|
75 __PRINTS( "CClockMainView::ConstructL - Entry" ); |
|
76 |
|
77 BaseConstructL( R_CLOCK_MAIN_VIEW ); |
|
78 |
|
79 // Save the model. |
|
80 iAlarmModel = aAlarmModel; |
|
81 |
|
82 // Construct the alarm array. |
|
83 iAlarmArray = CClockAlarmArray::NewL( iAlarmModel, iCoeEnv ); |
|
84 |
|
85 if( !iModelObserver ) |
|
86 { |
|
87 iModelObserver = CClkUiAlarmIdleObserver::NewL( this, KAlarmIdleObserverPriority ); |
|
88 // Set the observer for the model. |
|
89 iAlarmModel->SetModelObserver( iModelObserver ); |
|
90 } |
|
91 |
|
92 __PRINTS( "CClockMainView::ConstructL - Exit" ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // CClockMainView::CClockMainView |
|
97 // rest of the details are commented in the header |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 //Single click integration |
|
101 CClockMainView::CClockMainView() |
|
102 |
|
103 { |
|
104 __PRINTS( "CClockMainView::CClockMainView - Entry" ); |
|
105 |
|
106 // No implementation yet. |
|
107 |
|
108 __PRINTS( "CClockMainView::CClockMainView - Exit" ); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // CClockMainView::SetNewAlarmL |
|
113 // rest of the details are commented in the header |
|
114 // --------------------------------------------------------- |
|
115 // |
|
116 void CClockMainView::SetNewAlarmL() |
|
117 { |
|
118 __PRINTS( "CClockMainView::SetNewAlarmL - Entry" ); |
|
119 |
|
120 // Hide the navigation pane. |
|
121 CClockAppUi* appUi = static_cast< CClockAppUi* > ( AppUi() ); |
|
122 appUi->MakeNavigationPaneVisible( EFalse, EClockAppMainViewId ); |
|
123 |
|
124 // Mark the alarm editor as open. |
|
125 iAlarmEditorOpen = ETrue; |
|
126 |
|
127 // Construct the alarm editor. |
|
128 CClockAlarmEditor *alarmEditor = CClockAlarmEditor::NewL(); |
|
129 |
|
130 // Launch the editor. iAlarmId will give either alarm ID |
|
131 // or EClockAlarmExit or EClockAlarmDelete. |
|
132 iAlarmId = alarmEditor->LaunchL(); |
|
133 |
|
134 // Update the title pane text. |
|
135 static_cast< CClockAppUi* > ( AppUi() )->SetTitlePaneTextL( R_CLOCK_TITLE_MAIN_VIEW ); |
|
136 |
|
137 // Show the navigation pane again. |
|
138 appUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId ); |
|
139 |
|
140 if( EClockAlarmExit == iAlarmId ) |
|
141 { |
|
142 // Mark the alarm editor as closed. |
|
143 iAlarmEditorOpen = EFalse; |
|
144 |
|
145 // Cleanup. |
|
146 if( alarmEditor ) |
|
147 { |
|
148 delete alarmEditor; |
|
149 alarmEditor = NULL; |
|
150 } |
|
151 |
|
152 |
|
153 // Let the appui handle the exit. |
|
154 AppUi()->HandleCommandL( EClockAlarmExit ); |
|
155 |
|
156 __PRINTS( "CClockMainView::SetNewAlarmL:EClockAlarmExit - Exit" ); |
|
157 |
|
158 return; |
|
159 } |
|
160 |
|
161 if( EClockAlarmDelete == iAlarmId ) |
|
162 { |
|
163 |
|
164 // Mark the alarm editor as closed. |
|
165 iAlarmEditorOpen = EFalse; |
|
166 |
|
167 // Cleanup. |
|
168 if( alarmEditor ) |
|
169 { |
|
170 delete alarmEditor; |
|
171 alarmEditor = NULL; |
|
172 } |
|
173 |
|
174 // Do nothing. Just close the form without saving any data. |
|
175 __PRINTS( "CClockMainView::SetNewAlarmL:EClockAlarmDelete - Exit" ); |
|
176 |
|
177 return; |
|
178 } |
|
179 |
|
180 // If the user pressed cancel and if the alarm id is valid. |
|
181 if( KErrNone != iAlarmId ) |
|
182 { |
|
183 // Update the latest alarm details. |
|
184 iAlarmModel->ClockAlarmInfo( iAlarmId, iAlarmInfo ); |
|
185 |
|
186 // First update the model with the latest alarm id. |
|
187 iAlarmModel->SaveLatestAlarmId( iAlarmId ); |
|
188 |
|
189 // Update the container with the newly added alarm. |
|
190 iContainer->UpdateAlarmListL( iAlarmInfo, iAlarmId ); |
|
191 |
|
192 |
|
193 } |
|
194 else |
|
195 { |
|
196 // No implementation yet. |
|
197 } |
|
198 |
|
199 // Mark the alarm editor as closed. |
|
200 iAlarmEditorOpen = EFalse; |
|
201 |
|
202 // Cleanup. |
|
203 if( alarmEditor ) |
|
204 { |
|
205 delete alarmEditor; |
|
206 alarmEditor = NULL; |
|
207 } |
|
208 |
|
209 |
|
210 __PRINTS( "CClockMainView::SetNewAlarmL - Exit" ); |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------- |
|
214 // CClockMainView::RemoveAlarmL |
|
215 // rest of the details are commented in the header |
|
216 // --------------------------------------------------------- |
|
217 // |
|
218 void CClockMainView::RemoveAlarmL() |
|
219 { |
|
220 __PRINTS( "CClockMainView::RemoveAlarmL - Entry" ); |
|
221 |
|
222 // First get the index of the selected item in the list. |
|
223 TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() ); |
|
224 |
|
225 if( KErrNone >= itemIndex ) |
|
226 { |
|
227 __PRINTS( "CClockMainView::RemoveAlarmL - Exit" ); |
|
228 |
|
229 return; |
|
230 } |
|
231 |
|
232 |
|
233 SClkAlarmInfo alarmInfo; |
|
234 TAlarmId alarmId; |
|
235 // Get the alarm id from alarm model. |
|
236 iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo ); |
|
237 |
|
238 // Delete the alarm. |
|
239 User::LeaveIfError( iAlarmModel->DeleteClockAlarm( alarmId ) ); |
|
240 |
|
241 // Display the confirmation note to the user about alarm deletion. |
|
242 CAknConfirmationNote* confNote = new( ELeave ) CAknConfirmationNote; |
|
243 HBufC* confNoteText = StringLoader::LoadLC( R_QTN_CLOCK_ALARM_NOTE_DELETED, iCoeEnv ); |
|
244 // Display the note. |
|
245 confNote->ExecuteLD( *confNoteText ); |
|
246 // Cleanup. |
|
247 CleanupStack::PopAndDestroy( confNoteText ); |
|
248 |
|
249 // Update the container. |
|
250 iContainer->RemoveAlarmL( itemIndex ); |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 __PRINTS( "CClockMainView::RemoveAlarmL - Exit" ); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------- |
|
260 // CClockMainView::ActivateAlarmL |
|
261 // rest of the details are commented in the header |
|
262 // --------------------------------------------------------- |
|
263 // |
|
264 void CClockMainView::ActivateAlarmL() |
|
265 { |
|
266 __PRINTS( "CClockMainView::ActivateAlarmL - Entry" ); |
|
267 |
|
268 // First get the focused list item. |
|
269 TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() ); |
|
270 // Id of the alarm to be activated. |
|
271 TAlarmId alarmId; |
|
272 // Dummy alarm info. |
|
273 SClkAlarmInfo alarmInfo; |
|
274 |
|
275 // Get the id of the alarm at the index in the list. |
|
276 iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo ); |
|
277 |
|
278 // Activate the alarm. |
|
279 User::LeaveIfError( iAlarmModel->ClockAlarmEnable( alarmId, EAlarmStatusEnabled ) ); |
|
280 // Update the listbox. |
|
281 iContainer->ListBox()->SetCurrentItemIndexAndDraw( iAlarmArray->ListBoxIndex( alarmId ) ); |
|
282 |
|
283 __PRINTS( "CClockMainView::ActivateAlarmL - Exit" ); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------- |
|
287 // CClockMainView::DeactivateAlarmL |
|
288 // rest of the details are commented in the header |
|
289 // --------------------------------------------------------- |
|
290 // |
|
291 void CClockMainView::DeactivateAlarmL() |
|
292 { |
|
293 __PRINTS( "CClockMainView::DeactivateAlarmL - Entry" ); |
|
294 |
|
295 // First get the focused list item. |
|
296 TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() ); |
|
297 // Id of the alarm to be deactivated. |
|
298 TAlarmId alarmId; |
|
299 // Dummy alarm info. |
|
300 SClkAlarmInfo alarmInfo; |
|
301 |
|
302 // Get the id of the alarm at the index in the list. |
|
303 iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo ); |
|
304 |
|
305 // Deactivate the alarm. |
|
306 User::LeaveIfError( iAlarmModel->ClockAlarmEnable( alarmId, EAlarmStatusDisabled ) ); |
|
307 // Update the listbox. |
|
308 iContainer->ListBox()->SetCurrentItemIndexAndDraw( iAlarmArray->ListBoxIndex( alarmId ) ); |
|
309 |
|
310 __PRINTS( "CClockMainView::DeactivateAlarmL - Exit" ); |
|
311 } |
|
312 |
|
313 // --------------------------------------------------------- |
|
314 // CClockMainView::ResetAlarmL |
|
315 // rest of the details are commented in the header |
|
316 // --------------------------------------------------------- |
|
317 // |
|
318 void CClockMainView::ResetAlarmL() |
|
319 { |
|
320 __PRINTS( "CClockMainView::ResetAlarmL - Entry" ); |
|
321 |
|
322 // First get the focused list item. |
|
323 TInt itemIndex( iContainer->ListBox()->CurrentItemIndex() ); |
|
324 // Id of the alarm to be deactivated. |
|
325 TAlarmId alarmId; |
|
326 // Dummy alarm info. |
|
327 SClkAlarmInfo alarmInfo; |
|
328 |
|
329 // Get the id of the alarm at the index in the list. |
|
330 iAlarmArray->GetSortedAlmIdInfo( itemIndex, alarmId, alarmInfo ); |
|
331 |
|
332 // Hide the navigation pane. |
|
333 CClockAppUi* appUi = static_cast< CClockAppUi* > ( AppUi() ); |
|
334 appUi->MakeNavigationPaneVisible( EFalse, EClockAppMainViewId ); |
|
335 |
|
336 // Mark the alarm editor as open. |
|
337 iAlarmEditorOpen = ETrue; |
|
338 |
|
339 // Construct the alarm editor. |
|
340 CClockAlarmEditor* alarmEditor = CClockAlarmEditor::NewL( alarmId ); |
|
341 |
|
342 // Launch the editor.iAlarmId will give either alarm ID |
|
343 // or EClockAlarmExit or EClockAlarmDelete. |
|
344 iAlarmId = alarmEditor->LaunchL(); |
|
345 |
|
346 // Update the title pane text. |
|
347 static_cast< CClockAppUi* > ( AppUi() )->SetTitlePaneTextL( R_CLOCK_TITLE_MAIN_VIEW ); |
|
348 |
|
349 // Show the navigation pane again. |
|
350 appUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId ); |
|
351 |
|
352 if( EClockAlarmExit == iAlarmId ) |
|
353 { |
|
354 // Mark the alarm editor as closed. |
|
355 iAlarmEditorOpen = EFalse; |
|
356 |
|
357 if( alarmEditor ) |
|
358 { |
|
359 delete alarmEditor; |
|
360 alarmEditor = NULL; |
|
361 } |
|
362 |
|
363 // Let the appui handle the exit. |
|
364 AppUi()->HandleCommandL( EClockAlarmExit ); |
|
365 |
|
366 __PRINTS( "CClockMainView::ResetAlarmL:EClockAlarmExit - Exit" ); |
|
367 |
|
368 return; |
|
369 } |
|
370 |
|
371 if( EClockAlarmDiscardChanges == iAlarmId ) |
|
372 { |
|
373 // Mark the alarm editor as closed. |
|
374 iAlarmEditorOpen = EFalse; |
|
375 |
|
376 // Cleanup. |
|
377 if( alarmEditor ) |
|
378 { |
|
379 delete alarmEditor; |
|
380 alarmEditor = NULL; |
|
381 } |
|
382 |
|
383 // Dont do anything. Simply return. |
|
384 |
|
385 __PRINTS( "CClockMainView::ResetAlarmL:EClockAlarmDiscardChanges - Exit" ); |
|
386 |
|
387 return; |
|
388 } |
|
389 |
|
390 // If the user pressed cancel and if the alarm id is valid. |
|
391 if( KErrNone != iAlarmId ) |
|
392 { |
|
393 // Delete the previous alarm. |
|
394 User::LeaveIfError( iAlarmModel->DeleteClockAlarm( alarmId ) ); |
|
395 |
|
396 // Remove this alarm from the list. |
|
397 iContainer->RemoveAlarmL( itemIndex ); |
|
398 |
|
399 // Update the latest alarm details. |
|
400 iAlarmModel->ClockAlarmInfo( iAlarmId, iAlarmInfo ); |
|
401 |
|
402 // First update the model with the latest alarm id. |
|
403 iAlarmModel->SaveLatestAlarmId( iAlarmId ); |
|
404 |
|
405 // Update the container with the new alarm. |
|
406 iContainer->UpdateAlarmListL( iAlarmInfo, iAlarmId ); |
|
407 } |
|
408 |
|
409 // Mark the alarm editor as closed. |
|
410 iAlarmEditorOpen = EFalse; |
|
411 |
|
412 if( alarmEditor ) |
|
413 { |
|
414 delete alarmEditor; |
|
415 alarmEditor = NULL; |
|
416 } |
|
417 |
|
418 |
|
419 __PRINTS( "CClockMainView::ResetAlarmL - Exit" ); |
|
420 } |
|
421 |
|
422 // --------------------------------------------------------- |
|
423 // CClockMainView::~CClockMainView |
|
424 // rest of the details are commented in the header |
|
425 // --------------------------------------------------------- |
|
426 // |
|
427 CClockMainView::~CClockMainView() |
|
428 { |
|
429 __PRINTS( "CClockMainView::~CClockMainView - Entry" ); |
|
430 |
|
431 if( iAlarmArray ) |
|
432 { |
|
433 delete iAlarmArray; |
|
434 iAlarmArray = NULL; |
|
435 } |
|
436 if( iContainer ) |
|
437 { |
|
438 ( AppUi() )->RemoveFromStack( iContainer ); |
|
439 delete iContainer; |
|
440 iContainer = NULL; |
|
441 } |
|
442 if( iModelObserver ) |
|
443 { |
|
444 if( iAlarmModel ) |
|
445 { |
|
446 iAlarmModel->SetModelObserver( NULL ); |
|
447 } |
|
448 delete iModelObserver; |
|
449 iModelObserver = NULL; |
|
450 } |
|
451 |
|
452 __PRINTS( "CClockMainView::~CClockMainView - Exit" ); |
|
453 } |
|
454 |
|
455 // --------------------------------------------------------- |
|
456 // CClockMainView::Id |
|
457 // rest of the details are commented in the header |
|
458 // --------------------------------------------------------- |
|
459 // |
|
460 TUid CClockMainView::Id() const |
|
461 { |
|
462 __PRINTS( "CClockMainView::Id - Entry" ); |
|
463 |
|
464 __PRINTS( "CClockMainView::Id - Exit" ); |
|
465 |
|
466 return KClockAppMainViewId; |
|
467 } |
|
468 |
|
469 // --------------------------------------------------------- |
|
470 // CClockMainView::DoActivateL |
|
471 // rest of the details are commented in the header |
|
472 // --------------------------------------------------------- |
|
473 // |
|
474 void CClockMainView::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
475 TUid aCustomMessageId, |
|
476 const TDesC8& /*aCustomMessage*/ ) |
|
477 { |
|
478 __PRINTS( "CClockMainView::DoActivateL - Entry" ); |
|
479 |
|
480 if( KClockHideInBackground == aCustomMessageId.iUid ) |
|
481 { |
|
482 CClockAppUi* appUi = static_cast< CClockAppUi* > ( AppUi() ); |
|
483 |
|
484 // Enable bring-to-foreground on view activation. |
|
485 appUi->SetCustomControl( 0 ); |
|
486 } |
|
487 |
|
488 // Re-initialize the alarm id array. |
|
489 iAlarmArray->InitIdList(); |
|
490 |
|
491 if( ( KClockAppMainViewId == aCustomMessageId ) && iContainer ) |
|
492 { |
|
493 AppUi()->RemoveFromStack( iContainer ); |
|
494 delete iContainer; |
|
495 iContainer = NULL; |
|
496 } |
|
497 |
|
498 CClockAppUi* clockAppUi( static_cast< CClockAppUi* > ( AppUi() ) ); |
|
499 if( !iContainer ) |
|
500 { |
|
501 iContainer = CClockMainContainer::NewL( this, ClientRect(), iAlarmArray ); |
|
502 ( AppUi() )->AddToStackL( *this, iContainer ); |
|
503 iContainer->SetMopParent( this ); |
|
504 |
|
505 if( clockAppUi->IsAppExitHidden() ) |
|
506 { |
|
507 iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZerothIndex ); |
|
508 clockAppUi->SetAppHidden( EFalse ); |
|
509 |
|
510 } |
|
511 else |
|
512 { |
|
513 |
|
514 // Focus on the "New Alarm" whenever the main view is activated |
|
515 |
|
516 |
|
517 iContainer->ListBox()->SetCurrentItemIndexAndDraw( KErrNone); |
|
518 } |
|
519 } |
|
520 |
|
521 // Update the date and day text. |
|
522 iContainer->SetDayInfoL(); |
|
523 |
|
524 // Update the location information text. |
|
525 iContainer->SetZoneInfoL(); |
|
526 |
|
527 // Update the DST information in the container. |
|
528 iContainer->UpdateDSTStateL(); |
|
529 |
|
530 // Update the title pane text. |
|
531 clockAppUi->SetTitlePaneTextL( R_CLOCK_TITLE_MAIN_VIEW ); |
|
532 |
|
533 // If opened from clock, display the navigation pane again. |
|
534 clockAppUi->MakeNavigationPaneVisible( ETrue, EClockAppMainViewId ); |
|
535 |
|
536 // Activate the container. |
|
537 iContainer->ActivateL(); |
|
538 |
|
539 __PRINTS( "CClockMainView::DoActivateL - Exit" ); |
|
540 } |
|
541 |
|
542 // --------------------------------------------------------- |
|
543 // CClockMainView::DoDeactivate |
|
544 // rest of the details are commented in the header |
|
545 // --------------------------------------------------------- |
|
546 // |
|
547 void CClockMainView::DoDeactivate() |
|
548 { |
|
549 __PRINTS( "CClockMainView::DoDeactivate - Entry" ); |
|
550 |
|
551 // Ask the document to save the user data in the document file. |
|
552 CClockDocument* clockDocument = static_cast< CClockDocument* > ( AppUi()->Document() ); |
|
553 TRAP_IGNORE( clockDocument->StoreDataL() ); |
|
554 |
|
555 if( iContainer ) |
|
556 { |
|
557 |
|
558 // First remove the container from the control stack |
|
559 ( AppUi() )->RemoveFromStack( iContainer ); |
|
560 // And then destroy it. |
|
561 delete iContainer; |
|
562 iContainer = NULL; |
|
563 } |
|
564 |
|
565 __PRINTS( "CClockMainView::DoDeactivate - Exit" ); |
|
566 } |
|
567 |
|
568 // --------------------------------------------------------- |
|
569 // CClockMainView::HandleCommandL |
|
570 // rest of the details are commented in the header |
|
571 // --------------------------------------------------------- |
|
572 // |
|
573 void CClockMainView::HandleCommandL( TInt aCommand ) |
|
574 { |
|
575 __PRINTS( "CClockMainView::HandleCommandL - Entry" ); |
|
576 |
|
577 switch( aCommand ) |
|
578 { |
|
579 //Single click integration |
|
580 case EClockSelect: |
|
581 { |
|
582 if ( iContainer->ListBox()->CurrentItemIndex() == 0 ) |
|
583 { |
|
584 SetNewAlarmL(); |
|
585 } |
|
586 else |
|
587 { |
|
588 ResetAlarmL(); |
|
589 } |
|
590 } |
|
591 break; |
|
592 |
|
593 case EClockNewAlarm: |
|
594 { |
|
595 // Display the alarm editor for the user to set the alarm. |
|
596 SetNewAlarmL(); |
|
597 } |
|
598 break; |
|
599 |
|
600 case EClockResetAlarm: |
|
601 { |
|
602 // Reset the chosen alarm. |
|
603 ResetAlarmL(); |
|
604 } |
|
605 break; |
|
606 |
|
607 case EClockDeactivateAlarm: |
|
608 { |
|
609 // Deactivate the focused alarm item in the list. |
|
610 DeactivateAlarmL(); |
|
611 } |
|
612 break; |
|
613 |
|
614 case EClockActivateAlarm: |
|
615 { |
|
616 // Activate the focused alarm item in the list. |
|
617 ActivateAlarmL(); |
|
618 } |
|
619 break; |
|
620 |
|
621 case EClockRemoveAlarm: |
|
622 { |
|
623 // Delete the selected alarm. |
|
624 RemoveAlarmL(); |
|
625 } |
|
626 break; |
|
627 |
|
628 case EClockSettings: |
|
629 { |
|
630 // Let the appui handle the command. |
|
631 AppUi()->HandleCommandL( EClockSettings ); |
|
632 } |
|
633 break; |
|
634 |
|
635 case EClockMainViewExit: |
|
636 case EAknSoftkeyExit: |
|
637 { |
|
638 AppUi()->HandleCommandL( aCommand ); |
|
639 } |
|
640 break; |
|
641 |
|
642 case EAknCmdHelp: //EClockWorldHelp: |
|
643 { |
|
644 // Launch clock main view specific help. |
|
645 HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), iAvkonAppUi->AppHelpContextL() ); |
|
646 } |
|
647 break; |
|
648 |
|
649 default: |
|
650 { |
|
651 // No implementation yet. |
|
652 } |
|
653 break; |
|
654 } |
|
655 |
|
656 __PRINTS( "CClockMainView::HandleCommandL - Exit" ); |
|
657 } |
|
658 |
|
659 // --------------------------------------------------------- |
|
660 // CClockMainView::HandleUpdateL |
|
661 // rest of the details are commented in the header |
|
662 // --------------------------------------------------------- |
|
663 // |
|
664 void CClockMainView::HandleUpdateL( TInt /*aReason*/ ) |
|
665 { |
|
666 __PRINTS( "CClockMainView::HandleUpdateL - Entry" ); |
|
667 |
|
668 // Get the currently focussed item. |
|
669 TInt currentlyFocussedItem( KErrNotFound ); |
|
670 if( iContainer ) |
|
671 { |
|
672 currentlyFocussedItem = iContainer->ListBox()->CurrentItemIndex(); |
|
673 } |
|
674 // Update the alarm array. |
|
675 iAlarmArray->InitIdList(); |
|
676 |
|
677 // We redraw the container when an update is received from the uimodel (be it alarm or clockserver). |
|
678 if( iContainer ) |
|
679 { |
|
680 iContainer->DrawNow(); |
|
681 iContainer->ListBox()->HandleItemAdditionL(); |
|
682 |
|
683 // In case the currently focussed item is invalid,set the focus to last item and set the msk text accordingly. |
|
684 if( KErrNotFound == currentlyFocussedItem ) |
|
685 { |
|
686 TInt itemCount = iContainer->ListBox()->Model()->ItemTextArray()->MdcaCount(); |
|
687 iContainer->ListBox()->SetCurrentItemIndexAndDraw( itemCount -1 ); |
|
688 |
|
689 |
|
690 } |
|
691 } |
|
692 |
|
693 __PRINTS( "CClockMainView::HandleUpdateL - Exit" ); |
|
694 } |
|
695 |
|
696 // --------------------------------------------------------- |
|
697 // CClockMainView::DynInitMenuPaneL |
|
698 // rest of the details are commented in the header |
|
699 // --------------------------------------------------------- |
|
700 // |
|
701 void CClockMainView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
702 { |
|
703 __PRINTS( "CClockMainView::DynInitMenuPaneL - Entry" ); |
|
704 |
|
705 //Single click integration |
|
706 if( ( R_CLOCK_MAIN_VIEW_MENUPANE != aResourceId ) ) |
|
707 |
|
708 |
|
709 { |
|
710 __PRINTS( "CClockMainView::DynInitMenuPaneL - Exit" ); |
|
711 |
|
712 return; |
|
713 } |
|
714 |
|
715 // TODO: Initialize FeatureManager and remove Help option if its not supported. |
|
716 /*if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
717 { |
|
718 aMenuPane->DeleteMenuItem( EAlarmHelpAlarmClock ); |
|
719 }*/ |
|
720 |
|
721 |
|
722 TInt alarmCount = iAlarmArray->MdcaCount(); |
|
723 |
|
724 // There are no alarms set or the current focussed listitem is "New Alarm" then remove alarm specific options |
|
725 if( KZeroAlarms >= alarmCount || ( KErrNone == iContainer->ListBox()->CurrentItemIndex() ) ) |
|
726 { |
|
727 // There are no alarms set. Remove the irrelevant options from the menu. |
|
728 aMenuPane->DeleteMenuItem( EClockNewAlarm ); |
|
729 aMenuPane->DeleteMenuItem( EClockResetAlarm ); |
|
730 aMenuPane->DeleteMenuItem( EClockRemoveAlarm ); |
|
731 aMenuPane->DeleteMenuItem( EClockActivateAlarm ); |
|
732 aMenuPane->DeleteMenuItem( EClockDeactivateAlarm ); |
|
733 } |
|
734 else |
|
735 { |
|
736 // There is atleast one alarm set. Get the details to update the menu. |
|
737 SClkAlarmInfo alarmInfo; |
|
738 TAlarmId alarmId; |
|
739 |
|
740 |
|
741 iAlarmArray->GetSortedAlmIdInfo( iContainer->ListBox()->CurrentItemIndex(), alarmId, alarmInfo ); |
|
742 |
|
743 if( alarmInfo.iStatus == EAlarmStatusEnabled ) |
|
744 { |
|
745 // Alarm is already active. Remove the activate option. |
|
746 aMenuPane->DeleteMenuItem( EClockActivateAlarm ); |
|
747 |
|
748 |
|
749 |
|
750 if( ( EAlarmRepeatDefintionRepeatOnce == alarmInfo.iRepeat ) || |
|
751 ( EAlarmRepeatDefintionRepeatNext24Hours == alarmInfo.iRepeat) ) |
|
752 { |
|
753 // Alarm is not recurring. Remove the deactivate option from the menu. |
|
754 aMenuPane->DeleteMenuItem( EClockDeactivateAlarm ); |
|
755 } |
|
756 } |
|
757 else |
|
758 { |
|
759 // Alarm is already inactive. Remove the deactivate option from the menu. |
|
760 aMenuPane->DeleteMenuItem( EClockDeactivateAlarm ); |
|
761 } |
|
762 } |
|
763 |
|
764 |
|
765 |
|
766 __PRINTS( "CClockMainView::DynInitMenuPaneL - Exit" ); |
|
767 } |
|
768 |
|
769 // --------------------------------------------------------- |
|
770 // CClockMainView::DynInitMenuBarL |
|
771 // rest of the details are commented in the header |
|
772 // --------------------------------------------------------- |
|
773 // |
|
774 //Single click integration |
|
775 void CClockMainView::DynInitMenuBarL( TInt /*aResourceId*/, CEikMenuBar* /*aMenuBar*/ ) |
|
776 |
|
777 { |
|
778 __PRINTS( "CClockMainView::DynInitMenuBarL - Entry" ); |
|
779 |
|
780 |
|
781 |
|
782 __PRINTS( "CClockMainView::DynInitMenuBarL - Exit" ); |
|
783 } |
|
784 |
|
785 // --------------------------------------------------------- |
|
786 // CClockMainView::HandleForegroundEventL |
|
787 // rest of the details are commented in the header |
|
788 // --------------------------------------------------------- |
|
789 // |
|
790 void CClockMainView::HandleForegroundEventL( TBool aForeground ) |
|
791 { |
|
792 __PRINTS( "CClockMainView::HandleForegroundEventL - Entry" ); |
|
793 |
|
794 if( aForeground ) |
|
795 { |
|
796 CClockAppUi* clockAppUi( static_cast< CClockAppUi* > ( AppUi() ) ); |
|
797 if( clockAppUi->IsAppExitHidden() ) |
|
798 { |
|
799 if( iContainer ) |
|
800 { |
|
801 iContainer->ResetMarqueeLabelL(); |
|
802 iContainer->ListBox()->SetCurrentItemIndexAndDraw( KZerothIndex ); |
|
803 } |
|
804 clockAppUi->SetAppHidden( EFalse ); |
|
805 |
|
806 } |
|
807 } |
|
808 |
|
809 __PRINTS( "CClockMainView::HandleForegroundEventL - Exit" ); |
|
810 } |
|
811 // --------------------------------------------------------- |
|
812 // CClockMainView::GetApplicationRect |
|
813 // rest of the details are commented in the header |
|
814 // --------------------------------------------------------- |
|
815 // |
|
816 TRect CClockMainView::GetApplicationRect() |
|
817 { |
|
818 __PRINTS( "CClockMainView::GetApplicationRect - Entry" ); |
|
819 |
|
820 __PRINTS( "CClockMainView::GetApplicationRect - Exit" ); |
|
821 |
|
822 // Return the applicationrect from appui. |
|
823 return AppUi()->ApplicationRect(); |
|
824 } |
|
825 |
|
826 |
|
827 |
|
828 // --------------------------------------------------------- |
|
829 // CClockMainView::HandleEnvChangeL |
|
830 // rest of the details are commented in the header |
|
831 // --------------------------------------------------------- |
|
832 // |
|
833 void CClockMainView::HandleEnvChangeL( TClockEnvChanged /*aEnvChanged*/ ) |
|
834 { |
|
835 __PRINTS( "CClockMainView::HandleEnvChangeL - Entry" ); |
|
836 |
|
837 if( iContainer ) |
|
838 { |
|
839 // Update the main view information. |
|
840 iContainer->SetDayInfoL(); |
|
841 |
|
842 // Update the location information text. |
|
843 iContainer->SetZoneInfoL(); |
|
844 |
|
845 // Update the DST information. |
|
846 iContainer->UpdateDSTStateL(); |
|
847 |
|
848 // Update the container. |
|
849 iContainer->DrawNow(); |
|
850 } |
|
851 |
|
852 __PRINTS( "CClockMainView::HandleEnvChangeL - Exit" ); |
|
853 } |
|
854 |
|
855 // --------------------------------------------------------- |
|
856 // CClockMainView::IsAlarmEditorOpen |
|
857 // rest of the details are commented in the header |
|
858 // --------------------------------------------------------- |
|
859 // |
|
860 TBool CClockMainView::IsAlarmEditorOpen() |
|
861 { |
|
862 __PRINTS( "CClockMainView::IsAlarmEditorOpen - Entry" ); |
|
863 |
|
864 __PRINTS( "CClockMainView::IsAlarmEditorOpen - Exit" ); |
|
865 |
|
866 return iAlarmEditorOpen; |
|
867 } |
|
868 |
|
869 // --------------------------------------------------------- |
|
870 // CClockMainView::ClockApplicationUi |
|
871 // rest of the details are commented in the header |
|
872 // --------------------------------------------------------- |
|
873 // |
|
874 CClockAppUi* CClockMainView::ClockApplicationUi() |
|
875 { |
|
876 __PRINTS( "CClockMainView::ClockApplicationUi - Entry" ); |
|
877 |
|
878 __PRINTS( "CClockMainView::ClockApplicationUi - Exit" ); |
|
879 |
|
880 return static_cast< CClockAppUi* > ( AppUi() ); |
|
881 } |
|
882 |
|
883 // End of file |