|
1 /* |
|
2 * Copyright (c) 2007-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: For Month view of calendar application. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aknnavide.h> |
|
20 #include <bldvariant.hrh> // For FeatureIds (lint warns without) |
|
21 #include <eikmenup.h> |
|
22 #include <eikspane.h> //CEikStatusPane |
|
23 #include <StringLoader.h> |
|
24 #include <aknappui.h> |
|
25 #include <featmgr.h> |
|
26 #include <calinstance.h> |
|
27 #include <calinstanceview.h> |
|
28 #include <calcommon.h> |
|
29 #include <caliterator.h> |
|
30 #include <Calendar.rsg> |
|
31 #include <calencommonui.rsg> |
|
32 #include <calencommands.hrh> // Calendar commands |
|
33 #include <calencontext.h> |
|
34 #include <CalenStatusPaneUtils.h> |
|
35 #include <calenservices.h> |
|
36 #include <caleninstanceid.h> |
|
37 #include <calenviewutils.h> |
|
38 #include <calcalendarinfo.h> |
|
39 |
|
40 #include "calendarui_debug.h" |
|
41 #include "calenmonthview.h" |
|
42 #include "calenmonthcontainer.h" |
|
43 #include <CalenInterimUtils2.h> |
|
44 #include "calentitlepane.h" |
|
45 #include "calensend.h" |
|
46 #include "ToDo.hrh" |
|
47 #include "calendar.hrh" |
|
48 #include "CalenUid.h" |
|
49 |
|
50 // ================= MEMBER FUNCTIONS ========================================= |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // CCalenMonthView::NewLC |
|
54 // First stage construction |
|
55 // (other items were commented in a header). |
|
56 // ---------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C CCalenMonthView* CCalenMonthView::NewL( MCalenServices& aServices ) |
|
59 { |
|
60 TRACE_ENTRY_POINT; |
|
61 |
|
62 CCalenMonthView* self = new( ELeave ) CCalenMonthView( aServices ); |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 CleanupStack::Pop( self ); |
|
66 |
|
67 TRACE_EXIT_POINT; |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CCalenMonthView::~CCalenMonthView |
|
73 // Destructor |
|
74 // (other items were commented in a header). |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 CCalenMonthView::~CCalenMonthView() |
|
78 { |
|
79 TRACE_ENTRY_POINT; |
|
80 TRACE_EXIT_POINT; |
|
81 } |
|
82 |
|
83 // ---------------------------------------------------------------------------- |
|
84 // CCalenMonthView::CCalenMonthView |
|
85 // C++ default constructor can NOT contain any code, that might leave. |
|
86 // (other items were commented in a header). |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 CCalenMonthView::CCalenMonthView( MCalenServices& aServices ) |
|
90 : CCalenNativeView( aServices ), |
|
91 iPopulationStep( ENothingDone ) |
|
92 { |
|
93 TRACE_ENTRY_POINT; |
|
94 TRACE_EXIT_POINT; |
|
95 } |
|
96 |
|
97 // ---------------------------------------------------------------------------- |
|
98 // CCalenMonthView::ConstructL |
|
99 // Symbian OS constructor can leave. |
|
100 // (other items were commented in a header). |
|
101 // ---------------------------------------------------------------------------- |
|
102 // |
|
103 void CCalenMonthView::ConstructL() |
|
104 { |
|
105 TRACE_ENTRY_POINT; |
|
106 |
|
107 CommonConstructL( R_CALEN_MONTHVIEW_INFO ); |
|
108 //iLocalisedViewName = StringLoader::LoadL( R_CALEN_VIEW_MONTH, iCoeEnv ); |
|
109 |
|
110 TRACE_EXIT_POINT; |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------------------------------- |
|
114 // CCalenMonthView::SetStatusPaneFromActiveContextL |
|
115 // Set active date to Status pane |
|
116 // (other items were commented in a header). |
|
117 // ---------------------------------------------------------------------------- |
|
118 // |
|
119 void CCalenMonthView::SetStatusPaneFromActiveContextL() |
|
120 { |
|
121 TRACE_ENTRY_POINT; |
|
122 |
|
123 // title pane |
|
124 TBuf<KMaxMonthName> title; |
|
125 TTime activeDay = CCalenContainer::DateFromContextL( iServices.Context() ); |
|
126 TDateTime activeDayTime = activeDay.DateTime(); |
|
127 iSPUtils->MonthNameByActiveTime( title, activeDay ); |
|
128 iSPUtils->UnderLineTitleText( EFalse ); |
|
129 iSPUtils->SetTitleTextL( title ); |
|
130 |
|
131 |
|
132 // navi pane |
|
133 CAknNavigationDecorator* naviLabel = iSPUtils->ShowNaviPaneL( activeDay ); |
|
134 ShowValidScrollButtons( *naviLabel, |
|
135 activeDay - TTimeIntervalMonths(1), |
|
136 activeDay + TTimeIntervalMonths(1) ); |
|
137 |
|
138 iSPUtils->RefreshStatusPane(); |
|
139 TRACE_EXIT_POINT; |
|
140 } |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
|
143 // CCalenMonthView::DoActivateImplL |
|
144 // CCalenNativeView::DoActivateL() calls DoActivateImplL() |
|
145 // (other items were commented in a header). |
|
146 // ---------------------------------------------------------------------------- |
|
147 // |
|
148 void CCalenMonthView::DoActivateImplL( const TVwsViewId& /*aPrevViewId*/, |
|
149 TUid /*aCustomMessageId*/, |
|
150 const TDesC8& /*aCustomMessage*/ ) |
|
151 { |
|
152 TRACE_ENTRY_POINT; |
|
153 |
|
154 static_cast<CCalenMonthContainer*>(iContainer)->InitDataForMonthL(); |
|
155 |
|
156 TRACE_EXIT_POINT; |
|
157 } |
|
158 |
|
159 // ---------------------------------------------------------------------------- |
|
160 // CCalenMonthView::DoDeactivateImpl |
|
161 // CCalenNativeView::DoDeactivateL() calls DoDeactivateImplL() |
|
162 // (other items were commented in a header). |
|
163 // ---------------------------------------------------------------------------- |
|
164 // |
|
165 void CCalenMonthView::DoDeactivateImpl() |
|
166 { |
|
167 TRACE_ENTRY_POINT; |
|
168 |
|
169 if (!iAvkonAppUi->IsDisplayingMenuOrDialog()) |
|
170 { |
|
171 iSPUtils->HideNaviPane(); |
|
172 //iNaviContainer->Pop(iNaviLabel); |
|
173 //delete iNaviLabel; |
|
174 //iNaviLabel = NULL; |
|
175 } |
|
176 |
|
177 TRACE_EXIT_POINT; |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CCalenMonthView::CreateContainerImplL |
|
182 // making CCalendarContainer. In this class, it is CCalenMonthContainer. |
|
183 // (other items were commented in a header). |
|
184 // ---------------------------------------------------------------------------- |
|
185 // |
|
186 CCalenContainer* CCalenMonthView::CreateContainerImplL() |
|
187 { |
|
188 TRACE_ENTRY_POINT; |
|
189 |
|
190 TRACE_EXIT_POINT; |
|
191 return new( ELeave )CCalenMonthContainer( this, iDate, iServices ); |
|
192 } |
|
193 |
|
194 // ---------------------------------------------------------------------------- |
|
195 // CCalenMonthView::OnLocaleChangedL |
|
196 // Locale or Today was changed when this function is called. |
|
197 // (other items were commented in a header). |
|
198 // ---------------------------------------------------------------------------- |
|
199 // |
|
200 void CCalenMonthView::OnLocaleChangedL(TInt aReason) |
|
201 { |
|
202 TRACE_ENTRY_POINT; |
|
203 |
|
204 if (iContainer) |
|
205 { |
|
206 if (iContainer->IsVisible()) |
|
207 { |
|
208 if (aReason & EChangesLocale) |
|
209 { |
|
210 if (IsContainerFocused()) |
|
211 { |
|
212 SetStatusPaneFromActiveContextL(); |
|
213 } |
|
214 else |
|
215 { |
|
216 iLocChangeReason = aReason; |
|
217 } |
|
218 } |
|
219 if ((aReason & EChangesSystemTime ) || (aReason & EChangesMidnightCrossover )) |
|
220 { |
|
221 static_cast<CCalenMonthContainer*>(iContainer)->ChangesMidnightCrossover(); |
|
222 } |
|
223 } |
|
224 else |
|
225 { // Not visible |
|
226 iLocChangeReason = aReason; |
|
227 } |
|
228 } |
|
229 |
|
230 TRACE_EXIT_POINT; |
|
231 } |
|
232 |
|
233 // ---------------------------------------------------------------------------- |
|
234 // CCalenMonthView::RedrawStatusPaneL |
|
235 // Redraw status pane when Form is closed |
|
236 // (other items were commented in a header). |
|
237 // ---------------------------------------------------------------------------- |
|
238 // |
|
239 void CCalenMonthView::RedrawStatusPaneL() |
|
240 { |
|
241 TRACE_ENTRY_POINT; |
|
242 |
|
243 SetStatusPaneFromActiveContextL(); |
|
244 |
|
245 static_cast<CCalenMonthContainer*>( |
|
246 iContainer)->ChangesMidnightCrossover(); |
|
247 |
|
248 static_cast<CCalenMonthContainer*>( |
|
249 iContainer)->RedrawPreviewPane(); |
|
250 |
|
251 TRACE_EXIT_POINT; |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------------------------------- |
|
255 // CCalenMonthView::DynInitMenuPaneL |
|
256 // Changes MenuPane dynamically |
|
257 // (other items were commented in a header). |
|
258 // ---------------------------------------------------------------------------- |
|
259 // |
|
260 void CCalenMonthView::DynInitMenuPaneL(TInt aResourceId, |
|
261 CEikMenuPane* aMenuPane) |
|
262 { |
|
263 TRACE_ENTRY_POINT; |
|
264 |
|
265 TBool isEntry = EFalse; |
|
266 static_cast<CCalenMonthContainer*>(iContainer)->HidePopup(); |
|
267 |
|
268 |
|
269 CCalenNativeView::DynInitMenuPaneL(aResourceId, aMenuPane); |
|
270 switch (aResourceId) |
|
271 { |
|
272 case R_CALENDAR_MONTH_MENUPANE: |
|
273 { |
|
274 |
|
275 #ifdef RD_CALEN_EXTERNAL_CAL |
|
276 TBool isit=ExtCalendarAvailableL(); |
|
277 if (!isit) |
|
278 { |
|
279 ReleaseServiceHandler(); |
|
280 TInt dummy; |
|
281 if (aMenuPane->MenuItemExists(ECalenExtAiwCommandId,dummy)) |
|
282 { |
|
283 aMenuPane->DeleteMenuItem(ECalenExtAiwCommandId); |
|
284 } |
|
285 } |
|
286 #endif //RD_CALEN_EXTERNAL_CAL |
|
287 |
|
288 if ( ! FeatureManager::FeatureSupported(KFeatureIdHelp) ) |
|
289 { |
|
290 aMenuPane->DeleteMenuItem(EAknCmdHelp); |
|
291 } |
|
292 |
|
293 RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
294 iServices.GetAllCalendarInfoL(calendarInfoList); |
|
295 CleanupClosePushL(calendarInfoList); |
|
296 |
|
297 for(TInt index=0 ; index < calendarInfoList.Count();index++ ) |
|
298 { |
|
299 if(calendarInfoList[index]->Enabled() ) |
|
300 { |
|
301 CCalIter* iterator = CCalIter::NewL( |
|
302 iServices.SessionL(calendarInfoList[index]->FileNameL()) ); |
|
303 CleanupStack::PushL( iterator ); |
|
304 if( iterator->FirstL() != KNullDesC8() ) |
|
305 { |
|
306 isEntry = ETrue; |
|
307 } |
|
308 CleanupStack::PopAndDestroy( iterator ); |
|
309 } |
|
310 |
|
311 } |
|
312 CleanupStack::PopAndDestroy(&calendarInfoList); |
|
313 |
|
314 if( !isEntry ) |
|
315 { |
|
316 aMenuPane->DeleteMenuItem( ECalenDeleteAllEntries ); |
|
317 } |
|
318 if( !iServices.InterimUtilsL().MRViewersEnabledL( ETrue ) ) |
|
319 { |
|
320 aMenuPane->DeleteMenuItem( ECalenNewMeetingRequest ); |
|
321 } |
|
322 // Offer the menu pane to the services for customisation by the |
|
323 // the view manager/plugins |
|
324 iServices.OfferMenuPaneL( aResourceId, aMenuPane ); |
|
325 } |
|
326 break; |
|
327 |
|
328 default: |
|
329 break; |
|
330 } |
|
331 |
|
332 TRACE_EXIT_POINT; |
|
333 } |
|
334 |
|
335 // ---------------------------------------------------------------------------- |
|
336 // CMonthCalenView::HandleCommandL |
|
337 // Command handling for month view. |
|
338 // (other items were commented in a header). |
|
339 // ---------------------------------------------------------------------------- |
|
340 // |
|
341 void CCalenMonthView::HandleCommandL(TInt aCommand) |
|
342 { |
|
343 TRACE_ENTRY_POINT; |
|
344 |
|
345 switch (aCommand) |
|
346 { |
|
347 // if MSK Open was selected then switch into Day view. |
|
348 case EAknSoftkeyOpen: |
|
349 CCalenNativeView::HandleCommandL( ECalenForwardsToDayView ); |
|
350 break; |
|
351 // otherwise let CCalenNativeView handle the command. |
|
352 default: |
|
353 CCalenNativeView::HandleCommandL(aCommand); |
|
354 break; |
|
355 } |
|
356 |
|
357 TRACE_EXIT_POINT; |
|
358 } |
|
359 |
|
360 // ---------------------------------------------------------------------------- |
|
361 // CCalenMonthView::Id |
|
362 // From CAknView |
|
363 // Return the UID of the month view |
|
364 // (other items were commented in a header) |
|
365 // ---------------------------------------------------------------------------- |
|
366 // |
|
367 TUid CCalenMonthView::Id() const |
|
368 { |
|
369 TRACE_ENTRY_POINT; |
|
370 |
|
371 TRACE_EXIT_POINT; |
|
372 return KUidCalenMonthView; |
|
373 } |
|
374 |
|
375 // ---------------------------------------------------------------------------- |
|
376 // CCalenMonthView::ClearViewSpecificDataL |
|
377 // Clears any cached data for the specific view, e.g. currently |
|
378 // highlighted row, column, etc. |
|
379 // (other items were commented in a header) |
|
380 // ---------------------------------------------------------------------------- |
|
381 // |
|
382 void CCalenMonthView::ClearViewSpecificDataL() |
|
383 { |
|
384 TRACE_ENTRY_POINT; |
|
385 |
|
386 iDate = Time::NullTTime(); |
|
387 |
|
388 TRACE_EXIT_POINT; |
|
389 } |
|
390 |
|
391 // ---------------------------------------------------------------------------- |
|
392 // CCalenMonthView::IsViewSpecificDataNullL |
|
393 // From CCalenNativeView |
|
394 // Returns ETrue if the view specific data is null, EFalse otherwise. |
|
395 // (other items were commented in a header) |
|
396 // ---------------------------------------------------------------------------- |
|
397 // |
|
398 TBool CCalenMonthView::IsViewSpecificDataNullL() |
|
399 { |
|
400 TRACE_ENTRY_POINT; |
|
401 TRACE_EXIT_POINT; |
|
402 return ( iDate == Time::NullTTime() ); |
|
403 } |
|
404 |
|
405 // ---------------------------------------------------------------------------- |
|
406 // CCalenMonthView::ActiveStepL |
|
407 // From CCalenView |
|
408 // (other items were commented in a header) |
|
409 // ---------------------------------------------------------------------------- |
|
410 // |
|
411 CCalenView::TNextPopulationStep CCalenMonthView::ActiveStepL() |
|
412 { |
|
413 TRACE_ENTRY_POINT; |
|
414 |
|
415 CCalenMonthContainer* cnt = static_cast<CCalenMonthContainer*>( iContainer ); |
|
416 |
|
417 switch( iPopulationStep ) |
|
418 { |
|
419 case ENothingDone: |
|
420 { |
|
421 cnt->PrepareForPopulationL(); |
|
422 iPopulationStep = ERequestedInstanceView; |
|
423 |
|
424 CCalenView::TNextPopulationStep nextStep = CCalenView::EDone; |
|
425 |
|
426 // Get the active collection ids. |
|
427 RArray<TInt> colIdArray; |
|
428 CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray ); |
|
429 |
|
430 if(colIdArray.Count() > 0) |
|
431 { |
|
432 if( !iServices.InstanceViewL(colIdArray) ) |
|
433 { |
|
434 TRACE_EXIT_POINT; |
|
435 nextStep = CCalenView::EWaitForInstanceView; |
|
436 } |
|
437 else |
|
438 { |
|
439 TRACE_EXIT_POINT; |
|
440 nextStep = CCalenView::EKeepGoing; |
|
441 } |
|
442 } |
|
443 else |
|
444 { |
|
445 if( !iServices.InstanceViewL() ) |
|
446 { |
|
447 TRACE_EXIT_POINT; |
|
448 nextStep = CCalenView::EWaitForInstanceView; |
|
449 } |
|
450 else |
|
451 { |
|
452 TRACE_EXIT_POINT; |
|
453 nextStep = CCalenView::EKeepGoing; |
|
454 } |
|
455 } |
|
456 colIdArray.Reset(); |
|
457 return nextStep; |
|
458 } |
|
459 |
|
460 case ERequestedInstanceView: |
|
461 { |
|
462 cnt->PopulateWithInstanceViewL(); |
|
463 iPopulationStep = ESetIndicatorNext; |
|
464 TRACE_EXIT_POINT; |
|
465 return CCalenView::EKeepGoing; |
|
466 } |
|
467 case ESetIndicatorNext: |
|
468 { |
|
469 cnt->SetIndicatorL(); |
|
470 iPopulationStep = ESetFocusNext; |
|
471 TRACE_EXIT_POINT; |
|
472 return CCalenView::EKeepGoing; |
|
473 } |
|
474 case ESetFocusNext: |
|
475 { |
|
476 cnt->SetFocusL(); |
|
477 iPopulationStep = EPopulationDone; |
|
478 TRACE_EXIT_POINT; |
|
479 return CCalenView::EKeepGoing; |
|
480 } |
|
481 case EPopulationDone: /* fall through... */ |
|
482 default: |
|
483 { |
|
484 cnt->CompletePopulationL(); |
|
485 |
|
486 TRACE_EXIT_POINT; |
|
487 return CCalenView::EDone; |
|
488 } |
|
489 } |
|
490 } |
|
491 |
|
492 // ---------------------------------------------------------------------------- |
|
493 // CCalenMonthView::CancelPopulation |
|
494 // From CCalenView |
|
495 // (other items were commented in a header) |
|
496 // ---------------------------------------------------------------------------- |
|
497 // |
|
498 void CCalenMonthView::CancelPopulation() |
|
499 { |
|
500 TRACE_ENTRY_POINT; |
|
501 |
|
502 iPopulationStep = ENothingDone; |
|
503 |
|
504 TRACE_EXIT_POINT; |
|
505 } |
|
506 |
|
507 // ---------------------------------------------------------------------------- |
|
508 // CCalenMonthView::CyclePosition |
|
509 // From CCalenView |
|
510 // (other items were commented in a header) |
|
511 // ---------------------------------------------------------------------------- |
|
512 // |
|
513 CCalenView::TCyclePosition CCalenMonthView::CyclePosition() const |
|
514 { |
|
515 TRACE_ENTRY_POINT; |
|
516 TRACE_EXIT_POINT; |
|
517 return CCalenView::EReplaceMonthView; |
|
518 } |
|
519 |
|
520 // ---------------------------------------------------------------------------- |
|
521 // CCalenMonthView::LocalisedViewNameL |
|
522 // From CCalenView |
|
523 // (other items were commented in a header) |
|
524 // ---------------------------------------------------------------------------- |
|
525 // |
|
526 const TDesC& CCalenMonthView::LocalisedViewNameL( CCalenView::TViewName aViewName ) |
|
527 { |
|
528 TRACE_ENTRY_POINT; |
|
529 |
|
530 HBufC* ret = NULL; |
|
531 |
|
532 switch ( aViewName ) |
|
533 { |
|
534 case CCalenView::EMenuName: |
|
535 if ( !iMenuName ) |
|
536 { |
|
537 iMenuName = StringLoader::LoadL( R_CALEN_VIEW_MONTH, iCoeEnv ); |
|
538 } |
|
539 ret = iMenuName; |
|
540 break; |
|
541 case CCalenView::ESettingsName: |
|
542 if ( !iSettingsName ) |
|
543 { |
|
544 iSettingsName = StringLoader::LoadL( R_CALEN_QTN_DEFAULT_MONTH_VIEW, |
|
545 iCoeEnv ); |
|
546 } |
|
547 ret = iSettingsName; |
|
548 break; |
|
549 default: |
|
550 ASSERT( EFalse ); |
|
551 break; |
|
552 } |
|
553 |
|
554 TRACE_EXIT_POINT; |
|
555 return *ret; |
|
556 } |
|
557 |
|
558 // ---------------------------------------------------------------------------- |
|
559 // CCalenMonthView::ViewIconL |
|
560 // From CCalenView |
|
561 // (other items were commented in a header) |
|
562 // ---------------------------------------------------------------------------- |
|
563 // |
|
564 CGulIcon* CCalenMonthView::ViewIconL() const |
|
565 { |
|
566 TRACE_ENTRY_POINT; |
|
567 TRACE_EXIT_POINT; |
|
568 return iServices.GetIconL( MCalenServices::ECalenMonthViewIcon ); |
|
569 } |
|
570 |
|
571 // ---------------------------------------------------------------------------- |
|
572 // CCalenMonthView::UpdatePreviewPaneL |
|
573 // Updates preview pane/preview popup |
|
574 // (other items were commented in a header) |
|
575 // ---------------------------------------------------------------------------- |
|
576 // |
|
577 void CCalenMonthView::UpdatePreviewPaneL() |
|
578 { |
|
579 TRACE_ENTRY_POINT; |
|
580 |
|
581 CCalenMonthContainer* cnt = static_cast<CCalenMonthContainer*>( iContainer ); |
|
582 if(cnt) |
|
583 { |
|
584 cnt->RedrawPreviewPane(); |
|
585 } |
|
586 |
|
587 TRACE_EXIT_POINT; |
|
588 } |
|
589 |
|
590 // ---------------------------------------------------------------------------- |
|
591 // CCalenMonthView::HidePreviewPane |
|
592 // Hides preview pane/preview popup |
|
593 // (other items were commented in a header) |
|
594 // ---------------------------------------------------------------------------- |
|
595 // |
|
596 void CCalenMonthView::HidePreviewPane() |
|
597 { |
|
598 TRACE_ENTRY_POINT; |
|
599 |
|
600 CCalenMonthContainer* cnt = static_cast<CCalenMonthContainer*>( iContainer ); |
|
601 if(cnt) |
|
602 { |
|
603 cnt->HidePopup(); |
|
604 } |
|
605 |
|
606 TRACE_EXIT_POINT; |
|
607 } |
|
608 |
|
609 // End of File |