calendarui/views/src/calendayview.cpp
changeset 49 5de72ea7a065
parent 32 ea672fcb0ea0
equal deleted inserted replaced
37:360d55486d7f 49:5de72ea7a065
    19 #include <QGraphicsSceneEvent>
    19 #include <QGraphicsSceneEvent>
    20 #include <hbmainwindow.h>
    20 #include <hbmainwindow.h>
    21 #include <hbaction.h>
    21 #include <hbaction.h>
    22 #include <hbpangesture.h>
    22 #include <hbpangesture.h>
    23 #include <hbswipegesture.h>
    23 #include <hbswipegesture.h>
       
    24 #include <hbapplication.h> // hbapplication
       
    25 #include <hbactivitymanager.h> // Activity Manager
    24 
    26 
    25 // User includes
    27 // User includes
    26 #include "calendayview.h"
    28 #include "calendayview.h"
    27 #include "calendocloader.h"
    29 #include "calendocloader.h"
    28 #include "calendayviewwidget.h"
    30 #include "calendayviewwidget.h"
    29 #include "calenservices.h"
    31 #include "calenservices.h"
    30 #include "calencommon.h"
    32 #include "calencommon.h"
    31 #include "calencontext.h"
    33 #include "calencontext.h"
    32 #include "calendateutils.h"
    34 #include "calendateutils.h"
       
    35 #include "calenconstants.h"
    33 
    36 
    34 // ----------------------------------------------------------------------------
    37 // ----------------------------------------------------------------------------
    35 // CalenDayView::CalenDayView
    38 // CalenDayView::CalenDayView
    36 // Rest of the details are commented in the header
    39 // Rest of the details are commented in the header
    37 // ----------------------------------------------------------------------------
    40 // ----------------------------------------------------------------------------
    38 //
    41 //
    39 CalenDayView::CalenDayView(MCalenServices &services):
    42 CalenDayView::CalenDayView(MCalenServices &services):
    40 CalenNativeView(services),
    43 CalenNativeView(services),
    41 mSoftKeyAction(NULL),
    44 mSoftKeyAction(NULL),
    42 mGoToTodayAction(NULL),
    45 mGoToTodayAction(NULL),
    43 mActionTaken(false)
    46 mActionTaken(false),
       
    47 mIsAboutToQuitEventConnected(false)
    44 {
    48 {
    45     // No implementation yet
    49     // No implementation yet
    46     grabGesture(Qt::SwipeGesture);
    50     grabGesture(Qt::SwipeGesture);
    47 }
    51 }
    48 
    52 
    81 	}
    85 	}
    82 	mDayViewWidget->setupWidget(this);
    86 	mDayViewWidget->setupWidget(this);
    83 	
    87 	
    84 	// Initialize all the menu and toolbar actions
    88 	// Initialize all the menu and toolbar actions
    85 	setupActions();
    89 	setupActions();
       
    90 	// get a poitner to activity manager
       
    91 	HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
       
    92 
       
    93 	// clean up any previous versions of this activity, if any, i.e. activityName, from the activity manager. 
       
    94 	// Ignore return value, first boot would always return False. bool declared 
       
    95 	// only for debugging purpose.
       
    96 	bool ok = activityManager->removeActivity(activityName);
       
    97 	
    86 }
    98 }
    87 
    99 
    88 // ----------------------------------------------------------------------------
   100 // ----------------------------------------------------------------------------
    89 // CCalenDayView::doPopulation
   101 // CCalenDayView::doPopulation
    90 // Rest of the details are commented in the header
   102 // Rest of the details are commented in the header
   121 		        SLOT(launchMonthView()));
   133 		        SLOT(launchMonthView()));
   122 	}
   134 	}
   123     // Initialize the content widget
   135     // Initialize the content widget
   124     mDayViewWidget->showWidget();
   136     mDayViewWidget->showWidget();
   125     
   137     
       
   138 	//set Current Activity as day view
       
   139     mActivityId = ECalenDayView;
       
   140 
       
   141 	// connect to receive a call back on Day View exit. Call back would result in saveActivity 
       
   142 	// to be called in Native View
       
   143     if (!mIsAboutToQuitEventConnected) // check if already not connected
       
   144         {
       
   145         connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
       
   146 		mIsAboutToQuitEventConnected = true;
       
   147         }
       
   148 
       
   149 
   126     // Population is complete, issue a notification
   150     // Population is complete, issue a notification
   127     populationComplete();
   151     populationComplete();
   128     }
   152     }
   129 
   153 
   130 /*!
   154 /*!
   263 //    
   287 //    
   264 void CalenDayView::launchMonthView()
   288 void CalenDayView::launchMonthView()
   265 {
   289 {
   266     // Issue the command to launch the month view
   290     // Issue the command to launch the month view
   267     mServices.IssueCommandL(ECalenMonthView);
   291     mServices.IssueCommandL(ECalenMonthView);
       
   292 	// month view launched now, disconnect to get the call backs for saveActivity 
       
   293 	// on aboutToQuit signal
       
   294     disconnectAboutToQuitEvent();
   268 }
   295 }
   269 
   296 
   270 // ----------------------------------------------------------------------------
   297 // ----------------------------------------------------------------------------
   271 // CCalenDayView::clearListModel
   298 // CCalenDayView::clearListModel
   272 // clears the list model 
   299 // clears the list model 
   273 // ----------------------------------------------------------------------------
   300 // ----------------------------------------------------------------------------
   274 // 
   301 // 
   275 void CalenDayView::clearListModel()
   302 void CalenDayView::clearListModel()
   276     {
   303     {
       
   304 	// day view is removed from the list disconnect for aboutToQuit events
       
   305     disconnectAboutToQuitEvent();
   277     mDayViewWidget->clearListModel();
   306     mDayViewWidget->clearListModel();
   278     }
   307     }
   279 
   308 
       
   309 // ----------------------------------------------------------------------------
       
   310 // disconnectAboutToQuitEvent disconnects for the aboutToQuit events
       
   311 // ----------------------------------------------------------------------------
       
   312 // 
       
   313 void CalenDayView::disconnectAboutToQuitEvent()
       
   314     {
       
   315     if (mIsAboutToQuitEventConnected)
       
   316         {
       
   317         disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
       
   318         mIsAboutToQuitEventConnected = false;
       
   319         }
       
   320     }
       
   321 
   280 // End of file	--Don't remove this.
   322 // End of file	--Don't remove this.