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
|
81
|
26 |
|
45
|
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),
|
83
|
54 |
mIsAboutToQuitEventConnected(false)
|
45
|
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 |
|
81
|
116 |
// clean up any previous versions of this activity, if any, i.e. activityName,
|
45
|
117 |
// Ignore return value, first boot would always return False. bool declared
|
|
118 |
// only for debugging purpose.
|
81
|
119 |
bool ok = removeActivity();
|
51
|
120 |
OstTraceFunctionExit0( DUP1_CALENAGENDAVIEW_SETUPVIEW_EXIT );
|
45
|
121 |
}
|
|
122 |
|
|
123 |
// ----------------------------------------------------------------------------
|
|
124 |
// CalenAgendaView::doPopulation
|
|
125 |
// Rest of the details are commented in the header
|
|
126 |
// ----------------------------------------------------------------------------
|
|
127 |
//
|
|
128 |
void CalenAgendaView::doPopulation()
|
|
129 |
{
|
51
|
130 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_DOPOPULATION_ENTRY );
|
83
|
131 |
|
45
|
132 |
// The content widget has not been constructed. Don't do anything
|
|
133 |
if (!mAgendaViewWidget) {
|
51
|
134 |
OstTraceFunctionExit0( CALENAGENDAVIEW_DOPOPULATION_EXIT );
|
45
|
135 |
return;
|
|
136 |
}
|
|
137 |
// Get the day for which this view is being shown from the context
|
|
138 |
mDate = mServices.Context().focusDateAndTime();
|
|
139 |
|
|
140 |
// Check if the current day being shown is "Today"
|
|
141 |
if (mGoToTodayAction) {
|
|
142 |
if (mDate.date() == CalenDateUtils::today().date()) {
|
|
143 |
// Hide the "Go to today" option
|
|
144 |
mGoToTodayAction->setVisible(false);
|
|
145 |
} else {
|
|
146 |
mGoToTodayAction->setVisible(true);
|
|
147 |
}
|
|
148 |
}
|
|
149 |
|
|
150 |
// Set self as the current view
|
|
151 |
// mServices.MainWindow().setCurrentView(this);
|
|
152 |
|
75
|
153 |
// Dont override the soft key behavior if day view or agenda view is the first view
|
|
154 |
if (ECalenMonthView == mServices.getFirstView()) {
|
45
|
155 |
mSoftKeyAction = new HbAction(Hb::BackNaviAction);
|
|
156 |
setNavigationAction(mSoftKeyAction);
|
|
157 |
// Connect to the signal triggered by clicking on back button.
|
|
158 |
connect(mSoftKeyAction, SIGNAL(triggered()), this,
|
|
159 |
SLOT(launchMonthView()));
|
|
160 |
}
|
75
|
161 |
|
45
|
162 |
// Initialize the content widget
|
|
163 |
mAgendaViewWidget->showWidget();
|
|
164 |
|
|
165 |
//set Current Activity as day view
|
|
166 |
mActivityId = ECalenAgendaView;
|
|
167 |
|
|
168 |
// connect to receive a call back on Day View exit. Call back would result in saveActivity
|
|
169 |
// to be called in Native View
|
|
170 |
if (!mIsAboutToQuitEventConnected) // check if already not connected
|
|
171 |
{
|
|
172 |
connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
|
|
173 |
mIsAboutToQuitEventConnected = true;
|
|
174 |
}
|
|
175 |
|
|
176 |
|
|
177 |
// Population is complete, issue a notification
|
|
178 |
populationComplete();
|
83
|
179 |
|
51
|
180 |
OstTraceFunctionExit0( DUP1_CALENAGENDAVIEW_DOPOPULATION_EXIT );
|
45
|
181 |
}
|
|
182 |
|
|
183 |
/*!
|
|
184 |
Funtion to refresh the current view upon selecting a date
|
|
185 |
from GoToDate popup
|
|
186 |
*/
|
|
187 |
void CalenAgendaView::refreshViewOnGoToDate()
|
|
188 |
{
|
51
|
189 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_REFRESHVIEWONGOTODATE_ENTRY );
|
|
190 |
|
45
|
191 |
// Get the day for which this view is being shown from the context
|
|
192 |
mDate = mServices.Context().focusDateAndTime();
|
|
193 |
|
|
194 |
// Check if the current day being shown is "Today"
|
|
195 |
if (mGoToTodayAction) {
|
|
196 |
if (mDate.date() == CalenDateUtils::today().date()) {
|
|
197 |
// Hide the "Go to today" option
|
|
198 |
mGoToTodayAction->setVisible(false);
|
|
199 |
} else {
|
|
200 |
mGoToTodayAction->setVisible(true);
|
|
201 |
}
|
|
202 |
}
|
|
203 |
|
|
204 |
// Initialize the content widget
|
|
205 |
mAgendaViewWidget->showWidget();
|
51
|
206 |
|
|
207 |
OstTraceFunctionExit0( CALENAGENDAVIEW_REFRESHVIEWONGOTODATE_EXIT );
|
45
|
208 |
}
|
|
209 |
|
|
210 |
// ----------------------------------------------------------------------------
|
|
211 |
// CalenAgendaView::docLoader
|
|
212 |
// Rest of the details are commented in the header
|
|
213 |
// ----------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
CalenDocLoader* CalenAgendaView::docLoader()
|
|
216 |
{
|
51
|
217 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_DOCLOADER_ENTRY );
|
|
218 |
|
|
219 |
OstTraceFunctionExit0( CALENAGENDAVIEW_DOCLOADER_EXIT );
|
45
|
220 |
return mDocLoader;
|
|
221 |
}
|
|
222 |
|
|
223 |
/*
|
|
224 |
Function to listen for gestures
|
|
225 |
*/
|
|
226 |
void CalenAgendaView::gestureEvent(QGestureEvent *event)
|
|
227 |
{
|
51
|
228 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_GESTUREEVENT_ENTRY );
|
|
229 |
|
45
|
230 |
if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) {
|
|
231 |
if (gesture->state() == Qt::GestureStarted) {
|
|
232 |
if(QSwipeGesture::Left == gesture->sceneHorizontalDirection()) {
|
75
|
233 |
// Check if we can swipe
|
|
234 |
if (checkIfWeCanSwipe(mDate, false)) {
|
|
235 |
mServices.IssueCommandL(ECalenShowNextDay);
|
|
236 |
}
|
45
|
237 |
event->accept(Qt::SwipeGesture);
|
|
238 |
} else if(QSwipeGesture::Right == gesture->sceneHorizontalDirection()) {
|
75
|
239 |
// Check if we can swipe
|
|
240 |
if (checkIfWeCanSwipe(mDate, true)) {
|
|
241 |
mServices.IssueCommandL(ECalenShowPrevDay);
|
|
242 |
}
|
45
|
243 |
event->accept(Qt::SwipeGesture);
|
|
244 |
}
|
|
245 |
}
|
|
246 |
}
|
51
|
247 |
|
|
248 |
OstTraceFunctionExit0( CALENAGENDAVIEW_GESTUREEVENT_EXIT );
|
45
|
249 |
}
|
|
250 |
|
|
251 |
// ----------------------------------------------------------------------------
|
|
252 |
// CalenAgendaView::createToolBar
|
|
253 |
// Rest of the details are commented in the header
|
|
254 |
// ----------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
void CalenAgendaView::setupActions()
|
|
257 |
{
|
51
|
258 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_SETUPACTIONS_ENTRY );
|
|
259 |
|
45
|
260 |
// Get the actions associated with this view
|
|
261 |
HbAction *newEventAction = qobject_cast<HbAction *>
|
|
262 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_NEW_EVENT));
|
|
263 |
if (!newEventAction) {
|
|
264 |
qFatal("calenagendaview.cpp : Unable to find new event action");
|
|
265 |
}
|
|
266 |
// Connect to the signal triggered by new event action
|
51
|
267 |
connect(newEventAction, SIGNAL(triggered()), this, SLOT(createNewEvent()));
|
|
268 |
|
45
|
269 |
mGoToTodayAction = qobject_cast<HbAction *>
|
|
270 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_GO_TO_TODAY));
|
|
271 |
if (!mGoToTodayAction) {
|
|
272 |
qFatal("calenagendaview.cpp : Unable to find go to today action");
|
|
273 |
}
|
|
274 |
// Connect to the signal triggered by go to Today action
|
|
275 |
connect(mGoToTodayAction, SIGNAL(triggered()), mAgendaViewWidget, SLOT(goToToday()));
|
|
276 |
|
|
277 |
HbAction *goToDateAction = qobject_cast<HbAction *>
|
|
278 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_GO_TO_DATE));
|
|
279 |
if (!goToDateAction) {
|
|
280 |
qFatal("calenagendaview.cpp : Unable to find go to date action");
|
|
281 |
}
|
|
282 |
// Connect to the signal triggered by go to Date action
|
|
283 |
connect(goToDateAction, SIGNAL(triggered()), this, SLOT(goToDate()));
|
|
284 |
|
|
285 |
mSwitchToDayViewAction = qobject_cast<HbAction *>
|
|
286 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_SWITCH_TO_DAYVIEW));
|
|
287 |
if (!mSwitchToDayViewAction) {
|
|
288 |
qFatal("calenagendaview.cpp : Unable to find go to date action");
|
|
289 |
}
|
|
290 |
// Connect to the signal triggered by switch to dayview action
|
|
291 |
connect(mSwitchToDayViewAction, SIGNAL(triggered()), this, SLOT(launchDayView()));
|
|
292 |
|
|
293 |
HbAction *settingsAction = qobject_cast<HbAction *>
|
|
294 |
(mDocLoader->findObject(CALEN_AGENDAVIEW_MENU_SETTINGS));
|
|
295 |
if (!settingsAction) {
|
|
296 |
qFatal("calenagendaview.cpp : Unable to find settings action");
|
|
297 |
}
|
|
298 |
// Connect to the signal triggered by settings action
|
|
299 |
connect(settingsAction, SIGNAL(triggered()), this, SLOT(launchSettingsView()));
|
51
|
300 |
|
70
|
301 |
// Close the menu once closeDialogs() is received
|
|
302 |
connect(this, SIGNAL(closeDialogs()), menu(), SLOT(close()));
|
51
|
303 |
OstTraceFunctionExit0( CALENAGENDAVIEW_SETUPACTIONS_EXIT );
|
|
304 |
}
|
|
305 |
|
|
306 |
// ----------------------------------------------------------------------------
|
|
307 |
// CalenAgendaView::createNewEvent
|
|
308 |
// ----------------------------------------------------------------------------
|
|
309 |
//
|
|
310 |
void CalenAgendaView::createNewEvent()
|
|
311 |
{
|
83
|
312 |
captureScreenshot(true);
|
51
|
313 |
mAgendaViewWidget->createNewEvent();
|
45
|
314 |
}
|
|
315 |
|
|
316 |
// ----------------------------------------------------------------------------
|
|
317 |
// CalenAgendaView::onLocaleChanged
|
|
318 |
// Rest of the details are commented in the header
|
|
319 |
// ----------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
void CalenAgendaView::onLocaleChanged(int reason)
|
|
322 |
{
|
51
|
323 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_ONLOCALECHANGED_ENTRY );
|
|
324 |
|
45
|
325 |
Q_UNUSED(reason)
|
|
326 |
// Notify the content widget about the change
|
|
327 |
if(mAgendaViewWidget) {
|
|
328 |
mAgendaViewWidget->handleLocaleChange();
|
|
329 |
}
|
51
|
330 |
|
|
331 |
OstTraceFunctionExit0( CALENAGENDAVIEW_ONLOCALECHANGED_EXIT );
|
45
|
332 |
}
|
|
333 |
|
|
334 |
// ----------------------------------------------------------------------------
|
|
335 |
// CalenAgendaView::orientationChanged
|
|
336 |
// Rest of the details are commented in the header
|
|
337 |
// ----------------------------------------------------------------------------
|
|
338 |
//
|
|
339 |
void CalenAgendaView::orientationChanged(Qt::Orientation orientation)
|
|
340 |
{
|
51
|
341 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_ORIENTATIONCHANGED_ENTRY );
|
|
342 |
|
45
|
343 |
// Notify the content widget about the change
|
|
344 |
if (mAgendaViewWidget) {
|
|
345 |
mAgendaViewWidget->orientationChanged(orientation);
|
|
346 |
}
|
51
|
347 |
OstTraceFunctionExit0( CALENAGENDAVIEW_ORIENTATIONCHANGED_EXIT );
|
45
|
348 |
}
|
|
349 |
|
|
350 |
// ----------------------------------------------------------------------------
|
|
351 |
// CalenAgendaView::launchMonthView
|
|
352 |
// ----------------------------------------------------------------------------
|
|
353 |
//
|
|
354 |
void CalenAgendaView::launchMonthView()
|
|
355 |
{
|
51
|
356 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_LAUNCHMONTHVIEW_ENTRY );
|
|
357 |
|
45
|
358 |
// Issue the command to launch the month view
|
|
359 |
mServices.IssueCommandL(ECalenMonthView);
|
|
360 |
// month view launched now, disconnect to get the call backs for saveActivity
|
|
361 |
// on aboutToQuit signal
|
|
362 |
disconnectAboutToQuitEvent();
|
51
|
363 |
|
|
364 |
OstTraceFunctionExit0( CALENAGENDAVIEW_LAUNCHMONTHVIEW_EXIT );
|
45
|
365 |
}
|
|
366 |
|
|
367 |
// ----------------------------------------------------------------------------
|
|
368 |
// CalenAgendaView::launchDayView
|
|
369 |
// ----------------------------------------------------------------------------
|
|
370 |
//
|
|
371 |
void CalenAgendaView::launchDayView()
|
|
372 |
{
|
51
|
373 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_LAUNCHDAYVIEW_ENTRY );
|
83
|
374 |
|
45
|
375 |
// Issue the command to launch the day view
|
|
376 |
mServices.IssueCommandL(ECalenDayView);
|
51
|
377 |
|
|
378 |
OstTraceFunctionExit0( CALENAGENDAVIEW_LAUNCHDAYVIEW_EXIT );
|
45
|
379 |
}
|
|
380 |
|
|
381 |
// ----------------------------------------------------------------------------
|
|
382 |
// clears the list model
|
|
383 |
// ----------------------------------------------------------------------------
|
|
384 |
//
|
|
385 |
void CalenAgendaView::clearListModel()
|
|
386 |
{
|
51
|
387 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_CLEARLISTMODEL_ENTRY );
|
83
|
388 |
|
45
|
389 |
// day view is removed from the list disconnect for aboutToQuit events
|
|
390 |
disconnectAboutToQuitEvent();
|
|
391 |
mAgendaViewWidget->clearListModel();
|
51
|
392 |
|
|
393 |
OstTraceFunctionExit0( CALENAGENDAVIEW_CLEARLISTMODEL_EXIT );
|
45
|
394 |
}
|
|
395 |
|
|
396 |
// ----------------------------------------------------------------------------
|
|
397 |
// disconnectAboutToQuitEvent disconnects for the aboutToQuit events
|
|
398 |
// ----------------------------------------------------------------------------
|
|
399 |
//
|
|
400 |
void CalenAgendaView::disconnectAboutToQuitEvent()
|
|
401 |
{
|
51
|
402 |
OstTraceFunctionEntry0( CALENAGENDAVIEW_DISCONNECTABOUTTOQUITEVENT_ENTRY );
|
|
403 |
|
45
|
404 |
if (mIsAboutToQuitEventConnected)
|
|
405 |
{
|
|
406 |
disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
|
|
407 |
mIsAboutToQuitEventConnected = false;
|
|
408 |
}
|
51
|
409 |
|
|
410 |
OstTraceFunctionExit0( CALENAGENDAVIEW_DISCONNECTABOUTTOQUITEVENT_EXIT );
|
45
|
411 |
}
|
|
412 |
|
|
413 |
// End of file --Don't remove this.
|