clock/clockui/clockviewmanager/src/clockviewmanager.cpp
changeset 49 5de72ea7a065
parent 26 a949c2543c15
child 58 ef813d54df51
equal deleted inserted replaced
37:360d55486d7f 49:5de72ea7a065
    17 */
    17 */
    18 
    18 
    19 // System includes
    19 // System includes
    20 #include <HbMainWindow>
    20 #include <HbMainWindow>
    21 #include <HbInstance>
    21 #include <HbInstance>
       
    22 #include <hbapplication> // hbapplication
       
    23 #include <hbactivitymanager> // hbactivitymanager
    22 
    24 
    23 // User includes
    25 // User includes
    24 #include "clockviewmanager.h"
    26 #include "clockviewmanager.h"
    25 #include "clockdocloader.h"
    27 #include "clockdocloader.h"
    26 #include "clockmainview.h"
    28 #include "clockmainview.h"
    44 		ClockAppControllerIf &controllerIf, QObject *parent)
    46 		ClockAppControllerIf &controllerIf, QObject *parent)
    45 :QObject(parent),
    47 :QObject(parent),
    46  mAppControllerIf(controllerIf),
    48  mAppControllerIf(controllerIf),
    47  mWorldClockView(0)
    49  mWorldClockView(0)
    48 {
    50 {
    49 	// Load the main view at the start up.
    51     // Activity Reason from Activity Manager
    50 	loadMainView();
    52     int activityReason = qobject_cast<HbApplication*>(qApp)->activateReason();
       
    53     
       
    54     if (Hb::ActivationReasonActivity == activityReason) {
       
    55         // Application is started from an activity
       
    56 		// extract activity data
       
    57         QVariant data = qobject_cast<HbApplication*>(qApp)->activateData();
       
    58         // restore state from activity data
       
    59         QByteArray serializedModel = data.toByteArray();
       
    60         QDataStream stream(&serializedModel, QIODevice::ReadOnly);
       
    61         int activityId;
       
    62         stream >> activityId;
       
    63         
       
    64         if (MainView == activityId) {
       
    65             // Load the main view at the start up.
       
    66             loadMainView();
       
    67 			// Delay loading of other views till main view is loaded.
       
    68         	HbMainWindow *window = hbInstance->allMainWindows().first();
       
    69         	connect(
       
    70                 window, SIGNAL(viewReady()),
       
    71                 this, SLOT(loadOtherViews()));
    51 
    72 
    52 	// Delay loading of other views till main view is loaded.
    73         }
    53 	HbMainWindow *window = hbInstance->allMainWindows().first();
    74         else if (WorldClock == activityId) {
    54 	connect(
    75             //no implentation yet, UI specs are not clear
    55 			window, SIGNAL(viewReady()),
    76         }
    56 			this, SLOT(loadOtherViews()));
    77 
       
    78     }
       
    79     else {
       
    80         // Load the main view at the start up.
       
    81         loadMainView();
       
    82         // Delay loading of other views till main view is loaded.
       
    83         HbMainWindow *window = hbInstance->allMainWindows().first();
       
    84         connect(
       
    85                 window, SIGNAL(viewReady()),
       
    86                 this, SLOT(loadOtherViews()));
       
    87     }
       
    88 
    57 }
    89 }
    58 
    90 
    59 /*!
    91 /*!
    60 	Destructor.
    92 	Destructor.
    61  */
    93  */
    73 {
   105 {
    74 	HbMainWindow *window = hbInstance->allMainWindows().first();
   106 	HbMainWindow *window = hbInstance->allMainWindows().first();
    75 
   107 
    76 	switch (view) {
   108 	switch (view) {
    77 		case MainView:
   109 		case MainView:
       
   110 		    // set captured screenshot as invalid as main view 
       
   111 			// is the current view
       
   112 		    mMainView->captureScreenShot(false);
    78 			window->removeView(window->currentView());
   113 			window->removeView(window->currentView());
    79 			window->addView(mMainView);
   114 			window->addView(mMainView);
    80 			window->setCurrentView(mMainView);
   115 			window->setCurrentView(mMainView);
    81 			break;
   116 			break;
    82 
   117 
    83 		case WorldClock:
   118 		case WorldClock:
       
   119 		    if (mMainView) {
       
   120 				// capture main view as the screenshot for future use 
       
   121 				// to save the main view as an activity, if application is 
       
   122 				// exited/Quit from world view
       
   123                 mMainView->captureScreenShot(true);
       
   124 		    }
    84 			window->removeView(window->currentView());
   125 			window->removeView(window->currentView());
    85 			window->addView(mWorldClockView);
   126 			window->addView(mWorldClockView);
    86 			window->setCurrentView(mWorldClockView);
   127 			window->setCurrentView(mWorldClockView);
    87 			break;
   128 			break;
    88 
   129