calendarui/views/src/calenagendaview.cpp
changeset 51 0b38fc5b94c6
parent 45 b6db4fd4947b
child 70 a5ed90760192
equal deleted inserted replaced
46:ecd7b9840282 51:0b38fc5b94c6
    31 #include "calenservices.h"
    31 #include "calenservices.h"
    32 #include "calencommon.h"
    32 #include "calencommon.h"
    33 #include "calencontext.h"
    33 #include "calencontext.h"
    34 #include "calendateutils.h"
    34 #include "calendateutils.h"
    35 #include "calenconstants.h"
    35 #include "calenconstants.h"
       
    36 #include "OstTraceDefinitions.h"
       
    37 #ifdef OST_TRACE_COMPILER_IN_USE
       
    38 #include "calenagendaviewTraces.h"
       
    39 #endif
       
    40 
    36 
    41 
    37 // ----------------------------------------------------------------------------
    42 // ----------------------------------------------------------------------------
    38 // CalenAgendaView::CalenAgendaView
    43 // CalenAgendaView::CalenAgendaView
    39 // Rest of the details are commented in the header
    44 // Rest of the details are commented in the header
    40 // ----------------------------------------------------------------------------
    45 // ----------------------------------------------------------------------------
    45 mGoToTodayAction(NULL),
    50 mGoToTodayAction(NULL),
    46 mSwitchToDayViewAction(NULL),
    51 mSwitchToDayViewAction(NULL),
    47 mActionTaken(false),
    52 mActionTaken(false),
    48 mIsAboutToQuitEventConnected(false)
    53 mIsAboutToQuitEventConnected(false)
    49 {
    54 {
       
    55     OstTraceFunctionEntry0( CALENAGENDAVIEW_CALENAGENDAVIEW_ENTRY );
       
    56     
    50     // No implementation yet
    57     // No implementation yet
    51     grabGesture(Qt::SwipeGesture);
    58     grabGesture(Qt::SwipeGesture);
       
    59     
       
    60     OstTraceFunctionExit0( CALENAGENDAVIEW_CALENAGENDAVIEW_EXIT );
    52 }
    61 }
    53 
    62 
    54 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
    55 // CalenAgendaView::~CalenAgendaView
    64 // CalenAgendaView::~CalenAgendaView
    56 // Rest of the details are commented in the header
    65 // Rest of the details are commented in the header
    57 // ----------------------------------------------------------------------------
    66 // ----------------------------------------------------------------------------
    58 //    
    67 //    
    59 CalenAgendaView::~CalenAgendaView()
    68 CalenAgendaView::~CalenAgendaView()
    60 {
    69 {
       
    70     OstTraceFunctionEntry0( DUP1_CALENAGENDAVIEW_CALENAGENDAVIEW_ENTRY );
       
    71     
    61     // No implementation yet
    72     // No implementation yet
       
    73     
       
    74     OstTraceFunctionExit0( DUP1_CALENAGENDAVIEW_CALENAGENDAVIEW_EXIT );
    62 }
    75 }
    63 
    76 
    64 // ----------------------------------------------------------------------------
    77 // ----------------------------------------------------------------------------
    65 // CalenAgendaView::setupView
    78 // CalenAgendaView::setupView
    66 // Rest of the details are commented in the header
    79 // Rest of the details are commented in the header
    67 // ----------------------------------------------------------------------------
    80 // ----------------------------------------------------------------------------
    68 //    
    81 //    
    69 void CalenAgendaView::setupView(CalenDocLoader *docLoader)
    82 void CalenAgendaView::setupView(CalenDocLoader *docLoader)
    70 {
    83 {
       
    84     OstTraceFunctionEntry0( CALENAGENDAVIEW_SETUPVIEW_ENTRY );
       
    85     
    71     if (!docLoader) {
    86     if (!docLoader) {
    72         // Nothing can be done. Simply return
    87         // Nothing can be done. Simply return
       
    88         OstTraceFunctionExit0( CALENAGENDAVIEW_SETUPVIEW_EXIT );
    73         return;
    89         return;
    74     }
    90     }
    75     // Store the document loader for reference later
    91     // Store the document loader for reference later
    76 	mDocLoader = docLoader;
    92 	mDocLoader = docLoader;
    77 	
    93 	
    86 	}
   102 	}
    87 	mAgendaViewWidget->setupWidget(this);
   103 	mAgendaViewWidget->setupWidget(this);
    88 	
   104 	
    89 	// Initialize all the menu and toolbar actions
   105 	// Initialize all the menu and toolbar actions
    90 	setupActions();
   106 	setupActions();
       
   107 	
       
   108     //add "show lunar data" action item ,if regional plugin is present
       
   109     //regional plugin will add the option itself and handles it accordingly
       
   110     //use this api after adding all action item to the menu
       
   111     //so that plugin add the "Show lunar data" item as a second last option 
       
   112     // in all views
       
   113    mServices.OfferMenu(menu());
       
   114 	
    91 	// get a poitner to activity manager
   115 	// get a poitner to activity manager
    92 	HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
   116 	HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
    93 
   117 
    94 	// clean up any previous versions of this activity, if any, i.e. activityName, from the activity manager. 
   118 	// clean up any previous versions of this activity, if any, i.e. activityName, from the activity manager. 
    95 	// Ignore return value, first boot would always return False. bool declared 
   119 	// Ignore return value, first boot would always return False. bool declared 
    96 	// only for debugging purpose.
   120 	// only for debugging purpose.
    97 	bool ok = activityManager->removeActivity(activityName);
   121 	bool ok = activityManager->removeActivity(activityName);
    98 	
   122 	
       
   123 	OstTraceFunctionExit0( DUP1_CALENAGENDAVIEW_SETUPVIEW_EXIT );
    99 }
   124 }
   100 
   125 
   101 // ----------------------------------------------------------------------------
   126 // ----------------------------------------------------------------------------
   102 // CalenAgendaView::doPopulation
   127 // CalenAgendaView::doPopulation
   103 // Rest of the details are commented in the header
   128 // Rest of the details are commented in the header
   104 // ----------------------------------------------------------------------------
   129 // ----------------------------------------------------------------------------
   105 // 
   130 // 
   106 void CalenAgendaView::doPopulation()
   131 void CalenAgendaView::doPopulation()
   107     {
   132     {
       
   133     OstTraceFunctionEntry0( CALENAGENDAVIEW_DOPOPULATION_ENTRY );
       
   134     
   108     // The content widget has not been constructed. Don't do anything
   135     // The content widget has not been constructed. Don't do anything
   109     if (!mAgendaViewWidget) {
   136     if (!mAgendaViewWidget) {
       
   137         OstTraceFunctionExit0( CALENAGENDAVIEW_DOPOPULATION_EXIT );
   110         return;
   138         return;
   111     }
   139     }
   112     // Get the day for which this view is being shown from the context
   140     // Get the day for which this view is being shown from the context
   113     mDate = mServices.Context().focusDateAndTime();
   141     mDate = mServices.Context().focusDateAndTime();
   114     
   142     
   155         }
   183         }
   156 
   184 
   157 
   185 
   158     // Population is complete, issue a notification
   186     // Population is complete, issue a notification
   159     populationComplete();
   187     populationComplete();
       
   188     
       
   189     OstTraceFunctionExit0( DUP1_CALENAGENDAVIEW_DOPOPULATION_EXIT );
   160     }
   190     }
   161 
   191 
   162 /*!
   192 /*!
   163  Funtion to refresh the current view upon selecting a date
   193  Funtion to refresh the current view upon selecting a date
   164  from GoToDate popup
   194  from GoToDate popup
   165  */
   195  */
   166 void CalenAgendaView::refreshViewOnGoToDate()
   196 void CalenAgendaView::refreshViewOnGoToDate()
   167 {
   197 {
       
   198     OstTraceFunctionEntry0( CALENAGENDAVIEW_REFRESHVIEWONGOTODATE_ENTRY );
       
   199     
   168 	// Get the day for which this view is being shown from the context
   200 	// Get the day for which this view is being shown from the context
   169 	mDate = mServices.Context().focusDateAndTime();
   201 	mDate = mServices.Context().focusDateAndTime();
   170 	
   202 	
   171 	// Check if the current day being shown is "Today"
   203 	// Check if the current day being shown is "Today"
   172 	if (mGoToTodayAction) {
   204 	if (mGoToTodayAction) {
   178 		}
   210 		}
   179 	}
   211 	}
   180 	
   212 	
   181 	// Initialize the content widget
   213 	// Initialize the content widget
   182 	mAgendaViewWidget->showWidget();
   214 	mAgendaViewWidget->showWidget();
       
   215 	
       
   216 	OstTraceFunctionExit0( CALENAGENDAVIEW_REFRESHVIEWONGOTODATE_EXIT );
   183 }
   217 }
   184 
   218 
   185 // ----------------------------------------------------------------------------
   219 // ----------------------------------------------------------------------------
   186 // CalenAgendaView::HandleNotification
   220 // CalenAgendaView::HandleNotification
   187 // Rest of the details are commented in the header
   221 // Rest of the details are commented in the header
   188 // ----------------------------------------------------------------------------
   222 // ----------------------------------------------------------------------------
   189 //    
   223 //    
   190 void CalenAgendaView::HandleNotification(const TCalenNotification notification)
   224 void CalenAgendaView::HandleNotification(const TCalenNotification notification)
   191 {
   225 {
       
   226     OstTraceFunctionEntry0( CALENAGENDAVIEW_HANDLENOTIFICATION_ENTRY );
       
   227     
   192     Q_UNUSED(notification)
   228     Q_UNUSED(notification)
   193     // No implementation yet
   229     // No implementation yet
       
   230     OstTraceFunctionExit0( CALENAGENDAVIEW_HANDLENOTIFICATION_EXIT );
   194 }
   231 }
   195 
   232 
   196 // ----------------------------------------------------------------------------
   233 // ----------------------------------------------------------------------------
   197 // CalenAgendaView::docLoader
   234 // CalenAgendaView::docLoader
   198 // Rest of the details are commented in the header
   235 // Rest of the details are commented in the header
   199 // ----------------------------------------------------------------------------
   236 // ----------------------------------------------------------------------------
   200 //    
   237 //    
   201 CalenDocLoader* CalenAgendaView::docLoader()
   238 CalenDocLoader* CalenAgendaView::docLoader()
   202 {
   239 {
       
   240     OstTraceFunctionEntry0( CALENAGENDAVIEW_DOCLOADER_ENTRY );
       
   241     
       
   242     OstTraceFunctionExit0( CALENAGENDAVIEW_DOCLOADER_EXIT );
   203     return mDocLoader;
   243     return mDocLoader;
   204 }
   244 }
   205 
   245 
   206 /*
   246 /*
   207 	Function to listen for gestures
   247 	Function to listen for gestures
   208 */
   248 */
   209 void CalenAgendaView::gestureEvent(QGestureEvent *event)
   249 void CalenAgendaView::gestureEvent(QGestureEvent *event)
   210 {
   250 {
       
   251     OstTraceFunctionEntry0( CALENAGENDAVIEW_GESTUREEVENT_ENTRY );
       
   252     
   211     if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) {
   253     if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) {
   212         if (gesture->state() == Qt::GestureStarted) {
   254         if (gesture->state() == Qt::GestureStarted) {
   213             if(QSwipeGesture::Left == gesture->sceneHorizontalDirection()) {
   255             if(QSwipeGesture::Left == gesture->sceneHorizontalDirection()) {
   214                 mServices.IssueCommandL(ECalenShowNextDay);
   256                 mServices.IssueCommandL(ECalenShowNextDay);
   215                 event->accept(Qt::SwipeGesture);
   257                 event->accept(Qt::SwipeGesture);
   217                 mServices.IssueCommandL(ECalenShowPrevDay);
   259                 mServices.IssueCommandL(ECalenShowPrevDay);
   218                event->accept(Qt::SwipeGesture);
   260                event->accept(Qt::SwipeGesture);
   219             }
   261             }
   220         }
   262         }
   221     } 
   263     } 
       
   264     
       
   265     OstTraceFunctionExit0( CALENAGENDAVIEW_GESTUREEVENT_EXIT );
   222 }
   266 }
   223 
   267 
   224 // ----------------------------------------------------------------------------
   268 // ----------------------------------------------------------------------------
   225 // CalenAgendaView::createToolBar
   269 // CalenAgendaView::createToolBar
   226 // Rest of the details are commented in the header
   270 // Rest of the details are commented in the header
   227 // ----------------------------------------------------------------------------
   271 // ----------------------------------------------------------------------------
   228 //
   272 //
   229 void CalenAgendaView::setupActions()
   273 void CalenAgendaView::setupActions()
   230 {
   274 {
       
   275     OstTraceFunctionEntry0( CALENAGENDAVIEW_SETUPACTIONS_ENTRY );
       
   276     
   231 	// Get the actions associated with this view
   277 	// Get the actions associated with this view
   232 	HbAction *newEventAction = qobject_cast<HbAction *>
   278 	HbAction *newEventAction = qobject_cast<HbAction *>
   233                                 (mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_NEW_EVENT));
   279                                 (mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_NEW_EVENT));
   234 	if (!newEventAction) {
   280 	if (!newEventAction) {
   235 	    qFatal("calenagendaview.cpp : Unable to find new event action");
   281 	    qFatal("calenagendaview.cpp : Unable to find new event action");
   236 	}
   282 	}
   237 	// Connect to the signal triggered by new event action
   283 	// Connect to the signal triggered by new event action
   238 	connect(newEventAction, SIGNAL(triggered()), mAgendaViewWidget, SLOT(createNewEvent()));
   284 	connect(newEventAction, SIGNAL(triggered()), this, SLOT(createNewEvent()));
   239 	
   285 	    
   240 	mGoToTodayAction = qobject_cast<HbAction *>
   286 	mGoToTodayAction = qobject_cast<HbAction *>
   241                         (mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_GO_TO_TODAY));
   287                         (mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_GO_TO_TODAY));
   242 	if (!mGoToTodayAction) {
   288 	if (!mGoToTodayAction) {
   243 	    qFatal("calenagendaview.cpp : Unable to find go to today action");
   289 	    qFatal("calenagendaview.cpp : Unable to find go to today action");
   244 	}
   290 	}
   266 	if (!settingsAction) {
   312 	if (!settingsAction) {
   267 	    qFatal("calenagendaview.cpp : Unable to find settings action");
   313 	    qFatal("calenagendaview.cpp : Unable to find settings action");
   268 	}
   314 	}
   269 	// Connect to the signal triggered by settings action
   315 	// Connect to the signal triggered by settings action
   270 	connect(settingsAction, SIGNAL(triggered()), this, SLOT(launchSettingsView()));
   316 	connect(settingsAction, SIGNAL(triggered()), this, SLOT(launchSettingsView()));
       
   317 	
       
   318 	OstTraceFunctionExit0( CALENAGENDAVIEW_SETUPACTIONS_EXIT );
       
   319 }
       
   320 
       
   321 // ----------------------------------------------------------------------------
       
   322 // CalenAgendaView::createNewEvent
       
   323 // ----------------------------------------------------------------------------
       
   324 //    
       
   325 void CalenAgendaView::createNewEvent()
       
   326 {
       
   327     captureScreenshot(true);
       
   328     mAgendaViewWidget->createNewEvent();
   271 }
   329 }
   272 
   330 
   273 // ----------------------------------------------------------------------------
   331 // ----------------------------------------------------------------------------
   274 // CalenAgendaView::onLocaleChanged
   332 // CalenAgendaView::onLocaleChanged
   275 // Rest of the details are commented in the header
   333 // Rest of the details are commented in the header
   276 // ----------------------------------------------------------------------------
   334 // ----------------------------------------------------------------------------
   277 //    
   335 //    
   278 void CalenAgendaView::onLocaleChanged(int reason)
   336 void CalenAgendaView::onLocaleChanged(int reason)
   279 {
   337 {
       
   338     OstTraceFunctionEntry0( CALENAGENDAVIEW_ONLOCALECHANGED_ENTRY );
       
   339     
   280     Q_UNUSED(reason)
   340     Q_UNUSED(reason)
   281     // Notify the content widget about the change
   341     // Notify the content widget about the change
   282     if(mAgendaViewWidget) {
   342     if(mAgendaViewWidget) {
   283     mAgendaViewWidget->handleLocaleChange();
   343     mAgendaViewWidget->handleLocaleChange();
   284     }
   344     }
       
   345     
       
   346     OstTraceFunctionExit0( CALENAGENDAVIEW_ONLOCALECHANGED_EXIT );
   285 }
   347 }
   286 
   348 
   287 // ----------------------------------------------------------------------------
   349 // ----------------------------------------------------------------------------
   288 // CalenAgendaView::orientationChanged
   350 // CalenAgendaView::orientationChanged
   289 // Rest of the details are commented in the header
   351 // Rest of the details are commented in the header
   290 // ----------------------------------------------------------------------------
   352 // ----------------------------------------------------------------------------
   291 // 
   353 // 
   292 void CalenAgendaView::orientationChanged(Qt::Orientation orientation)
   354 void CalenAgendaView::orientationChanged(Qt::Orientation orientation)
   293 {
   355 {
       
   356     OstTraceFunctionEntry0( CALENAGENDAVIEW_ORIENTATIONCHANGED_ENTRY );
       
   357     
   294     // Notify the content widget about the change
   358     // Notify the content widget about the change
   295     if (mAgendaViewWidget) {
   359     if (mAgendaViewWidget) {
   296     mAgendaViewWidget->orientationChanged(orientation);
   360     mAgendaViewWidget->orientationChanged(orientation);
   297     }
   361     }
       
   362     OstTraceFunctionExit0( CALENAGENDAVIEW_ORIENTATIONCHANGED_EXIT );
   298 }
   363 }
   299 
   364 
   300 // ----------------------------------------------------------------------------
   365 // ----------------------------------------------------------------------------
   301 // CalenAgendaView::launchMonthView
   366 // CalenAgendaView::launchMonthView
   302 // ----------------------------------------------------------------------------
   367 // ----------------------------------------------------------------------------
   303 //    
   368 //    
   304 void CalenAgendaView::launchMonthView()
   369 void CalenAgendaView::launchMonthView()
   305 {
   370 {
       
   371     OstTraceFunctionEntry0( CALENAGENDAVIEW_LAUNCHMONTHVIEW_ENTRY );
       
   372     
   306     // Issue the command to launch the month view
   373     // Issue the command to launch the month view
   307     mServices.IssueCommandL(ECalenMonthView);
   374     mServices.IssueCommandL(ECalenMonthView);
   308 	// month view launched now, disconnect to get the call backs for saveActivity 
   375 	// month view launched now, disconnect to get the call backs for saveActivity 
   309 	// on aboutToQuit signal
   376 	// on aboutToQuit signal
   310     disconnectAboutToQuitEvent();
   377     disconnectAboutToQuitEvent();
       
   378     
       
   379     OstTraceFunctionExit0( CALENAGENDAVIEW_LAUNCHMONTHVIEW_EXIT );
   311 }
   380 }
   312 
   381 
   313 // ----------------------------------------------------------------------------
   382 // ----------------------------------------------------------------------------
   314 // CalenAgendaView::launchDayView
   383 // CalenAgendaView::launchDayView
   315 // ----------------------------------------------------------------------------
   384 // ----------------------------------------------------------------------------
   316 //    
   385 //    
   317 void CalenAgendaView::launchDayView()
   386 void CalenAgendaView::launchDayView()
   318 {
   387 {
       
   388     OstTraceFunctionEntry0( CALENAGENDAVIEW_LAUNCHDAYVIEW_ENTRY );
       
   389     
   319     // Issue the command to launch the day view
   390     // Issue the command to launch the day view
   320     mServices.IssueCommandL(ECalenDayView);
   391     mServices.IssueCommandL(ECalenDayView);
       
   392     
       
   393     OstTraceFunctionExit0( CALENAGENDAVIEW_LAUNCHDAYVIEW_EXIT );
   321 }
   394 }
   322 
   395 
   323 // ----------------------------------------------------------------------------
   396 // ----------------------------------------------------------------------------
   324 // clears the list model 
   397 // clears the list model 
   325 // ----------------------------------------------------------------------------
   398 // ----------------------------------------------------------------------------
   326 // 
   399 // 
   327 void CalenAgendaView::clearListModel()
   400 void CalenAgendaView::clearListModel()
   328     {
   401     {
       
   402     OstTraceFunctionEntry0( CALENAGENDAVIEW_CLEARLISTMODEL_ENTRY );
       
   403     
   329 	// day view is removed from the list disconnect for aboutToQuit events
   404 	// day view is removed from the list disconnect for aboutToQuit events
   330     disconnectAboutToQuitEvent();
   405     disconnectAboutToQuitEvent();
   331     mAgendaViewWidget->clearListModel();
   406     mAgendaViewWidget->clearListModel();
       
   407     
       
   408     OstTraceFunctionExit0( CALENAGENDAVIEW_CLEARLISTMODEL_EXIT );
   332     }
   409     }
   333 
   410 
   334 // ----------------------------------------------------------------------------
   411 // ----------------------------------------------------------------------------
   335 // disconnectAboutToQuitEvent disconnects for the aboutToQuit events
   412 // disconnectAboutToQuitEvent disconnects for the aboutToQuit events
   336 // ----------------------------------------------------------------------------
   413 // ----------------------------------------------------------------------------
   337 // 
   414 // 
   338 void CalenAgendaView::disconnectAboutToQuitEvent()
   415 void CalenAgendaView::disconnectAboutToQuitEvent()
   339     {
   416     {
       
   417     OstTraceFunctionEntry0( CALENAGENDAVIEW_DISCONNECTABOUTTOQUITEVENT_ENTRY );
       
   418     
   340     if (mIsAboutToQuitEventConnected)
   419     if (mIsAboutToQuitEventConnected)
   341         {
   420         {
   342         disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
   421         disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
   343         mIsAboutToQuitEventConnected = false;
   422         mIsAboutToQuitEventConnected = false;
   344         }
   423         }
       
   424     
       
   425     OstTraceFunctionExit0( CALENAGENDAVIEW_DISCONNECTABOUTTOQUITEVENT_EXIT );
   345     }
   426     }
   346 
   427 
   347 // End of file	--Don't remove this.
   428 // End of file	--Don't remove this.