45
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: CalenAgendaView implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
#include <QGraphicsSceneEvent>
|
|
20 |
#include <hbmainwindow.h>
|
70
|
21 |
#include <hbmenu.h>
|
45
|
22 |
#include <hbaction.h>
|
|
23 |
#include <hbpangesture.h>
|
|
24 |
#include <hbswipegesture.h>
|
|
25 |
#include <hbapplication.h> // hbapplication
|
|
26 |
#include <hbactivitymanager.h> // Activity Manager
|
|
27 |
|
|
28 |
// User includes
|
|
29 |
#include "calenagendaview.h"
|
|
30 |
#include "calendocloader.h"
|
|
31 |
#include "calenagendaviewwidget.h"
|
|
32 |
#include "calenservices.h"
|
|
33 |
#include "calencommon.h"
|
|
34 |
#include "calencontext.h"
|
|
35 |
#include "calendateutils.h"
|
|
36 |
#include "calenconstants.h"
|
51
|
37 |
#include "OstTraceDefinitions.h"
|
|
38 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
39 |
#include "calenagendaviewTraces.h"
|
|
40 |
#endif
|
|
41 |
|
45
|
42 |
|
|
43 |
// ----------------------------------------------------------------------------
|
|
44 |
// CalenAgendaView::CalenAgendaView
|
|
45 |
// Rest of the details are commented in the header
|
|
46 |
// ----------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
CalenAgendaView::CalenAgendaView(MCalenServices &services):
|
|
49 |
CalenNativeView(services),
|
|
50 |
mSoftKeyAction(NULL),
|
|
51 |
mGoToTodayAction(NULL),
|
|
52 |
mSwitchToDayViewAction(NULL),
|
|
53 |
mActionTaken(false),
|
|
54 |
mIsAboutToQuitEventConnected(false)
|
|
55 |
{
|
51
|
56 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_CALENAGENDAVIEW_ENTRY );
|
|
57 |
|
45
|
58 |
// No implementation yet
|
|
59 |
grabGesture(Qt::SwipeGesture);
|
51
|
60 |
|
|
61 |
OstTraceFunctionExit0( CALENAGENDAVIEW_CALENAGENDAVIEW_EXIT );
|
45
|
62 |
}
|
|
63 |
|
|
64 |
// ----------------------------------------------------------------------------
|
|
65 |
// CalenAgendaView::~CalenAgendaView
|
|
66 |
// Rest of the details are commented in the header
|
|
67 |
// ----------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
CalenAgendaView::~CalenAgendaView()
|
|
70 |
{
|
51
|
71 |
OstTraceFunctionEntry0( DUP1_CALENAGENDAVIEW_CALENAGENDAVIEW_ENTRY );
|
|
72 |
|
45
|
73 |
// No implementation yet
|
51
|
74 |
|
|
75 |
OstTraceFunctionExit0( DUP1_CALENAGENDAVIEW_CALENAGENDAVIEW_EXIT );
|
45
|
76 |
}
|
|
77 |
|
|
78 |
// ----------------------------------------------------------------------------
|
|
79 |
// CalenAgendaView::setupView
|
|
80 |
// Rest of the details are commented in the header
|
|
81 |
// ----------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
void CalenAgendaView::setupView(CalenDocLoader *docLoader)
|
|
84 |
{
|
51
|
85 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_SETUPVIEW_ENTRY );
|
|
86 |
|
45
|
87 |
if (!docLoader) {
|
|
88 |
// Nothing can be done. Simply return
|
51
|
89 |
OstTraceFunctionExit0( CALENAGENDAVIEW_SETUPVIEW_EXIT );
|
45
|
90 |
return;
|
|
91 |
}
|
|
92 |
// Store the document loader for reference later
|
|
93 |
mDocLoader = docLoader;
|
|
94 |
|
|
95 |
// Listen to orientation change events
|
|
96 |
connect(&(mServices.MainWindow()), SIGNAL(orientationChanged(Qt::Orientation)),
|
|
97 |
this, SLOT(orientationChanged(Qt::Orientation)));
|
|
98 |
|
|
99 |
// Get the pointer to the content widget
|
|
100 |
mAgendaViewWidget = qobject_cast<CalenAgendaViewWidget*>(mDocLoader->findWidget(CALEN_AGENDAVIEW_WIDGET));
|
|
101 |
if (!mAgendaViewWidget) {
|
|
102 |
qFatal("calenagendaview.cpp : Unable to find the content widget");
|
|
103 |
}
|
|
104 |
mAgendaViewWidget->setupWidget(this);
|
|
105 |
|
|
106 |
// Initialize all the menu and toolbar actions
|
|
107 |
setupActions();
|
51
|
108 |
|
|
109 |
//add "show lunar data" action item ,if regional plugin is present
|
|
110 |
//regional plugin will add the option itself and handles it accordingly
|
|
111 |
//use this api after adding all action item to the menu
|
|
112 |
//so that plugin add the "Show lunar data" item as a second last option
|
|
113 |
// in all views
|
|
114 |
mServices.OfferMenu(menu());
|
|
115 |
|
45
|
116 |
// get a poitner to activity manager
|
|
117 |
HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
|
|
118 |
|
|
119 |
// clean up any previous versions of this activity, if any, i.e. activityName, from the activity manager.
|
|
120 |
// Ignore return value, first boot would always return False. bool declared
|
|
121 |
// only for debugging purpose.
|
|
122 |
bool ok = activityManager->removeActivity(activityName);
|
|
123 |
|
51
|
124 |
OstTraceFunctionExit0( DUP1_CALENAGENDAVIEW_SETUPVIEW_EXIT );
|
45
|
125 |
}
|
|
126 |
|
|
127 |
// ----------------------------------------------------------------------------
|
|
128 |
// CalenAgendaView::doPopulation
|
|
129 |
// Rest of the details are commented in the header
|
|
130 |
// ----------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CalenAgendaView::doPopulation()
|
|
133 |
{
|
51
|
134 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_DOPOPULATION_ENTRY );
|
|
135 |
|
45
|
136 |
// The content widget has not been constructed. Don't do anything
|
|
137 |
if (!mAgendaViewWidget) {
|
51
|
138 |
OstTraceFunctionExit0( CALENAGENDAVIEW_DOPOPULATION_EXIT );
|
45
|
139 |
return;
|
|
140 |
}
|
|
141 |
// Get the day for which this view is being shown from the context
|
|
142 |
mDate = mServices.Context().focusDateAndTime();
|
|
143 |
|
|
144 |
// Check if the current day being shown is "Today"
|
|
145 |
if (mGoToTodayAction) {
|
|
146 |
if (mDate.date() == CalenDateUtils::today().date()) {
|
|
147 |
// Hide the "Go to today" option
|
|
148 |
mGoToTodayAction->setVisible(false);
|
|
149 |
} else {
|
|
150 |
mGoToTodayAction->setVisible(true);
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
// Set self as the current view
|
|
155 |
// mServices.MainWindow().setCurrentView(this);
|
|
156 |
|
|
157 |
// Dont override the soft key behavior if day view is the first view
|
|
158 |
if (ECalenAgendaView != mServices.getFirstView()) {
|
|
159 |
mSoftKeyAction = new HbAction(Hb::BackNaviAction);
|
|
160 |
setNavigationAction(mSoftKeyAction);
|
|
161 |
// Connect to the signal triggered by clicking on back button.
|
|
162 |
connect(mSoftKeyAction, SIGNAL(triggered()), this,
|
|
163 |
SLOT(launchMonthView()));
|
|
164 |
if (mSwitchToDayViewAction) {
|
|
165 |
mSwitchToDayViewAction->setVisible(true);
|
|
166 |
}
|
|
167 |
} else {
|
|
168 |
if (mSwitchToDayViewAction) {
|
|
169 |
mSwitchToDayViewAction->setVisible(false);
|
|
170 |
}
|
|
171 |
}
|
|
172 |
// Initialize the content widget
|
|
173 |
mAgendaViewWidget->showWidget();
|
|
174 |
|
|
175 |
//set Current Activity as day view
|
|
176 |
mActivityId = ECalenAgendaView;
|
|
177 |
|
|
178 |
// connect to receive a call back on Day View exit. Call back would result in saveActivity
|
|
179 |
// to be called in Native View
|
|
180 |
if (!mIsAboutToQuitEventConnected) // check if already not connected
|
|
181 |
{
|
|
182 |
connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
|
|
183 |
mIsAboutToQuitEventConnected = true;
|
|
184 |
}
|
|
185 |
|
|
186 |
|
|
187 |
// Population is complete, issue a notification
|
|
188 |
populationComplete();
|
51
|
189 |
|
|
190 |
OstTraceFunctionExit0( DUP1_CALENAGENDAVIEW_DOPOPULATION_EXIT );
|
45
|
191 |
}
|
|
192 |
|
|
193 |
/*!
|
|
194 |
Funtion to refresh the current view upon selecting a date
|
|
195 |
from GoToDate popup
|
|
196 |
*/
|
|
197 |
void CalenAgendaView::refreshViewOnGoToDate()
|
|
198 |
{
|
51
|
199 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_REFRESHVIEWONGOTODATE_ENTRY );
|
|
200 |
|
45
|
201 |
// Get the day for which this view is being shown from the context
|
|
202 |
mDate = mServices.Context().focusDateAndTime();
|
|
203 |
|
|
204 |
// Check if the current day being shown is "Today"
|
|
205 |
if (mGoToTodayAction) {
|
|
206 |
if (mDate.date() == CalenDateUtils::today().date()) {
|
|
207 |
// Hide the "Go to today" option
|
|
208 |
mGoToTodayAction->setVisible(false);
|
|
209 |
} else {
|
|
210 |
mGoToTodayAction->setVisible(true);
|
|
211 |
}
|
|
212 |
}
|
|
213 |
|
|
214 |
// Initialize the content widget
|
|
215 |
mAgendaViewWidget->showWidget();
|
51
|
216 |
|
|
217 |
OstTraceFunctionExit0( CALENAGENDAVIEW_REFRESHVIEWONGOTODATE_EXIT );
|
45
|
218 |
}
|
|
219 |
|
|
220 |
// ----------------------------------------------------------------------------
|
|
221 |
// CalenAgendaView::docLoader
|
|
222 |
// Rest of the details are commented in the header
|
|
223 |
// ----------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
CalenDocLoader* CalenAgendaView::docLoader()
|
|
226 |
{
|
51
|
227 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_DOCLOADER_ENTRY );
|
|
228 |
|
|
229 |
OstTraceFunctionExit0( CALENAGENDAVIEW_DOCLOADER_EXIT );
|
45
|
230 |
return mDocLoader;
|
|
231 |
}
|
|
232 |
|
|
233 |
/*
|
|
234 |
Function to listen for gestures
|
|
235 |
*/
|
|
236 |
void CalenAgendaView::gestureEvent(QGestureEvent *event)
|
|
237 |
{
|
51
|
238 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_GESTUREEVENT_ENTRY );
|
|
239 |
|
45
|
240 |
if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) {
|
|
241 |
if (gesture->state() == Qt::GestureStarted) {
|
|
242 |
if(QSwipeGesture::Left == gesture->sceneHorizontalDirection()) {
|
|
243 |
mServices.IssueCommandL(ECalenShowNextDay);
|
|
244 |
event->accept(Qt::SwipeGesture);
|
|
245 |
} else if(QSwipeGesture::Right == gesture->sceneHorizontalDirection()) {
|
|
246 |
mServices.IssueCommandL(ECalenShowPrevDay);
|
|
247 |
event->accept(Qt::SwipeGesture);
|
|
248 |
}
|
|
249 |
}
|
|
250 |
}
|
51
|
251 |
|
|
252 |
OstTraceFunctionExit0( CALENAGENDAVIEW_GESTUREEVENT_EXIT );
|
45
|
253 |
}
|
|
254 |
|
|
255 |
// ----------------------------------------------------------------------------
|
|
256 |
// CalenAgendaView::createToolBar
|
|
257 |
// Rest of the details are commented in the header
|
|
258 |
// ----------------------------------------------------------------------------
|
|
259 |
//
|
|
260 |
void CalenAgendaView::setupActions()
|
|
261 |
{
|
51
|
262 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_SETUPACTIONS_ENTRY );
|
|
263 |
|
45
|
264 |
// Get the actions associated with this view
|
|
265 |
HbAction *newEventAction = qobject_cast<HbAction *>
|
|
266 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_NEW_EVENT));
|
|
267 |
if (!newEventAction) {
|
|
268 |
qFatal("calenagendaview.cpp : Unable to find new event action");
|
|
269 |
}
|
|
270 |
// Connect to the signal triggered by new event action
|
51
|
271 |
connect(newEventAction, SIGNAL(triggered()), this, SLOT(createNewEvent()));
|
|
272 |
|
45
|
273 |
mGoToTodayAction = qobject_cast<HbAction *>
|
|
274 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_GO_TO_TODAY));
|
|
275 |
if (!mGoToTodayAction) {
|
|
276 |
qFatal("calenagendaview.cpp : Unable to find go to today action");
|
|
277 |
}
|
|
278 |
// Connect to the signal triggered by go to Today action
|
|
279 |
connect(mGoToTodayAction, SIGNAL(triggered()), mAgendaViewWidget, SLOT(goToToday()));
|
|
280 |
|
|
281 |
HbAction *goToDateAction = qobject_cast<HbAction *>
|
|
282 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_GO_TO_DATE));
|
|
283 |
if (!goToDateAction) {
|
|
284 |
qFatal("calenagendaview.cpp : Unable to find go to date action");
|
|
285 |
}
|
|
286 |
// Connect to the signal triggered by go to Date action
|
|
287 |
connect(goToDateAction, SIGNAL(triggered()), this, SLOT(goToDate()));
|
|
288 |
|
|
289 |
mSwitchToDayViewAction = qobject_cast<HbAction *>
|
|
290 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_SWITCH_TO_DAYVIEW));
|
|
291 |
if (!mSwitchToDayViewAction) {
|
|
292 |
qFatal("calenagendaview.cpp : Unable to find go to date action");
|
|
293 |
}
|
|
294 |
// Connect to the signal triggered by switch to dayview action
|
|
295 |
connect(mSwitchToDayViewAction, SIGNAL(triggered()), this, SLOT(launchDayView()));
|
|
296 |
|
|
297 |
HbAction *settingsAction = qobject_cast<HbAction *>
|
|
298 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_SETTINGS));
|
|
299 |
if (!settingsAction) {
|
|
300 |
qFatal("calenagendaview.cpp : Unable to find settings action");
|
|
301 |
}
|
|
302 |
// Connect to the signal triggered by settings action
|
|
303 |
connect(settingsAction, SIGNAL(triggered()), this, SLOT(launchSettingsView()));
|
51
|
304 |
|
70
|
305 |
// Close the menu once closeDialogs() is received
|
|
306 |
connect(this, SIGNAL(closeDialogs()), menu(), SLOT(close()));
|
51
|
307 |
OstTraceFunctionExit0( CALENAGENDAVIEW_SETUPACTIONS_EXIT );
|
|
308 |
}
|
|
309 |
|
|
310 |
// ----------------------------------------------------------------------------
|
|
311 |
// CalenAgendaView::createNewEvent
|
|
312 |
// ----------------------------------------------------------------------------
|
|
313 |
//
|
|
314 |
void CalenAgendaView::createNewEvent()
|
|
315 |
{
|
|
316 |
captureScreenshot(true);
|
|
317 |
mAgendaViewWidget->createNewEvent();
|
45
|
318 |
}
|
|
319 |
|
|
320 |
// ----------------------------------------------------------------------------
|
|
321 |
// CalenAgendaView::onLocaleChanged
|
|
322 |
// Rest of the details are commented in the header
|
|
323 |
// ----------------------------------------------------------------------------
|
|
324 |
//
|
|
325 |
void CalenAgendaView::onLocaleChanged(int reason)
|
|
326 |
{
|
51
|
327 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_ONLOCALECHANGED_ENTRY );
|
|
328 |
|
45
|
329 |
Q_UNUSED(reason)
|
|
330 |
// Notify the content widget about the change
|
|
331 |
if(mAgendaViewWidget) {
|
|
332 |
mAgendaViewWidget->handleLocaleChange();
|
|
333 |
}
|
51
|
334 |
|
|
335 |
OstTraceFunctionExit0( CALENAGENDAVIEW_ONLOCALECHANGED_EXIT );
|
45
|
336 |
}
|
|
337 |
|
|
338 |
// ----------------------------------------------------------------------------
|
|
339 |
// CalenAgendaView::orientationChanged
|
|
340 |
// Rest of the details are commented in the header
|
|
341 |
// ----------------------------------------------------------------------------
|
|
342 |
//
|
|
343 |
void CalenAgendaView::orientationChanged(Qt::Orientation orientation)
|
|
344 |
{
|
51
|
345 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_ORIENTATIONCHANGED_ENTRY );
|
|
346 |
|
45
|
347 |
// Notify the content widget about the change
|
|
348 |
if (mAgendaViewWidget) {
|
|
349 |
mAgendaViewWidget->orientationChanged(orientation);
|
|
350 |
}
|
51
|
351 |
OstTraceFunctionExit0( CALENAGENDAVIEW_ORIENTATIONCHANGED_EXIT );
|
45
|
352 |
}
|
|
353 |
|
|
354 |
// ----------------------------------------------------------------------------
|
|
355 |
// CalenAgendaView::launchMonthView
|
|
356 |
// ----------------------------------------------------------------------------
|
|
357 |
//
|
|
358 |
void CalenAgendaView::launchMonthView()
|
|
359 |
{
|
51
|
360 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_LAUNCHMONTHVIEW_ENTRY );
|
|
361 |
|
45
|
362 |
// Issue the command to launch the month view
|
|
363 |
mServices.IssueCommandL(ECalenMonthView);
|
|
364 |
// month view launched now, disconnect to get the call backs for saveActivity
|
|
365 |
// on aboutToQuit signal
|
|
366 |
disconnectAboutToQuitEvent();
|
51
|
367 |
|
|
368 |
OstTraceFunctionExit0( CALENAGENDAVIEW_LAUNCHMONTHVIEW_EXIT );
|
45
|
369 |
}
|
|
370 |
|
|
371 |
// ----------------------------------------------------------------------------
|
|
372 |
// CalenAgendaView::launchDayView
|
|
373 |
// ----------------------------------------------------------------------------
|
|
374 |
//
|
|
375 |
void CalenAgendaView::launchDayView()
|
|
376 |
{
|
51
|
377 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_LAUNCHDAYVIEW_ENTRY );
|
|
378 |
|
45
|
379 |
// Issue the command to launch the day view
|
|
380 |
mServices.IssueCommandL(ECalenDayView);
|
51
|
381 |
|
|
382 |
OstTraceFunctionExit0( CALENAGENDAVIEW_LAUNCHDAYVIEW_EXIT );
|
45
|
383 |
}
|
|
384 |
|
|
385 |
// ----------------------------------------------------------------------------
|
|
386 |
// clears the list model
|
|
387 |
// ----------------------------------------------------------------------------
|
|
388 |
//
|
|
389 |
void CalenAgendaView::clearListModel()
|
|
390 |
{
|
51
|
391 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_CLEARLISTMODEL_ENTRY );
|
|
392 |
|
45
|
393 |
// day view is removed from the list disconnect for aboutToQuit events
|
|
394 |
disconnectAboutToQuitEvent();
|
|
395 |
mAgendaViewWidget->clearListModel();
|
51
|
396 |
|
|
397 |
OstTraceFunctionExit0( CALENAGENDAVIEW_CLEARLISTMODEL_EXIT );
|
45
|
398 |
}
|
|
399 |
|
|
400 |
// ----------------------------------------------------------------------------
|
|
401 |
// disconnectAboutToQuitEvent disconnects for the aboutToQuit events
|
|
402 |
// ----------------------------------------------------------------------------
|
|
403 |
//
|
|
404 |
void CalenAgendaView::disconnectAboutToQuitEvent()
|
|
405 |
{
|
51
|
406 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_DISCONNECTABOUTTOQUITEVENT_ENTRY );
|
|
407 |
|
45
|
408 |
if (mIsAboutToQuitEventConnected)
|
|
409 |
{
|
|
410 |
disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
|
|
411 |
mIsAboutToQuitEventConnected = false;
|
|
412 |
}
|
51
|
413 |
|
|
414 |
OstTraceFunctionExit0( CALENAGENDAVIEW_DISCONNECTABOUTTOQUITEVENT_EXIT );
|
45
|
415 |
}
|
|
416 |
|
|
417 |
// End of file --Don't remove this.
|