10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Calendar view manager |
14 * Description: Calendar view manager |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 //system includes |
19 #include <aknViewAppUi.h> |
20 #include <hbmainwindow.h> |
20 #include <centralrepository.h> |
21 #include <hbinstance.h> |
21 #include <AknQueryDialog.h> |
22 #include <hbapplication.h> // hbapplication |
22 #include <Calendar.rsg> |
23 #include <xqserviceutil.h> // service utils |
23 #include <calencommonui.rsg> |
24 #include <afactivation.h> |
24 #include <akntoolbar.h> |
25 #include <AfActivityStorage.h> |
25 #include <calendateutils.h> |
26 //user includes |
26 #include <calencommandhandler.h> |
|
27 #include <calencommands.hrh> // Calendar commands |
|
28 #include <calentoolbar.h> |
|
29 #include <akntoolbarextension.h> |
|
30 #include <calenactionuiutils.h> |
|
31 #include <featmgr.h> |
|
32 |
|
33 #include "calendarui_debug.h" |
27 #include "calenviewmanager.h" |
34 #include "calenviewmanager.h" |
|
35 #include "CalenUid.h" |
28 #include "calencontroller.h" |
36 #include "calencontroller.h" |
29 #include "hb_calencommands.hrh" |
37 #include "calenviewpopulator.h" |
|
38 #include "calenglobaldata.h" |
|
39 #include "CalendarPrivateCRKeys.h" // includes CalendarInternalCRKeys.h |
|
40 #include "calenmonthview.h" // Native month view |
|
41 #include "calenweekview.h" // Native week view |
|
42 #include "calendayview.h" // Native day view |
|
43 #include "calentodoview.h" // Native todo view |
|
44 #include "caleneventview.h" // Event View |
|
45 #include "calenmissedalarmsview.h" // Missed alarms view |
|
46 #include "calenmissedeventview.h" // Missed event view |
|
47 #include "calensetting.h" // CCalenSetting::TViewType |
|
48 #include "calencmdlinelauncher.h" // Command line launcher |
30 #include "calenservicesimpl.h" |
49 #include "calenservicesimpl.h" |
31 #include "calenmonthview.h" |
50 #include "CleanupResetAndDestroy.h" |
32 #include "calenagendaview.h" |
51 #include "calentoolbarimpl.h" |
33 #include "calenmonthview.h" |
52 #include "calencustomisationmanager.h" |
34 #include "agendaeventviewer.h" |
53 #include "calenviewinfo.h" |
35 #include "calennotificationhandler.h" |
54 #include "calentitlepane.h" |
36 #include "CalenUid.h" |
55 #include "calenicons.h" |
37 #include "calenactionuiutils.h" |
56 #include "calendummyview.h" |
38 #include "calensettingsview.h" |
57 |
39 #include "calendocloader.h" |
58 const TInt KArrayGranularity = 5; |
40 #include "calendarui_debug.h" |
59 |
41 #include "calencommon.h" |
60 // ---------------------------------------------------------------------------- |
42 #include "calendayview.h" |
61 // CCalenViewManager::NewL |
43 #include <agendautil.h> |
62 // 1st phase of construction |
44 #include "OstTraceDefinitions.h" |
63 // (other items were commented in a header). |
45 #ifdef OST_TRACE_COMPILER_IN_USE |
64 // ---------------------------------------------------------------------------- |
46 #include "calenviewmanagerTraces.h" |
65 // |
47 #endif |
66 CCalenViewManager* CCalenViewManager::NewL( CAknViewAppUi& aAppUi, |
48 |
67 CCalenController& aController ) |
49 // ---------------------------------------------------------------------------- |
68 { |
50 // CalenViewManager::CalenViewManager |
69 TRACE_ENTRY_POINT; |
|
70 |
|
71 CCalenViewManager* self = new( ELeave ) CCalenViewManager( aAppUi,aController ); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop( self ); |
|
75 |
|
76 TRACE_EXIT_POINT; |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // CCalenViewManager::CCalenViewManager |
|
82 // C++ default Constructor. |
|
83 // (other items were commented in a header). |
|
84 // ---------------------------------------------------------------------------- |
|
85 // |
|
86 CCalenViewManager::CCalenViewManager( CAknViewAppUi& aAppUi, |
|
87 CCalenController& aController ) |
|
88 : iAppUi( aAppUi ), iController( aController ) |
|
89 { |
|
90 TRACE_ENTRY_POINT; |
|
91 TRACE_EXIT_POINT; |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // CCalenViewManager::~CCalenViewManager |
|
96 // Destructor. |
|
97 // (other items were commented in a header). |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 CCalenViewManager::~CCalenViewManager() |
|
101 { |
|
102 TRACE_ENTRY_POINT; |
|
103 |
|
104 delete iPopulator; |
|
105 if(iToolbar) |
|
106 { |
|
107 delete iToolbar; |
|
108 iToolbar = NULL; |
|
109 } |
|
110 if( iSetting ) |
|
111 { |
|
112 iSetting->Release(); |
|
113 } |
|
114 |
|
115 if( iGlobalData ) |
|
116 { |
|
117 iGlobalData->Release(); |
|
118 } |
|
119 |
|
120 iViewInfoArray.ResetAndDestroy(); |
|
121 iKnownPlugins.Reset(); |
|
122 |
|
123 delete iRemovedActiveView; |
|
124 delete iViewRemovalCallback; |
|
125 delete iIcons; |
|
126 |
|
127 TRACE_EXIT_POINT; |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // CCalenViewManager::ConstructL |
51 // 2nd phase of construction. |
132 // 2nd phase of construction. |
52 // (other items were commented in a header). |
133 // (other items were commented in a header). |
53 // ---------------------------------------------------------------------------- |
134 // ---------------------------------------------------------------------------- |
54 // |
135 // |
55 CalenViewManager::CalenViewManager( CCalenController& aController) |
136 void CCalenViewManager::ConstructL() |
56 : mController(aController) |
137 { |
57 { |
138 TRACE_ENTRY_POINT; |
58 OstTraceFunctionEntry0( CALENVIEWMANAGER_CALENVIEWMANAGER_ENTRY ); |
139 |
|
140 iGlobalData = CCalenGlobalData::InstanceL(); |
|
141 iPopulator = CCalenViewPopulator::NewL( iController ); |
|
142 |
|
143 // Only create a toolbar impl if touch is enabled and a CAknToolbar exists |
|
144 if( AknLayoutUtils::PenEnabled() ) |
|
145 { |
|
146 CAknAppUi* appUi = static_cast<CAknAppUi*>( CEikonEnv::Static()->EikAppUi() ); |
|
147 if (appUi->CurrentFixedToolbar()) |
|
148 { |
|
149 if ( FeatureManager::FeatureSupported( KFeatureIdFfCalDayView ) ) |
|
150 { |
|
151 appUi->CurrentFixedToolbar()->SetToolbarVisibility( EFalse ); |
|
152 } |
|
153 else |
|
154 { |
|
155 iToolbar = CCalenToolbarImpl::NewL( iController ); |
|
156 } |
|
157 } |
|
158 } |
|
159 |
|
160 iSetting = CCalenSetting::InstanceL(); |
|
161 iPreviousViewId.iViewUid = KNullUid; |
|
162 iAvoidRepopulation = EFalse; |
|
163 iStartupComplete = ETrue; |
|
164 iFakeExit = EFalse; |
|
165 TRACE_EXIT_POINT; |
|
166 } |
|
167 |
|
168 // ---------------------------------------------------------------------------- |
|
169 // CCalenViewManager::SetCustomisationManagerL |
|
170 // Creates custom views. |
|
171 // (other items were commented in a header). |
|
172 // ---------------------------------------------------------------------------- |
|
173 // |
|
174 void CCalenViewManager::ConstructCustomViewsL( |
|
175 CCalenCustomisationManager& aCustomisationManager ) |
|
176 { |
|
177 TRACE_ENTRY_POINT; |
|
178 |
|
179 iCustomisationManager = &aCustomisationManager; |
|
180 ConstructCustomViewsL(); |
|
181 ConstructNativeViewsL(); |
|
182 |
|
183 TUid defViewUid = iSetting->DefaultView(); |
|
184 ActivateDefaultViewL( defViewUid ); |
|
185 |
|
186 // Register for view activation events |
|
187 iAppUi.AddViewActivationObserverL( this ); |
|
188 |
|
189 TRACE_EXIT_POINT; |
|
190 } |
|
191 |
|
192 // ---------------------------------------------------------------------------- |
|
193 // CCalenViewManager::ViewInfoArray |
|
194 // Get info array |
|
195 // (other items were commented in a header). |
|
196 // ---------------------------------------------------------------------------- |
|
197 // |
|
198 RPointerArray<CCalenViewInfo>& CCalenViewManager::ViewInfoArray() |
|
199 { |
|
200 TRACE_ENTRY_POINT; |
|
201 TRACE_EXIT_POINT; |
|
202 return iViewInfoArray; |
|
203 } |
|
204 |
|
205 // ---------------------------------------------------------------------------- |
|
206 // CCalenViewManager::CustomiszationManager |
|
207 // Return reference to the customisation manager |
|
208 // (other items were commented in a header). |
|
209 // ---------------------------------------------------------------------------- |
|
210 // |
|
211 CCalenCustomisationManager& CCalenViewManager::CustomisationManager() |
|
212 { |
|
213 TRACE_ENTRY_POINT; |
|
214 |
|
215 ASSERT( iCustomisationManager ); |
|
216 |
|
217 TRACE_EXIT_POINT; |
|
218 return *iCustomisationManager; |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CCalenViewManager::ConstructNativeViewsL |
|
223 // Constructs the S60 native views and registers them with the view server |
|
224 // (other items were commented in a header). |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void CCalenViewManager::ConstructNativeViewsL() |
|
228 { |
|
229 TRACE_ENTRY_POINT; |
|
230 |
|
231 CCalenTitlePane::NewAndSwapL(iAppUi.StatusPane()); |
|
232 MCalenServices& services = iController.Services(); |
|
233 |
|
234 |
|
235 // Add the native views for the todo view, week view, day view , month |
|
236 // view and event view unless they are already provided by custom views |
|
237 // in ROM.This is enforced by the customisation manager rejecting any |
|
238 // views that try to replace the native views but are not in ROM. |
|
239 |
|
240 if (CreateNativeViewL(KUidCalenMonthView)) |
|
241 { |
|
242 // Views take ownership of services object instantly. |
|
243 // No need for cleanup stack. |
|
244 CCalenMonthView* monthView = CCalenMonthView::NewL(services); |
|
245 AddNativeViewL(monthView); // takes ownership immediately. |
|
246 } |
|
247 |
|
248 if (CreateNativeViewL(KUidCalenWeekView)) |
|
249 { |
|
250 // Views take ownership of services object instantly. |
|
251 // No need for cleanup stack. |
|
252 CCalenWeekView* weekView = CCalenWeekView::NewL(services); |
|
253 AddNativeViewL(weekView); // takes ownership immediately. |
|
254 } |
|
255 |
|
256 if (CreateNativeViewL(KUidCalenDayView)) |
|
257 { |
|
258 // Views take ownership of services object instantly. |
|
259 // No need for cleanup stack. |
|
260 CCalenDayView* dayView = CCalenDayView::NewL(services); |
|
261 AddNativeViewL(dayView); // takes ownership immediately. |
|
262 } |
|
263 |
|
264 if (CreateNativeViewL(KUidCalenTodoView)) |
|
265 { |
|
266 // Views take ownership of services object instantly. |
|
267 // No need for cleanup stack. |
|
268 CCalenTodoView* todoView = CCalenTodoView::NewL(services); |
|
269 AddNativeViewL(todoView); // takes ownership immediately. |
|
270 } |
59 |
271 |
60 // Following block intializes member variables |
272 if( CreateNativeViewL(KUidCalenEventView)) |
61 mCalenEventViewer = NULL; |
273 { |
62 mMonthViewDocLoader = NULL; |
274 // Views take ownership of services object instantly. |
63 mAgendaViewDocLoader = NULL; |
275 // No need for cleanup stack. |
64 mAgendaViewAltDocLoader = NULL; |
276 CCalenEventView* eventView = CCalenEventView::NewL(services); |
65 mCalenAgendaView = NULL; |
277 AddNativeViewL(eventView); // takes ownership immediately. |
66 mCalenMonthView = NULL; |
278 } |
67 mCalenAgendaViewAlt = NULL; |
279 |
68 mSettingsView = NULL; |
280 if( CreateNativeViewL(KUidCalenMissedAlarmsView)) |
69 mCalenDayView = NULL; |
281 { |
70 mInstanceViewCreated = false; |
282 // Views take ownership of services object instantly. |
|
283 // No need for cleanup stack. |
|
284 CCalenMissedAlarmsView* missedAlarmsView = CCalenMissedAlarmsView::NewL(services); |
|
285 AddNativeViewL(missedAlarmsView); // takes ownership immediately. |
|
286 } |
|
287 |
|
288 if( CreateNativeViewL(KUidCalenMissedEventView)) |
|
289 { |
|
290 // Views take ownership of services object instantly. |
|
291 // No need for cleanup stack. |
|
292 CCalenMissedEventView* missedEventView = CCalenMissedEventView::NewL(services); |
|
293 AddNativeViewL(missedEventView); // takes ownership immediately. |
|
294 } |
71 |
295 |
72 // Connect to instance view and entry view creation signals from agenda |
296 if(CreateNativeViewL(KUidCalenDummyView)) |
73 // interface |
297 { |
74 connect(mController.agendaInterface(), SIGNAL(instanceViewCreationCompleted(int)), |
298 CCalenDummyView* dummyView = CCalenDummyView::NewL(services); |
75 this, SLOT(handleInstanceViewCreation(int))); |
299 AddNativeViewL(dummyView); |
76 connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)), |
300 } |
77 this, SLOT(handleEntryViewCreation(int))); |
301 TRACE_EXIT_POINT; |
78 connect(mController.agendaInterface(), SIGNAL(entriesChanged(QList<ulong>)), |
302 } |
79 this, SLOT(handleEntriesChanged(QList<ulong>))); |
303 |
80 connect(mController.agendaInterface(), SIGNAL(entryUpdated(ulong)), |
304 // ---------------------------------------------------------------------------- |
81 this, SLOT(handleEntryUpdation(ulong))); |
305 // CCalenViewManager::CreateNativeViewL |
82 connect(mController.agendaInterface(), SIGNAL(entryAdded(ulong)), |
306 // Checks to see if the native view needs to created. |
83 this, SLOT(handleEntryUpdation(ulong))); |
307 // (other items were commented in a header). |
84 OstTraceFunctionExit0( CALENVIEWMANAGER_CALENVIEWMANAGER_EXIT ); |
308 // ---------------------------------------------------------------------------- |
85 } |
309 // |
86 |
310 TBool CCalenViewManager::CreateNativeViewL(TUid aViewUid) |
87 void CalenViewManager::SecondPhaseConstruction() |
311 { |
88 { |
312 TRACE_ENTRY_POINT; |
89 OstTraceFunctionEntry0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_ENTRY ); |
313 |
90 |
314 TBool createNativeView = ETrue; |
91 // Check if calendar is launched thru XQService framework |
315 TBool (*compareFn)(const TUid*, const CCalenViewInfo&) |
92 bool isFromServiceFrmWrk = XQServiceUtil::isService(); // Since activateReason |
316 = CCalenViewInfo::ViewInfoIdentifier; |
93 //of hbapplication is not returning right value if the activity is started |
317 |
94 //as services so using the above line temporarily untill a fix is available in |
318 TInt position = iViewInfoArray.Find( aViewUid, compareFn ); |
95 // hbappliac |
319 if ( position != KErrNotFound ) |
96 AfActivation *activation = new AfActivation(); |
320 { |
97 if(Af::ActivationReasonActivity == activation->reason()) |
321 // A plugin is trying to replace a native view, find if it is rom |
98 // as an activity |
322 // based or not |
99 { |
323 TBool romBased = CustomisationManager().IsViewRomBased( aViewUid ); |
100 // Application is started from an activity |
324 if ( romBased ) |
101 // Extract activity data |
325 { |
102 AfActivityStorage *activitystorage = new AfActivityStorage(); |
326 createNativeView = EFalse; |
103 QVariant data = activitystorage->activityData(activation->name()); |
327 } |
104 delete activitystorage; |
328 else |
105 |
329 { |
106 // Restore state from activity data |
330 // A non-rom plugin cannot replace the native views, so the view is |
107 QByteArray serializedModel = data.toByteArray(); |
331 // removed |
108 QDataStream stream(&serializedModel, QIODevice::ReadOnly); |
332 iAppUi.RemoveView( aViewUid ); |
109 int viewId; // int declared for debugging purpose |
333 |
110 stream >> viewId; // read stream into an int |
334 // Remove the entry from the view info array |
|
335 iViewInfoArray.Remove( position ); |
|
336 |
|
337 createNativeView = ETrue; |
|
338 } |
|
339 } |
111 |
340 |
112 mFirstView = viewId; |
341 TRACE_EXIT_POINT; |
113 if (ECalenMonthView == viewId) // Check if Activity was stored for month view |
342 return createNativeView; |
114 { |
343 } |
115 loadMonthView(); // Load month view |
344 |
116 } |
345 // ---------------------------------------------------------------------------- |
117 else if (ECalenAgendaView == viewId) // Check if Activity was stored for agenda view |
346 // CCalenViewManager::ConstructCustomViewsL |
118 { |
347 // Constructs any custom views from all the plugins and registers them |
119 loadAgendaView(); // Load agenda view |
348 // with the view server |
120 } |
349 // (other items were commented in a header). |
|
350 // ---------------------------------------------------------------------------- |
|
351 // |
|
352 void CCalenViewManager::ConstructCustomViewsL() |
|
353 { |
|
354 TRACE_ENTRY_POINT; |
|
355 |
|
356 // Get the array of active plugins |
|
357 const RArray<TUid>& plugins = CustomisationManager().ActivePlugins(); |
|
358 |
|
359 // For every active plugin, discover if it offers any customised views |
|
360 // and adds them to the view server. |
|
361 TInt numPlugins = plugins.Count(); |
|
362 for( TInt pluginIndex( 0 ); pluginIndex < numPlugins; ++pluginIndex ) |
|
363 { |
|
364 TUid pluginUid = plugins[pluginIndex]; |
|
365 ConstructCustomViewL( pluginUid ); |
|
366 } |
|
367 |
|
368 TRACE_EXIT_POINT; |
|
369 } |
|
370 |
|
371 // ---------------------------------------------------------------------------- |
|
372 // CCalenViewManager::ConstructCustomViewsL |
|
373 // Constructs the custom views from a particular plugin and registers them |
|
374 // with the view server |
|
375 // (other items were commented in a header). |
|
376 // ---------------------------------------------------------------------------- |
|
377 // |
|
378 void CCalenViewManager::ConstructCustomViewL( TUid aPluginUid ) |
|
379 { |
|
380 TRACE_ENTRY_POINT; |
|
381 |
|
382 iKnownPlugins.AppendL( aPluginUid ); |
|
383 |
|
384 RPointerArray<CCalenView> customViews; |
|
385 CleanupResetAndDestroyPushL( customViews ); |
|
386 |
|
387 TRAP_IGNORE(CustomisationManager().GetCustomViewsL( aPluginUid, customViews )); |
|
388 for( TInt viewIndex( customViews.Count()-1 ); viewIndex >= 0; --viewIndex ) |
|
389 { |
|
390 CCalenView* customView = customViews[viewIndex]; |
|
391 iAppUi.AddViewL( customView ); |
|
392 customViews.Remove( viewIndex ); |
|
393 } |
|
394 CleanupStack::PopAndDestroy(); // customViews |
|
395 |
|
396 TRACE_EXIT_POINT; |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------------------------------- |
|
400 // CCalenViewManager::ActivateDefaultViewL |
|
401 // Activates the default view (retrieved from settings). |
|
402 // ---------------------------------------------------------------------------- |
|
403 // |
|
404 void CCalenViewManager::ActivateDefaultViewL( TUid aDefaultView ) |
|
405 { |
|
406 TRACE_ENTRY_POINT; |
|
407 |
|
408 // Find the default view in the view cycle list |
|
409 TInt position = iViewInfoArray.Find( |
|
410 aDefaultView, CCalenViewInfo::ViewInfoIdentifier ); |
|
411 if( position != KErrNotFound ) |
|
412 { |
|
413 iAppUi.SetDefaultViewL( *iAppUi.View( aDefaultView ) ); |
|
414 iViewCycleIndex = position; |
|
415 } |
|
416 else |
|
417 { |
|
418 CRepository* repository = CRepository::NewL( KCRUidCalendar ); |
|
419 CleanupStack::PushL(repository); |
|
420 TInt tmp( static_cast<TInt>( KUidCalenMonthView.iUid ) ); |
|
421 TInt position = iViewInfoArray.Find( KUidCalenMonthView, CCalenViewInfo::ViewInfoIdentifier ); |
|
422 User::LeaveIfError( repository->Set( KCalendarDefaultStartView, tmp ) ); |
|
423 iAppUi.SetDefaultViewL( *iAppUi.View( KUidCalenMonthView ) ); |
|
424 iViewCycleIndex = position; |
|
425 CleanupStack::PopAndDestroy(repository); |
|
426 } |
|
427 TRACE_EXIT_POINT; |
|
428 |
|
429 } |
|
430 |
|
431 // ---------------------------------------------------------------------------- |
|
432 // CCalenViewManager::InterruptPopulationL |
|
433 // Interrupts the population of the current view. When the editors are launched |
|
434 // the view population is interrupted as it will be repopulated when the |
|
435 // the editor closes. |
|
436 // ---------------------------------------------------------------------------- |
|
437 // |
|
438 void CCalenViewManager::InterruptPopulationL() |
|
439 { |
|
440 TRACE_ENTRY_POINT; |
|
441 |
|
442 // Cancel population of current view, if it's ongoing. |
|
443 iPopulator->InterruptPopulationL(); |
|
444 |
|
445 TRACE_EXIT_POINT; |
|
446 } |
|
447 |
|
448 // ---------------------------------------------------------------------------- |
|
449 // CCalenViewManager::RemoveCurrentViewFromMenu |
|
450 // Removes the current view from the cascading view switch menu |
|
451 // (other items were commented in a header). |
|
452 // ---------------------------------------------------------------------------- |
|
453 // |
|
454 void CCalenViewManager::RemoveCurrentViewFromMenu( CEikMenuPane* aMenuPane ) |
|
455 { |
|
456 TRACE_ENTRY_POINT; |
|
457 |
|
458 TUid uid = CurrentView(); |
|
459 |
|
460 if( uid == KUidCalenMonthView ) |
|
461 { |
|
462 aMenuPane->DeleteMenuItem( ECalenMonthView ); |
|
463 } |
|
464 else if( uid == KUidCalenWeekView ) |
|
465 { |
|
466 aMenuPane->DeleteMenuItem( ECalenWeekView ); |
|
467 } |
|
468 else if( uid == KUidCalenDayView ) |
|
469 { |
|
470 aMenuPane->DeleteMenuItem( ECalenDayView ); |
|
471 } |
|
472 else if( uid == KUidCalenTodoView ) |
|
473 { |
|
474 aMenuPane->DeleteMenuItem( ECalenTodoView ); |
|
475 } |
|
476 else |
|
477 { |
|
478 // Assert as this point should never be reached |
|
479 ASSERT( 0 ); |
|
480 } |
|
481 |
|
482 TRACE_EXIT_POINT; |
|
483 } |
|
484 |
|
485 // ---------------------------------------------------------------------------- |
|
486 // CCalenViewManager::AddNativeViewL |
|
487 // Adds a view to the array. |
|
488 // (other items were commented in a header). |
|
489 // ---------------------------------------------------------------------------- |
|
490 // |
|
491 void CCalenViewManager::AddNativeViewL( CCalenView* aView ) |
|
492 { |
|
493 TRACE_ENTRY_POINT; |
|
494 |
|
495 CleanupStack::PushL( aView ); |
|
496 iAppUi.AddViewL( aView ); |
|
497 CleanupStack::Pop( aView ); |
|
498 |
|
499 const TDesC& menuName = aView->LocalisedViewNameL( CCalenView::EMenuName ); |
|
500 const TDesC& settingsName = aView->LocalisedViewNameL( CCalenView::ESettingsName ); |
|
501 |
|
502 TUid viewUid = aView->Id(); |
|
503 |
|
504 |
|
505 CCalenViewInfo* viewInfo = CCalenViewInfo::NewL( aView->Id(), |
|
506 KUidCalendar, |
|
507 menuName, |
|
508 settingsName, |
|
509 aView->CyclePosition() ); |
121 |
510 |
122 ActivateDefaultViewL(viewId); |
511 // Discover if a native view has been hidden by a plugin. |
123 // Connect to the view ready signal so that we can construct other views |
512 TBool hidden = iCustomisationManager->HiddenView( viewUid ); |
124 // once this view is ready |
513 viewInfo->Hide( hidden ); |
125 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
514 |
126 this, SLOT(handleMainViewReady())); |
515 // Append to view info array |
127 |
516 iViewInfoArray.InsertInOrderAllowRepeatsL( viewInfo, |
128 if (ECalenMonthView == viewId) // Check if Activity was stored for month view |
517 CCalenViewInfo::CyclePositionComparison ); |
129 { |
518 |
130 mController.MainWindow().addView(mCalenMonthView); // Add month view to main window |
519 TRACE_EXIT_POINT; |
131 mController.MainWindow().setCurrentView(mCalenMonthView); // Set month view as current view |
520 } |
132 } |
521 |
133 else if (ECalenAgendaView == viewId) // Check if Activity was stored for agenda view |
522 // ---------------------------------------------------------------------------- |
134 { |
523 // CCalenViewManager::HandleCommandL |
135 mController.MainWindow().addView(mCalenAgendaView); // Add agenda view to main window |
524 // Handles view manager commands. |
136 mController.MainWindow().setCurrentView(mCalenAgendaView); // Set agenda view as current view |
525 // (other items were commented in a header). |
137 } |
526 // ---------------------------------------------------------------------------- |
138 } else if (isFromServiceFrmWrk/*Hb::ActivationReasonService == activityReason*/) { |
527 // |
139 // Dont load any views until our remote slot gets called in |
528 TBool CCalenViewManager::HandleCommandL( const TCalenCommand& aCommand ) |
140 // calenserviceprovider.cpp |
529 { |
141 // Just have an empty mainwindow |
530 TRACE_ENTRY_POINT; |
142 } else { |
531 |
143 // Do the normal startup |
532 TBool commandUsed(EFalse); |
144 // Load the month view and active it and add it to main window |
533 |
145 mFirstView = ECalenMonthView; |
534 switch( aCommand.Command() ) |
146 loadMonthView(); |
535 { |
147 ActivateDefaultViewL(ECalenMonthView); |
536 case ECalenMonthView: |
148 // Connect to the view ready signal so that we construct other view |
537 { |
149 // once this view is shown |
538 RequestActivationL( KUidCalenMonthView ); |
150 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
539 } |
151 this, SLOT(handleMainViewReady())); |
540 break; |
|
541 case ECalenWeekView: |
|
542 { |
|
543 RequestActivationL( KUidCalenWeekView ); |
|
544 } |
|
545 break; |
|
546 case ECalenDayView: |
|
547 { |
|
548 // reset the flag iForwardedToDayView as view switching is active |
|
549 if(iPreviousToDayView.iViewUid!=KNullUid) |
|
550 { |
|
551 iPreviousToDayView.iViewUid = KNullUid; |
|
552 } |
|
553 |
|
554 TUid viewUid; |
|
555 if ( !iController.IsLaunchFromExternalApp() && FeatureManager::FeatureSupported( KFeatureIdFfCalDayView ) ) |
|
556 { |
|
557 viewUid = KUidCalenBCDayViewPlugin; |
|
558 } |
|
559 else |
|
560 { |
|
561 viewUid = KUidCalenDayView; |
|
562 } |
|
563 |
|
564 RequestActivationL( viewUid, KCalenDummyUid, KNullDesC8() ); |
|
565 if(iController.IsLaunchFromExternalApp()) |
|
566 { |
|
567 iAvoidRepopulation = ETrue; |
|
568 } |
|
569 } |
|
570 break; |
|
571 case ECalenTodoView: |
|
572 { |
|
573 if (iAvoidRepopulation) |
|
574 { |
|
575 iAvoidRepopulation = EFalse; |
|
576 } |
|
577 RequestActivationL( KUidCalenTodoView ); |
|
578 } |
|
579 break; |
|
580 case ECalenEventView: |
|
581 { |
|
582 // Fix for EJCU-7LKC2C :: to prevent the display of blank view, |
|
583 // just set the iAvoidRepopulation to EFalse, |
|
584 // so that view is populated properly |
|
585 |
|
586 if (iAvoidRepopulation) |
|
587 { |
|
588 iAvoidRepopulation = EFalse; |
|
589 } |
|
590 |
|
591 RequestActivationL( KUidCalenEventView ); |
|
592 } |
|
593 break; |
|
594 case ECalenForwardsToDayView: |
|
595 { |
|
596 // set the view iPreviousToDayView to handle the day view's cba |
|
597 // when returning from event view. |
|
598 // From month/week view -> day view -> event view -> day view |
|
599 iPreviousToDayView = iCurrentViewId; |
|
600 |
|
601 TUid viewUid; |
|
602 if ( FeatureManager::FeatureSupported( KFeatureIdFfCalDayView ) ) |
|
603 { |
|
604 viewUid = KUidCalenBCDayViewPlugin; |
|
605 } |
|
606 else |
|
607 { |
|
608 viewUid = KUidCalenDayView; |
|
609 } |
|
610 if(iAvoidRepopulation) |
|
611 { |
|
612 iAvoidRepopulation = EFalse; |
|
613 } |
|
614 RequestActivationL( viewUid, KUidCalenShowBackCba ); |
|
615 } |
|
616 break; |
|
617 case ECalenForwardsToWeekView: |
|
618 { |
|
619 // set the view iPreviousToWeekView to handle the week view's cba |
|
620 // From month view -> week view |
|
621 iPreviousToWeekView = iCurrentViewId; |
|
622 if(iAvoidRepopulation) |
|
623 { |
|
624 iAvoidRepopulation = EFalse; |
|
625 } |
|
626 RequestActivationL( KUidCalenWeekView, KUidCalenShowBackCba ); |
|
627 } |
|
628 break; |
|
629 case ECalenNextView: |
|
630 { |
|
631 CycleNextViewL(); |
|
632 } |
|
633 break; |
|
634 case ECalenPrevView: |
|
635 { |
|
636 CyclePrevViewL(); |
|
637 } |
|
638 break; |
|
639 case ECalenSwitchView: |
|
640 { |
|
641 ShowSwitchViewQueryL(); |
|
642 } |
|
643 break; |
|
644 case ECalenStartActiveStep: |
|
645 { |
|
646 StartActiveStepL(); |
|
647 } |
|
648 break; |
|
649 case ECalenFasterAppExit: |
|
650 { |
|
651 HandleFasterAppExitCommandL(); |
|
652 } |
|
653 break; |
|
654 case ECalenGotoToday: |
|
655 { |
|
656 // get today's date |
|
657 TTime today = CalenDateUtils::Today(); |
|
658 |
|
659 // get the context |
|
660 MCalenContext& context = iController.Services().Context(); |
|
661 TCalTime todayCalTime; |
|
662 todayCalTime.SetTimeLocalL( today ); |
|
663 // set today's date to the context |
|
664 context.SetFocusDateAndTimeL( todayCalTime, iCurrentViewId ); |
|
665 |
|
666 SetRepopulation(EFalse); |
|
667 // reactivate the current view |
|
668 //RequestActivationL(iCurrentViewId.iViewUid); |
|
669 RequestActivationL(KUidCalenDayView); |
|
670 |
|
671 // dim "today" toolbar item since focus is on today |
|
672 //iToolbar->Toolbar().SetItemDimmed( ECalenGotoToday, ETrue, ETrue); |
|
673 } |
|
674 break; |
|
675 case ECalenGotoNextDay: |
|
676 { |
|
677 ChangeDayL( ETrue ); |
|
678 |
|
679 // reactivate the current view |
|
680 RequestActivationL(iCurrentViewId.iViewUid); |
|
681 } |
|
682 break; |
|
683 case ECalenGotoPrevDay: |
|
684 { |
|
685 ChangeDayL( EFalse ); |
|
686 |
|
687 // reactivate the current view |
|
688 RequestActivationL(iCurrentViewId.iViewUid); |
|
689 } |
|
690 break; |
|
691 default: |
|
692 break; |
|
693 } |
|
694 |
|
695 TRACE_EXIT_POINT; |
|
696 return commandUsed; |
|
697 } |
|
698 |
|
699 // ---------------------------------------------------------------------------- |
|
700 // CCalenViewManager::CalenCommandHandlerExtensionL |
|
701 // Dummy implementation. |
|
702 // (other items were commented in a header). |
|
703 // ---------------------------------------------------------------------------- |
|
704 // |
|
705 TAny* CCalenViewManager::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ ) |
|
706 { |
|
707 TRACE_ENTRY_POINT; |
|
708 TRACE_EXIT_POINT; |
|
709 return NULL; |
|
710 } |
|
711 |
|
712 // ---------------------------------------------------------------------------- |
|
713 // CCalenViewManager::CurrentView |
|
714 // Returns the current view's view uid. |
|
715 // (other items were commented in a header). |
|
716 // ---------------------------------------------------------------------------- |
|
717 // |
|
718 TUid CCalenViewManager::CurrentView() const |
|
719 { |
|
720 TRACE_ENTRY_POINT; |
|
721 TRACE_EXIT_POINT; |
|
722 return iCurrentViewId.iViewUid; |
|
723 } |
|
724 |
|
725 // ---------------------------------------------------------------------------- |
|
726 // CCalenViewManager::HandleViewActivation |
|
727 // From MCoeViewActivationObserver |
|
728 // Called just before a view in this application is activated by the view server |
|
729 // (other items were commented in a header). |
|
730 // ---------------------------------------------------------------------------- |
|
731 // |
|
732 void CCalenViewManager::HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId, |
|
733 const TVwsViewId& aViewIdToBeDeactivated ) |
|
734 { |
|
735 TRACE_ENTRY_POINT; |
|
736 |
|
737 TBool externalViewSwitch( EFalse ); |
|
738 // See if this is an internal or external view switch request |
|
739 if( aViewIdToBeDeactivated.iAppUid != KUidCalendar ) |
|
740 { |
|
741 externalViewSwitch = ETrue; |
|
742 } |
|
743 |
|
744 // If this is an internal view switch (view cycling from the '*' key) |
|
745 // then ActivateLocalViewL will handle any necessary state changes. |
|
746 // If this is an external view switch then we need to find out if Calendar was already |
|
747 // running or if it is being launched to a specific view by another application |
|
748 // calling ActivateViewL with Calendars UID and the UID of one of the standard views. |
|
749 // In this case we need to set the current view in the state or we would get the |
|
750 // default view (from the settings) activated instead of the requested view. |
|
751 if( externalViewSwitch ) |
|
752 { |
|
753 // Check that the view being activated belongs to Calendar. Although I don't see |
|
754 // how this would be called if this was false anyway. |
|
755 if( aNewlyActivatedViewId.iAppUid == KUidCalendar ) |
|
756 { |
|
757 // Make sure that any when any open dialogs are closed Calendar will not close as well. |
|
758 // This could be true if Calendar was originally launched directly to the editor, and |
|
759 // so should be closed when the dialog is closed. If an external view switch request |
|
760 // arrives, we want the dialog to close but Calendar to remain open. |
|
761 // Otherwise we get a CONE 44 panic. |
|
762 //iIsExitOnDlgClose = EFalse; |
|
763 if( iFakeExit ) |
|
764 { |
|
765 iCurrentViewId.iViewUid = iSetting->DefaultView(); |
|
766 } |
|
767 else |
|
768 { |
|
769 iCurrentViewId = aNewlyActivatedViewId; |
|
770 } |
|
771 } |
|
772 } |
|
773 iFakeExit = EFalse; |
|
774 iViewsActivated = ETrue; |
|
775 |
|
776 // check for iAvoidRepopulation to avoid repopulation whenever |
|
777 // 1) Application comes to foreground |
|
778 // 2) Applictaion is opened after fake exit |
|
779 if(!iAvoidRepopulation || iController.IsLaunchFromExternalApp() ) |
|
780 { |
|
781 TRAPD(error,StartActiveStepL()); |
|
782 if(error!=KErrNone) |
|
783 { |
|
784 // do avoid warning |
|
785 } |
|
786 } |
|
787 |
|
788 // Reset the flag iAvoidRepopulation |
|
789 if (iAvoidRepopulation) |
|
790 { |
|
791 iAvoidRepopulation = EFalse; |
|
792 } |
|
793 TRACE_EXIT_POINT; |
|
794 } |
|
795 |
|
796 // ---------------------------------------------------------------------------- |
|
797 // CCalenViewManager::RemoveDeActivatedView |
|
798 // Asyncronous callback function to remove the current view after it has been |
|
799 // disabled. |
|
800 // (other items were commented in a header). |
|
801 // ---------------------------------------------------------------------------- |
|
802 // |
|
803 TInt CCalenViewManager::RemoveDeActivatedView( TAny* aObject ) |
|
804 { |
|
805 TRACE_ENTRY_POINT; |
|
806 |
|
807 CCalenViewManager* thisPtr( static_cast<CCalenViewManager*>( aObject ) ); |
|
808 TRAP_IGNORE( thisPtr->RemoveDeActivatedViewL() ); |
|
809 |
|
810 TRACE_EXIT_POINT; |
|
811 return 0; |
|
812 } |
|
813 |
|
814 // ---------------------------------------------------------------------------- |
|
815 // CCalenViewManager::RemoveDeActivatedViewL. |
|
816 // (Leaving version) |
|
817 // Asyncronous callback function to remove the current view after it has been |
|
818 // disabled. |
|
819 // (other items were commented in a header). |
|
820 // ---------------------------------------------------------------------------- |
|
821 // |
|
822 void CCalenViewManager::RemoveDeActivatedViewL() |
|
823 { |
|
824 TRACE_ENTRY_POINT; |
|
825 |
|
826 TUid removedViewUid = iRemovedActiveView->ViewUid(); |
|
827 TUid removedPluginUid = iRemovedActiveView->PluginUid(); |
|
828 |
|
829 // The view isn't the current view, so we |
|
830 // can remove it directly from the view server |
|
831 iAppUi.RemoveView( removedViewUid ); |
|
832 |
|
833 // Delete the view info |
|
834 delete iRemovedActiveView;; |
|
835 iRemovedActiveView = NULL; |
|
836 |
|
837 // Unload the plugin. |
|
838 RArray<TUid> pluginArray; |
|
839 CleanupClosePushL( pluginArray ); |
|
840 |
|
841 pluginArray.AppendL( removedPluginUid ); |
|
842 iCustomisationManager->UnloadPluginsL( pluginArray ); |
|
843 CleanupStack::PopAndDestroy(); // pluginArray |
|
844 |
|
845 if(!iController.IsFasterAppFlagEnabled()) |
|
846 { |
|
847 // Refresh the current view by simulating a settings close |
|
848 iController.BroadcastNotification( ECalenNotifySettingsClosed ); |
|
849 } |
|
850 else |
|
851 { |
|
852 iController.BroadcastNotification( ECalenNotifyCheckPluginUnloading ); |
|
853 } |
|
854 |
|
855 TRACE_EXIT_POINT; |
|
856 } |
|
857 |
|
858 // ---------------------------------------------------------------------------- |
|
859 // CCalenViewManager::CycleNextViewL |
|
860 // Requests activation for the next view in the view cycle |
|
861 // (other items were commented in a header). |
|
862 // ---------------------------------------------------------------------------- |
|
863 // |
|
864 void CCalenViewManager::CycleNextViewL() |
|
865 { |
|
866 TRACE_ENTRY_POINT; |
|
867 |
|
868 // Increment until we get to a valid view. |
|
869 do{ |
|
870 ++iViewCycleIndex; |
|
871 |
|
872 if( iViewCycleIndex >= iViewInfoArray.Count() ) |
|
873 { |
|
874 iViewCycleIndex = 0; |
|
875 } |
|
876 } |
|
877 while( iViewInfoArray[iViewCycleIndex]->CyclePosition() == CCalenView::ENoCyclePosition ); |
|
878 |
|
879 RequestActivationL( iViewInfoArray[iViewCycleIndex]->ViewUid() ); |
|
880 |
|
881 TRACE_EXIT_POINT; |
|
882 } |
|
883 |
|
884 // ---------------------------------------------------------------------------- |
|
885 // CCalenViewManager::CyclePrevViewL |
|
886 // Requests activation for the previous view in the view cycle |
|
887 // (other items were commented in a header). |
|
888 // ---------------------------------------------------------------------------- |
|
889 // |
|
890 void CCalenViewManager::CyclePrevViewL() |
|
891 { |
|
892 TRACE_ENTRY_POINT; |
|
893 |
|
894 // Decrement until we get to a valid view. |
|
895 do{ |
|
896 --iViewCycleIndex; |
|
897 |
|
898 if( iViewCycleIndex < 0 ) |
|
899 { |
|
900 iViewCycleIndex = iViewInfoArray.Count()-1; |
|
901 } |
|
902 } |
|
903 while ( iViewInfoArray[iViewCycleIndex]->CyclePosition() == CCalenView::ENoCyclePosition ); |
|
904 |
|
905 RequestActivationL( iViewInfoArray[iViewCycleIndex]->ViewUid() ); |
|
906 |
|
907 TRACE_EXIT_POINT; |
|
908 } |
|
909 |
|
910 // ---------------------------------------------------------------------------- |
|
911 // CCalenViewManager::RequestActivationL |
|
912 // Request activation of a specific view. |
|
913 // (other items were commented in a header). |
|
914 // ---------------------------------------------------------------------------- |
|
915 // |
|
916 void CCalenViewManager::RequestActivationL( const TVwsViewId& aViewId ) |
|
917 { |
|
918 TRACE_ENTRY_POINT; |
|
919 |
|
920 RequestActivationL( aViewId.iViewUid ); |
|
921 |
|
922 TRACE_EXIT_POINT; |
|
923 } |
|
924 |
|
925 // ---------------------------------------------------------------------------- |
|
926 // CCalenViewManager::RequestActivationL |
|
927 // Call this to try to activate a view |
|
928 // (other items were commented in a header). |
|
929 // ---------------------------------------------------------------------------- |
|
930 // |
|
931 void CCalenViewManager::RequestActivationL( const TUid& aViewUid, |
|
932 const TUid& aMessageId, |
|
933 const TDesC8& aMessage ) |
|
934 { |
|
935 TRACE_ENTRY_POINT; |
|
936 |
|
937 // Cancel population of current view, if it's ongoing. |
|
938 iPopulator->InterruptPopulationL(); |
|
939 // We start population of the newly activated view in HandleViewActivationL. |
|
940 |
|
941 // cache the previousviewid as we are getting aViewUid as reference. |
|
942 TUid cachePreviousViewId = iCurrentViewId.iViewUid; |
|
943 |
|
944 iCurrentViewId.iViewUid = aViewUid; |
|
945 // Update the view cycle index as iViewInfoArray would have changed |
|
946 iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, |
|
947 CCalenViewInfo::ViewInfoIdentifier ); |
|
948 |
|
949 if( iController.IsFasterAppFlagEnabled() ) |
|
950 { |
|
951 // Leave the application in background |
|
952 iAppUi.HideInBackground(); |
|
953 // Disable bring-to-foreground on view activation |
|
954 iAppUi.SetCustomControl(1); |
|
955 |
|
956 // activate the view |
|
957 iAppUi.ActivateLocalViewL( aViewUid, KCalenHideInBackGround, KNullDesC8() ); |
|
958 |
|
959 // Enable bring-to-foreground on view activation. |
|
960 iAppUi.SetCustomControl(0); |
|
961 } |
|
962 else |
|
963 { |
|
964 iAppUi.ActivateLocalViewL( aViewUid, aMessageId, aMessage ); |
|
965 } |
|
966 |
|
967 // set the previous view id |
|
968 if(cachePreviousViewId != KUidCalenEventView || cachePreviousViewId != iCurrentViewId.iViewUid) |
|
969 { |
|
970 iPreviousViewId.iViewUid = cachePreviousViewId; |
|
971 } |
|
972 TRACE_EXIT_POINT; |
|
973 } |
|
974 |
|
975 // ---------------------------------------------------------------------------- |
|
976 // CCalenViewManager::StartActiveStepL |
|
977 // Starts population of the current view. |
|
978 // ---------------------------------------------------------------------------- |
|
979 // |
|
980 void CCalenViewManager::StartActiveStepL() |
|
981 { |
|
982 TRACE_ENTRY_POINT; |
|
983 |
|
984 // check for current viewid |
|
985 // populate the view only if iCurrentViewId is set |
|
986 if(iCurrentViewId.iViewUid != KNullUid) |
|
987 { |
|
988 iPopulator->InterruptPopulationL(); |
|
989 iPopulator->BeginPopulationL(reinterpret_cast<CCalenView*>(iAppUi.View(CurrentView()))); |
|
990 } |
|
991 |
|
992 TRACE_EXIT_POINT; |
|
993 } |
|
994 |
|
995 // ---------------------------------------------------------------------------- |
|
996 // CCalenViewManager::ShowSwitchViewQueryL |
|
997 // Prompts the user to chose a view to switch to. If cancelled, returns |
|
998 // KErrCancel, otherwise one of ECalen*view. |
|
999 // (other items were commented in a header). |
|
1000 // ---------------------------------------------------------------------------- |
|
1001 // |
|
1002 void CCalenViewManager::ShowSwitchViewQueryL() |
|
1003 { |
|
1004 TRACE_ENTRY_POINT; |
|
1005 |
|
1006 // Create list of view names and uids |
|
1007 CDesCArrayFlat* viewNames = new( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
1008 CleanupStack::PushL( viewNames ); |
|
1009 |
|
1010 RArray<TUid> viewUids; |
|
1011 CleanupClosePushL( viewUids ); |
|
1012 |
|
1013 const RArray<TUid>& activePlugins = CustomisationManager().ActivePlugins(); |
|
1014 |
|
1015 for( TInt index( 0 ); index < iViewInfoArray.Count(); ++index ) |
|
1016 { |
|
1017 CCalenViewInfo& viewInfo = *( iViewInfoArray[index] ); |
|
1018 if( index != iViewCycleIndex ) |
|
1019 { |
|
1020 TUid pluginUid = viewInfo.PluginUid(); |
|
1021 TInt position = activePlugins.Find( pluginUid ); |
|
1022 |
|
1023 // If the view is from plugin or native view with cycle position, |
|
1024 // then add it to the switch view list |
|
1025 if(( position != KErrNotFound ) || |
|
1026 ( viewInfo.CyclePosition() != CCalenView::ENoCyclePosition )) |
|
1027 { |
|
1028 // Fetch the view name |
|
1029 TUid viewUid = viewInfo.ViewUid(); |
|
1030 const TDesC& viewName = viewInfo.MenuName(); |
|
1031 viewNames->AppendL( viewName ); |
|
1032 viewUids.AppendL(viewUid ); |
|
1033 } |
|
1034 } |
|
1035 } |
152 |
1036 |
153 mController.MainWindow().addView(mCalenMonthView); |
1037 // Show list query. |
154 mController.MainWindow().setCurrentView(mCalenMonthView); |
1038 TInt choice = KErrCancel; //KErrNotFound; |
155 } |
1039 CAknListQueryDialog* dlg = new( ELeave ) CAknListQueryDialog( &choice ); |
156 //delete the activity intsance |
1040 dlg->PrepareLC( R_CALENDAR_SWITCH_VIEW_QUERY ); // pushes dlg to CS |
157 delete activation; |
1041 dlg->SetItemTextArray( viewNames ); |
158 OstTraceFunctionExit0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_EXIT ); |
1042 dlg->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
159 } |
1043 |
160 |
1044 // Set title |
161 // ---------------------------------------------------------------------------- |
1045 CAknPopupHeadingPane* heading = dlg->Heading(); |
162 // CalenViewManager::~CalenViewManager |
1046 HBufC* title = NULL; |
163 // Destructor. |
1047 title = CCoeEnv::Static()->AllocReadResourceLC( R_CALENDAR_SWITCH_VIEW_QUERY_TITLE ); |
164 // (other items were commented in a header). |
1048 heading->SetTextL( *title ); |
165 // ---------------------------------------------------------------------------- |
1049 CleanupStack::PopAndDestroy( title ); |
166 // |
1050 |
167 CalenViewManager::~CalenViewManager() |
1051 if( dlg->RunLD() ) |
168 { |
1052 { |
169 OstTraceFunctionEntry0( DUP1_CALENVIEWMANAGER_CALENVIEWMANAGER_ENTRY ); |
1053 // user made a choice |
170 |
1054 TUid viewUid = viewUids[choice]; |
171 if (mSettingsView) { |
1055 iAvoidRepopulation = EFalse; |
172 delete mSettingsView; |
1056 RequestActivationL( viewUid ); |
173 mSettingsView = 0; |
1057 } |
174 } |
1058 |
175 if (mAgendaViewDocLoader) { |
1059 CleanupStack::PopAndDestroy(); // viewUids |
176 delete mAgendaViewDocLoader; |
1060 CleanupStack::PopAndDestroy( viewNames ); |
177 mAgendaViewDocLoader = 0; |
1061 |
178 } |
1062 TRACE_EXIT_POINT; |
179 if (mAgendaViewAltDocLoader) { |
1063 } |
180 delete mAgendaViewAltDocLoader; |
1064 |
181 mAgendaViewAltDocLoader = 0; |
1065 // ---------------------------------------------------------------------------- |
182 } |
1066 // CCalenViewManager::HandleNotification |
183 if (mMonthViewDocLoader) { |
1067 // Calls back when notifications that it has been registered for are broadcast |
184 delete mMonthViewDocLoader; |
1068 // (other items were commented in a header). |
185 mMonthViewDocLoader = 0; |
1069 // ---------------------------------------------------------------------------- |
186 } |
1070 // |
187 |
1071 void CCalenViewManager::HandleNotification(const TCalenNotification aNotification ) |
188 OstTraceFunctionExit0( DUP1_CALENVIEWMANAGER_CALENVIEWMANAGER_EXIT ); |
1072 { |
189 } |
1073 TRACE_ENTRY_POINT; |
190 |
1074 |
191 // ---------------------------------------------------------------------------- |
1075 PIM_TRAPD_HANDLE( HandleNotificationL( aNotification ) ); |
192 // CalenViewManager::constructAndActivateView |
1076 |
193 // Constructs and activates the requested view |
1077 TRACE_EXIT_POINT; |
194 // (other items were commented in a header). |
1078 } |
195 // ---------------------------------------------------------------------------- |
1079 |
196 // |
1080 // ---------------------------------------------------------------------------- |
197 void CalenViewManager::constructAndActivateView(int view) |
1081 // CCalenViewManager::HandleNotificationL |
198 { |
1082 // Called from HandleNotification() when notifications that it has been |
199 OstTraceFunctionEntry0( CALENVIEWMANAGER_CONSTRUCTANDACTIVATEVIEW_ENTRY ); |
1083 // registered for are broadcast |
200 |
1084 // (other items were commented in a header). |
201 // We are here because, some other application is launching calendar with |
1085 // ---------------------------------------------------------------------------- |
202 // the view, hence connect to viewReady() signal to do any lazy loading |
1086 // |
203 // in the slot |
1087 void CCalenViewManager::HandleNotificationL( TCalenNotification aNotification ) |
204 |
1088 { |
205 // Connect to the view ready signal so that we construct other view |
1089 TRACE_ENTRY_POINT; |
206 // once this view is shown |
1090 |
207 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
1091 switch( aNotification ) |
208 this, SLOT(handleMainViewReady())); |
1092 { |
209 if (view == ECalenMonthView) { |
1093 case ECalenNotifyPluginEnabledDisabled: |
210 mFirstView = ECalenMonthView; |
1094 { |
211 loadMonthView(); |
1095 UpdatePluginListL(); |
212 ActivateDefaultViewL(ECalenMonthView); |
1096 } |
213 // Add month view to mainwindow. |
1097 break; |
214 mController.MainWindow().addView(mCalenMonthView); |
1098 case ECalenNotifySettingsClosed: |
215 mController.MainWindow().setCurrentView(mCalenMonthView); |
1099 { |
216 } else if (view == ECalenAgendaView) { |
1100 // Nothing has changed, refresh statuspane only. |
217 mFirstView = ECalenAgendaView; |
1101 iAppUi.StatusPane()->DrawNow(); |
218 loadAgendaView(); |
1102 } |
219 ActivateDefaultViewL(ECalenAgendaView); |
1103 break; |
220 // Add agenda view to mainwindow. |
1104 case ECalenNotifySettingsChanged: |
221 mController.MainWindow().addView(mCalenAgendaView); |
1105 { |
222 mController.MainWindow().setCurrentView(mCalenAgendaView); |
1106 HandleSettingsChangeNotificationL(); |
223 mController.MainWindow().addView(mCalenAgendaViewAlt); |
1107 } |
224 } else if (view == ECalenDayView) { |
1108 break; |
225 mFirstView = ECalenDayView; |
1109 case ECalenNotifyEntryDeleted: |
226 loadDayView(); |
1110 case ECalenNotifyInstanceDeleted: |
227 ActivateDefaultViewL(ECalenDayView); |
1111 { |
228 // Add day view to mainwindow. |
1112 iAvoidRepopulation = EFalse; |
229 mController.MainWindow().addView(mCalenDayView); |
1113 HandleEntryDeleteNotificationL(); |
230 mController.MainWindow().setCurrentView(mCalenDayView); |
|
231 } |
|
232 OstTraceFunctionExit0( CALENVIEWMANAGER_CONSTRUCTANDACTIVATEVIEW_EXIT ); |
|
233 } |
|
234 |
|
235 // ---------------------------------------------------------------------------- |
|
236 // CalenViewManager::loadMonthView |
|
237 // Loads month view frm the docml |
|
238 // (other items were commented in a header). |
|
239 // ---------------------------------------------------------------------------- |
|
240 // |
|
241 void CalenViewManager::loadMonthView() |
|
242 { |
|
243 OstTraceFunctionEntry0( CALENVIEWMANAGER_LOADMONTHVIEW_ENTRY ); |
|
244 |
|
245 bool loadSuccess = false; |
|
246 Qt::Orientation currentOrienation = mController.MainWindow().orientation(); |
|
247 // Create the month view docloader object. |
|
248 mMonthViewDocLoader = new CalenDocLoader(mController); |
|
249 mMonthViewDocLoader->load(CALEN_MONTHVIEW_XML_FILE, &loadSuccess); |
|
250 Q_ASSERT_X(loadSuccess, "calenviewmanager.cpp", |
|
251 "Unable to load month view XML"); |
|
252 // Based on the current orientation, load the appropriate section |
|
253 if (Qt::Vertical == currentOrienation) { |
|
254 mMonthViewDocLoader->load(CALEN_MONTHVIEW_XML_FILE, |
|
255 CALEN_PORTRAIT, &loadSuccess); |
|
256 } else { |
|
257 mMonthViewDocLoader->load(CALEN_MONTHVIEW_XML_FILE, |
|
258 CALEN_LANDSCAPE, &loadSuccess); |
|
259 } |
|
260 Q_ASSERT_X(loadSuccess, "calenviewmanager.cpp", "Unable to load XML"); |
|
261 |
|
262 // Get the calenmonth view from the loader. |
|
263 mCalenMonthView = static_cast<CalenMonthView *> |
|
264 (mMonthViewDocLoader->findWidget(CALEN_MONTHVIEW)); |
|
265 Q_ASSERT_X(mCalenMonthView, "calenviewmanager.cpp", |
|
266 "Unable to load calenMonth view"); |
|
267 |
|
268 // Set the parent to delete the view once will exit the application |
|
269 mCalenMonthView->setParent(this); |
|
270 |
|
271 // Setup the month view. |
|
272 mCalenMonthView->setupView(mMonthViewDocLoader); |
|
273 |
|
274 OstTraceFunctionExit0( CALENVIEWMANAGER_LOADMONTHVIEW_EXIT ); |
|
275 } |
|
276 |
|
277 // ---------------------------------------------------------------------------- |
|
278 // CalenViewManager::loadAgendaView |
|
279 // Loads the agenda view frm the docml |
|
280 // (other items were commented in a header). |
|
281 // ---------------------------------------------------------------------------- |
|
282 // |
|
283 void CalenViewManager::loadAgendaView() |
|
284 { |
|
285 OstTraceFunctionEntry0( CALENVIEWMANAGER_LOADAGENDAVIEW_ENTRY ); |
|
286 |
|
287 bool loadSuccess = false; |
|
288 // Create the agenda view docloader object. |
|
289 mAgendaViewDocLoader = new CalenDocLoader(mController); |
|
290 |
|
291 // Load default section |
|
292 mAgendaViewDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, &loadSuccess); |
|
293 if (!loadSuccess) { |
|
294 qFatal("calenviewmanager.cpp : Unable to load XML"); |
|
295 } |
|
296 |
|
297 // Get the calenagenda view from the loader |
|
298 mCalenAgendaView = static_cast<CalenAgendaView *> (mAgendaViewDocLoader->findWidget(CALEN_AGENDAVIEW)); |
|
299 if (!mCalenAgendaView) { |
|
300 qFatal("calenviewmanager.cpp : Unable to find agenda view"); |
|
301 } |
|
302 |
|
303 // Set the parent to delete the view once will exit the application |
|
304 mCalenAgendaView->setParent(this); |
|
305 |
|
306 // Setup the agenda view |
|
307 mCalenAgendaView->setupView(mAgendaViewDocLoader); |
|
308 |
|
309 // The following code is done to provide swipe support |
|
310 // in agenda view. Idea is to create two views and keep |
|
311 // switiching between these two using view switch effects |
|
312 // to provide an illusion of flow to the user |
|
313 loadAlternateAgendaView(); |
|
314 |
|
315 OstTraceFunctionExit0( CALENVIEWMANAGER_LOADAGENDAVIEW_EXIT ); |
|
316 } |
|
317 |
|
318 // ---------------------------------------------------------------------------- |
|
319 // CalenViewManager::loadDayView |
|
320 // Loads day view from the docml |
|
321 // ---------------------------------------------------------------------------- |
|
322 void CalenViewManager::loadDayView() |
|
323 { |
|
324 bool loadSuccess = false; |
|
325 |
|
326 // Create the docloader object |
|
327 CalenDocLoader *docLoader = new CalenDocLoader(mController); |
|
328 |
|
329 if (docLoader) { |
|
330 docLoader->load(CALEN_DAYVIEW_DOCML, &loadSuccess); |
|
331 if (!loadSuccess) { |
|
332 qFatal("calenviewmanager.cpp : Unable to load day view XML"); |
|
333 } |
|
334 |
|
335 // Get the CalenDayView object from the loader |
|
336 mCalenDayView = static_cast<CalenDayView *> |
|
337 (docLoader->findWidget(CALEN_DAYVIEW)); |
|
338 if (!mCalenDayView) { |
|
339 qFatal("calenviewmanager.cpp : Unable to find day view"); |
|
340 } |
|
341 |
|
342 // Set the parent to delete the view once will exit the application |
|
343 mCalenDayView->setParent(this); |
|
344 |
|
345 // Set up the day view - day view takes the ownership |
|
346 mCalenDayView->setupView(docLoader); |
|
347 } |
|
348 } |
|
349 |
|
350 // ---------------------------------------------------------------------------- |
|
351 // CalenViewManager::handleMainViewReady |
|
352 // Slot to handle viewReady() signal from mainwindow |
|
353 // (other items were commented in a header). |
|
354 // ---------------------------------------------------------------------------- |
|
355 // |
|
356 void CalenViewManager::handleMainViewReady() |
|
357 { |
|
358 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEMAINVIEWREADY_ENTRY ); |
|
359 |
|
360 // Construct the month view part that is kept for lazy loading |
|
361 if (mCalenMonthView) { |
|
362 mCalenMonthView->doLazyLoading(); |
|
363 |
|
364 if (mInstanceViewCreated) { |
|
365 // populate entries for the month view if the month view is launched |
|
366 // from the service APIs. Otherwise the month view is not populated with |
|
367 // the entries as CalenViewManager::handleInstanceViewCreation is called |
|
368 // before the month view creation so the model array is not populated. |
|
369 mCalenMonthView->fetchEntriesAndUpdateModel(); |
|
370 } |
|
371 |
|
372 } |
|
373 |
|
374 // Construct other views |
|
375 constructOtherViews(); |
|
376 |
|
377 // Install the event filter for the controller once the view is ready |
|
378 // so that system language/locale changes can be handled |
|
379 //hbInstance->allMainWindows().first()->installEventFilter(&mController); |
|
380 |
|
381 // disconnect the view ready signal as we dont need it anymore |
|
382 disconnect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
383 this, SLOT(handleMainViewReady())); |
|
384 |
|
385 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEMAINVIEWREADY_EXIT ); |
|
386 } |
|
387 |
|
388 // ---------------------------------------------------------------------------- |
|
389 // CalenViewManager::constructOtherViews |
|
390 // Constructs the other views apart frm firstview and adds them to main window |
|
391 // (other items were commented in a header). |
|
392 // ---------------------------------------------------------------------------- |
|
393 // |
|
394 void CalenViewManager::constructOtherViews() |
|
395 { |
|
396 OstTraceFunctionEntry0( CALENVIEWMANAGER_CONSTRUCTOTHERVIEWS_ENTRY ); |
|
397 |
|
398 // Load all other views except mFirstView |
|
399 |
|
400 // NOTE: Right now, since Calendar has three views, month view, day view |
|
401 // and agenda view, when client launches agenda view, then there is no need |
|
402 // to construct the month view as per UI REQ., but tomorrow if new views |
|
403 // come after agenda view, then we need to construct those views if they are |
|
404 // native views. Right now, day view will be constructed as we need to |
|
405 // provide an option in options menu to switch between day view and agenda view |
|
406 // There is a event viewer but its not a native view, so no need to constrcut it |
|
407 // It will be constrcuted on demand. |
|
408 // Hence, if agenda view is launched, constrcut the day vuew but dont construct month view. |
|
409 // Vice-versa for when day view is maunched as first view |
|
410 if (mFirstView == ECalenMonthView) { |
|
411 // Load all other views |
|
412 loadAgendaView(); |
|
413 |
|
414 if (!mCalenDayView) { |
|
415 loadDayView(); |
|
416 } |
|
417 } else if (mFirstView == ECalenAgendaView) { //agenda view was launched as first view |
|
418 // Load day view |
|
419 if (!mCalenDayView) { |
|
420 loadDayView(); |
|
421 } |
|
422 } else if (mFirstView == ECalenDayView) { // Day view was launched as first view |
|
423 // Load agenda view |
|
424 loadAgendaView(); |
|
425 } |
|
426 |
|
427 // Setup the settings view |
|
428 mSettingsView = new CalenSettingsView(mController.Services()); |
|
429 |
|
430 OstTraceFunctionExit0( CALENVIEWMANAGER_CONSTRUCTOTHERVIEWS_EXIT ); |
|
431 } |
|
432 |
|
433 // ---------------------------------------------------------------------------- |
|
434 // CalenViewManager::getFirstView |
|
435 // Returns the first view |
|
436 // (other items were commented in a header). |
|
437 // ---------------------------------------------------------------------------- |
|
438 // |
|
439 int CalenViewManager::getFirstView() |
|
440 { |
|
441 OstTraceFunctionEntry0( CALENVIEWMANAGER_GETFIRSTVIEW_ENTRY ); |
|
442 |
|
443 OstTraceFunctionExit0( CALENVIEWMANAGER_GETFIRSTVIEW_EXIT ); |
|
444 return mFirstView; |
|
445 } |
|
446 |
|
447 // ---------------------------------------------------------------------------- |
|
448 // CalenViewManager::showNextDay |
|
449 // other items were commented in a header |
|
450 // ---------------------------------------------------------------------------- |
|
451 // |
|
452 void CalenViewManager::showNextDay() |
|
453 { |
|
454 OstTraceFunctionEntry0( CALENVIEWMANAGER_SHOWNEXTDAY_ENTRY ); |
|
455 |
|
456 // Set the context for the next day |
|
457 QDateTime currentDay = mController.Services().Context().focusDateAndTime(); |
|
458 currentDay = currentDay.addDays(1); |
|
459 mController.Services().Context().setFocusDate(currentDay); |
|
460 mCurrentViewId = ECalenAgendaView; |
|
461 // Check which is the currently activated view |
|
462 if (mController.MainWindow().currentView() == mCalenAgendaView) { |
|
463 mCalenAgendaView->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaView to get aboutToQuit Events |
|
464 HbEffect::add(mCalenAgendaView, |
|
465 ":/fxml/view_hide", |
|
466 "hide"); |
|
467 HbEffect::add(mCalenAgendaViewAlt, |
|
468 ":/fxml/view_show", |
|
469 "show"); |
|
470 // Set the other agenda view as the current view |
|
471 // and animate to provide illusion of swipe |
|
472 // It would also connect for aboutToQuit events |
|
473 mCalenAgendaViewAlt->doPopulation(); |
|
474 mController.MainWindow().setCurrentView(mCalenAgendaViewAlt, true, Hb::ViewSwitchUseNormalAnim); |
|
475 } else { |
|
476 mCalenAgendaViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaViewAlt to get aboutToQuit Events |
|
477 HbEffect::add(mCalenAgendaViewAlt, |
|
478 ":/fxml/view_hide", |
|
479 "hide"); |
|
480 HbEffect::add(mCalenAgendaView, |
|
481 ":/fxml/view_show", |
|
482 "show"); |
|
483 // It would also connect for aboutToQuit events |
|
484 mCalenAgendaView->doPopulation(); |
|
485 mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim); |
|
486 } |
|
487 OstTraceFunctionExit0( CALENVIEWMANAGER_SHOWNEXTDAY_EXIT ); |
|
488 } |
|
489 |
|
490 // ---------------------------------------------------------------------------- |
|
491 // CalenViewManager::showPrevDay |
|
492 // other items were commented in a header |
|
493 // ---------------------------------------------------------------------------- |
|
494 // |
|
495 void CalenViewManager::showPrevDay() |
|
496 { |
|
497 OstTraceFunctionEntry0( CALENVIEWMANAGER_SHOWPREVDAY_ENTRY ); |
|
498 |
|
499 QDateTime currentDay = mController.Services().Context().focusDateAndTime(); |
|
500 currentDay = currentDay.addDays(-1); |
|
501 mController.Services().Context().setFocusDate(currentDay); |
|
502 mCurrentViewId = ECalenAgendaView; |
|
503 if (mController.MainWindow().currentView() == mCalenAgendaView) { |
|
504 mCalenAgendaView->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaView to get aboutToQuit Events |
|
505 HbEffect::add(mCalenAgendaView, |
|
506 ":/fxml/view_hide_back", |
|
507 "hide"); |
|
508 HbEffect::add(mCalenAgendaViewAlt, |
|
509 ":/fxml/view_show_back", |
|
510 "show"); |
|
511 // It would also connect for aboutToQuit events |
|
512 mCalenAgendaViewAlt->doPopulation(); |
|
513 mController.MainWindow().setCurrentView(mCalenAgendaViewAlt, true, Hb::ViewSwitchUseNormalAnim); |
|
514 } else { |
|
515 mCalenAgendaViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaViewAlt to get aboutToQuit Events |
|
516 HbEffect::add(mCalenAgendaViewAlt, |
|
517 ":/fxml/view_hide_back", |
|
518 "hide"); |
|
519 HbEffect::add(mCalenAgendaView, |
|
520 ":/fxml/view_show_back", |
|
521 "show"); |
|
522 // It would also connect for aboutToQuit events |
|
523 mCalenAgendaView->doPopulation(); |
|
524 mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim); |
|
525 } |
|
526 |
|
527 OstTraceFunctionExit0( CALENVIEWMANAGER_SHOWPREVDAY_EXIT ); |
|
528 } |
|
529 |
|
530 // ---------------------------------------------------------------------------- |
|
531 // CalenViewManager::removePreviousView |
|
532 // Remove the previous view from main window |
|
533 // ---------------------------------------------------------------------------- |
|
534 // |
|
535 void CalenViewManager::removePreviousView() |
|
536 { |
|
537 OstTraceFunctionEntry0( CALENVIEWMANAGER_REMOVEPREVIOUSVIEW_ENTRY ); |
|
538 |
|
539 if (ECalenAgendaView == mCurrentViewId) { |
|
540 mCalenAgendaView->clearListModel(); |
|
541 mCalenAgendaViewAlt->clearListModel(); |
|
542 mController.MainWindow().removeView(mCalenAgendaView); |
|
543 mController.MainWindow().removeView(mCalenAgendaViewAlt); |
|
544 } else if (ECalenDayView == mCurrentViewId) { |
|
545 mController.MainWindow().removeView(mCalenDayView); |
|
546 } else { |
|
547 if (ECalenMonthView == mCurrentViewId) { |
|
548 mController.MainWindow().removeView(mCalenMonthView); |
|
549 } |
|
550 } |
|
551 |
|
552 OstTraceFunctionExit0( CALENVIEWMANAGER_REMOVEPREVIOUSVIEW_EXIT ); |
|
553 } |
|
554 |
|
555 // ---------------------------------------------------------------------------- |
|
556 // CalenViewManager::~ActivateDefaultViewL |
|
557 // Activates the default view, as retrieved from settings. |
|
558 // (other items were commented in a header). |
|
559 // ---------------------------------------------------------------------------- |
|
560 // |
|
561 void CalenViewManager::ActivateDefaultViewL(int defaultView) |
|
562 { |
|
563 OstTraceFunctionEntry0( CALENVIEWMANAGER_ACTIVATEDEFAULTVIEWL_ENTRY ); |
|
564 |
|
565 mCurrentViewId = defaultView; |
|
566 if (ECalenMonthView == defaultView) { |
|
567 mCalenMonthView->doPopulation(); |
|
568 } else if (ECalenAgendaView == defaultView) { |
|
569 mCalenAgendaView->doPopulation(); |
|
570 } else if (ECalenDayView == defaultView) { |
|
571 mCalenDayView->doPopulation(); |
|
572 } |
|
573 |
|
574 OstTraceFunctionExit0( CALENVIEWMANAGER_ACTIVATEDEFAULTVIEWL_EXIT ); |
|
575 } |
|
576 |
|
577 // ---------------------------------------------------------------------------- |
|
578 // Refresh current view. |
|
579 // (other items were commented in a header). |
|
580 // ---------------------------------------------------------------------------- |
|
581 void CalenViewManager::refreshCurrentViewL() |
|
582 { |
|
583 OstTraceFunctionEntry0( CALENVIEWMANAGER_REFRESHCURRENTVIEWL_ENTRY ); |
|
584 |
|
585 activateCurrentView(); |
|
586 |
|
587 OstTraceFunctionExit0( CALENVIEWMANAGER_REFRESHCURRENTVIEWL_EXIT ); |
|
588 } |
|
589 |
|
590 // ---------------------------------------------------------------------------- |
|
591 // Activate current view. |
|
592 // (other items were commented in a header). |
|
593 // ---------------------------------------------------------------------------- |
|
594 void CalenViewManager::activateCurrentView() |
|
595 { |
|
596 OstTraceFunctionEntry0( CALENVIEWMANAGER_ACTIVATECURRENTVIEW_ENTRY ); |
|
597 |
|
598 switch (mCurrentViewId) { |
|
599 case ECalenMonthView: |
|
600 mCalenMonthView->doPopulation(); |
|
601 mController.MainWindow().setCurrentView(mCalenMonthView); |
|
602 break; |
|
603 case ECalenAgendaView: |
|
604 if (mController.MainWindow().currentView() == mCalenAgendaView) { |
|
605 // This happens when settings view or event viewer is opened |
|
606 // from the agenda view. Simply repopulate the view |
|
607 if (mCalenAgendaView) { |
|
608 mCalenAgendaView->doPopulation(); |
|
609 mController.MainWindow().setCurrentView(mCalenAgendaView); |
|
610 } |
|
611 } else if (mController.MainWindow().currentView() == mCalenAgendaViewAlt){ |
|
612 // This happens when settings view or event viewer is opened |
|
613 // from the agenda view. Simply repopulate the view |
|
614 if (mCalenAgendaViewAlt) { |
|
615 mCalenAgendaViewAlt->doPopulation(); |
|
616 mController.MainWindow().setCurrentView(mCalenAgendaViewAlt); |
|
617 } |
|
618 } else { |
|
619 // This is called whenever the agenda view is opened from the month |
|
620 // view. Since the agenda view is not added to the mainwindow, |
|
621 // add the agenda views to mainwindow and set any one of them as |
|
622 // current view |
|
623 if (mCalenAgendaView) { |
|
624 mCalenAgendaView->doPopulation(); |
|
625 mController.MainWindow().addView(mCalenAgendaView); |
|
626 mController.MainWindow().setCurrentView(mCalenAgendaView); |
|
627 mController.MainWindow().addView(mCalenAgendaViewAlt); |
|
628 } |
|
629 } |
|
630 break; |
|
631 case ECalenShowSettings: |
|
632 mSettingsView->refreshView(); |
|
633 break; |
|
634 case ECalenDayView: |
|
635 mCalenDayView->doPopulation(); |
|
636 mController.MainWindow().setCurrentView(mCalenDayView); |
|
637 break; |
|
638 } |
|
639 |
|
640 OstTraceFunctionExit0( CALENVIEWMANAGER_ACTIVATECURRENTVIEW_EXIT ); |
|
641 } |
|
642 |
|
643 // ---------------------------------------------------------------------------- |
|
644 // CalenViewManager::launchEventView |
|
645 // Launch event view. |
|
646 // (other items were commented in a header). |
|
647 // ---------------------------------------------------------------------------- |
|
648 // |
|
649 void CalenViewManager::launchEventView() |
|
650 { |
|
651 OstTraceFunctionEntry0( CALENVIEWMANAGER_LAUNCHEVENTVIEW_ENTRY ); |
|
652 |
|
653 // capture cureent view in case app closed/quits from AgendaEventViewer |
|
654 if (mCalenMonthView) { |
|
655 mCalenMonthView->captureScreenshot(true); |
|
656 } |
|
657 else if (mCalenAgendaView) { |
|
658 mCalenAgendaView->captureScreenshot(true); |
|
659 } |
|
660 MCalenContext& context = mController.Services().Context(); |
|
661 AgendaEntry viewEntry= mController.Services().agendaInterface()->fetchById( |
|
662 context.instanceId().mEntryLocalUid ); |
|
663 if (viewEntry.isRepeating() |
|
664 && viewEntry.type() != AgendaEntry::TypeTodo) { |
|
665 QDateTime startDateTime = context.focusDateAndTime(); |
|
666 viewEntry.setStartAndEndTime(startDateTime, |
|
667 startDateTime.addSecs(viewEntry.durationInSecs())); |
|
668 } |
|
669 mCalenEventViewer = new AgendaEventViewer( |
|
670 mController.Services().agendaInterface(), this); |
|
671 connect(mCalenEventViewer, SIGNAL(viewingCompleted(const QDate)), |
|
672 this, SLOT(handleViewingCompleted(const QDate))); |
|
673 connect(mCalenEventViewer, SIGNAL(editingStarted()), |
|
674 this, SLOT(handleEditingStarted())); |
|
675 connect(mCalenEventViewer, SIGNAL(editingCompleted()), |
|
676 this, SLOT(handleEditingCompleted())); |
|
677 connect(mCalenEventViewer, SIGNAL(deletingStarted()), |
|
678 this, SLOT(handleDeletingStarted())); |
|
679 connect(mCalenEventViewer, SIGNAL(deletingCompleted()), |
|
680 this, SLOT(handleDeletingCompleted())); |
|
681 |
|
682 |
|
683 // Launch agenda event viewer |
|
684 mCalenEventViewer->view(viewEntry, AgendaEventViewer::ActionEditDelete); |
|
685 OstTraceFunctionExit0( CALENVIEWMANAGER_LAUNCHEVENTVIEW_EXIT ); |
|
686 } |
|
687 |
|
688 // ---------------------------------------------------------------------------- |
|
689 // CalenViewManager::loadAlternateAgendaView |
|
690 // other items were commented in a header |
|
691 // ---------------------------------------------------------------------------- |
|
692 // |
|
693 void CalenViewManager::loadAlternateAgendaView() |
|
694 { |
|
695 OstTraceFunctionEntry0( CALENVIEWMANAGER_LOADALTERNATEAGENDAVIEW_ENTRY ); |
|
696 |
|
697 bool loadSuccess = false; |
|
698 // Create the agenda view docloader object. |
|
699 mAgendaViewAltDocLoader = new CalenDocLoader(mController); |
|
700 |
|
701 // Load default section |
|
702 mAgendaViewAltDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, &loadSuccess); |
|
703 if (!loadSuccess) { |
|
704 qFatal("calenviewmanager.cpp : Unable to load XML"); |
|
705 } |
|
706 |
|
707 // Get the calenagenda view from the loader |
|
708 mCalenAgendaViewAlt = static_cast<CalenAgendaView *> (mAgendaViewAltDocLoader->findWidget(CALEN_AGENDAVIEW)); |
|
709 if (!mCalenAgendaViewAlt) { |
|
710 qFatal("calenviewmanager.cpp : Unable to find alternate agenda view"); |
|
711 } |
|
712 |
|
713 // Set the parent to delete the view once will exit the application |
|
714 mCalenAgendaViewAlt->setParent(this); |
|
715 |
|
716 // Setup the agenda view |
|
717 mCalenAgendaViewAlt->setupView(mAgendaViewAltDocLoader); |
|
718 OstTraceFunctionExit0( CALENVIEWMANAGER_LOADALTERNATEAGENDAVIEW_EXIT ); |
|
719 } |
|
720 |
|
721 // ---------------------------------------------------------------------------- |
|
722 // CalenViewManager::HandleCommandL |
|
723 // Handles view manager commands. |
|
724 // @return ETrue if command is handled, EFalse otherwise |
|
725 // ---------------------------------------------------------------------------- |
|
726 // |
|
727 TBool CalenViewManager::HandleCommandL(const TCalenCommand& command) |
|
728 { |
|
729 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLECOMMANDL_ENTRY ); |
|
730 |
|
731 TBool commandUsed(EFalse); |
|
732 |
|
733 switch (command.Command()) { |
|
734 case ECalenMonthView: |
|
735 // First remove the previous native view before |
|
736 // we set the mCurrentViewId with the current view |
|
737 removePreviousView(); |
|
738 // Add month view to mainwindow. |
|
739 mController.MainWindow().addView(mCalenMonthView); |
|
740 mCurrentViewId = ECalenMonthView; |
|
741 activateCurrentView(); |
|
742 break; |
|
743 case ECalenAgendaView: |
|
744 // First remove the previous native view before |
|
745 // we set the mCurrentViewId with the current view |
|
746 removePreviousView(); |
|
747 mCurrentViewId = ECalenAgendaView; |
|
748 activateCurrentView(); |
|
749 break; |
|
750 case ECalenDayView: |
|
751 { |
|
752 // First add new view |
|
753 mController.MainWindow().addView(mCalenDayView); |
|
754 |
|
755 // Removes current view |
|
756 // Notice: removing view should be done after new view is set as current to |
|
757 // avoid situation that there is no current view in application |
|
758 removePreviousView(); |
|
759 |
|
760 // Sets and activates day view |
|
761 mCurrentViewId = ECalenDayView; |
|
762 activateCurrentView(); |
|
763 } |
1114 } |
764 break; |
1115 break; |
765 case ECalenEventView: |
1116 case ECalenNotifySystemLocaleChanged: |
766 launchEventView(); |
1117 case ECalenNotifyEntrySaved: |
767 break; |
1118 case ECalenNotifyMultipleEntriesDeleted: |
768 case ECalenStartActiveStep: |
1119 case ECalenNotifyExternalDatabaseChanged: |
769 activateCurrentView(); |
1120 case ECalenNotifyCancelDelete: |
770 break; |
1121 case ECalenNotifyCalendarFieldChanged: |
771 case ECalenShowNextDay: |
1122 case ECalenNotifyMarkedEntryCompleted: |
772 showNextDay(); |
1123 case ECalenNotifyCalendarInfoCreated: |
773 break; |
1124 case ECalenNotifyCalendarInfoUpdated: |
774 case ECalenShowPrevDay: |
1125 { |
775 showPrevDay(); |
1126 StartActiveStepL(); |
776 break; |
1127 } |
|
1128 break; |
|
1129 case ECalenNotifyCalendarFileDeleted: |
|
1130 { |
|
1131 if(iCurrentViewId.iViewUid==KUidCalenEventView) |
|
1132 { |
|
1133 //If the entry which is being viewed belongs to a calendar |
|
1134 //that is deleted we check for collection ids of entry and |
|
1135 //calendar session if they are same return to previous view |
|
1136 TPtrC calFileName = iGlobalData->Context().GetCalendarFileNameL(); |
|
1137 TPtrC calFileNameForColId = |
|
1138 iGlobalData->GetCalFileNameForCollectionId(iGlobalData->Context().InstanceId().iColId); |
|
1139 if(!calFileNameForColId.CompareF(calFileName)) |
|
1140 { |
|
1141 ActivateDefaultViewL(iPreviousToDayView.iViewUid); |
|
1142 } |
|
1143 } |
|
1144 else |
|
1145 { |
|
1146 // refresh the current view |
|
1147 StartActiveStepL(); |
|
1148 } |
|
1149 } |
|
1150 break; |
|
1151 case ECalenNotifyEntryClosed: |
|
1152 { |
|
1153 HandleEntryClosedNotificationL(); |
|
1154 } |
|
1155 break; |
|
1156 case ECalenNotifySystemTimeChanged: |
|
1157 { |
|
1158 HandleSystemTimeChangeNotificationL(); |
|
1159 } |
|
1160 break; |
|
1161 case ECalenNotifyAppForegrounded: |
|
1162 { |
|
1163 // check for system time change whenever fake exit is done |
|
1164 // or application comes to foreground |
|
1165 if(!iStartupComplete) |
|
1166 { |
|
1167 iController.CheckSystemTimeAtStartUpL(); |
|
1168 } |
|
1169 |
|
1170 if( iController.IsFasterAppFlagEnabled() ) |
|
1171 { |
|
1172 iAppUi.HideApplicationFromFSW(EFalse); |
|
1173 iController.SetFasterAppFlag( EFalse ); |
|
1174 |
|
1175 ReloadAllPluginsL(); |
|
1176 } |
|
1177 else |
|
1178 { |
|
1179 iAvoidRepopulation = EFalse; |
|
1180 } |
|
1181 } |
|
1182 break; |
|
1183 case ECalenNotifyDayViewClosed: |
|
1184 { |
|
1185 if(iPreviousToDayView.iViewUid!= KNullUid) |
|
1186 { |
|
1187 // activate the previous view from where day view is launched |
|
1188 // From month/week view -> day view |
|
1189 RequestActivationL(iPreviousToDayView.iViewUid); |
|
1190 } |
|
1191 } |
|
1192 break; |
|
1193 case ECalenNotifyWeekViewClosed: |
|
1194 { |
|
1195 if(iPreviousToWeekView.iViewUid!= KNullUid) |
|
1196 { |
|
1197 // activate the previous view from where day view is launched |
|
1198 // From month/week view -> day view |
|
1199 RequestActivationL(iPreviousToWeekView.iViewUid); |
|
1200 } |
|
1201 } |
|
1202 break; |
|
1203 case ECalenNotifyAppBackgrounded: |
|
1204 { |
|
1205 // set the flag iAvoidRepopulation to prevent repopulation |
|
1206 // whenever application is brought to foreground |
|
1207 iAvoidRepopulation = ETrue; |
|
1208 |
|
1209 if( iController.IsFasterAppFlagEnabled() ) |
|
1210 { |
|
1211 TRAP_IGNORE(iController.RemoveDeadCalendarsL()); |
|
1212 } |
|
1213 } |
|
1214 break; |
|
1215 case ECalenNotifyViewPopulationComplete: |
|
1216 { |
|
1217 if(iStartupComplete) |
|
1218 { |
|
1219 iController.CheckSystemTimeAtStartUpL(); |
|
1220 iStartupComplete = EFalse; |
|
1221 } |
|
1222 break; |
|
1223 } |
|
1224 case ECalenNotifyAttachmentViewerClosed: |
|
1225 { |
|
1226 if( iCurrentViewId.iViewUid==KUidCalenEventView) |
|
1227 { |
|
1228 StartActiveStepL(); |
|
1229 } |
|
1230 } |
|
1231 case ECalenNotifyAttachmentRemoved: |
|
1232 case ECalenNotifyAttachmentAdded: |
|
1233 { |
|
1234 if( iCurrentViewId.iViewUid==KUidCalenEventView && |
|
1235 !iAvoidRepopulation ) |
|
1236 { |
|
1237 StartActiveStepL(); |
|
1238 } |
|
1239 } |
|
1240 case ECalenNotifyDeleteFailed: |
|
1241 // Do nothing on deletion failed |
|
1242 default: |
|
1243 break; |
|
1244 } |
|
1245 |
|
1246 TRACE_EXIT_POINT; |
|
1247 } |
|
1248 |
|
1249 // ---------------------------------------------------------------------------- |
|
1250 // CCalenViewManager::UpdatePluginListL |
|
1251 // Discovers if a plugin has been enabled or disabled |
|
1252 // (other items were commented in a header). |
|
1253 // ---------------------------------------------------------------------------- |
|
1254 // |
|
1255 void CCalenViewManager::UpdatePluginListL() |
|
1256 { |
|
1257 TRACE_ENTRY_POINT; |
|
1258 |
|
1259 const RArray<TUid>& activePlugins = CustomisationManager().ActivePlugins(); |
|
1260 |
|
1261 // Check for any new plugins |
|
1262 TInt activeCount = activePlugins.Count(); |
|
1263 for( TInt index( 0 ); index < activeCount; ++index ) |
|
1264 { |
|
1265 // For every active plugin, check to see if it is in the known list, |
|
1266 // if it isn't construct any custom views. |
|
1267 TUid pluginUid = activePlugins[index]; |
|
1268 TInt position = iKnownPlugins.Find( pluginUid ); |
|
1269 if( position == KErrNotFound ) |
|
1270 { |
|
1271 ConstructCustomViewL( pluginUid ); |
|
1272 } |
|
1273 } |
|
1274 |
|
1275 RArray<TUid> disabledPlugins; |
|
1276 CleanupClosePushL( disabledPlugins ); |
|
1277 |
|
1278 // Check for any disabled plugins |
|
1279 TInt knownCount = iKnownPlugins.Count(); |
|
1280 for( TInt index( knownCount - 1 ); index >= 0; --index ) |
|
1281 { |
|
1282 // For every known plugin, check to see if it is in the active list, |
|
1283 // if it isn't add to the disable plugin list, and remove from the |
|
1284 // known list. |
|
1285 TUid pluginUid = iKnownPlugins[index]; |
|
1286 TInt position = activePlugins.Find( pluginUid ); |
|
1287 if ( position == KErrNotFound ) |
|
1288 { |
|
1289 disabledPlugins.AppendL( pluginUid ); |
|
1290 iKnownPlugins.Remove( index ); |
|
1291 } |
|
1292 } |
|
1293 |
|
1294 TInt disabledPluginCount = disabledPlugins.Count(); |
|
1295 if( disabledPluginCount != 0 ) |
|
1296 { |
|
1297 RemoveDisabledPluginsViewsL( disabledPlugins ); |
|
1298 // Re sort the view info array |
|
1299 iViewInfoArray.Sort( CCalenViewInfo::CyclePositionComparison ); |
|
1300 } |
|
1301 else |
|
1302 { |
|
1303 // Update the view cycle index as iViewInfoArray would have changed |
|
1304 iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1305 } |
|
1306 UpdateToolbarNextViewIconL(iCurrentViewId.iViewUid); |
|
1307 |
|
1308 CleanupStack::PopAndDestroy(); // disabledPlugins |
|
1309 TRACE_EXIT_POINT; |
|
1310 } |
|
1311 |
|
1312 // ---------------------------------------------------------------------------- |
|
1313 // CCalenViewManager::RemoveDisabledPluginsViewsL |
|
1314 // Removes any custom views provided by disabled plugins |
|
1315 // from the view server. |
|
1316 // (other items were commented in a header). |
|
1317 // ---------------------------------------------------------------------------- |
|
1318 // |
|
1319 void CCalenViewManager::RemoveDisabledPluginsViewsL( RArray<TUid>& aDisabledPlugins ) |
|
1320 { |
|
1321 TRACE_ENTRY_POINT; |
|
1322 |
|
1323 // Find what views are provided by the disabled plugins |
|
1324 TInt disabledPluginCount = aDisabledPlugins.Count(); |
|
1325 RArray<TUid> removedViews; |
|
1326 CleanupClosePushL( removedViews ); |
|
1327 |
|
1328 TUid activeViewUid = CurrentView(); |
|
1329 |
|
1330 for( TInt index( disabledPluginCount - 1 ); index >= 0; --index ) |
|
1331 { |
|
1332 TUid pluginUid = aDisabledPlugins[index]; |
|
1333 |
|
1334 // Does this plugin offer any views |
|
1335 TInt position = iViewInfoArray.Find( pluginUid, |
|
1336 CCalenViewInfo::ViewPluginIdentifier ); |
|
1337 TBool alreadySet = EFalse; |
|
1338 while( position != KErrNotFound ) |
|
1339 { |
|
1340 CCalenViewInfo* view = iViewInfoArray[position]; |
|
1341 TUid viewUid = view->ViewUid(); |
|
1342 |
|
1343 // Remove from the view cycle list |
|
1344 iViewInfoArray.Remove( position ); |
|
1345 |
|
1346 RArray<TInt> hiddenViews; |
|
1347 iCustomisationManager->GetHiddenViewIdL(pluginUid, hiddenViews); |
|
1348 |
|
1349 if( viewUid == activeViewUid ) |
|
1350 { |
|
1351 // Removing the active view is done in three parts |
|
1352 // 1) It is removed from the viewInfo list |
|
1353 // 2) When settings is closed, the view is switched |
|
1354 // to the next view in the view cycle list. |
|
1355 // 3) When the view is deactivated it can be deleted. |
|
1356 |
|
1357 // Store the information about the current view. |
|
1358 iRemovedActiveView = view; |
|
1359 |
|
1360 // Update the view cycle index so that hidden view is launched while cycling next view |
|
1361 if(hiddenViews.Count()) |
|
1362 { |
|
1363 // Find the index of teh hidden view |
|
1364 TInt viewInfoIndex = iViewInfoArray.Find(TUid::Uid(hiddenViews[0]), CCalenViewInfo::ViewInfoIdentifier); |
|
1365 iViewCycleIndex = viewInfoIndex - 1; // Decrementing it as CycleNextView() funciton will increment it |
|
1366 } |
|
1367 else if(!alreadySet) |
|
1368 { |
|
1369 TInt nextViewCycleIndex = iViewCycleIndex - 1; // To update the view cycle index in plugin disable case |
|
1370 |
|
1371 // Update the view cycle index as iViewInfoArray would have changed |
|
1372 iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1373 |
|
1374 // If the current active view has been removed, |
|
1375 if(iViewCycleIndex == -1) |
|
1376 { |
|
1377 iViewCycleIndex = nextViewCycleIndex; |
|
1378 } |
|
1379 alreadySet = ETrue; |
|
1380 } |
|
1381 |
|
1382 hiddenViews.Reset(); |
|
1383 // Remove the plugin from the disabled plugin list |
|
1384 // to stop the plugin being deleted. |
|
1385 aDisabledPlugins.Remove( index ); |
|
1386 } |
|
1387 else |
|
1388 { |
|
1389 // The view isn't the current view, so we |
|
1390 // can remove it directly from the view server |
|
1391 iAppUi.RemoveView( viewUid ); |
|
1392 |
|
1393 // Delete the view info |
|
1394 delete view; |
|
1395 if(!alreadySet) |
|
1396 { |
|
1397 TInt nextViewCycleIndex = iViewCycleIndex - 1; // To update the view cycle index in plugin disable case |
|
1398 |
|
1399 // Update the view cycle index as iViewInfoArray would have changed |
|
1400 iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1401 |
|
1402 // If the current active view has been removed, |
|
1403 if(iViewCycleIndex == -1) |
|
1404 { |
|
1405 iViewCycleIndex = nextViewCycleIndex; |
|
1406 } |
|
1407 alreadySet = ETrue; |
|
1408 } |
|
1409 |
|
1410 } |
|
1411 |
|
1412 position = iViewInfoArray.Find( pluginUid, |
|
1413 CCalenViewInfo::ViewPluginIdentifier ); |
|
1414 } |
|
1415 } |
|
1416 |
|
1417 // Unload the disabled plugins |
|
1418 iCustomisationManager->UnloadPluginsL( aDisabledPlugins ); |
|
1419 |
|
1420 CleanupStack::PopAndDestroy(); // removedViews |
|
1421 |
|
1422 TRACE_EXIT_POINT; |
|
1423 } |
|
1424 |
|
1425 // ---------------------------------------------------------------------------- |
|
1426 // CCalenViewManager::ToolbarOrNull |
|
1427 // Provides access to the calendar toolbar if one is available |
|
1428 // ---------------------------------------------------------------------------- |
|
1429 MCalenToolbar* CCalenViewManager::ToolbarOrNull() |
|
1430 { |
|
1431 TRACE_ENTRY_POINT; |
|
1432 TRACE_EXIT_POINT; |
|
1433 if (iToolbar) |
|
1434 { |
|
1435 if (iToolbar->IsICalenToolBar()) |
|
1436 { |
|
1437 return iToolbar; |
|
1438 } |
|
1439 } |
|
1440 return NULL; |
|
1441 } |
|
1442 |
|
1443 // ---------------------------------------------------------------------------- |
|
1444 // CCalenViewManager::ViewsActivated |
|
1445 // Returns if the first view activation on start-up has taken place |
|
1446 // ---------------------------------------------------------------------------- |
|
1447 TBool CCalenViewManager::ViewsActivated() const |
|
1448 { |
|
1449 TRACE_ENTRY_POINT; |
|
1450 TRACE_EXIT_POINT; |
|
1451 return iViewsActivated; |
|
1452 } |
|
1453 |
|
1454 // ---------------------------------------------------------------------------- |
|
1455 // CCalenViewManager::UpdateToolbarNextViewIconL |
|
1456 // Updates the nextview icon on the toolbar when default view is not month view |
|
1457 // ---------------------------------------------------------------------------- |
|
1458 void CCalenViewManager::UpdateToolbarNextViewIconL(TUid aViewUid) |
|
1459 { |
|
1460 // Set the view cycle index based on the newly activated view, |
|
1461 // if the view is in the cycle array. |
|
1462 TInt index = iViewInfoArray.Find( aViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1463 if( index != KErrNotFound ) |
|
1464 { |
|
1465 iViewCycleIndex = index; |
|
1466 if( iToolbar ) |
|
1467 { |
|
1468 TInt nextVwIndex = iViewCycleIndex; |
|
1469 do{ |
|
1470 nextVwIndex = ( nextVwIndex + 1 )%(iViewInfoArray.Count()); |
|
1471 } |
|
1472 while( iViewInfoArray[nextVwIndex]->CyclePosition() == CCalenView::ENoCyclePosition ); |
|
1473 |
|
1474 CCalenView* nextview = static_cast<CCalenView*>( |
|
1475 iAppUi.View( iViewInfoArray[nextVwIndex]->ViewUid() ) ); |
|
1476 iToolbar->SetNextViewIcon( nextview->ViewIconL() ); |
|
1477 } |
|
1478 } |
777 } |
1479 } |
778 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLECOMMANDL_EXIT ); |
1480 |
779 return commandUsed; |
1481 // ---------------------------------------------------------------------------- |
780 } |
1482 // CCalenViewManager::HandleFasterAppExitCommandL |
781 |
1483 // Handles ECalenFasterAppExit command |
782 // ---------------------------------------------------------------------------- |
1484 // ---------------------------------------------------------------------------- |
783 // CalenViewManager::HandleNotification |
1485 void CCalenViewManager::HandleFasterAppExitCommandL() |
784 // Handles notifications. |
1486 { |
785 // (other items were commented in a header). |
1487 TRACE_ENTRY_POINT; |
786 // ---------------------------------------------------------------------------- |
1488 |
787 // |
1489 if(iToolbar) |
788 void CalenViewManager::HandleNotification( |
1490 { |
789 const TCalenNotification notification) |
1491 iToolbar->SetToolbarExtensionFocus(EFalse); |
790 { |
1492 } |
791 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLENOTIFICATION_ENTRY ); |
1493 |
792 |
1494 // For Handling : When the default view is changed keeping that view open, |
793 switch (notification) { |
1495 // from day view changing the default view from month view to day view, |
794 case ECalenNotifyExternalDatabaseChanged: |
1496 // we need to reset the previous view id. |
795 case ECalenNotifyDialogClosed: |
1497 if(iPreviousToDayView.iViewUid!=KNullUid) |
796 case ECalenNotifyMultipleEntriesDeleted: |
1498 { |
797 case ECalenNotifyEntrySaved: |
1499 iPreviousToDayView.iViewUid = KNullUid; |
798 case ECalenNotifyEntryDeleted: |
1500 } |
799 case ECalenNotifyInstanceDeleted: |
1501 |
800 case ECalenNotifyEntryClosed: |
1502 // For handling specific case::Calendar exited from FSW |
801 case ECalenNotifySystemLocaleChanged: |
1503 // iAvoidRepopulation is set when app backgrounded. |
802 case ECalenNotifySystemTimeChanged: |
1504 // Reset the flag for activating the view in background |
803 case ECalenNotifySystemLanguageChanged: { |
1505 if(iAvoidRepopulation) |
804 |
1506 { |
805 if (notification == ECalenNotifySystemTimeChanged) { |
1507 iAvoidRepopulation = EFalse; |
806 MCalenContext &context = mController.context(); |
1508 } |
807 QDateTime defaultTime = context.defaultCalTimeForViewsL(); |
1509 |
808 context.setFocusDateAndTime(defaultTime); |
1510 // In case of fasterapp exit, first activate the dummy view before deleting the plugin views |
809 } |
1511 // Get the default view before we remove plugins |
810 activateCurrentView(); |
1512 iPreviousViewId.iViewUid = KNullUid; |
811 if (mCalenMonthView) { |
1513 |
812 mCalenMonthView->captureScreenshot(); |
1514 iController.SetExitOnDialogFlag( EFalse ); // for making iisexitondialogclose EFalse. |
813 } else if (mCalenAgendaView) { |
1515 |
814 mCalenAgendaView->captureScreenshot(); |
1516 TUid defView = iSetting->DefaultView(); |
815 } |
1517 |
816 } |
1518 // unload all plugins |
817 break; |
1519 iCustomisationManager->DisableAllPluginsL(); |
818 case ECalenNotifySettingsClosed: { |
1520 ActivateViewOnFakeExitL(defView); |
819 //when setting view closed , switch to the previous view |
1521 // Though the current view is active view, there is no need to issue a callback as we are exiting the whole application. |
820 mCurrentViewId = mPreviousViewsId ; |
1522 if( iRemovedActiveView ) |
821 mController.Services().IssueCommandL(ECalenStartActiveStep); |
1523 { |
822 |
1524 |
823 // invalidate captured screenshots as either agenda view is activated now |
1525 if( !iViewRemovalCallback ) |
824 if (mCalenMonthView) { |
1526 { |
825 mCalenMonthView->captureScreenshot(); |
1527 TCallBack callback( RemoveDeActivatedView, this ); |
826 } else if (mCalenAgendaView) { |
1528 iViewRemovalCallback = new( ELeave ) CAsyncCallBack( callback, |
827 mCalenAgendaView->captureScreenshot(); |
1529 CActive::EPriorityStandard ); |
828 } |
1530 } |
829 |
1531 iViewRemovalCallback->CallBack(); |
830 } |
1532 } |
831 break; |
1533 |
832 default: |
1534 TRACE_EXIT_POINT; |
833 break; |
1535 } |
834 } |
1536 // ---------------------------------------------------------------------------- |
835 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLENOTIFICATION_EXIT ); |
1537 // CCalenViewManager::HandleSettingsChangeNotificationL |
836 } |
1538 // Handles ECalenNotifySettingsChanged notification |
837 |
1539 // ---------------------------------------------------------------------------- |
838 // ---------------------------------------------------------------------------- |
1540 void CCalenViewManager::HandleSettingsChangeNotificationL() |
839 // CalenViewManager::settingsView |
1541 { |
840 // Returns the settings view |
1542 TRACE_ENTRY_POINT; |
841 // (other items were commented in a header). |
1543 |
842 // ---------------------------------------------------------------------------- |
1544 if( iController.IsFasterAppFlagEnabled() ) |
843 // |
1545 { |
844 CalenSettingsView* CalenViewManager::settingsView() |
1546 TUid newViewUid = iSetting->DefaultView(); |
845 { |
1547 if(IsNativeView(newViewUid)) |
846 OstTraceFunctionEntry0( CALENVIEWMANAGER_SETTINGSVIEW_ENTRY ); |
1548 { |
847 |
1549 TUid oldViewUid = CurrentView(); |
848 OstTraceFunctionExit0( CALENVIEWMANAGER_SETTINGSVIEW_EXIT ); |
1550 if( newViewUid.iUid != oldViewUid.iUid ) |
849 return mSettingsView; |
1551 { |
850 } |
1552 RequestActivationL( newViewUid ); |
851 |
1553 } |
852 // ---------------------------------------------------------------------------- |
1554 } |
853 // CalenViewManager::handleViewingCompleted |
1555 |
854 // Slot to handle signal viewingCompleted by the agenda event viewer |
1556 // If the plugins are activated using general settings. |
855 // (other items were commented in a header). |
1557 // unload all plugins.Only load the plugins when application |
856 // ---------------------------------------------------------------------------- |
1558 // comes to foreground |
857 // |
1559 const RArray<TUid>& plugins = CustomisationManager().ActivePlugins(); |
858 void CalenViewManager::handleViewingCompleted(const QDate date) |
1560 if(plugins.Count()) |
859 { |
1561 { |
860 Q_UNUSED(date); |
1562 // unload all plugins |
861 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEVIEWINGCOMPLETED_ENTRY ); |
1563 iCustomisationManager->DisableAllPluginsL(); |
|
1564 } |
|
1565 } |
|
1566 |
|
1567 if( iRemovedActiveView ) |
|
1568 { |
|
1569 // If the active view has been disabled, the next view in |
|
1570 // the view cycle list is activated and the current view |
|
1571 // is removed asyncronously. |
|
1572 CycleNextViewL(); |
|
1573 |
|
1574 if( !iViewRemovalCallback ) |
|
1575 { |
|
1576 TCallBack callback( RemoveDeActivatedView, this ); |
|
1577 iViewRemovalCallback = new( ELeave ) CAsyncCallBack( callback, |
|
1578 CActive::EPriorityStandard ); |
|
1579 } |
|
1580 |
|
1581 iViewRemovalCallback->CallBack(); |
|
1582 } |
|
1583 else if(iCustomisationManager->HiddenView(iCurrentViewId.iViewUid)) |
|
1584 { |
|
1585 // Get the uid of the plugin view that is hiding the current view |
|
1586 TUid viewUid = iCustomisationManager->GetReplacePluginViewIdL(iCurrentViewId.iViewUid); |
|
1587 |
|
1588 // update the view cycle index before activating the plugin view |
|
1589 iViewCycleIndex = iViewInfoArray.Find( viewUid, |
|
1590 CCalenViewInfo::ViewInfoIdentifier ); |
|
1591 RequestActivationL(viewUid); |
|
1592 } |
|
1593 else |
|
1594 { |
|
1595 StartActiveStepL(); |
|
1596 } |
|
1597 |
|
1598 TRACE_EXIT_POINT; |
|
1599 } |
|
1600 |
|
1601 // ---------------------------------------------------------------------------- |
|
1602 // CCalenViewManager::HandleEntryDeleteNotificationL |
|
1603 // Handles ECalenNotifyEntryDeleted and ECalenNotifyInstanceDeleted |
|
1604 // notifications |
|
1605 // ---------------------------------------------------------------------------- |
|
1606 void CCalenViewManager::HandleEntryDeleteNotificationL() |
|
1607 { |
|
1608 TRACE_ENTRY_POINT; |
|
1609 |
|
1610 if(iCurrentViewId.iViewUid == KUidCalenEventView) |
|
1611 { |
|
1612 // Activate the previous view when an event is deleted from |
|
1613 // the event view |
|
1614 if(iPreviousViewId.iViewUid != KNullUid) |
|
1615 { |
|
1616 if(iPreviousToDayView.iViewUid != KNullUid) |
|
1617 { |
|
1618 RequestActivationL(iPreviousViewId.iViewUid, KUidCalenShowBackCba); |
|
1619 } |
|
1620 else |
|
1621 { |
|
1622 RequestActivationL(iPreviousViewId.iViewUid); |
|
1623 } |
|
1624 } |
|
1625 } |
|
1626 else |
|
1627 { |
|
1628 // refresh the current view |
|
1629 StartActiveStepL(); |
|
1630 } |
|
1631 |
|
1632 TRACE_EXIT_POINT; |
|
1633 } |
|
1634 |
|
1635 // ---------------------------------------------------------------------------- |
|
1636 // CCalenViewManager::HandleEntryClosedNotificationL |
|
1637 // Handles ECalenNotifyEntryClosed notification |
|
1638 // ---------------------------------------------------------------------------- |
|
1639 void CCalenViewManager::HandleEntryClosedNotificationL() |
|
1640 { |
|
1641 TRACE_ENTRY_POINT; |
862 |
1642 |
863 // Cleanup. |
1643 // reset tha flag iAvoidRepopulation to refresh the view. |
864 mCalenEventViewer->deleteLater(); |
1644 iAvoidRepopulation = EFalse; |
865 if (!date.isNull() && date.isValid()) { |
1645 |
866 mController.Services().Context().setFocusDate(QDateTime(date)); |
1646 // if previous view is native view activate that view |
867 } |
1647 // otherwise commandlauncher will handle |
868 mController.Services().IssueNotificationL(ECalenNotifyEntryClosed); |
1648 if(iPreviousViewId.iViewUid != KNullUid) |
869 |
1649 { |
870 // invalidate captured screenshots as either agenda view is activated now |
1650 // if iPreviousToDayView is active activate the day view with "Back" cba. |
871 if (mCalenMonthView) { |
1651 if(iPreviousToDayView.iViewUid!=KNullUid) |
872 mCalenMonthView->captureScreenshot(); |
1652 { |
873 } else if (mCalenAgendaView) { |
1653 RequestActivationL(iPreviousViewId.iViewUid, KUidCalenShowBackCba); |
874 mCalenAgendaView->captureScreenshot(); |
1654 } |
875 } |
1655 else |
876 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEVIEWINGCOMPLETED_EXIT ); |
1656 { |
877 } |
1657 if( !iController.GetExitOnDialogFlag() ) |
878 |
1658 { |
879 // ---------------------------------------------------------------------------- |
1659 RequestActivationL(iPreviousViewId.iViewUid); |
880 // CalenViewManager::handleEditingStarted |
1660 } |
881 // Slot to handle signal editingStarted by the agenda event viewer |
1661 } |
882 // (other items were commented in a header). |
1662 } |
883 // ---------------------------------------------------------------------------- |
1663 |
884 // |
1664 // reset tha flag iAvoidRepopulation to avoid the repopulation. |
885 void CalenViewManager::handleEditingStarted() |
1665 iAvoidRepopulation = ETrue; |
886 { |
1666 |
887 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEEDITINGSTARTED_ENTRY ); |
1667 TRACE_EXIT_POINT; |
888 |
1668 } |
889 mController.IssueCommandL(ECalenEditEntryFromViewer); |
1669 |
890 |
1670 // ---------------------------------------------------------------------------- |
891 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEEDITINGSTARTED_EXIT ); |
1671 // CCalenViewManager::HandleSystemTimeChangeNotificationL |
892 } |
1672 // Handles ECalenNotifySystemTimeChanged notification |
893 |
1673 // ---------------------------------------------------------------------------- |
894 // ---------------------------------------------------------------------------- |
1674 void CCalenViewManager::HandleSystemTimeChangeNotificationL() |
895 // CalenViewManager::handleEditingCompleted |
1675 { |
896 // Slot to handle signal editingCompleted by the agenda event viewer |
1676 TRACE_ENTRY_POINT; |
897 // (other items were commented in a header). |
1677 |
898 // ---------------------------------------------------------------------------- |
1678 //Set the context whenever system time is changed |
899 // |
1679 TUid newViewUid = iSetting->DefaultView(); |
900 void CalenViewManager::handleEditingCompleted() |
1680 MCalenContext& context = iController.Services().Context(); |
901 { |
1681 TCalTime focusTime = context.DefaultCalTimeForViewsL(); |
902 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEEDITINGCOMPLETED_ENTRY ); |
1682 context.SetFocusDateAndTimeL( focusTime, |
903 |
1683 TVwsViewId( KUidCalendar, newViewUid )); |
904 mController.Services().IssueNotificationL(ECalenNotifyEditorClosedFromViewer); |
1684 if( iController.IsFasterAppFlagEnabled() ) |
905 |
1685 { |
906 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEEDITINGCOMPLETED_EXIT ); |
1686 // reset tha flag iAvoidRepopulation to refresh the view whenever |
907 } |
1687 // system time is changed |
908 |
1688 iAvoidRepopulation = EFalse; |
909 // ---------------------------------------------------------------------------- |
1689 |
910 // CalenViewManager::handleDeletingStarted |
1690 if(IsNativeView(newViewUid)) |
911 // Slot to handle signal deletingStarted by the agenda event viewer |
1691 { |
912 // (other items were commented in a header). |
1692 // activate the default view in background |
913 // ---------------------------------------------------------------------------- |
1693 RequestActivationL( newViewUid ); |
914 // |
1694 } |
915 void CalenViewManager::handleDeletingStarted() |
1695 |
916 { |
1696 // set the flag iAvoidRepopulation to avoid repopulation |
917 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEDELETINGSTARTED_ENTRY ); |
1697 iAvoidRepopulation = ETrue; |
918 |
1698 } |
919 mController.IssueCommandL(ECalenDeleteEntryFromViewer); |
1699 else |
920 |
1700 { |
921 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEDELETINGSTARTED_EXIT ); |
1701 // refresh the current view |
922 } |
1702 StartActiveStepL(); |
923 |
1703 } |
924 // ---------------------------------------------------------------------------- |
1704 |
925 // CalenViewManager::handleDeletingCompleted |
1705 TRACE_EXIT_POINT; |
926 // Slot to handle signal deletingCompleted by the agenda event viewer |
1706 } |
927 // (other items were commented in a header). |
1707 |
928 // ---------------------------------------------------------------------------- |
1708 // ----------------------------------------------------------------------------- |
929 // |
1709 // CCalenViewManager::IconsL |
930 void CalenViewManager::handleDeletingCompleted() |
1710 // Create a CCalenIcons object if neccessary and return a reference |
931 { |
1711 // (other items were commented in a header). |
932 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEDELETINGCOMPLETED_ENTRY ); |
1712 // ----------------------------------------------------------------------------- |
933 |
1713 CCalenIcons& CCalenViewManager::IconsL() |
934 mController.Services().IssueNotificationL(ECalenNotifyEntryDeleted); |
1714 { |
935 |
1715 TRACE_ENTRY_POINT; |
936 // invalidate captured screenshots as either month view or agenda view is activated now |
1716 |
937 if (mCalenMonthView) { |
1717 if (!iIcons) |
938 mCalenMonthView->captureScreenshot(); |
1718 { |
939 } else if (mCalenAgendaView) { |
1719 // Icons |
940 mCalenAgendaView->captureScreenshot(); |
1720 iIcons = CCalenIcons::NewL(); |
941 } |
1721 } |
942 |
1722 |
943 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEDELETINGCOMPLETED_EXIT ); |
1723 TRACE_EXIT_POINT; |
944 } |
1724 return *iIcons; |
945 |
1725 } |
946 // ---------------------------------------------------------------------------- |
1726 |
947 // CalenViewManager::handleInstanceViewCreation |
1727 // ----------------------------------------------------------------------------- |
948 // Slot to handle completion of instance view creation |
1728 // CCalenViewManager::GetNextViewIconL |
949 // (other items were commented in a header). |
1729 // Gets next view icon |
950 // ---------------------------------------------------------------------------- |
1730 // ----------------------------------------------------------------------------- |
951 // |
1731 CGulIcon* CCalenViewManager::GetNextViewIconL() |
952 void CalenViewManager::handleInstanceViewCreation(int status) |
1732 { |
953 { |
1733 TRACE_ENTRY_POINT; |
954 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEINSTANCEVIEWCREATION_ENTRY ); |
1734 |
955 |
1735 // Set the view cycle index based on the newly activated view, |
956 Q_UNUSED(status); |
1736 // if the view is in the cycle array. |
957 |
1737 TInt index = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
958 // This flag is needed if mCalenMonthView and mCalenAgendaview is not created |
1738 if( index != KErrNotFound ) |
959 // and before that this slot is getting called. |
1739 { |
960 // if we launch views through services then this slot is getting called |
1740 iViewCycleIndex = index; |
961 // before the view construction. |
1741 TInt nextVwIndex = iViewCycleIndex; |
962 mInstanceViewCreated = true; |
1742 do |
963 |
1743 { |
964 // handleInstanceViewCreation function is called only once. Now that the instance |
1744 nextVwIndex = ( nextVwIndex + 1 )%(iViewInfoArray.Count()); |
965 // view creation is successfull. Events need to be populated on screen |
1745 }while( iViewInfoArray[nextVwIndex]->CyclePosition() == CCalenView::ENoCyclePosition ); |
966 // Ideal colution should be to call a uniform function, e.g. PopulateEvents |
1746 |
967 // where PopulateEvents should be implemeted by all views. Since the current |
1747 // Get the next view icon |
968 // solution for the month view implements the construction in two phases so |
1748 CCalenView* nextview = static_cast<CCalenView*>( iAppUi.View( iViewInfoArray[nextVwIndex]->ViewUid() ) ); |
969 // it needs to be refactored and a common solution needs to be put here. So |
1749 return( nextview->ViewIconL() ); |
970 // that code doesn't break if another view is added tomorow |
1750 } |
971 HbView *currentview = mController.MainWindow().currentView(); |
1751 |
972 |
1752 TRACE_EXIT_POINT; |
973 if (mCalenMonthView && currentview == mCalenMonthView) { |
1753 return NULL; |
974 mCalenMonthView->fetchEntriesAndUpdateModel(); |
1754 } |
975 } |
1755 |
976 else if (mCalenAgendaView && currentview == mCalenAgendaView) { |
1756 // ----------------------------------------------------------------------------- |
977 mCalenAgendaView->doPopulation(); |
1757 // CCalenViewManager::SetRepopulation |
978 } |
1758 // Resets the flag iAvoidRepopulation to activate the view. |
979 else if (mCalenDayView && currentview == mCalenDayView) { |
1759 // ----------------------------------------------------------------------------- |
980 mCalenDayView->doPopulation(); |
1760 void CCalenViewManager::SetRepopulation(TBool aRePopulate) |
981 } |
1761 { |
982 // Calls the emitAppReady function of CalenController. Need to emit this |
1762 TRACE_ENTRY_POINT; |
983 // signal after the view is fully constructed & populated |
1763 // to prevent the display of blank view, |
984 // with actual data and ready to be used. So entry view & instance view |
1764 // set the iAvoidRepopulation to EFalse, |
985 // needs to be created so that a new entry can also be created. Finally |
1765 // so that view is populated properly |
986 // NotesApplication object needs to emit applicationReady Signal. |
1766 |
987 mController.emitAppReady(); |
1767 iAvoidRepopulation = aRePopulate; |
988 |
1768 |
989 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEINSTANCEVIEWCREATION_EXIT ); |
1769 TRACE_EXIT_POINT; |
990 } |
1770 } |
991 |
1771 |
992 // ---------------------------------------------------------------------------- |
1772 // ----------------------------------------------------------------------------- |
993 // CalenViewManager::handleDeletingCompleted |
1773 // CCalenViewManager::CalenToolbar |
994 // Slot to handle completion of entry view creation |
1774 // Returns calendar toolbar |
995 // (other items were commented in a header). |
1775 // ----------------------------------------------------------------------------- |
996 // ---------------------------------------------------------------------------- |
1776 CCalenToolbarImpl* CCalenViewManager::CalenToolbar() |
997 // |
1777 { |
998 void CalenViewManager::handleEntryViewCreation(int status) |
1778 TRACE_ENTRY_POINT; |
999 { |
1779 TRACE_EXIT_POINT; |
1000 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEENTRYVIEWCREATION_ENTRY ); |
1780 return iToolbar; |
1001 |
1781 } |
1002 // Nothing Yet |
1782 |
1003 Q_UNUSED(status); |
1783 // ----------------------------------------------------------------------------- |
1004 |
1784 // CCalenViewManager::ReloadAllPluginsL |
1005 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEENTRYVIEWCREATION_EXIT ); |
1785 // Reload all plugins |
1006 } |
1786 // ----------------------------------------------------------------------------- |
1007 |
1787 void CCalenViewManager::ReloadAllPluginsL() |
1008 // ---------------------------------------------------------------------------- |
1788 { |
1009 // CalenViewManager::handleEntriesChanged |
1789 TRACE_ENTRY_POINT; |
1010 // this function will be called when someone else has changed the database |
1790 |
1011 // ---------------------------------------------------------------------------- |
1791 // load all plugins |
1012 // |
1792 iCustomisationManager->DoPluginLoadingL(); |
1013 void CalenViewManager::handleEntriesChanged(QList<ulong> ids) |
1793 UpdatePluginListL(); |
1014 { |
1794 |
1015 Q_UNUSED(ids); |
1795 // only activate plugin view if it is default view |
1016 HbView *currentview = mController.MainWindow().currentView(); |
1796 TUid defaultViewUid = iSetting->DefaultView(); |
1017 if((mCalenMonthView == currentview)||(mCalenDayView == currentview)|| |
1797 if(!IsNativeView(defaultViewUid)) |
1018 (mCalenAgendaView == currentview )||(mCalenAgendaViewAlt == currentview)) |
1798 { |
1019 { |
1799 iAvoidRepopulation = EFalse; |
1020 activateCurrentView(); |
1800 |
1021 } |
1801 // Find the default view in the view cycle list |
1022 delete currentview; |
1802 TInt position = iViewInfoArray.Find( |
1023 } |
1803 defaultViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
1024 |
1804 if( position != KErrNotFound ) |
1025 // ---------------------------------------------------------------------------- |
1805 { |
1026 // CalenViewManager::handleEntryUpdation |
1806 TVwsViewId targetViewId( KUidCalendar, defaultViewUid); |
1027 // this function will be called when any entry is updated or added into database |
1807 RequestActivationL(targetViewId); |
1028 // Here we need to set the context to the entry updated or added. |
1808 iViewCycleIndex = position; |
1029 // ---------------------------------------------------------------------------- |
1809 } |
1030 // |
1810 else |
1031 void CalenViewManager::handleEntryUpdation(ulong id) |
1811 { |
1032 { |
1812 // if plugin providing default view is already uninstalled |
1033 AgendaEntry updatedEntry = mController.agendaInterface()->fetchById(id); |
1813 // activate month view as default view |
1034 |
1814 CRepository* repository = CRepository::NewL( KCRUidCalendar ); |
1035 // Agenda entry is not null then refresh the view else close event viewer |
1815 CleanupStack::PushL(repository); |
1036 if (!updatedEntry.isNull()) { |
1816 TInt tmp( static_cast<TInt>( KUidCalenMonthView.iUid ) ); |
1037 if (AgendaEntry::TypeTodo != updatedEntry.type()) { |
1817 TInt position = iViewInfoArray.Find( KUidCalenMonthView, CCalenViewInfo::ViewInfoIdentifier ); |
1038 QDate date = updatedEntry.startTime().date(); |
1818 User::LeaveIfError( repository->Set( KCalendarDefaultStartView, tmp ) ); |
1039 if (!date.isNull() && date.isValid()) { |
1819 iAppUi.SetDefaultViewL( *iAppUi.View( KUidCalenMonthView ) ); |
1040 mController.Services().Context().setFocusDate(QDateTime(date)); |
1820 TVwsViewId targetViewId( KUidCalendar, KUidCalenMonthView); |
1041 } |
1821 RequestActivationL(targetViewId); |
1042 } |
1822 iViewCycleIndex = position; |
1043 } |
1823 CleanupStack::PopAndDestroy(repository); |
1044 |
1824 } |
1045 } |
1825 } |
1046 |
1826 |
1047 // ---------------------------------------------------------------------------- |
1827 TRACE_EXIT_POINT; |
1048 // CalenViewManager::launchSettingsView |
1828 } |
1049 // Launches settings view |
1829 |
1050 // (other items were commented in a header). |
1830 // ----------------------------------------------------------------------------- |
1051 // ---------------------------------------------------------------------------- |
1831 // CCalenViewManager::GetPreviousViewUid |
1052 // |
1832 // Rest of the details are commented in header. |
1053 void CalenViewManager::launchSettingsView() |
1833 // ----------------------------------------------------------------------------- |
1054 { |
1834 TUid CCalenViewManager::GetPreviousViewUid() |
1055 OstTraceFunctionEntry0( CALENVIEWMANAGER_LAUNCHSETTINGSVIEW_ENTRY ); |
1835 { |
1056 |
1836 return iPreviousViewId.iViewUid; |
1057 mPreviousViewsId = mCurrentViewId ; |
1837 } |
1058 mCurrentViewId = ECalenShowSettings; |
1838 |
1059 mSettingsView->initializeForm(); |
1839 // ----------------------------------------------------------------------------- |
1060 mController.Services().MainWindow().setCurrentView(mSettingsView); |
1840 // CCalenViewManager::SetPreviousViewUid |
1061 |
1841 // Rest of the details are commented in header. |
1062 // capture cureent view in case app closed/quits from settings view |
1842 // ----------------------------------------------------------------------------- |
1063 if (mCalenMonthView){ |
1843 void CCalenViewManager::SetPreviousViewUid(TUid aPreviousUid) |
1064 mCalenMonthView->captureScreenshot(true); |
1844 { |
1065 } else if(mCalenAgendaView){ |
1845 iPreviousViewId.iViewUid = aPreviousUid; |
1066 mCalenAgendaView->captureScreenshot(true); |
1846 } |
1067 } |
1847 // ----------------------------------------------------------------------------- |
1068 |
1848 // CCalenViewManager::IsNativeView |
1069 OstTraceFunctionExit0( CALENVIEWMANAGER_LAUNCHSETTINGSVIEW_EXIT ); |
1849 // Check for native view |
1070 } |
1850 // ----------------------------------------------------------------------------- |
1071 |
1851 TBool CCalenViewManager::IsNativeView(TUid aViewUid) |
1072 |
1852 { |
1073 // ---------------------------------------------------------------------------- |
1853 TRACE_ENTRY_POINT; |
1074 // CalenViewManager::removeSettingsView |
1854 |
1075 // remove settings view |
1855 if( (aViewUid == KUidCalenMonthView)|| |
1076 // ---------------------------------------------------------------------------- |
1856 (aViewUid == KUidCalenWeekView) || |
1077 // |
1857 (aViewUid == KUidCalenDayView) || |
1078 void CalenViewManager::removeSettingsView() |
1858 (aViewUid == KUidCalenTodoView) ) |
1079 { |
1859 { |
1080 if(mSettingsView){ |
1860 TRACE_EXIT_POINT; |
1081 mController.Services().MainWindow().removeView(mSettingsView); |
1861 return ETrue; |
1082 } |
1862 } |
1083 } |
1863 TRACE_EXIT_POINT; |
1084 |
1864 return EFalse; |
1085 // ---------------------------------------------------------------------------- |
1865 } |
1086 // CalenViewManager::isEventViewerActive |
1866 |
1087 // check if Agenda Event Viewer is active |
1867 // ----------------------------------------------------------------------------- |
1088 // ---------------------------------------------------------------------------- |
1868 // CCalenViewManager::ActivateViewOnFakeExitL |
1089 // |
1869 // Check for native view |
1090 bool CalenViewManager::isEventViewerActive() |
1870 // ----------------------------------------------------------------------------- |
1091 { |
1871 void CCalenViewManager::ActivateViewOnFakeExitL(TUid aDefView) |
1092 if(mCalenEventViewer) |
1872 { |
1093 return true; |
1873 TRACE_ENTRY_POINT; |
1094 else |
1874 iFakeExit = ETrue; |
1095 return false; |
1875 if(IsNativeView(aDefView)) |
1096 } |
1876 { |
1097 |
1877 // activate the view in background |
1098 // ---------------------------------------------------------------------------- |
1878 RequestActivationL( aDefView, KCalenHideInBackGround, KNullDesC8() ); |
1099 // CalenViewManager::saveAndCloseEditor |
1879 } |
1100 // save the entry and close the editor |
1880 else |
1101 // isEventViewerActive() should be called before this function |
1881 { |
1102 // ---------------------------------------------------------------------------- |
1882 RequestActivationL( KUidCalenDummyView, KCalenHideInBackGround, KNullDesC8() ); |
1103 // |
1883 } |
1104 void CalenViewManager::saveAndCloseEditor() |
1884 |
1105 { |
1885 // set the flag to avoid repopulation when application is |
1106 mCalenEventViewer->saveAndCloseEditor(); |
1886 // opened after faster exit |
1107 } |
1887 iAvoidRepopulation = ETrue; |
1108 |
1888 |
1109 // ---------------------------------------------------------------------------- |
1889 // set the context |
1110 // CalenViewManager::closeAgendaEventView |
1890 MCalenContext& context = iController.Services().Context(); |
1111 // close the agenda event view |
1891 TCalTime focusTime = context.DefaultCalTimeForViewsL(); |
1112 // isEventViewerActive() should be called before this function |
1892 context.SetFocusDateAndTimeL( focusTime, |
1113 // ---------------------------------------------------------------------------- |
1893 TVwsViewId( KUidCalendar, aDefView) ); |
1114 // |
1894 |
1115 void CalenViewManager::closeAgendaEventView() |
1895 TRACE_EXIT_POINT; |
1116 { |
1896 } |
1117 mCalenEventViewer->closeAgendaEventView(); |
1897 |
1118 } |
1898 // ----------------------------------------------------------------------------- |
1119 |
1899 // CCalenViewManager::ActivateLocalViewL |
1120 |
1900 // Activate the local view if application already in back ground |
1121 // End of file --Don't remove this. |
1901 // ----------------------------------------------------------------------------- |
|
1902 void CCalenViewManager::ActivateLocalViewL(TUid aDefView) |
|
1903 { |
|
1904 iAppUi.ActivateLocalViewL( aDefView ); |
|
1905 } |
|
1906 |
|
1907 // ----------------------------------------------------------------------------- |
|
1908 // CCalenViewManager::ChangeDayL |
|
1909 // Change day when preview pane swipped |
|
1910 // ----------------------------------------------------------------------------- |
|
1911 void CCalenViewManager::ChangeDayL( TBool aNextDay ) |
|
1912 { |
|
1913 TInt aInterval(1); |
|
1914 MCalenContext& context = iController.Services().Context(); |
|
1915 TCalTime focusedTime = context.FocusDateAndTimeL(); |
|
1916 TTime newDay(0); |
|
1917 if ( aNextDay ) |
|
1918 { |
|
1919 newDay = focusedTime.TimeLocalL() + TTimeIntervalDays( aInterval ); |
|
1920 } |
|
1921 else |
|
1922 { |
|
1923 newDay = focusedTime.TimeLocalL() - TTimeIntervalDays( aInterval ); |
|
1924 } |
|
1925 focusedTime.SetTimeLocalL( newDay ); |
|
1926 context.SetFocusDateAndTimeL( focusedTime, |
|
1927 iCurrentViewId ); |
|
1928 } |
|
1929 |
|
1930 // End of file |