calendarui/controller/src/calenviewmanager.cpp
changeset 58 ef813d54df51
parent 50 579cc610882e
child 68 a5a1242fd2e8
equal deleted inserted replaced
50:579cc610882e 58:ef813d54df51
    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>
       
    43 #include "OstTraceDefinitions.h"
       
    44 #ifdef OST_TRACE_COMPILER_IN_USE
       
    45 #include "calenviewmanagerTraces.h"
       
    46 #endif
    42 
    47 
    43 // ----------------------------------------------------------------------------
    48 // ----------------------------------------------------------------------------
    44 // CalenViewManager::CalenViewManager
    49 // CalenViewManager::CalenViewManager
    45 // 2nd phase of construction.
    50 // 2nd phase of construction.
    46 // (other items were commented in a header).
    51 // (other items were commented in a header).
    47 // ----------------------------------------------------------------------------
    52 // ----------------------------------------------------------------------------
    48 //
    53 //
    49 CalenViewManager::CalenViewManager( CCalenController& aController)
    54 CalenViewManager::CalenViewManager( CCalenController& aController)
    50 : mController(aController)
    55 : mController(aController)
    51 {
    56 {
    52 	TRACE_ENTRY_POINT;
    57 	OstTraceFunctionEntry0( CALENVIEWMANAGER_CALENVIEWMANAGER_ENTRY );
    53 	
    58 	
    54 	// Following block intializes member variables
    59 	// Following block intializes member variables
    55 	mCalenEventViewer = NULL;
    60 	mCalenEventViewer = NULL;
    56 	mMonthViewDocLoader = NULL;
    61 	mMonthViewDocLoader = NULL;
    57 	mAgendaViewDocLoader = NULL;	
    62 	mAgendaViewDocLoader = NULL;	
    59 	mCalenAgendaView = NULL;
    64 	mCalenAgendaView = NULL;
    60 	mCalenMonthView = NULL;
    65 	mCalenMonthView = NULL;
    61 	mCalenAgendaViewAlt = NULL;
    66 	mCalenAgendaViewAlt = NULL;
    62 	mSettingsView = NULL;
    67 	mSettingsView = NULL;
    63 	mCalenDayView = NULL;
    68 	mCalenDayView = NULL;
       
    69 	mInstanceViewCreated = false;
    64 	
    70 	
    65 	// Connect to instance view and entry view creation signals from agenda
    71 	// Connect to instance view and entry view creation signals from agenda
    66 	// interface
    72 	// interface
    67 	connect(mController.agendaInterface(), SIGNAL(instanceViewCreationCompleted(int)),
    73 	connect(mController.agendaInterface(), SIGNAL(instanceViewCreationCompleted(int)),
    68 	        this, SLOT(handleInstanceViewCreation(int)));
    74 	        this, SLOT(handleInstanceViewCreation(int)));
    69 	connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)),
    75 	connect(mController.agendaInterface(), SIGNAL(entryViewCreationCompleted(int)),
    70 		        this, SLOT(handleEntryViewCreation(int)));
    76 		        this, SLOT(handleEntryViewCreation(int)));
    71 	
    77 	connect(mController.agendaInterface(), SIGNAL(entriesChanged(QList<ulong>)),
    72 	TRACE_EXIT_POINT;
    78 								this, SLOT(handleEntriesChanged(QList<ulong>)));
       
    79     connect(mController.agendaInterface(), SIGNAL(entryUpdated(ulong)),
       
    80                                 this, SLOT(handleEntryUpdation(ulong)));
       
    81     connect(mController.agendaInterface(), SIGNAL(entryAdded(ulong)),
       
    82                                 this, SLOT(handleEntryUpdation(ulong)));
       
    83 	OstTraceFunctionExit0( CALENVIEWMANAGER_CALENVIEWMANAGER_EXIT );
    73 }
    84 }
    74 
    85 
    75 void CalenViewManager::SecondPhaseConstruction()
    86 void CalenViewManager::SecondPhaseConstruction()
    76 {
    87 {
    77 
    88     OstTraceFunctionEntry0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_ENTRY );
    78     TRACE_ENTRY_POINT;
       
    79     
    89     
    80     // Check the Application Startup reason from Activity Manager
    90     // Check the Application Startup reason from Activity Manager
    81     int activityReason = qobject_cast<HbApplication*>(qApp)->activateReason();
    91     int activityReason = qobject_cast<HbApplication*>(qApp)->activateReason();
    82     
    92     
    83     // Check if calendar is launched thru XQService framework
    93     // Check if calendar is launched thru XQService framework
   142         
   152         
   143         mController.MainWindow().addView(mCalenMonthView);
   153         mController.MainWindow().addView(mCalenMonthView);
   144         mController.MainWindow().setCurrentView(mCalenMonthView);
   154         mController.MainWindow().setCurrentView(mCalenMonthView);
   145     }
   155     }
   146     
   156     
   147     TRACE_EXIT_POINT;
   157 
   148 
   158     OstTraceFunctionExit0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_EXIT );
   149 }
   159 }
   150 
   160 
   151 // ----------------------------------------------------------------------------
   161 // ----------------------------------------------------------------------------
   152 // CalenViewManager::~CalenViewManager
   162 // CalenViewManager::~CalenViewManager
   153 // Destructor.
   163 // Destructor.
   154 // (other items were commented in a header).
   164 // (other items were commented in a header).
   155 // ----------------------------------------------------------------------------
   165 // ----------------------------------------------------------------------------
   156 //
   166 //
   157 CalenViewManager::~CalenViewManager()
   167 CalenViewManager::~CalenViewManager()
   158 {
   168 {
   159 	TRACE_ENTRY_POINT;
   169     OstTraceFunctionEntry0( DUP1_CALENVIEWMANAGER_CALENVIEWMANAGER_ENTRY );
   160 
   170     
   161 	if (mSettingsView) {
   171 	if (mSettingsView) {
   162 		delete mSettingsView;
   172 		delete mSettingsView;
   163 		mSettingsView = 0;
   173 		mSettingsView = 0;
   164 	}
   174 	}
   165 	if (mAgendaViewDocLoader) {
   175 	if (mAgendaViewDocLoader) {
   172 	}
   182 	}
   173 	if (mMonthViewDocLoader) {
   183 	if (mMonthViewDocLoader) {
   174 		delete mMonthViewDocLoader;
   184 		delete mMonthViewDocLoader;
   175 		mMonthViewDocLoader = 0;
   185 		mMonthViewDocLoader = 0;
   176 	}
   186 	}
   177 	TRACE_EXIT_POINT;
   187 	
       
   188 	OstTraceFunctionExit0( DUP1_CALENVIEWMANAGER_CALENVIEWMANAGER_EXIT );
   178 }
   189 }
   179 
   190 
   180 // ----------------------------------------------------------------------------
   191 // ----------------------------------------------------------------------------
   181 // CalenViewManager::constructAndActivateView
   192 // CalenViewManager::constructAndActivateView
   182 // Constructs and activates the requested view
   193 // Constructs and activates the requested view
   183 // (other items were commented in a header).
   194 // (other items were commented in a header).
   184 // ----------------------------------------------------------------------------
   195 // ----------------------------------------------------------------------------
   185 //
   196 //
   186 void CalenViewManager::constructAndActivateView(int view)
   197 void CalenViewManager::constructAndActivateView(int view)
   187 {
   198 {
   188 	TRACE_ENTRY_POINT;
   199 	OstTraceFunctionEntry0( CALENVIEWMANAGER_CONSTRUCTANDACTIVATEVIEW_ENTRY );
   189 	// We are here because, some other application is launching calendar with 
   200 	
       
   201     // We are here because, some other application is launching calendar with 
   190 	// the view, hence connect to viewReady() signal to do any lazy loading
   202 	// the view, hence connect to viewReady() signal to do any lazy loading
   191 	// in the slot
   203 	// in the slot
   192 	
   204 	
   193 	// Connect to the view ready signal so that we construct other view 
   205 	// Connect to the view ready signal so that we construct other view 
   194 	// once this view is shown
   206 	// once this view is shown
   206 		loadAgendaView();
   218 		loadAgendaView();
   207 		ActivateDefaultViewL(ECalenAgendaView);
   219 		ActivateDefaultViewL(ECalenAgendaView);
   208 		// Add agenda view to mainwindow.
   220 		// Add agenda view to mainwindow.
   209 		mController.MainWindow().addView(mCalenAgendaView);
   221 		mController.MainWindow().addView(mCalenAgendaView);
   210 		mController.MainWindow().setCurrentView(mCalenAgendaView);
   222 		mController.MainWindow().setCurrentView(mCalenAgendaView);
   211 	}
   223 		mController.MainWindow().addView(mCalenAgendaViewAlt);
   212 	TRACE_EXIT_POINT;
   224 	}
       
   225 	OstTraceFunctionExit0( CALENVIEWMANAGER_CONSTRUCTANDACTIVATEVIEW_EXIT );
   213 }
   226 }
   214 
   227 
   215 // ----------------------------------------------------------------------------
   228 // ----------------------------------------------------------------------------
   216 // CalenViewManager::loadMonthView
   229 // CalenViewManager::loadMonthView
   217 // Loads month view frm the docml
   230 // Loads month view frm the docml
   218 // (other items were commented in a header).
   231 // (other items were commented in a header).
   219 // ----------------------------------------------------------------------------
   232 // ----------------------------------------------------------------------------
   220 //
   233 //
   221 void CalenViewManager::loadMonthView()
   234 void CalenViewManager::loadMonthView()
   222 {
   235 {
       
   236     OstTraceFunctionEntry0( CALENVIEWMANAGER_LOADMONTHVIEW_ENTRY );
       
   237     
   223 	bool loadSuccess = false;
   238 	bool loadSuccess = false;
   224 	Qt::Orientation currentOrienation = mController.MainWindow().orientation();
   239 	Qt::Orientation currentOrienation = mController.MainWindow().orientation();
   225 	// Create the month view docloader object.
   240 	// Create the month view docloader object.
   226 	mMonthViewDocLoader = new CalenDocLoader(mController);
   241 	mMonthViewDocLoader = new CalenDocLoader(mController);
   227 	mMonthViewDocLoader->load(CALEN_MONTHVIEW_XML_FILE, &loadSuccess);
   242 	mMonthViewDocLoader->load(CALEN_MONTHVIEW_XML_FILE, &loadSuccess);
   243 	Q_ASSERT_X(mCalenMonthView, "calenviewmanager.cpp", 
   258 	Q_ASSERT_X(mCalenMonthView, "calenviewmanager.cpp", 
   244 											"Unable to load calenMonth view");
   259 											"Unable to load calenMonth view");
   245 	
   260 	
   246 	// Setup the month view.
   261 	// Setup the month view.
   247 	mCalenMonthView->setupView(mMonthViewDocLoader);
   262 	mCalenMonthView->setupView(mMonthViewDocLoader);
       
   263 	
       
   264 	OstTraceFunctionExit0( CALENVIEWMANAGER_LOADMONTHVIEW_EXIT );
   248 }
   265 }
   249 
   266 
   250 // ----------------------------------------------------------------------------
   267 // ----------------------------------------------------------------------------
   251 // CalenViewManager::loadAgendaView
   268 // CalenViewManager::loadAgendaView
   252 // Loads the agenda view frm the docml
   269 // Loads the agenda view frm the docml
   253 // (other items were commented in a header).
   270 // (other items were commented in a header).
   254 // ----------------------------------------------------------------------------
   271 // ----------------------------------------------------------------------------
   255 //
   272 //
   256 void CalenViewManager::loadAgendaView()
   273 void CalenViewManager::loadAgendaView()
   257 {
   274 {
       
   275     OstTraceFunctionEntry0( CALENVIEWMANAGER_LOADAGENDAVIEW_ENTRY );
       
   276     
   258 	bool loadSuccess = false;
   277 	bool loadSuccess = false;
   259 	// Create the agenda view docloader object.
   278 	// Create the agenda view docloader object.
   260 	mAgendaViewDocLoader = new CalenDocLoader(mController);
   279 	mAgendaViewDocLoader = new CalenDocLoader(mController);
   261 	
   280 	
   262 	// Load default section
   281 	// Load default section
   278 	// in agenda view. Idea is to create two views and keep
   297 	// in agenda view. Idea is to create two views and keep
   279 	// switiching between these two using view switch effects
   298 	// switiching between these two using view switch effects
   280 	// to provide an illusion of flow to the user
   299 	// to provide an illusion of flow to the user
   281 	loadAlternateAgendaView();
   300 	loadAlternateAgendaView();
   282 	
   301 	
       
   302 	OstTraceFunctionExit0( CALENVIEWMANAGER_LOADAGENDAVIEW_EXIT );
       
   303 }
       
   304 
       
   305 // ----------------------------------------------------------------------------
       
   306 // CalenViewManager::loadDayView
       
   307 // Loads day view from the docml
       
   308 // ----------------------------------------------------------------------------
       
   309 void CalenViewManager::loadDayView()
       
   310 {
       
   311     bool loadSuccess = false;
       
   312     
       
   313     // Create the docloader object
       
   314     CalenDocLoader *docLoader = new CalenDocLoader(mController);
       
   315     
       
   316     if (docLoader) {
       
   317         docLoader->load(CALEN_DAYVIEW_DOCML, &loadSuccess);
       
   318         if (!loadSuccess) {
       
   319             qFatal("calenviewmanager.cpp : Unable to load day view XML");
       
   320         }
       
   321         
       
   322         // Get the CalenDayView object from the loader
       
   323         mCalenDayView = static_cast<CalenDayView *>
       
   324             (docLoader->findWidget(CALEN_DAYVIEW));
       
   325         if (!mCalenDayView) {
       
   326             qFatal("calenviewmanager.cpp : Unable to find day view");
       
   327         }
       
   328         
       
   329         // Set up the day view - day view takes the ownership
       
   330         mCalenDayView->setupView(docLoader);
       
   331     }
   283 }
   332 }
   284 
   333 
   285 // ----------------------------------------------------------------------------
   334 // ----------------------------------------------------------------------------
   286 // CalenViewManager::handleMainViewReady
   335 // CalenViewManager::handleMainViewReady
   287 // Slot to handle viewReady() signal from mainwindow
   336 // Slot to handle viewReady() signal from mainwindow
   288 // (other items were commented in a header).
   337 // (other items were commented in a header).
   289 // ----------------------------------------------------------------------------
   338 // ----------------------------------------------------------------------------
   290 //
   339 //
   291 void CalenViewManager::handleMainViewReady()
   340 void CalenViewManager::handleMainViewReady()
   292 {
   341 {
       
   342     OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEMAINVIEWREADY_ENTRY );
       
   343     
   293 	// Construct the month view part that is kept for lazy loading
   344 	// Construct the month view part that is kept for lazy loading
   294 	if (mCalenMonthView) {
   345     if (mCalenMonthView) {
   295 		mCalenMonthView->doLazyLoading();
   346 		mCalenMonthView->doLazyLoading();
       
   347 
       
   348 		if (mInstanceViewCreated) {
       
   349 			// populate entries for the month view if the month view is launched 
       
   350 			// from the service APIs. Otherwise the month view is not populated with 
       
   351 			// the entries as CalenViewManager::handleInstanceViewCreation is called 
       
   352 			// before the month view creation so the model array is not populated.
       
   353 			mCalenMonthView->fetchEntriesAndUpdateModel();
       
   354 		}
       
   355 
   296 	}
   356 	}
   297 	
   357 	
   298 	// Construct other views
   358 	// Construct other views
   299 	constructOtherViews();
   359 	constructOtherViews();
   300 	
   360 	
   303 	//hbInstance->allMainWindows().first()->installEventFilter(&mController);
   363 	//hbInstance->allMainWindows().first()->installEventFilter(&mController);
   304 	
   364 	
   305 	// disconnect the view ready signal as we dont need it anymore
   365 	// disconnect the view ready signal as we dont need it anymore
   306 	disconnect(&mController.MainWindow(), SIGNAL(viewReady()), 
   366 	disconnect(&mController.MainWindow(), SIGNAL(viewReady()), 
   307 			   this, SLOT(handleMainViewReady()));
   367 			   this, SLOT(handleMainViewReady()));
       
   368 	
       
   369 	OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEMAINVIEWREADY_EXIT );
   308 }
   370 }
   309 
   371 
   310 // ----------------------------------------------------------------------------
   372 // ----------------------------------------------------------------------------
   311 // CalenViewManager::constructOtherViews
   373 // CalenViewManager::constructOtherViews
   312 // Constructs the other views apart frm firstview and adds them to main window
   374 // Constructs the other views apart frm firstview and adds them to main window
   313 // (other items were commented in a header).
   375 // (other items were commented in a header).
   314 // ----------------------------------------------------------------------------
   376 // ----------------------------------------------------------------------------
   315 //
   377 //
   316 void CalenViewManager::constructOtherViews()
   378 void CalenViewManager::constructOtherViews()
   317 {
   379 {
       
   380     OstTraceFunctionEntry0( CALENVIEWMANAGER_CONSTRUCTOTHERVIEWS_ENTRY );
       
   381     
   318 	// Load all other views except mFirstView
   382 	// Load all other views except mFirstView
   319 	
   383 	
   320 	// NOTE: Right now, since Calendar has only two views, month view 
   384 	// NOTE: Right now, since Calendar has only two views, month view 
   321 	// and agenda view, when client launches agenda view, then there is no need
   385 	// and agenda view, when client launches agenda view, then there is no need
   322 	// to construct the month view as per UI REQ., but tomorrow if new views
   386 	// to construct the month view as per UI REQ., but tomorrow if new views
   327 		{
   391 		{
   328 		// Load all other views 
   392 		// Load all other views 
   329 		loadAgendaView();
   393 		loadAgendaView();
   330 		
   394 		
   331 		if (!mCalenDayView) {
   395 		if (!mCalenDayView) {
   332 			mCalenDayView = new CalenDayView(mController.Services());
   396 		    loadDayView();
   333 		}
   397 		}
   334 	}
   398 	}
   335 	else //agenda view was launched as first view
   399 	else //agenda view was launched as first view
   336 	    {
   400 	    {
   337 		// No implementation yet. UI specs not clear
   401 		// No implementation yet. UI specs not clear
   342         // mCalenMonthView->doLazyLoading();
   406         // mCalenMonthView->doLazyLoading();
   343 	    }
   407 	    }
   344 
   408 
   345 	// Setup the settings view
   409 	// Setup the settings view
   346 	mSettingsView = new CalenSettingsView(mController.Services());
   410 	mSettingsView = new CalenSettingsView(mController.Services());
       
   411 	
       
   412 	OstTraceFunctionExit0( CALENVIEWMANAGER_CONSTRUCTOTHERVIEWS_EXIT );
   347 }
   413 }
   348 
   414 
   349 // ----------------------------------------------------------------------------
   415 // ----------------------------------------------------------------------------
   350 // CalenViewManager::getFirstView
   416 // CalenViewManager::getFirstView
   351 // Returns the first view
   417 // Returns the first view
   352 // (other items were commented in a header).
   418 // (other items were commented in a header).
   353 // ----------------------------------------------------------------------------
   419 // ----------------------------------------------------------------------------
   354 //
   420 //
   355 int CalenViewManager::getFirstView()
   421 int CalenViewManager::getFirstView()
   356 {
   422 {
       
   423     OstTraceFunctionEntry0( CALENVIEWMANAGER_GETFIRSTVIEW_ENTRY );
       
   424     
       
   425 	OstTraceFunctionExit0( CALENVIEWMANAGER_GETFIRSTVIEW_EXIT );
   357 	return mFirstView;
   426 	return mFirstView;
   358 }
   427 }
   359 
   428 
   360 // ----------------------------------------------------------------------------
   429 // ----------------------------------------------------------------------------
   361 // CalenViewManager::showNextDay
   430 // CalenViewManager::showNextDay
   362 // other items were commented in a header
   431 // other items were commented in a header
   363 // ----------------------------------------------------------------------------
   432 // ----------------------------------------------------------------------------
   364 //
   433 //
   365 void CalenViewManager::showNextDay()
   434 void CalenViewManager::showNextDay()
   366 {
   435 {
       
   436     OstTraceFunctionEntry0( CALENVIEWMANAGER_SHOWNEXTDAY_ENTRY );
       
   437     
   367     // Set the context for the next day
   438     // Set the context for the next day
   368     QDateTime currentDay = mController.Services().Context().focusDateAndTime();
   439     QDateTime currentDay = mController.Services().Context().focusDateAndTime();
   369     currentDay = currentDay.addDays(1);
   440     currentDay = currentDay.addDays(1);
   370     mController.Services().Context().setFocusDate(currentDay);
   441     mController.Services().Context().setFocusDate(currentDay);
   371     mCurrentViewId = ECalenAgendaView;
   442     mCurrentViewId = ECalenAgendaView;
   393                       "show");
   464                       "show");
   394 		// It would also connect for aboutToQuit events
   465 		// It would also connect for aboutToQuit events
   395         mCalenAgendaView->doPopulation();
   466         mCalenAgendaView->doPopulation();
   396         mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim);
   467         mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim);
   397     }
   468     }
       
   469     OstTraceFunctionExit0( CALENVIEWMANAGER_SHOWNEXTDAY_EXIT );
   398 }
   470 }
   399 
   471 
   400 // ----------------------------------------------------------------------------
   472 // ----------------------------------------------------------------------------
   401 // CalenViewManager::showPrevDay
   473 // CalenViewManager::showPrevDay
   402 // other items were commented in a header
   474 // other items were commented in a header
   403 // ----------------------------------------------------------------------------
   475 // ----------------------------------------------------------------------------
   404 //
   476 //
   405 void CalenViewManager::showPrevDay()
   477 void CalenViewManager::showPrevDay()
   406 {
   478 {
       
   479     OstTraceFunctionEntry0( CALENVIEWMANAGER_SHOWPREVDAY_ENTRY );
       
   480     
   407     QDateTime currentDay = mController.Services().Context().focusDateAndTime();
   481     QDateTime currentDay = mController.Services().Context().focusDateAndTime();
   408     currentDay = currentDay.addDays(-1);
   482     currentDay = currentDay.addDays(-1);
   409     mController.Services().Context().setFocusDate(currentDay);
   483     mController.Services().Context().setFocusDate(currentDay);
   410     mCurrentViewId = ECalenAgendaView;
   484     mCurrentViewId = ECalenAgendaView;
   411     if (mController.MainWindow().currentView() == mCalenAgendaView) {
   485     if (mController.MainWindow().currentView() == mCalenAgendaView) {
   429                       "show");
   503                       "show");
   430 		// It would also connect for aboutToQuit events
   504 		// It would also connect for aboutToQuit events
   431         mCalenAgendaView->doPopulation();
   505         mCalenAgendaView->doPopulation();
   432         mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim);
   506         mController.MainWindow().setCurrentView(mCalenAgendaView, true, Hb::ViewSwitchUseNormalAnim);
   433     }
   507     }
       
   508     
       
   509     OstTraceFunctionExit0( CALENVIEWMANAGER_SHOWPREVDAY_EXIT );
   434 }
   510 }
   435 
   511 
   436 // ----------------------------------------------------------------------------
   512 // ----------------------------------------------------------------------------
   437 // CalenViewManager::removePreviousView
   513 // CalenViewManager::removePreviousView
   438 // Remove the previous view from main window
   514 // Remove the previous view from main window
   439 // ----------------------------------------------------------------------------
   515 // ----------------------------------------------------------------------------
   440 //
   516 //
   441 void CalenViewManager::removePreviousView()
   517 void CalenViewManager::removePreviousView()
   442 {
   518 {
       
   519     OstTraceFunctionEntry0( CALENVIEWMANAGER_REMOVEPREVIOUSVIEW_ENTRY );
       
   520     
   443 	if (ECalenAgendaView == mCurrentViewId) {
   521 	if (ECalenAgendaView == mCurrentViewId) {
   444 		mCalenAgendaView->clearListModel();
   522 		mCalenAgendaView->clearListModel();
   445 		mCalenAgendaViewAlt->clearListModel();
   523 		mCalenAgendaViewAlt->clearListModel();
   446 		mController.MainWindow().removeView(mCalenAgendaView);
   524 		mController.MainWindow().removeView(mCalenAgendaView);
   447 		mController.MainWindow().removeView(mCalenAgendaViewAlt);
   525 		mController.MainWindow().removeView(mCalenAgendaViewAlt);
   451 		if (ECalenMonthView == mCurrentViewId) {
   529 		if (ECalenMonthView == mCurrentViewId) {
   452 			mController.MainWindow().removeView(mCalenMonthView);
   530 			mController.MainWindow().removeView(mCalenMonthView);
   453 		}
   531 		}
   454 	}
   532 	}
   455 
   533 
       
   534 	OstTraceFunctionExit0( CALENVIEWMANAGER_REMOVEPREVIOUSVIEW_EXIT );
   456 }
   535 }
   457 
   536 
   458 // ----------------------------------------------------------------------------
   537 // ----------------------------------------------------------------------------
   459 // CalenViewManager::~ActivateDefaultViewL
   538 // CalenViewManager::~ActivateDefaultViewL
   460 //  Activates the default view, as retrieved from settings.
   539 //  Activates the default view, as retrieved from settings.
   461 // (other items were commented in a header).
   540 // (other items were commented in a header).
   462 // ----------------------------------------------------------------------------
   541 // ----------------------------------------------------------------------------
   463 //
   542 //
   464 void CalenViewManager::ActivateDefaultViewL(int defaultView)
   543 void CalenViewManager::ActivateDefaultViewL(int defaultView)
   465 {
   544 {
   466 	TRACE_ENTRY_POINT;
   545     OstTraceFunctionEntry0( CALENVIEWMANAGER_ACTIVATEDEFAULTVIEWL_ENTRY );
       
   546     
   467 	mCurrentViewId = defaultView;
   547 	mCurrentViewId = defaultView;
   468 	if (ECalenMonthView == defaultView) {
   548 	if (ECalenMonthView == defaultView) {
   469 		mCalenMonthView->doPopulation();
   549 		mCalenMonthView->doPopulation();
   470 	} else if (ECalenAgendaView == defaultView) {
   550 	} else if (ECalenAgendaView == defaultView) {
   471 		mCalenAgendaView->doPopulation();
   551 		mCalenAgendaView->doPopulation();
   472 	}
   552 	}
   473 	TRACE_EXIT_POINT;
   553 	OstTraceFunctionExit0( CALENVIEWMANAGER_ACTIVATEDEFAULTVIEWL_EXIT );
   474 }
   554 }
   475 
   555 
   476 // ----------------------------------------------------------------------------
   556 // ----------------------------------------------------------------------------
   477 // Refresh current view.
   557 // Refresh current view.
   478 // (other items were commented in a header).
   558 // (other items were commented in a header).
   479 // ----------------------------------------------------------------------------
   559 // ----------------------------------------------------------------------------
   480 void CalenViewManager::refreshCurrentViewL()
   560 void CalenViewManager::refreshCurrentViewL()
   481 {
   561 {
   482 	TRACE_ENTRY_POINT;
   562     OstTraceFunctionEntry0( CALENVIEWMANAGER_REFRESHCURRENTVIEWL_ENTRY );
       
   563     
   483 	activateCurrentView();
   564 	activateCurrentView();
   484 	TRACE_EXIT_POINT;
   565 	
       
   566 	OstTraceFunctionExit0( CALENVIEWMANAGER_REFRESHCURRENTVIEWL_EXIT );
   485 }
   567 }
   486 
   568 
   487 // ----------------------------------------------------------------------------
   569 // ----------------------------------------------------------------------------
   488 // Activate current view.
   570 // Activate current view.
   489 // (other items were commented in a header).
   571 // (other items were commented in a header).
   490 // ----------------------------------------------------------------------------
   572 // ----------------------------------------------------------------------------
   491 void CalenViewManager::activateCurrentView()
   573 void CalenViewManager::activateCurrentView()
   492 {
   574 {
   493 	TRACE_ENTRY_POINT;
   575     OstTraceFunctionEntry0( CALENVIEWMANAGER_ACTIVATECURRENTVIEW_ENTRY );
       
   576     
   494 	switch (mCurrentViewId) {
   577 	switch (mCurrentViewId) {
   495 		case ECalenMonthView:
   578 		case ECalenMonthView:
   496 		    mCalenMonthView->doPopulation();
   579 		    mCalenMonthView->doPopulation();
   497 		    mController.MainWindow().setCurrentView(mCalenMonthView);
   580 		    mController.MainWindow().setCurrentView(mCalenMonthView);
   498 			break;
   581 			break;
   530 		case ECalenDayView:
   613 		case ECalenDayView:
   531 			mCalenDayView->doPopulation();
   614 			mCalenDayView->doPopulation();
   532 			mController.MainWindow().setCurrentView(mCalenDayView);
   615 			mController.MainWindow().setCurrentView(mCalenDayView);
   533 			break;
   616 			break;
   534 	}
   617 	}
   535 	TRACE_EXIT_POINT;
   618 	
       
   619 	OstTraceFunctionExit0( CALENVIEWMANAGER_ACTIVATECURRENTVIEW_EXIT );
   536 }
   620 }
   537 
   621 
   538 // ----------------------------------------------------------------------------
   622 // ----------------------------------------------------------------------------
   539 // CalenViewManager::launchEventView
   623 // CalenViewManager::launchEventView
   540 // Launch event view.
   624 // Launch event view.
   541 // (other items were commented in a header).
   625 // (other items were commented in a header).
   542 // ----------------------------------------------------------------------------
   626 // ----------------------------------------------------------------------------
   543 //
   627 //
   544 void CalenViewManager::launchEventView()
   628 void CalenViewManager::launchEventView()
   545 {
   629 {
       
   630     OstTraceFunctionEntry0( CALENVIEWMANAGER_LAUNCHEVENTVIEW_ENTRY );
       
   631     
   546     // capture cureent view in case app closed/quits from AgendaEventViewer
   632     // capture cureent view in case app closed/quits from AgendaEventViewer
   547     if (mCalenMonthView) {
   633     if (mCalenMonthView) {
   548     mCalenMonthView->captureScreenshot(true);
   634     mCalenMonthView->captureScreenshot(true);
   549     }
   635     }
   550     else if (mCalenAgendaView) {
   636     else if (mCalenAgendaView) {
   573 			        this, SLOT(handleDeletingCompleted()));
   659 			        this, SLOT(handleDeletingCompleted()));
   574 
   660 
   575 
   661 
   576 	// Launch agenda event viewer
   662 	// Launch agenda event viewer
   577 	mCalenEventViewer->view(viewEntry, AgendaEventViewer::ActionEditDelete);
   663 	mCalenEventViewer->view(viewEntry, AgendaEventViewer::ActionEditDelete);
       
   664 	OstTraceFunctionExit0( CALENVIEWMANAGER_LAUNCHEVENTVIEW_EXIT );
   578 }
   665 }
   579 
   666 
   580 // ----------------------------------------------------------------------------
   667 // ----------------------------------------------------------------------------
   581 // CalenViewManager::loadAlternateAgendaView
   668 // CalenViewManager::loadAlternateAgendaView
   582 // other items were commented in a header
   669 // other items were commented in a header
   583 // ----------------------------------------------------------------------------
   670 // ----------------------------------------------------------------------------
   584 //
   671 //
   585 void CalenViewManager::loadAlternateAgendaView()
   672 void CalenViewManager::loadAlternateAgendaView()
   586 {
   673 {
       
   674     OstTraceFunctionEntry0( CALENVIEWMANAGER_LOADALTERNATEAGENDAVIEW_ENTRY );
       
   675     
   587     bool loadSuccess = false;
   676     bool loadSuccess = false;
   588     // Create the agenda view docloader object.
   677     // Create the agenda view docloader object.
   589     mAgendaViewAltDocLoader = new CalenDocLoader(mController);
   678     mAgendaViewAltDocLoader = new CalenDocLoader(mController);
   590 
   679 
   591     // Load default section
   680     // Load default section
   600         qFatal("calenviewmanager.cpp : Unable to find alternate agenda view");
   689         qFatal("calenviewmanager.cpp : Unable to find alternate agenda view");
   601     }
   690     }
   602 
   691 
   603     // Setup the agenda view
   692     // Setup the agenda view
   604     mCalenAgendaViewAlt->setupView(mAgendaViewAltDocLoader);
   693     mCalenAgendaViewAlt->setupView(mAgendaViewAltDocLoader);
       
   694     OstTraceFunctionExit0( CALENVIEWMANAGER_LOADALTERNATEAGENDAVIEW_EXIT );
   605 }
   695 }
   606 
   696 
   607 // ----------------------------------------------------------------------------
   697 // ----------------------------------------------------------------------------
   608 // CalenViewManager::HandleCommandL
   698 // CalenViewManager::HandleCommandL
   609 // Handles view manager commands.
   699 // Handles view manager commands.
   610 // @return ETrue if command is handled, EFalse otherwise
   700 // @return ETrue if command is handled, EFalse otherwise
   611 // ----------------------------------------------------------------------------
   701 // ----------------------------------------------------------------------------
   612 //
   702 //
   613 TBool CalenViewManager::HandleCommandL(const TCalenCommand& command)
   703 TBool CalenViewManager::HandleCommandL(const TCalenCommand& command)
   614 {
   704 {
   615 	TRACE_ENTRY_POINT;
   705     OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLECOMMANDL_ENTRY );
       
   706     
   616 	TBool commandUsed(EFalse);
   707 	TBool commandUsed(EFalse);
   617 	
   708 	
   618 	switch (command.Command()) {
   709 	switch (command.Command()) {
   619 		case ECalenMonthView:
   710 		case ECalenMonthView:
   620 			// First remove the previous native view before 
   711 			// First remove the previous native view before 
   632 			mCurrentViewId = ECalenAgendaView;
   723 			mCurrentViewId = ECalenAgendaView;
   633 			activateCurrentView();
   724 			activateCurrentView();
   634 			break;
   725 			break;
   635 		case ECalenDayView:
   726 		case ECalenDayView:
   636             {
   727             {
   637             // First add new view and use QueuedConnection to assure that
   728             // First add new view
   638             // view is ready before setting it as the current view
       
   639 			mController.MainWindow().addView(mCalenDayView);
   729 			mController.MainWindow().addView(mCalenDayView);
   640 			QMetaObject::invokeMethod(this, "handleDayViewReady", 
   730 			
   641 			    Qt::QueuedConnection);
   731 			// Removes current view
       
   732 		    // Notice: removing view should be done after new view is set as current to
       
   733 		    // avoid situation that there is no current view in application
       
   734 		    removePreviousView();
       
   735     
       
   736 		    // Sets and activates day view
       
   737 		    mCurrentViewId = ECalenDayView;
       
   738 		    activateCurrentView();
   642 			}
   739 			}
   643 			break;
   740 			break;
   644 		case ECalenEventView:
   741 		case ECalenEventView:
   645 			launchEventView();
   742 			launchEventView();
   646 			break;
   743 			break;
   652 		    break;
   749 		    break;
   653 		case ECalenShowPrevDay:
   750 		case ECalenShowPrevDay:
   654             showPrevDay();
   751             showPrevDay();
   655 		    break;
   752 		    break;
   656 	}
   753 	}
   657 	TRACE_EXIT_POINT;
   754 	OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLECOMMANDL_EXIT );
   658 	return commandUsed;
   755 	return commandUsed;
   659 }
   756 }
   660 
   757 
   661 // ----------------------------------------------------------------------------
   758 // ----------------------------------------------------------------------------
   662 // CalenViewManager::HandleNotification
   759 // CalenViewManager::HandleNotification
   665 // ----------------------------------------------------------------------------
   762 // ----------------------------------------------------------------------------
   666 //
   763 //
   667 void CalenViewManager::HandleNotification(
   764 void CalenViewManager::HandleNotification(
   668                                          const TCalenNotification notification)
   765                                          const TCalenNotification notification)
   669 {
   766 {
   670 	TRACE_ENTRY_POINT;
   767     OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLENOTIFICATION_ENTRY );
       
   768     
   671 	switch (notification) {
   769 	switch (notification) {
   672 		case ECalenNotifyExternalDatabaseChanged:
   770 		case ECalenNotifyExternalDatabaseChanged:
   673 		case ECalenNotifyDialogClosed:
   771 		case ECalenNotifyDialogClosed:
   674 		case ECalenNotifyMultipleEntriesDeleted:
   772 		case ECalenNotifyMultipleEntriesDeleted:
   675 		case ECalenNotifyEntrySaved:
   773 		case ECalenNotifyEntrySaved:
   676 		case ECalenNotifyEntryDeleted:
   774 		case ECalenNotifyEntryDeleted:
   677 		case ECalenNotifyInstanceDeleted:
   775 		case ECalenNotifyInstanceDeleted:
   678 		case ECalenNotifyEntryClosed:
   776 		case ECalenNotifyEntryClosed:
   679 		case ECalenNotifySystemLocaleChanged:
   777 		case ECalenNotifySystemLocaleChanged:
   680 		case ECalenNotifySystemLanguageChanged:
   778 		case ECalenNotifySystemTimeChanged:
   681 		    {
   779 		case ECalenNotifySystemLanguageChanged: {
   682 		    activateCurrentView(); 
   780 
   683 		    }
   781 			if (notification == ECalenNotifySystemTimeChanged) {
       
   782 				MCalenContext &context = mController.context();
       
   783 				QDateTime defaultTime = context.defaultCalTimeForViewsL();
       
   784 				context.setFocusDateAndTime(defaultTime);
       
   785 			}
       
   786 			activateCurrentView();
       
   787 			if (mCalenMonthView) {
       
   788 				mCalenMonthView->captureScreenshot();
       
   789 			} else if (mCalenAgendaView) {
       
   790 				mCalenAgendaView->captureScreenshot();
       
   791 			}
       
   792 		}
   684 		    break;
   793 		    break;
   685 		case ECalenNotifySettingsClosed:
   794 		case ECalenNotifySettingsClosed: {
   686 		    {
       
   687 		    //when setting view closed , switch to the previous view
   795 		    //when setting view closed , switch to the previous view
   688 		    mCurrentViewId = mPreviousViewsId ;
   796 		    mCurrentViewId = mPreviousViewsId ;
   689 			mController.Services().IssueCommandL(ECalenStartActiveStep);
   797 			mController.Services().IssueCommandL(ECalenStartActiveStep);
   690 			
   798 			
   691 			 // invalidate captured screenshots as either agenda view is activated now
   799 			 // invalidate captured screenshots as either agenda view is activated now
   698 		    }
   806 		    }
   699 			break;
   807 			break;
   700 		default:
   808 		default:
   701 			break;
   809 			break;
   702 	}
   810 	}
   703 	TRACE_EXIT_POINT;
   811 	OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLENOTIFICATION_EXIT );
   704 }
   812 }
   705 
   813 
   706 // ----------------------------------------------------------------------------
   814 // ----------------------------------------------------------------------------
   707 // CalenViewManager::settingsView
   815 // CalenViewManager::settingsView
   708 //  Returns the settings view
   816 //  Returns the settings view
   709 // (other items were commented in a header).
   817 // (other items were commented in a header).
   710 // ----------------------------------------------------------------------------
   818 // ----------------------------------------------------------------------------
   711 //
   819 //
   712 CalenSettingsView* CalenViewManager::settingsView()
   820 CalenSettingsView* CalenViewManager::settingsView()
   713 {
   821 {
       
   822     OstTraceFunctionEntry0( CALENVIEWMANAGER_SETTINGSVIEW_ENTRY );
       
   823     
       
   824 	OstTraceFunctionExit0( CALENVIEWMANAGER_SETTINGSVIEW_EXIT );
   714 	return mSettingsView;
   825 	return mSettingsView;
   715 }
   826 }
   716 
   827 
   717 // ----------------------------------------------------------------------------
   828 // ----------------------------------------------------------------------------
   718 // CalenViewManager::handleViewingCompleted
   829 // CalenViewManager::handleViewingCompleted
   720 // (other items were commented in a header).
   831 // (other items were commented in a header).
   721 // ----------------------------------------------------------------------------
   832 // ----------------------------------------------------------------------------
   722 //
   833 //
   723 void CalenViewManager::handleViewingCompleted(const QDate date)
   834 void CalenViewManager::handleViewingCompleted(const QDate date)
   724 {
   835 {
       
   836 	Q_UNUSED(date);
       
   837 	OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEVIEWINGCOMPLETED_ENTRY );
   725 	
   838 	
   726 	// Cleanup.
   839 	// Cleanup.
   727 	mCalenEventViewer->deleteLater();
   840 	mCalenEventViewer->deleteLater();
   728 	if (!date.isNull() && date.isValid()) {
   841 	if (!date.isNull() && date.isValid()) {
   729 	mController.Services().Context().setFocusDate(QDateTime(date));
   842 	    mController.Services().Context().setFocusDate(QDateTime(date));
   730 	}
   843 	}
   731 	mController.Services().IssueNotificationL(ECalenNotifyEntryClosed);
   844 	mController.Services().IssueNotificationL(ECalenNotifyEntryClosed);
   732 	
   845 	
   733 	// invalidate captured screenshots as either agenda view is activated now
   846 	// invalidate captured screenshots as either agenda view is activated now
   734 	if (mCalenMonthView) {
   847 	if (mCalenMonthView) {
   735 	mCalenMonthView->captureScreenshot();
   848 	mCalenMonthView->captureScreenshot();
   736 	} else if (mCalenAgendaView) {
   849 	} else if (mCalenAgendaView) {
   737 		mCalenAgendaView->captureScreenshot();
   850 		mCalenAgendaView->captureScreenshot();
   738 	}
   851 	}
       
   852 	OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEVIEWINGCOMPLETED_EXIT );
   739 }
   853 }
   740 
   854 
   741 // ----------------------------------------------------------------------------
   855 // ----------------------------------------------------------------------------
   742 // CalenViewManager::handleEditingStarted
   856 // CalenViewManager::handleEditingStarted
   743 //  Slot to handle signal editingStarted by the agenda event viewer
   857 //  Slot to handle signal editingStarted by the agenda event viewer
   744 // (other items were commented in a header).
   858 // (other items were commented in a header).
   745 // ----------------------------------------------------------------------------
   859 // ----------------------------------------------------------------------------
   746 //
   860 //
   747 void CalenViewManager::handleEditingStarted()
   861 void CalenViewManager::handleEditingStarted()
   748 {
   862 {
       
   863 	OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEEDITINGSTARTED_ENTRY );
   749 	
   864 	
   750 	mController.IssueCommandL(ECalenEditEntryFromViewer);
   865 	mController.IssueCommandL(ECalenEditEntryFromViewer);
   751 	
   866 	
       
   867 	OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEEDITINGSTARTED_EXIT );
   752 }
   868 }
   753 
   869 
   754 // ----------------------------------------------------------------------------
   870 // ----------------------------------------------------------------------------
   755 // CalenViewManager::handleEditingCompleted
   871 // CalenViewManager::handleEditingCompleted
   756 //  Slot to handle signal editingCompleted by the agenda event viewer
   872 //  Slot to handle signal editingCompleted by the agenda event viewer
   757 // (other items were commented in a header).
   873 // (other items were commented in a header).
   758 // ----------------------------------------------------------------------------
   874 // ----------------------------------------------------------------------------
   759 //
   875 //
   760 void CalenViewManager::handleEditingCompleted()
   876 void CalenViewManager::handleEditingCompleted()
   761 {
   877 {
       
   878 	OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEEDITINGCOMPLETED_ENTRY );
   762 	
   879 	
   763 	mController.Services().IssueNotificationL(ECalenNotifyEditorClosedFromViewer);
   880 	mController.Services().IssueNotificationL(ECalenNotifyEditorClosedFromViewer);
   764 	
   881 	
       
   882 	OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEEDITINGCOMPLETED_EXIT );
   765 }
   883 }
   766 
   884 
   767 // ----------------------------------------------------------------------------
   885 // ----------------------------------------------------------------------------
   768 // CalenViewManager::handleDeletingStarted
   886 // CalenViewManager::handleDeletingStarted
   769 //  Slot to handle signal deletingStarted by the agenda event viewer
   887 //  Slot to handle signal deletingStarted by the agenda event viewer
   770 // (other items were commented in a header).
   888 // (other items were commented in a header).
   771 // ----------------------------------------------------------------------------
   889 // ----------------------------------------------------------------------------
   772 //
   890 //
   773 void CalenViewManager::handleDeletingStarted()
   891 void CalenViewManager::handleDeletingStarted()
   774 {
   892 {
       
   893 	OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEDELETINGSTARTED_ENTRY );
   775 	
   894 	
   776 	mController.IssueCommandL(ECalenDeleteEntryFromViewer);
   895 	mController.IssueCommandL(ECalenDeleteEntryFromViewer);
   777 	
   896 	
       
   897 	OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEDELETINGSTARTED_EXIT );
   778 }
   898 }
   779 
   899 
   780 // ----------------------------------------------------------------------------
   900 // ----------------------------------------------------------------------------
   781 // CalenViewManager::handleDeletingCompleted
   901 // CalenViewManager::handleDeletingCompleted
   782 //  Slot to handle signal deletingCompleted by the agenda event viewer
   902 //  Slot to handle signal deletingCompleted by the agenda event viewer
   783 // (other items were commented in a header).
   903 // (other items were commented in a header).
   784 // ----------------------------------------------------------------------------
   904 // ----------------------------------------------------------------------------
   785 //
   905 //
   786 void CalenViewManager::handleDeletingCompleted()
   906 void CalenViewManager::handleDeletingCompleted()
   787 {
   907 {
       
   908 	OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEDELETINGCOMPLETED_ENTRY );
   788 	
   909 	
   789 	mController.Services().IssueNotificationL(ECalenNotifyEntryDeleted);
   910 	mController.Services().IssueNotificationL(ECalenNotifyEntryDeleted);
   790 
   911 
   791 	// invalidate captured screenshots as either month view or agenda view is activated now
   912 	// invalidate captured screenshots as either month view or agenda view is activated now
   792     if (mCalenMonthView) {
   913     if (mCalenMonthView) {
   793     mCalenMonthView->captureScreenshot();
   914     mCalenMonthView->captureScreenshot();
   794     } else if (mCalenAgendaView) {
   915     } else if (mCalenAgendaView) {
   795     	mCalenAgendaView->captureScreenshot();
   916     	mCalenAgendaView->captureScreenshot();
   796     }
   917     }
   797 
   918 	
   798 	
   919     OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEDELETINGCOMPLETED_EXIT );
   799 }
   920 }
   800 
   921 
   801 // ----------------------------------------------------------------------------
   922 // ----------------------------------------------------------------------------
   802 // CalenViewManager::handleInstanceViewCreation
   923 // CalenViewManager::handleInstanceViewCreation
   803 //  Slot to handle completion of instance view creation
   924 //  Slot to handle completion of instance view creation
   804 // (other items were commented in a header).
   925 // (other items were commented in a header).
   805 // ----------------------------------------------------------------------------
   926 // ----------------------------------------------------------------------------
   806 //
   927 //
   807 void CalenViewManager::handleInstanceViewCreation(int status)
   928 void CalenViewManager::handleInstanceViewCreation(int status)
   808 {
   929 {
       
   930     OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEINSTANCEVIEWCREATION_ENTRY );
       
   931     
   809 	Q_UNUSED(status);
   932 	Q_UNUSED(status);
       
   933 	
       
   934 	// This flag is needed if mCalenMonthView and mCalenAgendaview is not created
       
   935 	// and before that this slot is getting called.
       
   936 	// if we launch views through services then this slot is getting called 
       
   937 	// before the view construction.
       
   938 	mInstanceViewCreated = true;
       
   939 	
   810 	// handleInstanceViewCreation function is called only once. Now that the instance
   940 	// handleInstanceViewCreation function is called only once. Now that the instance
   811 	// view creation is successfull. Events need to be populated on screen
   941 	// view creation is successfull. Events need to be populated on screen
   812 	// Ideal colution should be to call a uniform function, e.g. PopulateEvents
   942 	// Ideal colution should be to call a uniform function, e.g. PopulateEvents
   813 	// where PopulateEvents should be implemeted by all views. Since the current
   943 	// where PopulateEvents should be implemeted by all views. Since the current
   814 	// solution for the month view implements the construction in two phases so 
   944 	// solution for the month view implements the construction in two phases so 
   818 		mCalenMonthView->fetchEntriesAndUpdateModel();
   948 		mCalenMonthView->fetchEntriesAndUpdateModel();
   819 	}
   949 	}
   820 	else if (mCalenAgendaView) {
   950 	else if (mCalenAgendaView) {
   821 		mCalenAgendaView->doPopulation();
   951 		mCalenAgendaView->doPopulation();
   822 	}
   952 	}
       
   953 	// Calls the emitAppReady function of CalenController. Need to emit this
       
   954 	// signal after the view is fully constructed & populated
       
   955 	// with actual data and ready to be used. So entry view & instance view
       
   956 	// needs to be created so that a new entry can also be created. Finally
       
   957 	// NotesApplication object needs to emit applicationReady Signal.
       
   958 	mController.emitAppReady();
       
   959 	
       
   960 	OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEINSTANCEVIEWCREATION_EXIT );
   823 }
   961 }
   824 
   962 
   825 // ----------------------------------------------------------------------------
   963 // ----------------------------------------------------------------------------
   826 // CalenViewManager::handleDeletingCompleted
   964 // CalenViewManager::handleDeletingCompleted
   827 //  Slot to handle completion of entry view creation
   965 //  Slot to handle completion of entry view creation
   828 // (other items were commented in a header).
   966 // (other items were commented in a header).
   829 // ----------------------------------------------------------------------------
   967 // ----------------------------------------------------------------------------
   830 //
   968 //
   831 void CalenViewManager::handleEntryViewCreation(int status)
   969 void CalenViewManager::handleEntryViewCreation(int status)
   832 {
   970 {
       
   971     OstTraceFunctionEntry0( CALENVIEWMANAGER_HANDLEENTRYVIEWCREATION_ENTRY );
       
   972     
   833 	// Nothing Yet
   973 	// Nothing Yet
   834 	Q_UNUSED(status);
   974 	Q_UNUSED(status);
   835 }
   975 
   836 
   976 	OstTraceFunctionExit0( CALENVIEWMANAGER_HANDLEENTRYVIEWCREATION_EXIT );
   837 // ----------------------------------------------------------------------------
   977 }
   838 // CalenViewManager::handleDayViewReady
   978 
   839 // Launches day view when it is added to MainWindow and ready to be displayed
   979 // ----------------------------------------------------------------------------
   840 // ----------------------------------------------------------------------------
   980 // CalenViewManager::handleEntriesChanged
   841 //
   981 // this function will be called when someone else has changed the database
   842 void CalenViewManager::handleDayViewReady() 
   982 // ----------------------------------------------------------------------------
   843 {
   983 //
   844     // Removes current view
   984 void CalenViewManager::handleEntriesChanged(QList<ulong> ids)
   845     // Notice: removing view should be done after new view is set as current to
   985 {
   846     // avoid situation that there is no current view in application
   986 	Q_UNUSED(ids);
   847     removePreviousView();
   987 	HbView *currentview = mController.MainWindow().currentView();
   848     
   988 	if((mCalenMonthView == currentview)||(mCalenDayView == currentview)||
   849     // Sets and activates day view
   989                                             (mCalenAgendaView == currentview ))
   850     mCurrentViewId = ECalenDayView;
   990 	    {
   851     activateCurrentView();
   991         activateCurrentView();
       
   992 	    }
       
   993 }
       
   994 
       
   995 // ----------------------------------------------------------------------------
       
   996 // CalenViewManager::handleEntryUpdation
       
   997 // this function will be called when any entry is updated or added into database
       
   998 // Here we need to set the context to the entry updated or added.
       
   999 // ----------------------------------------------------------------------------
       
  1000 //
       
  1001 void CalenViewManager::handleEntryUpdation(ulong id)
       
  1002 {
       
  1003     AgendaEntry updatedEntry = mController.agendaInterface()->fetchById(id);
       
  1004 
       
  1005     // Agenda entry is not null then refresh the view else close event viewer
       
  1006     if (!updatedEntry.isNull()) {
       
  1007         if (AgendaEntry::TypeTodo != updatedEntry.type()) {
       
  1008             QDate date = updatedEntry.startTime().date();
       
  1009             if (!date.isNull() && date.isValid()) {
       
  1010                 mController.Services().Context().setFocusDate(QDateTime(date));
       
  1011             }
       
  1012         }
       
  1013     }
       
  1014 
   852 }
  1015 }
   853 
  1016 
   854 // ----------------------------------------------------------------------------
  1017 // ----------------------------------------------------------------------------
   855 // CalenViewManager::launchSettingsView
  1018 // CalenViewManager::launchSettingsView
   856 // Launches settings view
  1019 // Launches settings view
   857 // (other items were commented in a header).
  1020 // (other items were commented in a header).
   858 // ----------------------------------------------------------------------------
  1021 // ----------------------------------------------------------------------------
   859 //
  1022 //
   860 void CalenViewManager::launchSettingsView()
  1023 void CalenViewManager::launchSettingsView()
   861 {
  1024 {
       
  1025     OstTraceFunctionEntry0( CALENVIEWMANAGER_LAUNCHSETTINGSVIEW_ENTRY );
       
  1026     
   862     mPreviousViewsId = mCurrentViewId ;  
  1027     mPreviousViewsId = mCurrentViewId ;  
   863     mCurrentViewId = ECalenShowSettings;
  1028     mCurrentViewId = ECalenShowSettings;
   864     mSettingsView->initializeForm();
  1029     mSettingsView->initializeForm();
   865     mController.Services().MainWindow().setCurrentView(mSettingsView);
  1030     mController.Services().MainWindow().setCurrentView(mSettingsView);
   866     
  1031     
   868     if (mCalenMonthView){
  1033     if (mCalenMonthView){
   869     mCalenMonthView->captureScreenshot(true);
  1034     mCalenMonthView->captureScreenshot(true);
   870     } else if(mCalenAgendaView){
  1035     } else if(mCalenAgendaView){
   871     	mCalenAgendaView->captureScreenshot(true);
  1036     	mCalenAgendaView->captureScreenshot(true);
   872     }
  1037     }
       
  1038     
       
  1039     OstTraceFunctionExit0( CALENVIEWMANAGER_LAUNCHSETTINGSVIEW_EXIT );
   873 }
  1040 }
   874 
  1041 
   875 // End of file	--Don't remove this.
  1042 // End of file	--Don't remove this.