diff -r 579cc610882e -r ef813d54df51 calendarui/controller/src/calenviewmanager.cpp --- a/calendarui/controller/src/calenviewmanager.cpp Tue Jul 06 14:14:56 2010 +0300 +++ b/calendarui/controller/src/calenviewmanager.cpp Wed Aug 18 09:47:38 2010 +0300 @@ -39,6 +39,11 @@ #include "calendarui_debug.h" #include "calencommon.h" #include "calendayview.h" +#include +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "calenviewmanagerTraces.h" +#endif // ---------------------------------------------------------------------------- // CalenViewManager::CalenViewManager @@ -49,7 +54,7 @@ CalenViewManager::CalenViewManager( CCalenController& aController) : mController(aController) { - TRACE_ENTRY_POINT; + OstTraceFunctionEntry0( CALENVIEWMANAGER_CALENVIEWMANAGER_ENTRY ); // Following block intializes member variables mCalenEventViewer = NULL; @@ -61,6 +66,7 @@ mCalenAgendaViewAlt = NULL; mSettingsView = NULL; mCalenDayView = NULL; + mInstanceViewCreated = false; // Connect to instance view and entry view creation signals from agenda // interface @@ -68,14 +74,18 @@ this, SLOT(handleInstanceViewCreation(int))); connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)), this, SLOT(handleEntryViewCreation(int))); - - TRACE_EXIT_POINT; + connect(mController.agendaInterface(), SIGNAL(entriesChanged(QList)), + this, SLOT(handleEntriesChanged(QList))); + connect(mController.agendaInterface(), SIGNAL(entryUpdated(ulong)), + this, SLOT(handleEntryUpdation(ulong))); + connect(mController.agendaInterface(), SIGNAL(entryAdded(ulong)), + this, SLOT(handleEntryUpdation(ulong))); + OstTraceFunctionExit0( CALENVIEWMANAGER_CALENVIEWMANAGER_EXIT ); } void CalenViewManager::SecondPhaseConstruction() { - - TRACE_ENTRY_POINT; + OstTraceFunctionEntry0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_ENTRY ); // Check the Application Startup reason from Activity Manager int activityReason = qobject_cast(qApp)->activateReason(); @@ -144,8 +154,8 @@ mController.MainWindow().setCurrentView(mCalenMonthView); } - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_EXIT ); } // ---------------------------------------------------------------------------- @@ -156,8 +166,8 @@ // CalenViewManager::~CalenViewManager() { - TRACE_ENTRY_POINT; - + OstTraceFunctionEntry0( DUP1_CALENVIEWMANAGER_CALENVIEWMANAGER_ENTRY ); + if (mSettingsView) { delete mSettingsView; mSettingsView = 0; @@ -174,7 +184,8 @@ delete mMonthViewDocLoader; mMonthViewDocLoader = 0; } - TRACE_EXIT_POINT; + + OstTraceFunctionExit0( DUP1_CALENVIEWMANAGER_CALENVIEWMANAGER_EXIT ); } // ---------------------------------------------------------------------------- @@ -185,8 +196,9 @@ // void CalenViewManager::constructAndActivateView(int view) { - TRACE_ENTRY_POINT; - // We are here because, some other application is launching calendar with + OstTraceFunctionEntry0( CALENVIEWMANAGER_CONSTRUCTANDACTIVATEVIEW_ENTRY ); + + // We are here because, some other application is launching calendar with // the view, hence connect to viewReady() signal to do any lazy loading // in the slot @@ -208,8 +220,9 @@ // Add agenda view to mainwindow. mController.MainWindow().addView(mCalenAgendaView); mController.MainWindow().setCurrentView(mCalenAgendaView); + mController.MainWindow().addView(mCalenAgendaViewAlt); } - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CALENVIEWMANAGER_CONSTRUCTANDACTIVATEVIEW_EXIT ); } // ---------------------------------------------------------------------------- @@ -220,6 +233,8 @@ // void CalenViewManager::loadMonthView() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_LOADMONTHVIEW_ENTRY ); + bool loadSuccess = false; Qt::Orientation currentOrienation = mController.MainWindow().orientation(); // Create the month view docloader object. @@ -245,6 +260,8 @@ // Setup the month view. mCalenMonthView->setupView(mMonthViewDocLoader); + + OstTraceFunctionExit0( CALENVIEWMANAGER_LOADMONTHVIEW_EXIT ); } // ---------------------------------------------------------------------------- @@ -255,6 +272,8 @@ // void CalenViewManager::loadAgendaView() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_LOADAGENDAVIEW_ENTRY ); + bool loadSuccess = false; // Create the agenda view docloader object. mAgendaViewDocLoader = new CalenDocLoader(mController); @@ -280,6 +299,36 @@ // to provide an illusion of flow to the user loadAlternateAgendaView(); + OstTraceFunctionExit0( CALENVIEWMANAGER_LOADAGENDAVIEW_EXIT ); +} + +// ---------------------------------------------------------------------------- +// CalenViewManager::loadDayView +// Loads day view from the docml +// ---------------------------------------------------------------------------- +void CalenViewManager::loadDayView() +{ + bool loadSuccess = false; + + // Create the docloader object + CalenDocLoader *docLoader = new CalenDocLoader(mController); + + if (docLoader) { + docLoader->load(CALEN_DAYVIEW_DOCML, &loadSuccess); + if (!loadSuccess) { + qFatal("calenviewmanager.cpp : Unable to load day view XML"); + } + + // Get the CalenDayView object from the loader + mCalenDayView = static_cast + (docLoader->findWidget(CALEN_DAYVIEW)); + if (!mCalenDayView) { + qFatal("calenviewmanager.cpp : Unable to find day view"); + } + + // Set up the day view - day view takes the ownership + mCalenDayView->setupView(docLoader); + } } // ---------------------------------------------------------------------------- @@ -290,9 +339,20 @@ // void CalenViewManager::handleMainViewReady() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEMAINVIEWREADY_ENTRY ); + // Construct the month view part that is kept for lazy loading - if (mCalenMonthView) { + if (mCalenMonthView) { mCalenMonthView->doLazyLoading(); + + if (mInstanceViewCreated) { + // populate entries for the month view if the month view is launched + // from the service APIs. Otherwise the month view is not populated with + // the entries as CalenViewManager::handleInstanceViewCreation is called + // before the month view creation so the model array is not populated. + mCalenMonthView->fetchEntriesAndUpdateModel(); + } + } // Construct other views @@ -305,6 +365,8 @@ // disconnect the view ready signal as we dont need it anymore disconnect(&mController.MainWindow(), SIGNAL(viewReady()), this, SLOT(handleMainViewReady())); + + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEMAINVIEWREADY_EXIT ); } // ---------------------------------------------------------------------------- @@ -315,6 +377,8 @@ // void CalenViewManager::constructOtherViews() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_CONSTRUCTOTHERVIEWS_ENTRY ); + // Load all other views except mFirstView // NOTE: Right now, since Calendar has only two views, month view @@ -329,7 +393,7 @@ loadAgendaView(); if (!mCalenDayView) { - mCalenDayView = new CalenDayView(mController.Services()); + loadDayView(); } } else //agenda view was launched as first view @@ -344,6 +408,8 @@ // Setup the settings view mSettingsView = new CalenSettingsView(mController.Services()); + + OstTraceFunctionExit0( CALENVIEWMANAGER_CONSTRUCTOTHERVIEWS_EXIT ); } // ---------------------------------------------------------------------------- @@ -354,6 +420,9 @@ // int CalenViewManager::getFirstView() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_GETFIRSTVIEW_ENTRY ); + + OstTraceFunctionExit0( CALENVIEWMANAGER_GETFIRSTVIEW_EXIT ); return mFirstView; } @@ -364,6 +433,8 @@ // void CalenViewManager::showNextDay() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_SHOWNEXTDAY_ENTRY ); + // Set the context for the next day QDateTime currentDay = mController.Services().Context().focusDateAndTime(); currentDay = currentDay.addDays(1); @@ -395,6 +466,7 @@ mCalenAgendaView->doPopulation(); mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim); } + OstTraceFunctionExit0( CALENVIEWMANAGER_SHOWNEXTDAY_EXIT ); } // ---------------------------------------------------------------------------- @@ -404,6 +476,8 @@ // void CalenViewManager::showPrevDay() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_SHOWPREVDAY_ENTRY ); + QDateTime currentDay = mController.Services().Context().focusDateAndTime(); currentDay = currentDay.addDays(-1); mController.Services().Context().setFocusDate(currentDay); @@ -431,6 +505,8 @@ mCalenAgendaView->doPopulation(); mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim); } + + OstTraceFunctionExit0( CALENVIEWMANAGER_SHOWPREVDAY_EXIT ); } // ---------------------------------------------------------------------------- @@ -440,6 +516,8 @@ // void CalenViewManager::removePreviousView() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_REMOVEPREVIOUSVIEW_ENTRY ); + if (ECalenAgendaView == mCurrentViewId) { mCalenAgendaView->clearListModel(); mCalenAgendaViewAlt->clearListModel(); @@ -453,6 +531,7 @@ } } + OstTraceFunctionExit0( CALENVIEWMANAGER_REMOVEPREVIOUSVIEW_EXIT ); } // ---------------------------------------------------------------------------- @@ -463,14 +542,15 @@ // void CalenViewManager::ActivateDefaultViewL(int defaultView) { - TRACE_ENTRY_POINT; + OstTraceFunctionEntry0( CALENVIEWMANAGER_ACTIVATEDEFAULTVIEWL_ENTRY ); + mCurrentViewId = defaultView; if (ECalenMonthView == defaultView) { mCalenMonthView->doPopulation(); } else if (ECalenAgendaView == defaultView) { mCalenAgendaView->doPopulation(); } - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CALENVIEWMANAGER_ACTIVATEDEFAULTVIEWL_EXIT ); } // ---------------------------------------------------------------------------- @@ -479,9 +559,11 @@ // ---------------------------------------------------------------------------- void CalenViewManager::refreshCurrentViewL() { - TRACE_ENTRY_POINT; + OstTraceFunctionEntry0( CALENVIEWMANAGER_REFRESHCURRENTVIEWL_ENTRY ); + activateCurrentView(); - TRACE_EXIT_POINT; + + OstTraceFunctionExit0( CALENVIEWMANAGER_REFRESHCURRENTVIEWL_EXIT ); } // ---------------------------------------------------------------------------- @@ -490,7 +572,8 @@ // ---------------------------------------------------------------------------- void CalenViewManager::activateCurrentView() { - TRACE_ENTRY_POINT; + OstTraceFunctionEntry0( CALENVIEWMANAGER_ACTIVATECURRENTVIEW_ENTRY ); + switch (mCurrentViewId) { case ECalenMonthView: mCalenMonthView->doPopulation(); @@ -532,7 +615,8 @@ mController.MainWindow().setCurrentView(mCalenDayView); break; } - TRACE_EXIT_POINT; + + OstTraceFunctionExit0( CALENVIEWMANAGER_ACTIVATECURRENTVIEW_EXIT ); } // ---------------------------------------------------------------------------- @@ -543,6 +627,8 @@ // void CalenViewManager::launchEventView() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_LAUNCHEVENTVIEW_ENTRY ); + // capture cureent view in case app closed/quits from AgendaEventViewer if (mCalenMonthView) { mCalenMonthView->captureScreenshot(true); @@ -575,6 +661,7 @@ // Launch agenda event viewer mCalenEventViewer->view(viewEntry, AgendaEventViewer::ActionEditDelete); + OstTraceFunctionExit0( CALENVIEWMANAGER_LAUNCHEVENTVIEW_EXIT ); } // ---------------------------------------------------------------------------- @@ -584,6 +671,8 @@ // void CalenViewManager::loadAlternateAgendaView() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_LOADALTERNATEAGENDAVIEW_ENTRY ); + bool loadSuccess = false; // Create the agenda view docloader object. mAgendaViewAltDocLoader = new CalenDocLoader(mController); @@ -602,6 +691,7 @@ // Setup the agenda view mCalenAgendaViewAlt->setupView(mAgendaViewAltDocLoader); + OstTraceFunctionExit0( CALENVIEWMANAGER_LOADALTERNATEAGENDAVIEW_EXIT ); } // ---------------------------------------------------------------------------- @@ -612,7 +702,8 @@ // TBool CalenViewManager::HandleCommandL(const TCalenCommand& command) { - TRACE_ENTRY_POINT; + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLECOMMANDL_ENTRY ); + TBool commandUsed(EFalse); switch (command.Command()) { @@ -634,11 +725,17 @@ break; case ECalenDayView: { - // First add new view and use QueuedConnection to assure that - // view is ready before setting it as the current view + // First add new view mController.MainWindow().addView(mCalenDayView); - QMetaObject::invokeMethod(this, "handleDayViewReady", - Qt::QueuedConnection); + + // Removes current view + // Notice: removing view should be done after new view is set as current to + // avoid situation that there is no current view in application + removePreviousView(); + + // Sets and activates day view + mCurrentViewId = ECalenDayView; + activateCurrentView(); } break; case ECalenEventView: @@ -654,7 +751,7 @@ showPrevDay(); break; } - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLECOMMANDL_EXIT ); return commandUsed; } @@ -667,7 +764,8 @@ void CalenViewManager::HandleNotification( const TCalenNotification notification) { - TRACE_ENTRY_POINT; + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLENOTIFICATION_ENTRY ); + switch (notification) { case ECalenNotifyExternalDatabaseChanged: case ECalenNotifyDialogClosed: @@ -677,13 +775,23 @@ case ECalenNotifyInstanceDeleted: case ECalenNotifyEntryClosed: case ECalenNotifySystemLocaleChanged: - case ECalenNotifySystemLanguageChanged: - { - activateCurrentView(); - } + case ECalenNotifySystemTimeChanged: + case ECalenNotifySystemLanguageChanged: { + + if (notification == ECalenNotifySystemTimeChanged) { + MCalenContext &context = mController.context(); + QDateTime defaultTime = context.defaultCalTimeForViewsL(); + context.setFocusDateAndTime(defaultTime); + } + activateCurrentView(); + if (mCalenMonthView) { + mCalenMonthView->captureScreenshot(); + } else if (mCalenAgendaView) { + mCalenAgendaView->captureScreenshot(); + } + } break; - case ECalenNotifySettingsClosed: - { + case ECalenNotifySettingsClosed: { //when setting view closed , switch to the previous view mCurrentViewId = mPreviousViewsId ; mController.Services().IssueCommandL(ECalenStartActiveStep); @@ -700,7 +808,7 @@ default: break; } - TRACE_EXIT_POINT; + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLENOTIFICATION_EXIT ); } // ---------------------------------------------------------------------------- @@ -711,6 +819,9 @@ // CalenSettingsView* CalenViewManager::settingsView() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_SETTINGSVIEW_ENTRY ); + + OstTraceFunctionExit0( CALENVIEWMANAGER_SETTINGSVIEW_EXIT ); return mSettingsView; } @@ -722,11 +833,13 @@ // void CalenViewManager::handleViewingCompleted(const QDate date) { + Q_UNUSED(date); + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEVIEWINGCOMPLETED_ENTRY ); // Cleanup. mCalenEventViewer->deleteLater(); if (!date.isNull() && date.isValid()) { - mController.Services().Context().setFocusDate(QDateTime(date)); + mController.Services().Context().setFocusDate(QDateTime(date)); } mController.Services().IssueNotificationL(ECalenNotifyEntryClosed); @@ -736,6 +849,7 @@ } else if (mCalenAgendaView) { mCalenAgendaView->captureScreenshot(); } + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEVIEWINGCOMPLETED_EXIT ); } // ---------------------------------------------------------------------------- @@ -746,9 +860,11 @@ // void CalenViewManager::handleEditingStarted() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEEDITINGSTARTED_ENTRY ); mController.IssueCommandL(ECalenEditEntryFromViewer); + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEEDITINGSTARTED_EXIT ); } // ---------------------------------------------------------------------------- @@ -759,9 +875,11 @@ // void CalenViewManager::handleEditingCompleted() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEEDITINGCOMPLETED_ENTRY ); mController.Services().IssueNotificationL(ECalenNotifyEditorClosedFromViewer); + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEEDITINGCOMPLETED_EXIT ); } // ---------------------------------------------------------------------------- @@ -772,9 +890,11 @@ // void CalenViewManager::handleDeletingStarted() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEDELETINGSTARTED_ENTRY ); mController.IssueCommandL(ECalenDeleteEntryFromViewer); + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEDELETINGSTARTED_EXIT ); } // ---------------------------------------------------------------------------- @@ -785,6 +905,7 @@ // void CalenViewManager::handleDeletingCompleted() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEDELETINGCOMPLETED_ENTRY ); mController.Services().IssueNotificationL(ECalenNotifyEntryDeleted); @@ -794,8 +915,8 @@ } else if (mCalenAgendaView) { mCalenAgendaView->captureScreenshot(); } - + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEDELETINGCOMPLETED_EXIT ); } // ---------------------------------------------------------------------------- @@ -806,7 +927,16 @@ // void CalenViewManager::handleInstanceViewCreation(int status) { + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEINSTANCEVIEWCREATION_ENTRY ); + Q_UNUSED(status); + + // This flag is needed if mCalenMonthView and mCalenAgendaview is not created + // and before that this slot is getting called. + // if we launch views through services then this slot is getting called + // before the view construction. + mInstanceViewCreated = true; + // handleInstanceViewCreation function is called only once. Now that the instance // view creation is successfull. Events need to be populated on screen // Ideal colution should be to call a uniform function, e.g. PopulateEvents @@ -820,6 +950,14 @@ else if (mCalenAgendaView) { mCalenAgendaView->doPopulation(); } + // Calls the emitAppReady function of CalenController. Need to emit this + // signal after the view is fully constructed & populated + // with actual data and ready to be used. So entry view & instance view + // needs to be created so that a new entry can also be created. Finally + // NotesApplication object needs to emit applicationReady Signal. + mController.emitAppReady(); + + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEINSTANCEVIEWCREATION_EXIT ); } // ---------------------------------------------------------------------------- @@ -830,25 +968,50 @@ // void CalenViewManager::handleEntryViewCreation(int status) { + OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEENTRYVIEWCREATION_ENTRY ); + // Nothing Yet Q_UNUSED(status); + + OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEENTRYVIEWCREATION_EXIT ); } // ---------------------------------------------------------------------------- -// CalenViewManager::handleDayViewReady -// Launches day view when it is added to MainWindow and ready to be displayed +// CalenViewManager::handleEntriesChanged +// this function will be called when someone else has changed the database // ---------------------------------------------------------------------------- // -void CalenViewManager::handleDayViewReady() +void CalenViewManager::handleEntriesChanged(QList ids) { - // Removes current view - // Notice: removing view should be done after new view is set as current to - // avoid situation that there is no current view in application - removePreviousView(); - - // Sets and activates day view - mCurrentViewId = ECalenDayView; - activateCurrentView(); + Q_UNUSED(ids); + HbView *currentview = mController.MainWindow().currentView(); + if((mCalenMonthView == currentview)||(mCalenDayView == currentview)|| + (mCalenAgendaView == currentview )) + { + activateCurrentView(); + } +} + +// ---------------------------------------------------------------------------- +// CalenViewManager::handleEntryUpdation +// this function will be called when any entry is updated or added into database +// Here we need to set the context to the entry updated or added. +// ---------------------------------------------------------------------------- +// +void CalenViewManager::handleEntryUpdation(ulong id) +{ + AgendaEntry updatedEntry = mController.agendaInterface()->fetchById(id); + + // Agenda entry is not null then refresh the view else close event viewer + if (!updatedEntry.isNull()) { + if (AgendaEntry::TypeTodo != updatedEntry.type()) { + QDate date = updatedEntry.startTime().date(); + if (!date.isNull() && date.isValid()) { + mController.Services().Context().setFocusDate(QDateTime(date)); + } + } + } + } // ---------------------------------------------------------------------------- @@ -859,6 +1022,8 @@ // void CalenViewManager::launchSettingsView() { + OstTraceFunctionEntry0( CALENVIEWMANAGER_LAUNCHSETTINGSVIEW_ENTRY ); + mPreviousViewsId = mCurrentViewId ; mCurrentViewId = ECalenShowSettings; mSettingsView->initializeForm(); @@ -870,6 +1035,8 @@ } else if(mCalenAgendaView){ mCalenAgendaView->captureScreenshot(true); } + + OstTraceFunctionExit0( CALENVIEWMANAGER_LAUNCHSETTINGSVIEW_EXIT ); } // End of file --Don't remove this.