41 // CalenViewManager::CalenViewManager |
44 // CalenViewManager::CalenViewManager |
42 // 2nd phase of construction. |
45 // 2nd phase of construction. |
43 // (other items were commented in a header). |
46 // (other items were commented in a header). |
44 // ---------------------------------------------------------------------------- |
47 // ---------------------------------------------------------------------------- |
45 // |
48 // |
46 CalenViewManager::CalenViewManager( CCalenController& aController, |
49 CalenViewManager::CalenViewManager( CCalenController& aController) |
47 bool isFromServiceFrmwrk) |
|
48 : mController(aController) |
50 : mController(aController) |
49 { |
51 { |
50 TRACE_ENTRY_POINT; |
52 TRACE_ENTRY_POINT; |
51 |
53 |
|
54 // Following block intializes member variables |
52 mCalenEventViewer = NULL; |
55 mCalenEventViewer = NULL; |
53 mMonthViewDocLoader = NULL; |
56 mMonthViewDocLoader = NULL; |
54 mDayViewDocLoader = NULL; |
57 mDayViewDocLoader = NULL; |
55 mDayViewAltDocLoader = NULL; |
58 mDayViewAltDocLoader = NULL; |
56 mCalenDayView = NULL; |
59 mCalenDayView = NULL; |
63 connect(mController.agendaInterface(), SIGNAL(instanceViewCreationCompleted(int)), |
66 connect(mController.agendaInterface(), SIGNAL(instanceViewCreationCompleted(int)), |
64 this, SLOT(handleInstanceViewCreation(int))); |
67 this, SLOT(handleInstanceViewCreation(int))); |
65 connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)), |
68 connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)), |
66 this, SLOT(handleEntryViewCreation(int))); |
69 this, SLOT(handleEntryViewCreation(int))); |
67 |
70 |
68 if (isFromServiceFrmwrk) { |
|
69 // Dont load any views until our remote slot gets called in |
|
70 // calenserviceprovider.cpp |
|
71 // Just have an empty mainwindow |
|
72 } else { |
|
73 // Do the normal startup |
|
74 // Load the month view and active it and add it to main window |
|
75 mFirstView = ECalenMonthView; |
|
76 loadMonthView(); |
|
77 ActivateDefaultViewL(ECalenMonthView); |
|
78 // Connect to the view ready signal so that we construct other view |
|
79 // once this view is shown |
|
80 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
81 this, SLOT(handleMainViewReady())); |
|
82 |
|
83 mController.MainWindow().addView(mCalenMonthView); |
|
84 mController.MainWindow().setCurrentView(mCalenMonthView); |
|
85 } |
|
86 |
|
87 TRACE_EXIT_POINT; |
71 TRACE_EXIT_POINT; |
|
72 } |
|
73 |
|
74 void CalenViewManager::SecondPhaseConstruction() |
|
75 { |
|
76 |
|
77 TRACE_ENTRY_POINT; |
|
78 |
|
79 // Check the Application Startup reason from Activity Manager |
|
80 int activityReason = qobject_cast<HbApplication*>(qApp)->activateReason(); |
|
81 |
|
82 // Check if calendar is launched thru XQService framework |
|
83 bool isFromServiceFrmWrk = XQServiceUtil::isService(); // Since activateReason |
|
84 //of hbapplication is not returning right value if the activity is started |
|
85 //as services so using the above line temporarily untill a fix is available in |
|
86 // hbappliacation. Need to remove this line after the fix is available for hbapplcation |
|
87 |
|
88 |
|
89 if (Hb::ActivationReasonActivity == activityReason) // Check if application is started |
|
90 // as an activity |
|
91 { |
|
92 // Application is started from an activity |
|
93 // Extract activity data |
|
94 QVariant data = qobject_cast<HbApplication*>(qApp)->activateData(); |
|
95 // Restore state from activity data |
|
96 QByteArray serializedModel = data.toByteArray(); |
|
97 QDataStream stream(&serializedModel, QIODevice::ReadOnly); |
|
98 int viewId; // int declared for debugging purpose |
|
99 stream >> viewId; // read stream into an int |
|
100 |
|
101 mFirstView = viewId; |
|
102 if (ECalenMonthView == viewId) // Check if Activity was stored for month view |
|
103 { |
|
104 loadMonthView(); // Load month view |
|
105 } |
|
106 else if (ECalenDayView == viewId) // Check if Activity was stored for day view |
|
107 { |
|
108 loadDayView(); // Load day view |
|
109 } |
|
110 |
|
111 ActivateDefaultViewL(viewId); |
|
112 // Connect to the view ready signal so that we can construct other views |
|
113 // once this view is ready |
|
114 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
115 this, SLOT(handleMainViewReady())); |
|
116 |
|
117 if (ECalenMonthView == viewId) // Check if Activity was stored for month view |
|
118 { |
|
119 mController.MainWindow().addView(mCalenMonthView); // Add month view to main window |
|
120 mController.MainWindow().setCurrentView(mCalenMonthView); // Set month view as current view |
|
121 } |
|
122 else if (ECalenDayView == viewId) // Check if Activity was stored for day view |
|
123 { |
|
124 mController.MainWindow().addView(mCalenDayView); // Add day view to main window |
|
125 mController.MainWindow().setCurrentView(mCalenDayView); // Set day view as current view |
|
126 } |
|
127 } else if (isFromServiceFrmWrk/*Hb::ActivationReasonService == activityReason*/) { |
|
128 // Dont load any views until our remote slot gets called in |
|
129 // calenserviceprovider.cpp |
|
130 // Just have an empty mainwindow |
|
131 } else { |
|
132 // Do the normal startup |
|
133 // Load the month view and active it and add it to main window |
|
134 mFirstView = ECalenMonthView; |
|
135 loadMonthView(); |
|
136 ActivateDefaultViewL(ECalenMonthView); |
|
137 // Connect to the view ready signal so that we construct other view |
|
138 // once this view is shown |
|
139 connect(&mController.MainWindow(), SIGNAL(viewReady()), |
|
140 this, SLOT(handleMainViewReady())); |
|
141 |
|
142 mController.MainWindow().addView(mCalenMonthView); |
|
143 mController.MainWindow().setCurrentView(mCalenMonthView); |
|
144 } |
|
145 |
|
146 TRACE_EXIT_POINT; |
|
147 |
88 } |
148 } |
89 |
149 |
90 // ---------------------------------------------------------------------------- |
150 // ---------------------------------------------------------------------------- |
91 // CalenViewManager::~CalenViewManager |
151 // CalenViewManager::~CalenViewManager |
92 // Destructor. |
152 // Destructor. |
255 // and day view, when client launches day view, then there is no need |
315 // and day view, when client launches day view, then there is no need |
256 // to construct the month view as per UI REQ., but tomorrow if new views |
316 // to construct the month view as per UI REQ., but tomorrow if new views |
257 // come after day view, then we need to construct those views if they are |
317 // come after day view, then we need to construct those views if they are |
258 // native views. Right now, there is a event viewer but its not a native |
318 // native views. Right now, there is a event viewer but its not a native |
259 // view. Hence, if day view is launched, dont construct month view |
319 // view. Hence, if day view is launched, dont construct month view |
260 if (mFirstView == ECalenDayView) { |
320 if (mFirstView != ECalenDayView) // check if day view is not already loaded |
261 // Construct other views as mentioned above |
321 { |
262 return; |
|
263 } else { |
|
264 // Load all other views |
322 // Load all other views |
265 loadDayView(); |
323 loadDayView(); |
266 } |
324 } |
|
325 else //day view was launched as first view |
|
326 { |
|
327 // No implementation yet. UI specs not clear |
|
328 // to be commented in with some more code once UI specs is frozen |
|
329 // for day view launching as first view after it was saved as activity |
|
330 // when it was launched from month view |
|
331 // loadMonthView(); |
|
332 // mCalenMonthView->doLazyLoading(); |
|
333 } |
267 |
334 |
268 // Setup the settings view |
335 // Setup the settings view |
269 mSettingsView = new CalenSettingsView(mController.Services()); |
336 mSettingsView = new CalenSettingsView(mController.Services()); |
270 } |
337 } |
271 |
338 |
292 currentDay = currentDay.addDays(1); |
359 currentDay = currentDay.addDays(1); |
293 mController.Services().Context().setFocusDateL(currentDay, ECalenDayView); |
360 mController.Services().Context().setFocusDateL(currentDay, ECalenDayView); |
294 mCurrentViewId = ECalenDayView; |
361 mCurrentViewId = ECalenDayView; |
295 // Check which is the currently activated view |
362 // Check which is the currently activated view |
296 if (mController.MainWindow().currentView() == mCalenDayView) { |
363 if (mController.MainWindow().currentView() == mCalenDayView) { |
|
364 mCalenDayView->disconnectAboutToQuitEvent(); // disconnect mCalenDayView to get aboutToQuit Events |
297 HbEffect::add(mCalenDayView, |
365 HbEffect::add(mCalenDayView, |
298 ":/fxml/view_hide", |
366 ":/fxml/view_hide", |
299 "hide"); |
367 "hide"); |
300 HbEffect::add(mCalenDayViewAlt, |
368 HbEffect::add(mCalenDayViewAlt, |
301 ":/fxml/view_show", |
369 ":/fxml/view_show", |
302 "show"); |
370 "show"); |
303 // Set the other day view as the current view |
371 // Set the other day view as the current view |
304 // and animate to provide illusion of swipe |
372 // and animate to provide illusion of swipe |
|
373 // It would also connect for aboutToQuit events |
305 mCalenDayViewAlt->doPopulation(); |
374 mCalenDayViewAlt->doPopulation(); |
306 mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseNormalAnim); |
375 mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseNormalAnim); |
307 } else { |
376 } else { |
|
377 mCalenDayViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenDayViewAlt to get aboutToQuit Events |
308 HbEffect::add(mCalenDayViewAlt, |
378 HbEffect::add(mCalenDayViewAlt, |
309 ":/fxml/view_hide", |
379 ":/fxml/view_hide", |
310 "hide"); |
380 "hide"); |
311 HbEffect::add(mCalenDayView, |
381 HbEffect::add(mCalenDayView, |
312 ":/fxml/view_show", |
382 ":/fxml/view_show", |
313 "show"); |
383 "show"); |
|
384 // It would also connect for aboutToQuit events |
314 mCalenDayView->doPopulation(); |
385 mCalenDayView->doPopulation(); |
315 mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseNormalAnim); |
386 mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseNormalAnim); |
316 } |
387 } |
317 } |
388 } |
318 |
389 |
326 QDateTime currentDay = mController.Services().Context().focusDateAndTimeL(); |
397 QDateTime currentDay = mController.Services().Context().focusDateAndTimeL(); |
327 currentDay = currentDay.addDays(-1); |
398 currentDay = currentDay.addDays(-1); |
328 mController.Services().Context().setFocusDateL(currentDay, ECalenDayView); |
399 mController.Services().Context().setFocusDateL(currentDay, ECalenDayView); |
329 mCurrentViewId = ECalenDayView; |
400 mCurrentViewId = ECalenDayView; |
330 if (mController.MainWindow().currentView() == mCalenDayView) { |
401 if (mController.MainWindow().currentView() == mCalenDayView) { |
|
402 mCalenDayView->disconnectAboutToQuitEvent(); // disconnect mCalenDayView to get aboutToQuit Events |
331 HbEffect::add(mCalenDayView, |
403 HbEffect::add(mCalenDayView, |
332 ":/fxml/view_hide_back", |
404 ":/fxml/view_hide_back", |
333 "hide"); |
405 "hide"); |
334 HbEffect::add(mCalenDayViewAlt, |
406 HbEffect::add(mCalenDayViewAlt, |
335 ":/fxml/view_show_back", |
407 ":/fxml/view_show_back", |
336 "show"); |
408 "show"); |
|
409 // It would also connect for aboutToQuit events |
337 mCalenDayViewAlt->doPopulation(); |
410 mCalenDayViewAlt->doPopulation(); |
338 mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseNormalAnim); |
411 mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseNormalAnim); |
339 } else { |
412 } else { |
|
413 mCalenDayViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenDayViewAlt to get aboutToQuit Events |
340 HbEffect::add(mCalenDayViewAlt, |
414 HbEffect::add(mCalenDayViewAlt, |
341 ":/fxml/view_hide_back", |
415 ":/fxml/view_hide_back", |
342 "hide"); |
416 "hide"); |
343 HbEffect::add(mCalenDayView, |
417 HbEffect::add(mCalenDayView, |
344 ":/fxml/view_show_back", |
418 ":/fxml/view_show_back", |
345 "show"); |
419 "show"); |
|
420 // It would also connect for aboutToQuit events |
346 mCalenDayView->doPopulation(); |
421 mCalenDayView->doPopulation(); |
347 mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseNormalAnim); |
422 mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseNormalAnim); |
348 } |
423 } |
349 } |
424 } |
350 |
425 |
406 if (mController.MainWindow().currentView() == mCalenDayView) { |
481 if (mController.MainWindow().currentView() == mCalenDayView) { |
407 // This happens when settings view or event viewer is opened |
482 // This happens when settings view or event viewer is opened |
408 // from the agenda view. Simply repopulate the view |
483 // from the agenda view. Simply repopulate the view |
409 if (mCalenDayView) { |
484 if (mCalenDayView) { |
410 // Remove month view from mainwindow. |
485 // Remove month view from mainwindow. |
411 mController.MainWindow().removeView(mCalenMonthView); |
486 mController.MainWindow().removeView(mCalenMonthView); // what if month view is never loaded |
412 mCalenDayView->doPopulation(); |
487 mCalenDayView->doPopulation(); |
413 mController.MainWindow().setCurrentView(mCalenDayView); |
488 mController.MainWindow().setCurrentView(mCalenDayView); |
414 } |
489 } |
415 } else if (mController.MainWindow().currentView() == mCalenDayViewAlt){ |
490 } else if (mController.MainWindow().currentView() == mCalenDayViewAlt){ |
416 // This happens when settings view or event viewer is opened |
491 // This happens when settings view or event viewer is opened |
445 // (other items were commented in a header). |
525 // (other items were commented in a header). |
446 // ---------------------------------------------------------------------------- |
526 // ---------------------------------------------------------------------------- |
447 // |
527 // |
448 void CalenViewManager::launchEventView() |
528 void CalenViewManager::launchEventView() |
449 { |
529 { |
|
530 // capture cureent view in case app closed/quits from AgendaEventViewer |
|
531 if (mCalenMonthView) { |
|
532 mCalenMonthView->captureScreenshot(true); |
|
533 } |
|
534 else if (mCalenDayView) { |
|
535 mCalenDayView->captureScreenshot(true); |
|
536 } |
450 MCalenContext& context = mController.Services().Context(); |
537 MCalenContext& context = mController.Services().Context(); |
451 AgendaEntry viewEntry= mController.Services().agendaInterface()->fetchById( |
538 AgendaEntry viewEntry= mController.Services().agendaInterface()->fetchById( |
452 context.instanceId().mEntryLocalUid ); |
539 context.instanceId().mEntryLocalUid ); |
453 if (viewEntry.isRepeating() |
540 if (viewEntry.isRepeating() |
454 && viewEntry.type() != AgendaEntry::TypeTodo) { |
541 && viewEntry.type() != AgendaEntry::TypeTodo) { |
554 void CalenViewManager::HandleNotification( |
641 void CalenViewManager::HandleNotification( |
555 const TCalenNotification notification) |
642 const TCalenNotification notification) |
556 { |
643 { |
557 TRACE_ENTRY_POINT; |
644 TRACE_ENTRY_POINT; |
558 switch (notification) { |
645 switch (notification) { |
559 case ECalenNotifySystemLocaleChanged: |
|
560 case ECalenNotifyExternalDatabaseChanged: |
646 case ECalenNotifyExternalDatabaseChanged: |
561 case ECalenNotifyDialogClosed: |
647 case ECalenNotifyDialogClosed: |
562 case ECalenNotifyMultipleEntriesDeleted: |
648 case ECalenNotifyMultipleEntriesDeleted: |
563 case ECalenNotifyEntrySaved: |
649 case ECalenNotifyEntrySaved: |
564 case ECalenNotifyEntryDeleted: |
650 case ECalenNotifyEntryDeleted: |
565 case ECalenNotifyInstanceDeleted: |
651 case ECalenNotifyInstanceDeleted: |
566 case ECalenNotifyEntryClosed: |
652 case ECalenNotifyEntryClosed: |
|
653 case ECalenNotifySystemLocaleChanged: |
|
654 case ECalenNotifySystemLanguageChanged: |
|
655 { |
|
656 activateCurrentView(); |
|
657 } |
|
658 break; |
567 case ECalenNotifySettingsClosed: |
659 case ECalenNotifySettingsClosed: |
|
660 { |
|
661 //when setting view closed , switch to the previous view |
|
662 mCurrentViewId = mPreviousViewsId ; |
568 mController.Services().IssueCommandL(ECalenStartActiveStep); |
663 mController.Services().IssueCommandL(ECalenStartActiveStep); |
|
664 |
|
665 // invalidate captured screenshots as either day view is activated now |
|
666 if (mCalenMonthView) { |
|
667 mCalenMonthView->captureScreenshot(); |
|
668 } else if (mCalenDayView) { |
|
669 mCalenDayView->captureScreenshot(); |
|
670 } |
|
671 |
|
672 } |
569 break; |
673 break; |
570 default: |
674 default: |
571 break; |
675 break; |
572 } |
676 } |
573 TRACE_EXIT_POINT; |
677 TRACE_EXIT_POINT; |
672 // ---------------------------------------------------------------------------- |
790 // ---------------------------------------------------------------------------- |
673 // |
791 // |
674 void CalenViewManager::handleInstanceViewCreation(int status) |
792 void CalenViewManager::handleInstanceViewCreation(int status) |
675 { |
793 { |
676 Q_UNUSED(status); |
794 Q_UNUSED(status); |
|
795 // handleInstanceViewCreation function is called only once. Now that the instance |
|
796 // view creation is successfull. Events need to be populated on screen |
|
797 // Ideal colution should be to call a uniform function, e.g. PopulateEvents |
|
798 // where PopulateEvents should be implemeted by all views. Since the current |
|
799 // solution for the month view implements the construction in two phases so |
|
800 // it needs to be refactored and a common solution needs to be put here. So |
|
801 // that code doesn't break if another view is added tomorow |
677 if (mCalenMonthView) { |
802 if (mCalenMonthView) { |
678 mCalenMonthView->fetchEntriesAndUpdateModel(); |
803 mCalenMonthView->fetchEntriesAndUpdateModel(); |
679 } |
804 } |
|
805 else if (mCalenDayView) { |
|
806 mCalenDayView->doPopulation(); |
|
807 } |
680 } |
808 } |
681 |
809 |
682 // ---------------------------------------------------------------------------- |
810 // ---------------------------------------------------------------------------- |
683 // CalenViewManager::handleDeletingCompleted |
811 // CalenViewManager::handleDeletingCompleted |
684 // Slot to handle completion of entry view creation |
812 // Slot to handle completion of entry view creation |
688 void CalenViewManager::handleEntryViewCreation(int status) |
816 void CalenViewManager::handleEntryViewCreation(int status) |
689 { |
817 { |
690 // Nothing Yet |
818 // Nothing Yet |
691 Q_UNUSED(status); |
819 Q_UNUSED(status); |
692 } |
820 } |
|
821 // ---------------------------------------------------------------------------- |
|
822 // CalenViewManager::launchSettingsView |
|
823 // Launches settings view |
|
824 // (other items were commented in a header). |
|
825 // ---------------------------------------------------------------------------- |
|
826 // |
|
827 void CalenViewManager::launchSettingsView() |
|
828 { |
|
829 mPreviousViewsId = mCurrentViewId ; |
|
830 mCurrentViewId = ECalenShowSettings; |
|
831 mSettingsView->initializeForm(); |
|
832 mController.Services().MainWindow().setCurrentView(mSettingsView); |
|
833 |
|
834 // capture cureent view in case app closed/quits from settings view |
|
835 if (mCalenMonthView){ |
|
836 mCalenMonthView->captureScreenshot(true); |
|
837 } else if(mCalenDayView){ |
|
838 mCalenDayView->captureScreenshot(true); |
|
839 } |
|
840 } |
|
841 |
693 // End of file --Don't remove this. |
842 // End of file --Don't remove this. |