calendarui/controller/src/calenviewmanager.cpp
changeset 81 ce92091cbd61
parent 75 7ac58b2aae6f
child 89 b57382753122
equal deleted inserted replaced
75:7ac58b2aae6f 81:ce92091cbd61
    19 //system includes
    19 //system includes
    20 #include <hbmainwindow.h>
    20 #include <hbmainwindow.h>
    21 #include <hbinstance.h>
    21 #include <hbinstance.h>
    22 #include <hbapplication.h> // hbapplication
    22 #include <hbapplication.h> // hbapplication
    23 #include <xqserviceutil.h> // service utils
    23 #include <xqserviceutil.h> // service utils
    24 
    24 #include <afactivation.h>
       
    25 #include <AfActivityStorage.h>
    25 //user includes
    26 //user includes
    26 #include "calenviewmanager.h"
    27 #include "calenviewmanager.h"
    27 #include "calencontroller.h"
    28 #include "calencontroller.h"
    28 #include "hb_calencommands.hrh"
    29 #include "hb_calencommands.hrh"
    29 #include "calenservicesimpl.h"
    30 #include "calenservicesimpl.h"
    84 }
    85 }
    85 
    86 
    86 void CalenViewManager::SecondPhaseConstruction()
    87 void CalenViewManager::SecondPhaseConstruction()
    87 {
    88 {
    88     OstTraceFunctionEntry0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_ENTRY );
    89     OstTraceFunctionEntry0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_ENTRY );
    89     
    90 
    90     // Check the Application Startup reason from Activity Manager
       
    91     int activityReason = qobject_cast<HbApplication*>(qApp)->activateReason();
       
    92     
       
    93     // Check if calendar is launched thru XQService framework
    91     // Check if calendar is launched thru XQService framework
    94     bool isFromServiceFrmWrk = XQServiceUtil::isService(); // Since activateReason 
    92     bool isFromServiceFrmWrk = XQServiceUtil::isService(); // Since activateReason 
    95     //of hbapplication is not returning right value if the activity is started 
    93     //of hbapplication is not returning right value if the activity is started 
    96     //as services so using the above line temporarily untill a fix is available in 
    94     //as services so using the above line temporarily untill a fix is available in 
    97     // hbappliacation. Need to remove this line after the fix is available for hbapplcation
    95     // hbappliac
    98 
    96     AfActivation *activation = new AfActivation();
    99     
    97     if(Af::ActivationReasonActivity == activation->reason())
   100     if (Hb::ActivationReasonActivity == activityReason) // Check if application is started 
       
   101     // as an activity
    98     // as an activity
   102         {
    99         {
   103         // Application is started from an activity
   100         // Application is started from an activity
   104         // Extract activity data
   101         // Extract activity data
   105         QVariant data = qobject_cast<HbApplication*>(qApp)->activateData();
   102         AfActivityStorage *activitystorage = new AfActivityStorage();
       
   103         QVariant data = activitystorage->activityData(activation->name());
       
   104         delete activitystorage;
       
   105 
   106         // Restore state from activity data
   106         // Restore state from activity data
   107         QByteArray serializedModel = data.toByteArray();
   107         QByteArray serializedModel = data.toByteArray();
   108         QDataStream stream(&serializedModel, QIODevice::ReadOnly);
   108         QDataStream stream(&serializedModel, QIODevice::ReadOnly);
   109         int viewId; // int declared for debugging purpose
   109         int viewId; // int declared for debugging purpose
   110         stream >> viewId; // read stream into an int
   110         stream >> viewId; // read stream into an int
   151                         this, SLOT(handleMainViewReady()));
   151                         this, SLOT(handleMainViewReady()));
   152         
   152         
   153         mController.MainWindow().addView(mCalenMonthView);
   153         mController.MainWindow().addView(mCalenMonthView);
   154         mController.MainWindow().setCurrentView(mCalenMonthView);
   154         mController.MainWindow().setCurrentView(mCalenMonthView);
   155     }
   155     }
   156     
   156     //delete the activity intsance
   157 
   157     delete activation;
   158     OstTraceFunctionExit0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_EXIT );
   158     OstTraceFunctionExit0( CALENVIEWMANAGER_SECONDPHASECONSTRUCTION_EXIT );
   159 }
   159 }
   160 
   160 
   161 // ----------------------------------------------------------------------------
   161 // ----------------------------------------------------------------------------
   162 // CalenViewManager::~CalenViewManager
   162 // CalenViewManager::~CalenViewManager
  1013 void CalenViewManager::handleEntriesChanged(QList<ulong> ids)
  1013 void CalenViewManager::handleEntriesChanged(QList<ulong> ids)
  1014 {
  1014 {
  1015 	Q_UNUSED(ids);
  1015 	Q_UNUSED(ids);
  1016 	HbView *currentview = mController.MainWindow().currentView();
  1016 	HbView *currentview = mController.MainWindow().currentView();
  1017 	if((mCalenMonthView == currentview)||(mCalenDayView == currentview)||
  1017 	if((mCalenMonthView == currentview)||(mCalenDayView == currentview)||
  1018                                             (mCalenAgendaView == currentview ))
  1018                                             (mCalenAgendaView == currentview )||(mCalenAgendaViewAlt == currentview))
  1019 	    {
  1019 	    {
  1020         activateCurrentView();
  1020         activateCurrentView();
  1021 	    }
  1021 	    }
       
  1022 	delete currentview;
  1022 }
  1023 }
  1023 
  1024 
  1024 // ----------------------------------------------------------------------------
  1025 // ----------------------------------------------------------------------------
  1025 // CalenViewManager::handleEntryUpdation
  1026 // CalenViewManager::handleEntryUpdation
  1026 // this function will be called when any entry is updated or added into database
  1027 // this function will be called when any entry is updated or added into database