calendarui/views/src/calennativeview.cpp
changeset 49 5de72ea7a065
parent 26 a949c2543c15
child 50 579cc610882e
equal deleted inserted replaced
37:360d55486d7f 49:5de72ea7a065
    22 #include <hbaction.h>
    22 #include <hbaction.h>
    23 #include <hbdialog.h>
    23 #include <hbdialog.h>
    24 #include <hbmainwindow.h>
    24 #include <hbmainwindow.h>
    25 #include <hbdatetimepicker.h>
    25 #include <hbdatetimepicker.h>
    26 #include <vwsdef.h>
    26 #include <vwsdef.h>
       
    27 #include <hbactivitymanager.h> //Activity Manager
       
    28 #include <hbapplication.h> //hbapplication
    27 
    29 
    28 //user includes
    30 //user includes
    29 #include <CalenUid.h>
    31 #include <CalenUid.h>
    30 #include "calennativeview.h"
    32 #include "calennativeview.h"
    31 #include "calenservices.h"
    33 #include "calenservices.h"
    32 #include "calencontext.h"
    34 #include "calencontext.h"
    33 #include "calensettingsview.h"
    35 #include "calensettingsview.h"
    34 #include "calendateutils.h"
    36 #include "calendateutils.h"
       
    37 #include "calenconstants.h"
    35 
    38 
    36 /*!
    39 /*!
    37  \class CalenNativeView
    40  \class CalenNativeView
    38  Base class for all calendar views
    41  Base class for all calendar views
    39  */
    42  */
    40 
    43 
    41 /*!
    44 /*!
    42  Default constructor.
    45  Default constructor.
    43  */
    46  */
    44 CalenNativeView::CalenNativeView(MCalenServices &services) :
    47 CalenNativeView::CalenNativeView(MCalenServices &services) :
    45 	mServices(services)
    48 	mServices(services), mIsCapturedScreenShotValid(false)
    46 {
    49 {
    47 	setTitle(hbTrId("txt_calendar_title_calendar"));
    50 	setTitle(hbTrId("txt_calendar_title_calendar"));
    48 
    51 
    49 	// Create services API and register for notifications
    52 	// Create services API and register for notifications
    50 	RArray<TCalenNotification> notificationArray;
    53 	RArray<TCalenNotification> notificationArray;
   204 QString *CalenNativeView::pluginText()
   207 QString *CalenNativeView::pluginText()
   205 {
   208 {
   206 	return mServices.InfobarTextL();
   209 	return mServices.InfobarTextL();
   207 }
   210 }
   208 
   211 
       
   212 // ----------------------------------------------------------------------------
       
   213 // captureScreenshot caltures screen shot for the given viewId
       
   214 // @param viewId view for which screenshot needs to be captured
       
   215 // ----------------------------------------------------------------------------
       
   216 // 
       
   217 void CalenNativeView::captureScreenshot(bool captureScreenShot)
       
   218     {
       
   219     // get a screenshot for saving to the activity manager. It's done for once
       
   220     // to optimize the performance
       
   221     if (captureScreenShot) {
       
   222         mScreenShotMetadata.clear(); // remove any screenshot captured earlier
       
   223         mScreenShotMetadata.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
       
   224         }
       
   225     mIsCapturedScreenShotValid = captureScreenShot; // set the validity of the screenshot captured
       
   226     }
       
   227 
       
   228 // ----------------------------------------------------------------------------
       
   229 // saveActivity saves the activity for current view
       
   230 // ----------------------------------------------------------------------------
       
   231 // 
       
   232 void CalenNativeView::saveActivity()
       
   233  {
       
   234    // Get a pointer to activity manager 
       
   235    HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
       
   236  
       
   237    // check if alerady a valid screen shot is captured
       
   238    if (!mIsCapturedScreenShotValid) {
       
   239        mScreenShotMetadata.clear(); // remove any screenshot captured earlier
       
   240        mScreenShotMetadata.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect()));
       
   241        }
       
   242    
       
   243    // Save any data necessary to save the state
       
   244    QByteArray serializedActivity;
       
   245    QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append);
       
   246    stream << mActivityId;
       
   247  
       
   248    bool ok(false);
       
   249    // Save activity
       
   250    ok = activityManager->addActivity(activityName, serializedActivity, mScreenShotMetadata);
       
   251 
       
   252    // Check is activity saved sucessfully
       
   253    if ( !ok )  {
       
   254        qFatal("Add failed" ); // Panic is activity is not saved successfully
       
   255        }
       
   256  }
   209 //End Of File
   257 //End Of File