45
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: CalenDayView class definition.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
55
|
18 |
// System includes
|
45
|
19 |
#include <QDateTime>
|
|
20 |
#include <QGraphicsLinearLayout>
|
|
21 |
#include <xqsettingsmanager.h>
|
55
|
22 |
#include <HbWidget>
|
63
|
23 |
#include <HbFrameItem>
|
|
24 |
#include <HbInstance>
|
|
25 |
#include <HbAction>
|
|
26 |
#include <HbMenu>
|
|
27 |
#include <HbMainWindow>
|
|
28 |
#include <HbModelIterator>
|
|
29 |
#include <HbStyleLoader>
|
|
30 |
#include <HbGroupBox>
|
|
31 |
#include <HbExtendedLocale>
|
75
|
32 |
#include <HbModelIterator>
|
45
|
33 |
#include <agendautil.h>
|
55
|
34 |
|
|
35 |
// User includes
|
45
|
36 |
#include "calendayview.h"
|
55
|
37 |
#include "calencommon.h"
|
45
|
38 |
#include "calencontext.h"
|
|
39 |
#include "calenservices.h"
|
|
40 |
#include "calendocloader.h"
|
|
41 |
#include "calendateutils.h" //useful date/time utils
|
|
42 |
#include "calendaycontentscrollarea.h"
|
|
43 |
#include "calendaycontentwidget.h"
|
|
44 |
#include "calendayhourscrollarea.h"
|
75
|
45 |
#include "calendayitemview.h"
|
45
|
46 |
#include "calendaymodelmanager.h"
|
|
47 |
#include "CalenUid.h"
|
|
48 |
#include "CalendarPrivateCRKeys.h"
|
|
49 |
#include "calenpluginlabel.h"
|
|
50 |
#include "calendaymodel.h"
|
63
|
51 |
#include "calendayutils.h"
|
45
|
52 |
|
|
53 |
//constants
|
|
54 |
|
57
|
55 |
|
|
56 |
/*!
|
|
57 |
\brief Constructor
|
|
58 |
*/
|
45
|
59 |
CalenDayView::CalenDayView(MCalenServices &services) :
|
|
60 |
CalenNativeView(services), mContentScrollArea(NULL), mContentWidget(NULL),
|
63
|
61 |
mHourScrollArea(NULL), mVLayout(NULL), mMainContainer(NULL),
|
|
62 |
mDocLoader(NULL), mIsLaunching(true), mSettingsManager(NULL),
|
|
63 |
mRegionalInfoKey(XQSettingsKey::TargetCentralRepository,
|
|
64 |
KCRUidCalendar, KCalendarShowRegionalInfo), mServices(services),
|
70
|
65 |
mRegionalInfoGroupBox(NULL), mGoToTodayMenuAction(NULL), mBg(NULL),
|
|
66 |
mGesturesAbsorber(NULL)
|
45
|
67 |
{
|
|
68 |
setupMenu();
|
55
|
69 |
|
45
|
70 |
// Create model manager
|
55
|
71 |
mModelManager = new CalenDayModelManager(mServices, true, this);
|
45
|
72 |
mSettingsManager = new XQSettingsManager(this);
|
63
|
73 |
mSettingsManager->startMonitoring(mRegionalInfoKey);
|
45
|
74 |
|
75
|
75 |
//setup Back functionality, launch the month view only when it is
|
|
76 |
// the first view
|
|
77 |
if (ECalenMonthView == mServices.getFirstView()) {
|
45
|
78 |
HbAction* action = new HbAction(Hb::BackNaviAction, this);
|
|
79 |
setNavigationAction(action);
|
|
80 |
// Connect to the signal triggered by clicking on back button.
|
|
81 |
connect(action, SIGNAL(triggered()), this, SLOT(onBack()));
|
|
82 |
}
|
|
83 |
|
|
84 |
HbStyleLoader::registerFilePath(":/calendayhourelement.css");
|
|
85 |
HbStyleLoader::registerFilePath(":/calendayhourelement.widgetml");
|
|
86 |
HbStyleLoader::registerFilePath(":/calendayitem.css");
|
|
87 |
HbStyleLoader::registerFilePath(":/calendayitem.widgetml");
|
55
|
88 |
HbStyleLoader::registerFilePath(":/calendayeventspane.css");
|
57
|
89 |
HbStyleLoader::registerFilePath(":/calendayhourscrollarea.css");
|
45
|
90 |
}
|
|
91 |
|
57
|
92 |
/*!
|
|
93 |
\brief Destructor
|
|
94 |
*/
|
45
|
95 |
CalenDayView::~CalenDayView()
|
|
96 |
{
|
63
|
97 |
mSettingsManager->stopMonitoring(mRegionalInfoKey);
|
|
98 |
|
|
99 |
if (mRegionalInfoGroupBox) {
|
|
100 |
delete mRegionalInfoGroupBox;
|
|
101 |
mRegionalInfoGroupBox = NULL;
|
|
102 |
}
|
|
103 |
|
55
|
104 |
if (mDocLoader) {
|
|
105 |
delete mDocLoader;
|
|
106 |
mDocLoader = NULL;
|
|
107 |
}
|
45
|
108 |
}
|
|
109 |
|
57
|
110 |
/*!
|
|
111 |
\brief Handles locale change.
|
|
112 |
|
|
113 |
\param reason the reason of a change
|
|
114 |
*/
|
45
|
115 |
void CalenDayView::onLocaleChanged(int reason)
|
|
116 |
{
|
|
117 |
Q_UNUSED( reason )
|
81
|
118 |
if ((reason & EChangesSystemTime) || (reason & EChangesMidnightCrossover)) {
|
|
119 |
mDate = CalenDateUtils::today();
|
|
120 |
}
|
|
121 |
|
|
122 |
if ((reason & EChangesLocale)) {
|
|
123 |
mHourScrollArea->localeChanged();
|
|
124 |
}
|
45
|
125 |
}
|
|
126 |
|
57
|
127 |
/*!
|
|
128 |
\brief Reimplemented from CalenView. Handles view (re)population
|
|
129 |
*/
|
45
|
130 |
void CalenDayView::doPopulation()
|
|
131 |
{
|
|
132 |
// Triggers fading effect for heading label
|
|
133 |
getCurrentDate();
|
|
134 |
HbEffect::start(mHeadingLabel, "fadeOut", this, "setHeadingText");
|
|
135 |
|
|
136 |
mModelManager->refreshAllModels();
|
|
137 |
//Set date and time for hour scroll area.
|
|
138 |
//It's later used by hour element to display timeline
|
|
139 |
mHourScrollArea->setDateTime(mDate);
|
|
140 |
|
81
|
141 |
isDateValid();
|
|
142 |
|
45
|
143 |
//set in menu go to today visible
|
|
144 |
QDateTime currentDateTime = QDateTime::currentDateTime();
|
|
145 |
if (mGoToTodayMenuAction and currentDateTime.date() == mDate.date()) {
|
|
146 |
mGoToTodayMenuAction->setVisible(false);
|
|
147 |
}
|
|
148 |
else if(mGoToTodayMenuAction) {
|
|
149 |
mGoToTodayMenuAction->setVisible(true);
|
|
150 |
}
|
|
151 |
|
55
|
152 |
// Call async. if the view is loaded first time (fix to ou1cimx1#482516)
|
|
153 |
if (mIsLaunching) {
|
|
154 |
mIsLaunching = false;
|
|
155 |
QMetaObject::invokeMethod(this, "setupViewport", Qt::QueuedConnection);
|
|
156 |
} else {
|
|
157 |
setupViewport();
|
|
158 |
}
|
70
|
159 |
|
|
160 |
//Set gestures absorber
|
|
161 |
if (!mGesturesAbsorber) {
|
|
162 |
mGesturesAbsorber = new HbWidget(this);
|
|
163 |
mGesturesAbsorber->setZValue(100);
|
|
164 |
mGesturesAbsorber->grabGesture(Qt::SwipeGesture);
|
|
165 |
mGesturesAbsorber->grabGesture(Qt::PanGesture);
|
|
166 |
mGesturesAbsorber->setGeometry(rect());
|
|
167 |
mGesturesAbsorber->installEventFilter(mContentScrollArea);
|
|
168 |
}
|
45
|
169 |
|
|
170 |
populationComplete();
|
|
171 |
}
|
|
172 |
|
57
|
173 |
/*!
|
|
174 |
\brief Reimplemented from CalenView. Informs the organizer that the view's population is complete.
|
|
175 |
*/
|
45
|
176 |
void CalenDayView::populationComplete()
|
|
177 |
{
|
|
178 |
CalenNativeView::populationComplete();
|
|
179 |
}
|
|
180 |
|
57
|
181 |
/*!
|
|
182 |
\brief Sets up the view accroding to the 'xml'
|
|
183 |
|
|
184 |
\param docLoader Pointer to document loader
|
|
185 |
*/
|
45
|
186 |
void CalenDayView::setupView(CalenDocLoader* docLoader)
|
|
187 |
{
|
55
|
188 |
// Store document loader for further use
|
|
189 |
mDocLoader = docLoader;
|
|
190 |
|
|
191 |
// Get vertical layout from day view
|
|
192 |
mVLayout = static_cast<QGraphicsLinearLayout *> (this->layout());
|
|
193 |
|
|
194 |
// Set up day info
|
|
195 |
mHeadingLabel = qobject_cast<HbGroupBox *> (mDocLoader->findWidget(
|
|
196 |
CALEN_DAYVIEW_DAYINFO));
|
|
197 |
HbEffect::add(mHeadingLabel, ":/fade_out.fxml", "fadeOut");
|
|
198 |
HbEffect::add(mHeadingLabel, ":/fade_in.fxml", "fadeIn");
|
63
|
199 |
|
|
200 |
// Set up main container for hour elements/content area
|
|
201 |
mMainContainer = qobject_cast<HbWidget *> (mDocLoader->findWidget(
|
|
202 |
CALEN_DAYVIEW_CONTENTWIDGET));
|
|
203 |
if (Qt::Vertical == CalenDayUtils::instance()->orientation()) {
|
|
204 |
mBg = new HbFrameItem(KCalenBackgroundColorPortrait,
|
|
205 |
HbFrameDrawer::OnePiece, this);
|
|
206 |
}
|
|
207 |
else {
|
|
208 |
mBg = new HbFrameItem(KCalenBackgroundColorLandscape,
|
|
209 |
HbFrameDrawer::OnePiece, this);
|
|
210 |
}
|
|
211 |
mMainContainer->setBackgroundItem(mBg);
|
55
|
212 |
|
|
213 |
// Set up hour scroll area
|
|
214 |
mHourScrollArea
|
|
215 |
= static_cast<CalenDayHourScrollArea *> (mDocLoader->findWidget(
|
|
216 |
CALEN_DAYVIEW_HOURSCROLLAREA));
|
|
217 |
|
|
218 |
// Set up content scroll area
|
|
219 |
mContentScrollArea
|
|
220 |
= static_cast<CalenDayContentScrollArea *> (mDocLoader->findWidget(
|
|
221 |
CALEN_DAYVIEW_CONTENTSCROLLAREA));
|
63
|
222 |
// Pass parent object to mContentWidget to install event filters on parent
|
75
|
223 |
mContentWidget = new CalenDayContentWidget(mContentScrollArea);
|
55
|
224 |
mContentScrollArea->setContentWidget(mContentWidget);
|
75
|
225 |
|
|
226 |
initializeViews();
|
63
|
227 |
setupSlots();
|
|
228 |
|
55
|
229 |
// Set up regional info if variant is correct
|
|
230 |
showRegionalInformationFadeIn();
|
45
|
231 |
}
|
|
232 |
|
|
233 |
//private slots
|
|
234 |
|
57
|
235 |
/*!
|
|
236 |
\brief Handles 'back' functionality
|
|
237 |
*/
|
45
|
238 |
void CalenDayView::onBack()
|
|
239 |
{
|
|
240 |
TRAP_IGNORE(mServices.IssueCommandL(ECalenMonthView));
|
|
241 |
}
|
|
242 |
|
57
|
243 |
/*!
|
|
244 |
\brief Slot that handles first phase of day change
|
|
245 |
|
|
246 |
\param direction indicates to which day view needs to be scrolled (previous or next day)
|
|
247 |
*/
|
45
|
248 |
void CalenDayView::dayChangeStarted(CalenScrollDirection direction)
|
|
249 |
{
|
81
|
250 |
switch (direction) {
|
|
251 |
case ECalenScrollToNext:
|
|
252 |
mDate = mDate.addDays(1);
|
|
253 |
break;
|
|
254 |
case ECalenScrollToPrev:
|
|
255 |
mDate = mDate.addDays(-1);
|
|
256 |
break;
|
|
257 |
default:
|
|
258 |
break;
|
45
|
259 |
}
|
|
260 |
|
81
|
261 |
// Update the visibility of 'Go to today' option in menu
|
|
262 |
QDateTime currentDateTime = QDateTime::currentDateTime();
|
45
|
263 |
if (mGoToTodayMenuAction and currentDateTime.date() == mDate.date()) {
|
|
264 |
mGoToTodayMenuAction->setVisible(false);
|
|
265 |
}
|
|
266 |
else if(mGoToTodayMenuAction) {
|
|
267 |
mGoToTodayMenuAction->setVisible(true);
|
|
268 |
}
|
|
269 |
|
|
270 |
// Triggers fading effect for heading label.
|
|
271 |
HbEffect::start(mHeadingLabel, "fadeOut", this, "setHeadingText");
|
63
|
272 |
if (mRegionalInfoGroupBox) {
|
|
273 |
HbEffect::start(mRegionalInfoGroupBox, "fadeOut", this,
|
|
274 |
"showRegionalInformation");
|
|
275 |
}
|
45
|
276 |
|
|
277 |
mServices.Context().setFocusDate(mDate);
|
|
278 |
}
|
|
279 |
|
57
|
280 |
/*!
|
|
281 |
\brief Slot that is triggered when operation of day change is completed
|
|
282 |
|
|
283 |
\param direction ndicates to which day view was scrolled (previous or next day)
|
|
284 |
*/
|
45
|
285 |
void CalenDayView::dayChanged(CalenScrollDirection direction)
|
|
286 |
{
|
|
287 |
mModelManager->viewsScrollingFinished(direction);
|
|
288 |
mHourScrollArea->setDateTime(mDate);
|
81
|
289 |
mHourScrollArea->updateTimeIndicator();
|
|
290 |
isDateValid();
|
45
|
291 |
}
|
|
292 |
|
57
|
293 |
/*!
|
|
294 |
\brief Gets current date from context
|
|
295 |
*/
|
45
|
296 |
void CalenDayView::getCurrentDate()
|
|
297 |
{
|
|
298 |
mDate = CalenNativeView::mServices.Context().focusDateAndTime();
|
|
299 |
}
|
|
300 |
|
57
|
301 |
/*!
|
|
302 |
\brief Sets the menu for day view
|
|
303 |
*/
|
45
|
304 |
void CalenDayView::setupMenu()
|
|
305 |
{
|
70
|
306 |
menu()->addAction(hbTrId("txt_calendar_opt_new_event"), this, SLOT(runNewMeeting()));
|
|
307 |
//get pointer to this position, because need to change visibility
|
|
308 |
mGoToTodayMenuAction = menu()->addAction(hbTrId("txt_calendar_opt_go_to_today"), this, SLOT(runGoToToday()));
|
|
309 |
menu()->addAction(hbTrId("txt_calendar_opt_go_to_date"), this, SLOT(goToDate()));
|
|
310 |
//TODO: Add id for this text
|
|
311 |
//"Switch to Agenda view"
|
|
312 |
menu()->addAction(hbTrId("txt_calendar_opt_switch_to_agenda_view"), this, SLOT(runChangeToAgendaView()));
|
|
313 |
//TODO: Add id for this text (lunar data)
|
|
314 |
//"Show lunar data"
|
|
315 |
if (pluginEnabled())
|
|
316 |
{
|
45
|
317 |
menu()->addAction(hbTrId("txt_calendar_opt_show_lunar_data"), this, SLOT(runLunarData()));
|
70
|
318 |
}
|
|
319 |
menu()->addAction(hbTrId("txt_calendar_opt_settings"), this, SLOT(launchSettingsView()));
|
|
320 |
|
|
321 |
// Close the menu once closeDialogs() is received
|
|
322 |
connect(this, SIGNAL(closeDialogs()), menu(), SLOT(close()));
|
45
|
323 |
}
|
|
324 |
|
|
325 |
/*!
|
57
|
326 |
\brief To change Day view to Agenda View
|
45
|
327 |
*/
|
|
328 |
void CalenDayView::runChangeToAgendaView()
|
|
329 |
{
|
|
330 |
changeView(ECalenAgendaView);
|
|
331 |
}
|
|
332 |
|
|
333 |
/*!
|
|
334 |
\brief Shows lunar data in popup box
|
|
335 |
*/
|
|
336 |
void CalenDayView::runLunarData()
|
|
337 |
{
|
|
338 |
TRAP_IGNORE(mServices.IssueCommandL(ECalenRegionalPluginTapEvent));
|
|
339 |
}
|
|
340 |
|
57
|
341 |
/*!
|
|
342 |
\brief This is a helper function to established connections between signals and slots
|
|
343 |
*/
|
45
|
344 |
void CalenDayView::setupSlots()
|
|
345 |
{
|
|
346 |
// Connecting other view-related signals/slots
|
|
347 |
connect(mContentScrollArea,
|
|
348 |
SIGNAL(scrollAreaMoveStarted(CalenScrollDirection)), this,
|
|
349 |
SLOT(dayChangeStarted(CalenScrollDirection)));
|
|
350 |
|
|
351 |
connect(mContentScrollArea,
|
|
352 |
SIGNAL(scrollAreaMoveFinished(CalenScrollDirection)), mContentWidget,
|
|
353 |
SLOT(relayoutWidgets(CalenScrollDirection)));
|
|
354 |
|
|
355 |
connect(mContentWidget, SIGNAL(
|
|
356 |
widgetsRelayoutFinished(CalenScrollDirection)), mContentScrollArea,
|
|
357 |
SLOT(scrollToMiddleWidget()));
|
|
358 |
|
|
359 |
connect(mContentWidget,
|
|
360 |
SIGNAL(widgetsRelayoutFinished(CalenScrollDirection)), this,
|
|
361 |
SLOT(dayChanged(CalenScrollDirection)));
|
|
362 |
|
|
363 |
connect(mContentWidget, SIGNAL(scrollPositionChanged(const QPointF &)),
|
|
364 |
mHourScrollArea, SLOT(scrollVertically(const QPointF &)));
|
63
|
365 |
|
45
|
366 |
connect(mHourScrollArea, SIGNAL(scrollPositionChanged(const QPointF &)),
|
|
367 |
mContentWidget, SLOT(widgetScrolled(const QPointF &)));
|
63
|
368 |
|
|
369 |
connect(CalenDayUtils::instance()->mainWindow(),
|
|
370 |
SIGNAL(orientationChanged(Qt::Orientation)), this,
|
|
371 |
SLOT(orientationChanged(Qt::Orientation)));
|
|
372 |
|
45
|
373 |
connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)),
|
|
374 |
this, SLOT(showHideRegionalInformationChanged(XQSettingsKey, QVariant)));
|
|
375 |
}
|
|
376 |
|
57
|
377 |
/*!
|
75
|
378 |
\brief Initializes internal views.
|
|
379 |
|
|
380 |
CalenDayView uses 3 child views which represent previous, current and next days.
|
|
381 |
This assures that swiping to prev/next day works smoothly, because population
|
|
382 |
of data is done earlier.
|
|
383 |
*/
|
|
384 |
void CalenDayView::initializeViews()
|
|
385 |
{
|
|
386 |
// Create item views
|
|
387 |
HbModelIterator *iterator(0);
|
|
388 |
|
|
389 |
iterator = new HbModelIterator(&mModelManager->getModel(
|
|
390 |
CalenDayModelManager::PreviousDay));
|
|
391 |
CalenDayItemView *prevItemView = new CalenDayItemView(
|
|
392 |
mModelManager->getServices(), iterator, 0);
|
|
393 |
|
|
394 |
iterator = new HbModelIterator(&mModelManager->getModel(
|
|
395 |
CalenDayModelManager::CurrentDay));
|
|
396 |
CalenDayItemView *currItemView = new CalenDayItemView(
|
|
397 |
mModelManager->getServices(), iterator, 0);
|
|
398 |
|
|
399 |
iterator = new HbModelIterator(&mModelManager->getModel(
|
|
400 |
CalenDayModelManager::NextDay));
|
|
401 |
CalenDayItemView *nextItemView = new CalenDayItemView(
|
|
402 |
mModelManager->getServices(), iterator, 0);
|
|
403 |
|
|
404 |
// Connect views with widgetScrolled SLOT to support simultanous vertical scrolling
|
|
405 |
connect(prevItemView, SIGNAL(scrollPositionChanged(const QPointF&)), mContentWidget,
|
|
406 |
SLOT(widgetScrolled(const QPointF&)));
|
|
407 |
connect(currItemView, SIGNAL(scrollPositionChanged(const QPointF&)), mContentWidget,
|
|
408 |
SLOT(widgetScrolled(const QPointF&)));
|
|
409 |
connect(nextItemView, SIGNAL(scrollPositionChanged(const QPointF&)), mContentWidget,
|
|
410 |
SLOT(widgetScrolled(const QPointF&)));
|
|
411 |
|
|
412 |
// Close menu once closeDialogs() is received
|
|
413 |
connect(this, SIGNAL(closeDialogs()), prevItemView->contextMenu(), SLOT(close()));
|
|
414 |
connect(this, SIGNAL(closeDialogs()), currItemView->contextMenu(), SLOT(close()));
|
|
415 |
connect(this, SIGNAL(closeDialogs()), nextItemView->contextMenu(), SLOT(close()));
|
|
416 |
|
|
417 |
// Install event filters to receive events necessary for gesture handling
|
|
418 |
prevItemView->installEventFilter(mContentScrollArea);
|
|
419 |
currItemView->installEventFilter(mContentScrollArea);
|
|
420 |
nextItemView->installEventFilter(mContentScrollArea);
|
|
421 |
|
|
422 |
// Add views to layout
|
|
423 |
mContentWidget->add(prevItemView);
|
|
424 |
mContentWidget->add(currItemView);
|
|
425 |
mContentWidget->add(nextItemView);
|
|
426 |
}
|
|
427 |
|
|
428 |
/*!
|
81
|
429 |
\brief Checks current date and if previous/next days are valid.
|
|
430 |
|
|
431 |
Checks if previous/next day is in range of supported dates: 1900-01-01 - 2100-12-30
|
|
432 |
*/
|
|
433 |
void CalenDayView::isDateValid()
|
|
434 |
{
|
|
435 |
// Fix to ou1cimx1#583805: user shouldnot be able to scroll
|
|
436 |
// before 01/01/1900 and after 30/12/2100
|
|
437 |
mContentScrollArea->setDisallowedScrollDirection(ECalenScrollNoDayChange);
|
|
438 |
if (!CalenDateUtils::isValidDay(mDate.addDays(-1))) {
|
|
439 |
mContentScrollArea->setDisallowedScrollDirection(ECalenScrollToPrev);
|
|
440 |
}
|
|
441 |
else
|
|
442 |
if (!CalenDateUtils::isValidDay(mDate.addDays(1))) {
|
|
443 |
mContentScrollArea->setDisallowedScrollDirection(ECalenScrollToNext);
|
|
444 |
}
|
|
445 |
}
|
|
446 |
|
|
447 |
/*!
|
57
|
448 |
\brief This slot triggers new meeting creation view
|
|
449 |
*/
|
45
|
450 |
void CalenDayView::runNewMeeting()
|
|
451 |
{
|
|
452 |
QDateTime dateTime(mDate);
|
|
453 |
TRAP_IGNORE(
|
|
454 |
dateTime.setTime(mServices.Context().defaultCalTimeForViewsL().time());
|
|
455 |
mServices.Context().setFocusDateAndTime(dateTime);
|
|
456 |
mServices.IssueCommandL(ECalenNewMeeting)
|
55
|
457 |
);
|
45
|
458 |
}
|
|
459 |
|
57
|
460 |
/*!
|
|
461 |
\brief This slot switches current view to today
|
|
462 |
*/
|
45
|
463 |
void CalenDayView::runGoToToday()
|
|
464 |
{
|
|
465 |
mServices.Context().setFocusDateAndTime(CalenDateUtils::today());
|
|
466 |
TRAP_IGNORE(mServices.IssueCommandL(ECalenGotoToday));
|
|
467 |
refreshViewOnGoToDate();
|
|
468 |
}
|
|
469 |
|
|
470 |
|
57
|
471 |
/*!
|
|
472 |
\brief This slot switches current view to the given by id
|
|
473 |
|
|
474 |
\param viewId id of the view that needs to be displayed
|
|
475 |
*/
|
45
|
476 |
void CalenDayView::changeView(TCalenCommandId viewId)
|
|
477 |
{
|
|
478 |
TRAP_IGNORE(mServices.IssueCommandL(viewId));
|
|
479 |
}
|
|
480 |
|
57
|
481 |
/*!
|
|
482 |
\brief Sets heading text according to date from model and locale.
|
|
483 |
It's connected to modelReset signal.
|
|
484 |
|
|
485 |
\param status Parameter required in order to call this slot autmatically
|
|
486 |
when an effect is complete.
|
|
487 |
*/
|
45
|
488 |
void CalenDayView::setHeadingText(const HbEffect::EffectStatus &status)
|
|
489 |
{
|
|
490 |
Q_UNUSED(status)
|
|
491 |
|
|
492 |
// Format the date as per the device locale settings
|
|
493 |
HbExtendedLocale systemLocale = HbExtendedLocale::system();
|
|
494 |
|
|
495 |
// Get localised name of the day from locale
|
|
496 |
QString dayString = systemLocale.dayName(mDate.date().dayOfWeek());
|
|
497 |
// Append a single space
|
|
498 |
dayString.append(" ");
|
|
499 |
// Set the heading
|
|
500 |
|
|
501 |
// Append the date which is formatted as per the locale
|
64
|
502 |
mHeadingLabel->setHeading(QString("%1 %2").arg(dayString).arg(
|
45
|
503 |
systemLocale.format(mDate.date(), r_qtn_date_usual_with_zero)));
|
|
504 |
|
|
505 |
HbEffect::start(mHeadingLabel, "fadeIn");
|
|
506 |
}
|
|
507 |
|
57
|
508 |
/*!
|
|
509 |
\brief Displays regional information
|
|
510 |
|
|
511 |
\param status Parameter required in order to call this slot autmatically
|
|
512 |
when an effect is complete.
|
|
513 |
*/
|
45
|
514 |
void CalenDayView::showRegionalInformation(const HbEffect::EffectStatus &status)
|
|
515 |
{
|
|
516 |
Q_UNUSED(status);
|
|
517 |
showRegionalInformationFadeIn();
|
|
518 |
}
|
|
519 |
|
57
|
520 |
/*!
|
|
521 |
\brief Runs effect on lunar data label and change text according to date change.
|
|
522 |
*/
|
45
|
523 |
void CalenDayView::showRegionalInformationFadeIn()
|
57
|
524 |
{
|
63
|
525 |
showHideRegionalInformationChanged(mRegionalInfoKey, 3);
|
|
526 |
if (mRegionalInfoGroupBox) {
|
|
527 |
HbEffect::start(mRegionalInfoGroupBox, "fadeIn");
|
|
528 |
}
|
57
|
529 |
}
|
45
|
530 |
|
57
|
531 |
/*!
|
|
532 |
\brief To Show and hide regional plugin label depends upon settings.
|
|
533 |
*/
|
55
|
534 |
void CalenDayView::showHideRegionalInformationChanged(
|
|
535 |
const XQSettingsKey& key,
|
|
536 |
const QVariant&)
|
|
537 |
{
|
63
|
538 |
if ((key.key() == mRegionalInfoKey.key()) && pluginEnabled()) {
|
55
|
539 |
int showRegionalInfo =
|
63
|
540 |
mSettingsManager->readItemValue(mRegionalInfoKey).toUInt();
|
|
541 |
if (showRegionalInfo) {
|
|
542 |
if (!mRegionalInfoGroupBox) {
|
|
543 |
mRegionalInfoGroupBox = new HbGroupBox();
|
|
544 |
CalenPluginLabel *regionalInfo = new CalenPluginLabel(
|
|
545 |
mServices, this);
|
|
546 |
regionalInfo->setFontSpec(HbFontSpec(HbFontSpec::Primary));
|
|
547 |
mRegionalInfoGroupBox->setContentWidget(regionalInfo);
|
|
548 |
mVLayout->insertItem(1, mRegionalInfoGroupBox);
|
|
549 |
}
|
55
|
550 |
QString *pluginString = pluginText();
|
63
|
551 |
HbLabel *pluginInfoLabel = qobject_cast<HbLabel *> (
|
|
552 |
mRegionalInfoGroupBox->contentWidget());
|
|
553 |
pluginInfoLabel->setPlainText(*pluginString);
|
55
|
554 |
}
|
|
555 |
else {
|
|
556 |
if (mRegionalInfoGroupBox) {
|
|
557 |
mVLayout->removeItem(mRegionalInfoGroupBox);
|
|
558 |
delete mRegionalInfoGroupBox;
|
|
559 |
mRegionalInfoGroupBox = NULL;
|
|
560 |
}
|
|
561 |
}
|
|
562 |
}
|
|
563 |
}
|
45
|
564 |
|
57
|
565 |
/*!
|
|
566 |
\brief Scrolls view according to current day and events.
|
|
567 |
*/
|
45
|
568 |
void CalenDayView::setupViewport()
|
|
569 |
{
|
|
570 |
QDateTime currentTime = QDateTime::currentDateTime();
|
55
|
571 |
|
45
|
572 |
// If we have event in current day and hour, scroll to this event
|
55
|
573 |
if (mDate.date() == currentTime.date()){
|
|
574 |
|
|
575 |
QDateTime midnight = currentTime;
|
|
576 |
midnight.setTime(QTime(23, 59));
|
|
577 |
|
|
578 |
//Filter flags (only timed events)
|
|
579 |
AgendaUtil::FilterFlags filter = AgendaUtil::FilterFlags(AgendaUtil::IncludeAppointments);
|
|
580 |
QList<AgendaEntry> list;
|
|
581 |
// Fetch the instance list from the agenda interface
|
|
582 |
list = mServices.agendaInterface()->fetchEntriesInRange(currentTime, midnight, filter);
|
|
583 |
|
|
584 |
if(!list.isEmpty()){
|
|
585 |
int hourToScrollTo(list.first().startTime().time().hour());
|
|
586 |
mHourScrollArea->scrollToHour(hourToScrollTo);
|
|
587 |
}
|
|
588 |
else{
|
|
589 |
mHourScrollArea->scrollToHour(currentTime.time().hour());
|
|
590 |
}
|
45
|
591 |
}
|
55
|
592 |
else {
|
45
|
593 |
//Scroll view to 7am
|
|
594 |
mHourScrollArea->scrollToHour(7);
|
|
595 |
}
|
|
596 |
}
|
|
597 |
|
63
|
598 |
/*!
|
|
599 |
\brief Slot which is called whenever the orientation of the device changes.
|
|
600 |
|
|
601 |
Changes the backgroung graphic element when orientation chandes.
|
|
602 |
|
|
603 |
\param orientation Current device orientation
|
|
604 |
*/
|
|
605 |
void CalenDayView::orientationChanged(Qt::Orientation orientation)
|
|
606 |
{
|
|
607 |
if (Qt::Vertical == orientation) {
|
|
608 |
mBg = new HbFrameItem(KCalenBackgroundColorPortrait,
|
|
609 |
HbFrameDrawer::OnePiece, this);
|
|
610 |
}
|
|
611 |
else {
|
|
612 |
mBg = new HbFrameItem(KCalenBackgroundColorLandscape,
|
|
613 |
HbFrameDrawer::OnePiece, this);
|
|
614 |
}
|
|
615 |
mMainContainer->setBackgroundItem(mBg);
|
|
616 |
}
|
|
617 |
|
45
|
618 |
//End of File
|