calendarui/controller/src/calenviewmanager.cpp
changeset 50 579cc610882e
parent 49 5de72ea7a065
child 58 ef813d54df51
--- a/calendarui/controller/src/calenviewmanager.cpp	Wed Jun 23 18:11:28 2010 +0300
+++ b/calendarui/controller/src/calenviewmanager.cpp	Tue Jul 06 14:14:56 2010 +0300
@@ -17,7 +17,6 @@
 
 
 //system includes
-#include <QDebug>
 #include <hbmainwindow.h>
 #include <hbinstance.h>
 #include <hbapplication.h> // hbapplication
@@ -29,7 +28,7 @@
 #include "hb_calencommands.hrh"
 #include "calenservicesimpl.h"
 #include "calenmonthview.h"
-#include "calendayview.h"
+#include "calenagendaview.h"
 #include "calenmonthview.h"
 #include "agendaeventviewer.h"
 #include "calennotificationhandler.h"
@@ -39,6 +38,7 @@
 #include "calendocloader.h"
 #include "calendarui_debug.h"
 #include "calencommon.h"
+#include "calendayview.h"
 
 // ----------------------------------------------------------------------------
 // CalenViewManager::CalenViewManager
@@ -54,12 +54,13 @@
 	// Following block intializes member variables
 	mCalenEventViewer = NULL;
 	mMonthViewDocLoader = NULL;
-	mDayViewDocLoader = NULL;	
-	mDayViewAltDocLoader = NULL;
+	mAgendaViewDocLoader = NULL;	
+	mAgendaViewAltDocLoader = NULL;
+	mCalenAgendaView = NULL;
+	mCalenMonthView = NULL;
+	mCalenAgendaViewAlt = NULL;
+	mSettingsView = NULL;
 	mCalenDayView = NULL;
-	mCalenMonthView = NULL;
-	mCalenDayViewAlt = NULL;
-	mSettingsView = NULL;
 	
 	// Connect to instance view and entry view creation signals from agenda
 	// interface
@@ -103,9 +104,9 @@
             {
             loadMonthView(); // Load month view
             }
-        else if (ECalenDayView == viewId) // Check if Activity was stored for day view
+        else if (ECalenAgendaView == viewId) // Check if Activity was stored for agenda view
             {
-            loadDayView(); // Load day view
+        	loadAgendaView(); // Load agenda view
             }
         
         ActivateDefaultViewL(viewId);
@@ -119,10 +120,10 @@
             mController.MainWindow().addView(mCalenMonthView); // Add month view to main window
             mController.MainWindow().setCurrentView(mCalenMonthView); // Set month view as current view
             } 
-        else if (ECalenDayView == viewId) // Check if Activity was stored for day view
+        else if (ECalenAgendaView == viewId) // Check if Activity was stored for agenda view
             {
-            mController.MainWindow().addView(mCalenDayView); // Add day view to main window
-            mController.MainWindow().setCurrentView(mCalenDayView); // Set day view as current view
+            mController.MainWindow().addView(mCalenAgendaView); // Add agenda view to main window
+            mController.MainWindow().setCurrentView(mCalenAgendaView); // Set agenda view as current view
             }
         } else if (isFromServiceFrmWrk/*Hb::ActivationReasonService == activityReason*/) {
         // Dont load any views until our remote slot gets called in
@@ -161,13 +162,13 @@
 		delete mSettingsView;
 		mSettingsView = 0;
 	}
-	if (mDayViewDocLoader) {
-		delete mDayViewDocLoader;
-		mDayViewDocLoader = 0;
+	if (mAgendaViewDocLoader) {
+		delete mAgendaViewDocLoader;
+		mAgendaViewDocLoader = 0;
 	}
-	if (mDayViewAltDocLoader) {
-		delete mDayViewAltDocLoader;
-		mDayViewAltDocLoader = 0;
+	if (mAgendaViewAltDocLoader) {
+		delete mAgendaViewAltDocLoader;
+		mAgendaViewAltDocLoader = 0;
 	}
 	if (mMonthViewDocLoader) {
 		delete mMonthViewDocLoader;
@@ -200,13 +201,13 @@
 		// Add month view to mainwindow.
 		mController.MainWindow().addView(mCalenMonthView);
 		mController.MainWindow().setCurrentView(mCalenMonthView);
-	} else if (view == ECalenDayView) {
-		mFirstView = ECalenDayView;
-		loadDayView();
-		ActivateDefaultViewL(ECalenDayView);
-		// Add day view to mainwindow.
-		mController.MainWindow().addView(mCalenDayView);
-		mController.MainWindow().setCurrentView(mCalenDayView);
+	} else if (view == ECalenAgendaView) {
+		mFirstView = ECalenAgendaView;
+		loadAgendaView();
+		ActivateDefaultViewL(ECalenAgendaView);
+		// Add agenda view to mainwindow.
+		mController.MainWindow().addView(mCalenAgendaView);
+		mController.MainWindow().setCurrentView(mCalenAgendaView);
 	}
 	TRACE_EXIT_POINT;
 }
@@ -247,37 +248,38 @@
 }
 
 // ----------------------------------------------------------------------------
-// CalenViewManager::loadDayView
-// Loads the day view frm the docml
+// CalenViewManager::loadAgendaView
+// Loads the agenda view frm the docml
 // (other items were commented in a header).
 // ----------------------------------------------------------------------------
 //
-void CalenViewManager::loadDayView()
+void CalenViewManager::loadAgendaView()
 {
 	bool loadSuccess = false;
-	// Create the day view docloader object.
-	mDayViewDocLoader = new CalenDocLoader(mController);
+	// Create the agenda view docloader object.
+	mAgendaViewDocLoader = new CalenDocLoader(mController);
 	
 	// Load default section
-	mDayViewDocLoader->load(CALEN_DAYVIEW_XML_FILE, &loadSuccess);
+	mAgendaViewDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, &loadSuccess);
 	if (!loadSuccess) {
 		qFatal("calenviewmanager.cpp : Unable to load XML");
 	}
 	
-	// Get the calenday view from the loader
-	mCalenDayView = static_cast<CalenDayView *> (mDayViewDocLoader->findWidget(CALEN_DAYVIEW));
-	if (!mCalenDayView) {
-		qFatal("calenviewmanager.cpp : Unable to find day view");
+	// Get the calenagenda view from the loader
+	mCalenAgendaView = static_cast<CalenAgendaView *> (mAgendaViewDocLoader->findWidget(CALEN_AGENDAVIEW));
+	if (!mCalenAgendaView) {
+		qFatal("calenviewmanager.cpp : Unable to find agenda view");
 	}
 	
-	// Setup the day view
-	mCalenDayView->setupView(mDayViewDocLoader);
+	// Setup the agenda view
+	mCalenAgendaView->setupView(mAgendaViewDocLoader);
 	
 	// The following code is done to provide swipe support
-	// in day view. Idea is to create two views and keep
+	// in agenda view. Idea is to create two views and keep
 	// switiching between these two using view switch effects
 	// to provide an illusion of flow to the user
-	loadAlternateDayView();
+	loadAlternateAgendaView();
+	
 }
 
 // ----------------------------------------------------------------------------
@@ -296,6 +298,10 @@
 	// Construct other views
 	constructOtherViews();
 	
+    // Install the event filter for the controller once the view is ready
+    // so that system language/locale changes can be handled
+	//hbInstance->allMainWindows().first()->installEventFilter(&mController);
+	
 	// disconnect the view ready signal as we dont need it anymore
 	disconnect(&mController.MainWindow(), SIGNAL(viewReady()), 
 			   this, SLOT(handleMainViewReady()));
@@ -312,21 +318,25 @@
 	// Load all other views except mFirstView
 	
 	// NOTE: Right now, since Calendar has only two views, month view 
-	// and day view, when client launches day view, then there is no need
+	// and agenda view, when client launches agenda view, then there is no need
 	// to construct the month view as per UI REQ., but tomorrow if new views
-	// come after day view, then we need to construct those views if they are
+	// come after agenda view, then we need to construct those views if they are
 	// native views. Right now, there is a event viewer but its not a native
-	// view. Hence, if day view is launched, dont construct month view
-	if (mFirstView != ECalenDayView) // check if day view is not already loaded
+	// view. Hence, if agenda view is launched, dont construct month view
+	if (mFirstView != ECalenAgendaView) // check if agenda view is not already loaded
 		{
 		// Load all other views 
-		loadDayView();
+		loadAgendaView();
+		
+		if (!mCalenDayView) {
+			mCalenDayView = new CalenDayView(mController.Services());
+		}
 	}
-	else //day view was launched as first view
+	else //agenda view was launched as first view
 	    {
 		// No implementation yet. UI specs not clear
 		// to be commented in with some more code once UI specs is frozen
-		// for day view launching as first view after it was saved as activity
+		// for agenda view launching as first view after it was saved as activity
 		// when it was launched from month view
         // loadMonthView();
         // mCalenMonthView->doLazyLoading();
@@ -355,35 +365,35 @@
 void CalenViewManager::showNextDay()
 {
     // Set the context for the next day
-    QDateTime currentDay = mController.Services().Context().focusDateAndTimeL();
+    QDateTime currentDay = mController.Services().Context().focusDateAndTime();
     currentDay = currentDay.addDays(1);
-    mController.Services().Context().setFocusDateL(currentDay, ECalenDayView);
-    mCurrentViewId = ECalenDayView;
+    mController.Services().Context().setFocusDate(currentDay);
+    mCurrentViewId = ECalenAgendaView;
     // Check which is the currently activated view
-    if (mController.MainWindow().currentView() == mCalenDayView) {
-        mCalenDayView->disconnectAboutToQuitEvent(); // disconnect mCalenDayView to get aboutToQuit Events
-        HbEffect::add(mCalenDayView,
+    if (mController.MainWindow().currentView() == mCalenAgendaView) {
+        mCalenAgendaView->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaView to get aboutToQuit Events
+        HbEffect::add(mCalenAgendaView,
                       ":/fxml/view_hide",
                       "hide");
-        HbEffect::add(mCalenDayViewAlt,
+        HbEffect::add(mCalenAgendaViewAlt,
                       ":/fxml/view_show",
                       "show");
-        // Set the other day view as the current view
+        // Set the other agenda view as the current view
         // and animate to provide illusion of swipe
 		// It would also connect for aboutToQuit events
-        mCalenDayViewAlt->doPopulation();
-        mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseNormalAnim);
+        mCalenAgendaViewAlt->doPopulation();
+        mController.MainWindow().setCurrentView(mCalenAgendaViewAlt, true, Hb::ViewSwitchUseNormalAnim);
     } else {
-        mCalenDayViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenDayViewAlt to get aboutToQuit Events
-        HbEffect::add(mCalenDayViewAlt,
+    mCalenAgendaViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaViewAlt to get aboutToQuit Events
+        HbEffect::add(mCalenAgendaViewAlt,
                       ":/fxml/view_hide",
                       "hide");
-        HbEffect::add(mCalenDayView,
+        HbEffect::add(mCalenAgendaView,
                       ":/fxml/view_show",
                       "show");
 		// It would also connect for aboutToQuit events
-        mCalenDayView->doPopulation();
-        mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseNormalAnim);
+        mCalenAgendaView->doPopulation();
+        mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim);
     }
 }
 
@@ -394,46 +404,55 @@
 //
 void CalenViewManager::showPrevDay()
 {
-    QDateTime currentDay = mController.Services().Context().focusDateAndTimeL();
+    QDateTime currentDay = mController.Services().Context().focusDateAndTime();
     currentDay = currentDay.addDays(-1);
-    mController.Services().Context().setFocusDateL(currentDay, ECalenDayView);
-    mCurrentViewId = ECalenDayView;
-    if (mController.MainWindow().currentView() == mCalenDayView) {
-        mCalenDayView->disconnectAboutToQuitEvent(); // disconnect mCalenDayView to get aboutToQuit Events
-        HbEffect::add(mCalenDayView,
+    mController.Services().Context().setFocusDate(currentDay);
+    mCurrentViewId = ECalenAgendaView;
+    if (mController.MainWindow().currentView() == mCalenAgendaView) {
+    mCalenAgendaView->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaView to get aboutToQuit Events
+        HbEffect::add(mCalenAgendaView,
                       ":/fxml/view_hide_back",
                       "hide");
-        HbEffect::add(mCalenDayViewAlt,
+        HbEffect::add(mCalenAgendaViewAlt,
                       ":/fxml/view_show_back",
                       "show");
 		// It would also connect for aboutToQuit events
-        mCalenDayViewAlt->doPopulation();
-        mController.MainWindow().setCurrentView(mCalenDayViewAlt, true, Hb::ViewSwitchUseNormalAnim);
+        mCalenAgendaViewAlt->doPopulation();
+        mController.MainWindow().setCurrentView(mCalenAgendaViewAlt, true, Hb::ViewSwitchUseNormalAnim);
     } else {
-        mCalenDayViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenDayViewAlt to get aboutToQuit Events
-        HbEffect::add(mCalenDayViewAlt,
+    mCalenAgendaViewAlt->disconnectAboutToQuitEvent(); // disconnect mCalenAgendaViewAlt to get aboutToQuit Events
+        HbEffect::add(mCalenAgendaViewAlt,
                       ":/fxml/view_hide_back",
                       "hide");
-        HbEffect::add(mCalenDayView,
+        HbEffect::add(mCalenAgendaView,
                       ":/fxml/view_show_back",
                       "show");
 		// It would also connect for aboutToQuit events
-        mCalenDayView->doPopulation();
-        mController.MainWindow().setCurrentView(mCalenDayView, true, Hb::ViewSwitchUseNormalAnim);
+        mCalenAgendaView->doPopulation();
+        mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim);
     }
 }
 
 // ----------------------------------------------------------------------------
-// CalenViewManager::removeDayViews
-// other items were commented in a header
+// CalenViewManager::removePreviousView
+// Remove the previous view from main window
 // ----------------------------------------------------------------------------
 //
-void CalenViewManager::removeDayViews()
+void CalenViewManager::removePreviousView()
 {
-    mCalenDayView->clearListModel();
-    mCalenDayViewAlt->clearListModel();
-    mController.MainWindow().removeView(mCalenDayView);
-    mController.MainWindow().removeView(mCalenDayViewAlt);
+	if (ECalenAgendaView == mCurrentViewId) {
+		mCalenAgendaView->clearListModel();
+		mCalenAgendaViewAlt->clearListModel();
+		mController.MainWindow().removeView(mCalenAgendaView);
+		mController.MainWindow().removeView(mCalenAgendaViewAlt);
+	} else if (ECalenDayView == mCurrentViewId) {
+		mController.MainWindow().removeView(mCalenDayView);
+	} else {
+		if (ECalenMonthView == mCurrentViewId) {
+			mController.MainWindow().removeView(mCalenMonthView);
+		}
+	}
+
 }
 
 // ----------------------------------------------------------------------------
@@ -448,8 +467,8 @@
 	mCurrentViewId = defaultView;
 	if (ECalenMonthView == defaultView) {
 		mCalenMonthView->doPopulation();
-	} else if (ECalenDayView == defaultView) {
-		mCalenDayView->doPopulation();
+	} else if (ECalenAgendaView == defaultView) {
+		mCalenAgendaView->doPopulation();
 	}
 	TRACE_EXIT_POINT;
 }
@@ -477,43 +496,40 @@
 		    mCalenMonthView->doPopulation();
 		    mController.MainWindow().setCurrentView(mCalenMonthView);
 			break;
-		case ECalenDayView:
-		    if (mController.MainWindow().currentView() == mCalenDayView) {
+		case ECalenAgendaView:
+		    if (mController.MainWindow().currentView() == mCalenAgendaView) {
 		        // This happens when settings view or event viewer is opened
 		        // from the agenda view. Simply repopulate the view
-		    	if (mCalenDayView) {
-		    		// Remove month view from mainwindow.
-		    		mController.MainWindow().removeView(mCalenMonthView); // what if month view is never loaded
-					mCalenDayView->doPopulation();
-					mController.MainWindow().setCurrentView(mCalenDayView);
+		    	if (mCalenAgendaView) {
+		    		mCalenAgendaView->doPopulation();
+					mController.MainWindow().setCurrentView(mCalenAgendaView);
 		    	} 
-		    } else if (mController.MainWindow().currentView() == mCalenDayViewAlt){
+		    } else if (mController.MainWindow().currentView() == mCalenAgendaViewAlt){
 		        // This happens when settings view or event viewer is opened
 		        // from the agenda view. Simply repopulate the view
-		    	if (mCalenDayViewAlt) {
-					mCalenDayViewAlt->doPopulation();
-					mController.MainWindow().setCurrentView(mCalenDayViewAlt);
+		    	if (mCalenAgendaViewAlt) {
+		    		mCalenAgendaViewAlt->doPopulation();
+		    		mController.MainWindow().setCurrentView(mCalenAgendaViewAlt);
 		    	}
 		    } else {
-		        // This is called whenever the day view is opened from the month
-		        // view. Since the day view is not added to the mainwindow,
-		        // add the day views to mainwindow and set any one of them as 
+		        // This is called whenever the agenda view is opened from the month
+		        // view. Since the agenda view is not added to the mainwindow,
+		        // add the agenda views to mainwindow and set any one of them as 
 		        // current view
-		    	if (mCalenDayView) {
-		    		mCalenDayView->doPopulation();
-					mController.MainWindow().addView(mCalenDayView);
-					mController.MainWindow().setCurrentView(mCalenDayView);
-					mController.MainWindow().addView(mCalenDayViewAlt);
+		    	if (mCalenAgendaView) {
+		    		mCalenAgendaView->doPopulation();
+		    		mController.MainWindow().addView(mCalenAgendaView);
+		    		mController.MainWindow().setCurrentView(mCalenAgendaView);
+		    		mController.MainWindow().addView(mCalenAgendaViewAlt);
 		    	}
 		    }
 			break;
 		case ECalenShowSettings:
-		    {
 		    mSettingsView->refreshView();
-		    }
 			break;
-		case ECalenLandscapeDayView:
-			// For later implementation
+		case ECalenDayView:
+			mCalenDayView->doPopulation();
+			mController.MainWindow().setCurrentView(mCalenDayView);
 			break;
 	}
 	TRACE_EXIT_POINT;
@@ -531,15 +547,15 @@
     if (mCalenMonthView) {
     mCalenMonthView->captureScreenshot(true);
     }
-    else if (mCalenDayView) {
-    mCalenDayView->captureScreenshot(true);
+    else if (mCalenAgendaView) {
+    	mCalenAgendaView->captureScreenshot(true);
     }
 	MCalenContext& context = mController.Services().Context();
 	AgendaEntry viewEntry= mController.Services().agendaInterface()->fetchById(
 			context.instanceId().mEntryLocalUid );
 	if (viewEntry.isRepeating() 
 			&& viewEntry.type() != AgendaEntry::TypeTodo) {
-		QDateTime startDateTime = context.focusDateAndTimeL();
+		QDateTime startDateTime = context.focusDateAndTime();
 		viewEntry.setStartAndEndTime(startDateTime, 
 		                     startDateTime.addSecs(viewEntry.durationInSecs()));
 	}
@@ -562,30 +578,30 @@
 }
 
 // ----------------------------------------------------------------------------
-// CalenViewManager::loadAlternateDayView
+// CalenViewManager::loadAlternateAgendaView
 // other items were commented in a header
 // ----------------------------------------------------------------------------
 //
-void CalenViewManager::loadAlternateDayView()
+void CalenViewManager::loadAlternateAgendaView()
 {
     bool loadSuccess = false;
-    // Create the day view docloader object.
-    mDayViewAltDocLoader = new CalenDocLoader(mController);
+    // Create the agenda view docloader object.
+    mAgendaViewAltDocLoader = new CalenDocLoader(mController);
 
     // Load default section
-    mDayViewAltDocLoader->load(CALEN_DAYVIEW_XML_FILE, &loadSuccess);
+    mAgendaViewAltDocLoader->load(CALEN_AGENDAVIEW_XML_FILE, &loadSuccess);
     if (!loadSuccess) {
         qFatal("calenviewmanager.cpp : Unable to load XML");
     }
 
-    // Get the calenday view from the loader
-    mCalenDayViewAlt = static_cast<CalenDayView *> (mDayViewAltDocLoader->findWidget(CALEN_DAYVIEW));
-    if (!mCalenDayViewAlt) {
-        qFatal("calenviewmanager.cpp : Unable to find alternate day view");
+    // Get the calenagenda view from the loader
+    mCalenAgendaViewAlt = static_cast<CalenAgendaView *> (mAgendaViewAltDocLoader->findWidget(CALEN_AGENDAVIEW));
+    if (!mCalenAgendaViewAlt) {
+        qFatal("calenviewmanager.cpp : Unable to find alternate agenda view");
     }
 
-    // Setup the day view
-    mCalenDayViewAlt->setupView(mDayViewAltDocLoader);
+    // Setup the agenda view
+    mCalenAgendaViewAlt->setupView(mAgendaViewAltDocLoader);
 }
 
 // ----------------------------------------------------------------------------
@@ -601,23 +617,33 @@
 	
 	switch (command.Command()) {
 		case ECalenMonthView:
-		    removeDayViews();
-		    // Add month view to mainwindow.
+			// First remove the previous native view before 
+			// we set the mCurrentViewId with the current view
+			removePreviousView();
+			// Add month view to mainwindow.
 			mController.MainWindow().addView(mCalenMonthView);
 			mCurrentViewId = ECalenMonthView;
 			activateCurrentView();
 			break;
+		case ECalenAgendaView:
+			// First remove the previous native view before 
+			// we set the mCurrentViewId with the current view
+			removePreviousView();
+			mCurrentViewId = ECalenAgendaView;
+			activateCurrentView();
+			break;
 		case ECalenDayView:
-			mCurrentViewId = ECalenDayView;
-			activateCurrentView();
+            {
+            // First add new view and use QueuedConnection to assure that
+            // view is ready before setting it as the current view
+			mController.MainWindow().addView(mCalenDayView);
+			QMetaObject::invokeMethod(this, "handleDayViewReady", 
+			    Qt::QueuedConnection);
+			}
 			break;
 		case ECalenEventView:
 			launchEventView();
 			break;
-		case ECalenLandscapeDayView:
-			mCurrentViewId = ECalenLandscapeDayView;
-			activateCurrentView();
-			break;
 		case ECalenStartActiveStep:
 			activateCurrentView();
 			break;
@@ -662,11 +688,11 @@
 		    mCurrentViewId = mPreviousViewsId ;
 			mController.Services().IssueCommandL(ECalenStartActiveStep);
 			
-			 // invalidate captured screenshots as either day view is activated now
+			 // invalidate captured screenshots as either agenda view is activated now
 			if (mCalenMonthView) {
 			mCalenMonthView->captureScreenshot();
-			} else if (mCalenDayView) {
-			mCalenDayView->captureScreenshot();
+			} else if (mCalenAgendaView) {
+				mCalenAgendaView->captureScreenshot();
 			}
 
 		    }
@@ -696,23 +722,20 @@
 //
 void CalenViewManager::handleViewingCompleted(const QDate date)
 {
-	qDebug() <<"calendar: CalenViewManager::handleEditingCompleted -->";
 	
 	// Cleanup.
 	mCalenEventViewer->deleteLater();
 	if (!date.isNull() && date.isValid()) {
-	mController.Services().Context().setFocusDateL(QDateTime(date), 
-	                                               ECalenDayView);
+	mController.Services().Context().setFocusDate(QDateTime(date));
 	}
 	mController.Services().IssueNotificationL(ECalenNotifyEntryClosed);
 	
-	// invalidate captured screenshots as either day view is activated now
+	// invalidate captured screenshots as either agenda view is activated now
 	if (mCalenMonthView) {
 	mCalenMonthView->captureScreenshot();
-	} else if (mCalenDayView) {
-	mCalenDayView->captureScreenshot();
+	} else if (mCalenAgendaView) {
+		mCalenAgendaView->captureScreenshot();
 	}
-	qDebug() <<"calendar: CalenViewManager::handleEditingCompleted <--";
 }
 
 // ----------------------------------------------------------------------------
@@ -723,11 +746,9 @@
 //
 void CalenViewManager::handleEditingStarted()
 {
-	qDebug() <<"calendar: CalenViewManager::handleEditingStarted -->";
 	
 	mController.IssueCommandL(ECalenEditEntryFromViewer);
 	
-	qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--";
 }
 
 // ----------------------------------------------------------------------------
@@ -738,11 +759,9 @@
 //
 void CalenViewManager::handleEditingCompleted()
 {
-	qDebug() <<"calendar: CalenViewManager::handleEditingStarted -->";
 	
 	mController.Services().IssueNotificationL(ECalenNotifyEditorClosedFromViewer);
 	
-	qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--";
 }
 
 // ----------------------------------------------------------------------------
@@ -753,11 +772,9 @@
 //
 void CalenViewManager::handleDeletingStarted()
 {
-	qDebug() <<"calendar: CalenViewManager::handleEditingStarted -->";
 	
 	mController.IssueCommandL(ECalenDeleteEntryFromViewer);
 	
-	qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--";
 }
 
 // ----------------------------------------------------------------------------
@@ -768,19 +785,17 @@
 //
 void CalenViewManager::handleDeletingCompleted()
 {
-	qDebug() <<"calendar: CalenViewManager::handleEditingStarted -->";
 	
 	mController.Services().IssueNotificationL(ECalenNotifyEntryDeleted);
 
-	// invalidate captured screenshots as either month view or day view is activated now
+	// invalidate captured screenshots as either month view or agenda view is activated now
     if (mCalenMonthView) {
     mCalenMonthView->captureScreenshot();
-    } else if (mCalenDayView) {
-    mCalenDayView->captureScreenshot();
+    } else if (mCalenAgendaView) {
+    	mCalenAgendaView->captureScreenshot();
     }
 
 	
-	qDebug() <<"calendar: CalenViewManager::handleEditingStarted <--";
 }
 
 // ----------------------------------------------------------------------------
@@ -802,8 +817,8 @@
 	if (mCalenMonthView) {
 		mCalenMonthView->fetchEntriesAndUpdateModel();
 	}
-	else if (mCalenDayView) {
-	mCalenDayView->doPopulation();
+	else if (mCalenAgendaView) {
+		mCalenAgendaView->doPopulation();
 	}
 }
 
@@ -818,6 +833,24 @@
 	// Nothing Yet
 	Q_UNUSED(status);
 }
+
+// ----------------------------------------------------------------------------
+// CalenViewManager::handleDayViewReady
+// Launches day view when it is added to MainWindow and ready to be displayed
+// ----------------------------------------------------------------------------
+//
+void CalenViewManager::handleDayViewReady() 
+{
+    // 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();
+}
+
 // ----------------------------------------------------------------------------
 // CalenViewManager::launchSettingsView
 // Launches settings view
@@ -825,7 +858,7 @@
 // ----------------------------------------------------------------------------
 //
 void CalenViewManager::launchSettingsView()
-    {
+{
     mPreviousViewsId = mCurrentViewId ;  
     mCurrentViewId = ECalenShowSettings;
     mSettingsView->initializeForm();
@@ -834,9 +867,9 @@
     // capture cureent view in case app closed/quits from settings view
     if (mCalenMonthView){
     mCalenMonthView->captureScreenshot(true);
-    } else if(mCalenDayView){
-    mCalenDayView->captureScreenshot(true);
+    } else if(mCalenAgendaView){
+    	mCalenAgendaView->captureScreenshot(true);
     }
-  	}
+}
 
 // End of file	--Don't remove this.