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