37 #include "calensettingsview.h" |
37 #include "calensettingsview.h" |
38 #include "calendocloader.h" |
38 #include "calendocloader.h" |
39 #include "calendarui_debug.h" |
39 #include "calendarui_debug.h" |
40 #include "calencommon.h" |
40 #include "calencommon.h" |
41 #include "calendayview.h" |
41 #include "calendayview.h" |
42 #include "agendautil.h" |
42 #include <agendautil.h> |
43 #include "OstTraceDefinitions.h" |
43 #include "OstTraceDefinitions.h" |
44 #ifdef OST_TRACE_COMPILER_IN_USE |
44 #ifdef OST_TRACE_COMPILER_IN_USE |
45 #include "calenviewmanagerTraces.h" |
45 #include "calenviewmanagerTraces.h" |
46 #endif |
46 #endif |
47 |
47 |
73 this, SLOT(handleInstanceViewCreation(int))); |
73 this, SLOT(handleInstanceViewCreation(int))); |
74 connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)), |
74 connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)), |
75 this, SLOT(handleEntryViewCreation(int))); |
75 this, SLOT(handleEntryViewCreation(int))); |
76 connect(mController.agendaInterface(), SIGNAL(entriesChanged(QList<ulong>)), |
76 connect(mController.agendaInterface(), SIGNAL(entriesChanged(QList<ulong>)), |
77 this, SLOT(handleEntriesChanged(QList<ulong>))); |
77 this, SLOT(handleEntriesChanged(QList<ulong>))); |
|
78 connect(mController.agendaInterface(), SIGNAL(entryUpdated(ulong)), |
|
79 this, SLOT(handleEntryUpdation(ulong))); |
|
80 connect(mController.agendaInterface(), SIGNAL(entryAdded(ulong)), |
|
81 this, SLOT(handleEntryUpdation(ulong))); |
78 OstTraceFunctionExit0( CALENVIEWMANAGER_CALENVIEWMANAGER_EXIT ); |
82 OstTraceFunctionExit0( CALENVIEWMANAGER_CALENVIEWMANAGER_EXIT ); |
79 } |
83 } |
80 |
84 |
81 void CalenViewManager::SecondPhaseConstruction() |
85 void CalenViewManager::SecondPhaseConstruction() |
82 { |
86 { |
295 |
299 |
296 OstTraceFunctionExit0( CALENVIEWMANAGER_LOADAGENDAVIEW_EXIT ); |
300 OstTraceFunctionExit0( CALENVIEWMANAGER_LOADAGENDAVIEW_EXIT ); |
297 } |
301 } |
298 |
302 |
299 // ---------------------------------------------------------------------------- |
303 // ---------------------------------------------------------------------------- |
|
304 // CalenViewManager::loadDayView |
|
305 // Loads day view from the docml |
|
306 // ---------------------------------------------------------------------------- |
|
307 void CalenViewManager::loadDayView() |
|
308 { |
|
309 bool loadSuccess = false; |
|
310 |
|
311 // Create the docloader object |
|
312 CalenDocLoader *docLoader = new CalenDocLoader(mController); |
|
313 |
|
314 if (docLoader) { |
|
315 docLoader->load(CALEN_DAYVIEW_DOCML, &loadSuccess); |
|
316 if (!loadSuccess) { |
|
317 qFatal("calenviewmanager.cpp : Unable to load day view XML"); |
|
318 } |
|
319 |
|
320 // Get the CalenDayView object from the loader |
|
321 mCalenDayView = static_cast<CalenDayView *> |
|
322 (docLoader->findWidget(CALEN_DAYVIEW)); |
|
323 if (!mCalenDayView) { |
|
324 qFatal("calenviewmanager.cpp : Unable to find day view"); |
|
325 } |
|
326 |
|
327 // Set up the day view - day view takes the ownership |
|
328 mCalenDayView->setupView(docLoader); |
|
329 } |
|
330 } |
|
331 |
|
332 // ---------------------------------------------------------------------------- |
300 // CalenViewManager::handleMainViewReady |
333 // CalenViewManager::handleMainViewReady |
301 // Slot to handle viewReady() signal from mainwindow |
334 // Slot to handle viewReady() signal from mainwindow |
302 // (other items were commented in a header). |
335 // (other items were commented in a header). |
303 // ---------------------------------------------------------------------------- |
336 // ---------------------------------------------------------------------------- |
304 // |
337 // |
679 mCurrentViewId = ECalenAgendaView; |
712 mCurrentViewId = ECalenAgendaView; |
680 activateCurrentView(); |
713 activateCurrentView(); |
681 break; |
714 break; |
682 case ECalenDayView: |
715 case ECalenDayView: |
683 { |
716 { |
684 // First add new view and use QueuedConnection to assure that |
717 // First add new view |
685 // view is ready before setting it as the current view |
|
686 mController.MainWindow().addView(mCalenDayView); |
718 mController.MainWindow().addView(mCalenDayView); |
687 QMetaObject::invokeMethod(this, "handleDayViewReady", |
719 |
688 Qt::QueuedConnection); |
720 // Removes current view |
|
721 // Notice: removing view should be done after new view is set as current to |
|
722 // avoid situation that there is no current view in application |
|
723 removePreviousView(); |
|
724 |
|
725 // Sets and activates day view |
|
726 mCurrentViewId = ECalenDayView; |
|
727 activateCurrentView(); |
689 } |
728 } |
690 break; |
729 break; |
691 case ECalenEventView: |
730 case ECalenEventView: |
692 launchEventView(); |
731 launchEventView(); |
693 break; |
732 break; |
723 case ECalenNotifyEntrySaved: |
762 case ECalenNotifyEntrySaved: |
724 case ECalenNotifyEntryDeleted: |
763 case ECalenNotifyEntryDeleted: |
725 case ECalenNotifyInstanceDeleted: |
764 case ECalenNotifyInstanceDeleted: |
726 case ECalenNotifyEntryClosed: |
765 case ECalenNotifyEntryClosed: |
727 case ECalenNotifySystemLocaleChanged: |
766 case ECalenNotifySystemLocaleChanged: |
|
767 case ECalenNotifySystemTimeChanged: |
728 case ECalenNotifySystemLanguageChanged: { |
768 case ECalenNotifySystemLanguageChanged: { |
729 activateCurrentView(); |
769 |
730 if (mCalenMonthView) { |
770 if (notification == ECalenNotifySystemTimeChanged) { |
731 mCalenMonthView->captureScreenshot(); |
771 MCalenContext &context = mController.context(); |
732 } else if (mCalenAgendaView) { |
772 QDateTime defaultTime = context.defaultCalTimeForViewsL(); |
733 mCalenAgendaView->captureScreenshot(); |
773 context.setFocusDateAndTime(defaultTime); |
734 } |
774 } |
|
775 activateCurrentView(); |
|
776 if (mCalenMonthView) { |
|
777 mCalenMonthView->captureScreenshot(); |
|
778 } else if (mCalenAgendaView) { |
|
779 mCalenAgendaView->captureScreenshot(); |
|
780 } |
735 } |
781 } |
736 break; |
782 break; |
737 case ECalenNotifySettingsClosed: { |
783 case ECalenNotifySettingsClosed: { |
738 //when setting view closed , switch to the previous view |
784 //when setting view closed , switch to the previous view |
739 mCurrentViewId = mPreviousViewsId ; |
785 mCurrentViewId = mPreviousViewsId ; |
774 // (other items were commented in a header). |
820 // (other items were commented in a header). |
775 // ---------------------------------------------------------------------------- |
821 // ---------------------------------------------------------------------------- |
776 // |
822 // |
777 void CalenViewManager::handleViewingCompleted(const QDate date) |
823 void CalenViewManager::handleViewingCompleted(const QDate date) |
778 { |
824 { |
|
825 Q_UNUSED(date); |
779 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEVIEWINGCOMPLETED_ENTRY ); |
826 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEVIEWINGCOMPLETED_ENTRY ); |
780 |
827 |
781 // Cleanup. |
828 // Cleanup. |
782 mCalenEventViewer->deleteLater(); |
829 mCalenEventViewer->deleteLater(); |
|
830 if (!date.isNull() && date.isValid()) { |
|
831 mController.Services().Context().setFocusDate(QDateTime(date)); |
|
832 } |
783 mController.Services().IssueNotificationL(ECalenNotifyEntryClosed); |
833 mController.Services().IssueNotificationL(ECalenNotifyEntryClosed); |
784 |
834 |
785 // invalidate captured screenshots as either agenda view is activated now |
835 // invalidate captured screenshots as either agenda view is activated now |
786 if (mCalenMonthView) { |
836 if (mCalenMonthView) { |
787 mCalenMonthView->captureScreenshot(); |
837 mCalenMonthView->captureScreenshot(); |
880 mCalenMonthView->fetchEntriesAndUpdateModel(); |
930 mCalenMonthView->fetchEntriesAndUpdateModel(); |
881 } |
931 } |
882 else if (mCalenAgendaView) { |
932 else if (mCalenAgendaView) { |
883 mCalenAgendaView->doPopulation(); |
933 mCalenAgendaView->doPopulation(); |
884 } |
934 } |
|
935 // Calls the emitAppReady function of CalenController. Need to emit this |
|
936 // signal after the view is fully constructed & populated |
|
937 // with actual data and ready to be used. So entry view & instance view |
|
938 // needs to be created so that a new entry can also be created. Finally |
|
939 // NotesApplication object needs to emit applicationReady Signal. |
|
940 mController.emitAppReady(); |
885 |
941 |
886 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEINSTANCEVIEWCREATION_EXIT ); |
942 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEINSTANCEVIEWCREATION_EXIT ); |
887 } |
943 } |
888 |
944 |
889 // ---------------------------------------------------------------------------- |
945 // ---------------------------------------------------------------------------- |
901 |
957 |
902 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEENTRYVIEWCREATION_EXIT ); |
958 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEENTRYVIEWCREATION_EXIT ); |
903 } |
959 } |
904 |
960 |
905 // ---------------------------------------------------------------------------- |
961 // ---------------------------------------------------------------------------- |
906 // CalenViewManager::handleDayViewReady |
|
907 // Launches day view when it is added to MainWindow and ready to be displayed |
|
908 // ---------------------------------------------------------------------------- |
|
909 // |
|
910 void CalenViewManager::handleDayViewReady() |
|
911 { |
|
912 OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEDAYVIEWREADY_ENTRY ); |
|
913 |
|
914 // Removes current view |
|
915 // Notice: removing view should be done after new view is set as current to |
|
916 // avoid situation that there is no current view in application |
|
917 removePreviousView(); |
|
918 |
|
919 // Sets and activates day view |
|
920 mCurrentViewId = ECalenDayView; |
|
921 activateCurrentView(); |
|
922 OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEDAYVIEWREADY_EXIT ); |
|
923 } |
|
924 |
|
925 // ---------------------------------------------------------------------------- |
|
926 // CalenViewManager::handleEntriesChanged |
962 // CalenViewManager::handleEntriesChanged |
927 // this function will be called when someone else has changed the database |
963 // this function will be called when someone else has changed the database |
928 // ---------------------------------------------------------------------------- |
964 // ---------------------------------------------------------------------------- |
929 // |
965 // |
930 void CalenViewManager::handleEntriesChanged(QList<ulong> ids) |
966 void CalenViewManager::handleEntriesChanged(QList<ulong> ids) |
931 { |
967 { |
|
968 Q_UNUSED(ids); |
932 // Update and refresh the view. |
969 // Update and refresh the view. |
933 activateCurrentView(); |
970 activateCurrentView(); |
|
971 } |
|
972 |
|
973 // ---------------------------------------------------------------------------- |
|
974 // CalenViewManager::handleEntryUpdation |
|
975 // this function will be called when any entry is updated or added into database |
|
976 // Here we need to set the context to the entry updated or added. |
|
977 // ---------------------------------------------------------------------------- |
|
978 // |
|
979 void CalenViewManager::handleEntryUpdation(ulong id) |
|
980 { |
|
981 AgendaEntry updatedEntry = mController.agendaInterface()->fetchById(id); |
|
982 |
|
983 // Agenda entry is not null then refresh the view else close event viewer |
|
984 if (!updatedEntry.isNull()) { |
|
985 if (AgendaEntry::TypeTodo != updatedEntry.type()) { |
|
986 QDate date = updatedEntry.startTime().date(); |
|
987 if (!date.isNull() && date.isValid()) { |
|
988 mController.Services().Context().setFocusDate(QDateTime(date)); |
|
989 } |
|
990 } |
|
991 } |
|
992 |
934 } |
993 } |
935 |
994 |
936 // ---------------------------------------------------------------------------- |
995 // ---------------------------------------------------------------------------- |
937 // CalenViewManager::launchSettingsView |
996 // CalenViewManager::launchSettingsView |
938 // Launches settings view |
997 // Launches settings view |