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 |
*
|
55
|
14 |
* Description: Day view container - parent widget for events (CalenDayItem) and
|
|
15 |
* hours area widgets (CalenDayEventsPane)
|
|
16 |
* Responsible for positioning and resizing events widgets.
|
45
|
17 |
*/
|
|
18 |
|
|
19 |
//System includes
|
|
20 |
#include <QTime>
|
|
21 |
#include <QGraphicsLinearLayout>
|
|
22 |
#include <QGesture>
|
|
23 |
|
|
24 |
#ifdef _DEBUG
|
|
25 |
#include <QPainter>
|
|
26 |
#endif
|
|
27 |
|
|
28 |
#include <hbabstractitemview.h>
|
|
29 |
#include <hbtextitem.h>
|
|
30 |
#include <hbmodeliterator.h>
|
|
31 |
#include <hbinstance.h>
|
|
32 |
|
|
33 |
//User includes
|
|
34 |
#include "calendaycontainer.h"
|
|
35 |
#include "calendayutils.h"
|
|
36 |
#include "calendayeventspane.h"
|
|
37 |
#include "calendayitem.h"
|
|
38 |
#include "calendaymodel.h"
|
|
39 |
#include "calendayinfo.h"
|
|
40 |
#include "calendayview.h"
|
|
41 |
|
55
|
42 |
/*!
|
|
43 |
\brief Constructor
|
|
44 |
|
|
45 |
Sets container initial geometry, creates hours area widgets.
|
|
46 |
*/
|
45
|
47 |
CalenDayContainer::CalenDayContainer(QGraphicsItem *parent) :
|
|
48 |
HbAbstractItemContainer(parent), mGeometryUpdated(false), mInfo(0)
|
|
49 |
{
|
|
50 |
getTimedEventLayoutValues(mLayoutValues);
|
|
51 |
|
|
52 |
QGraphicsLinearLayout* timeLinesLayout = new QGraphicsLinearLayout(
|
|
53 |
Qt::Vertical, this);
|
|
54 |
for (int i = 0; i < 24; i++) {
|
|
55 |
CalenDayEventsPane* element = new CalenDayEventsPane(this);
|
|
56 |
// Draw top line at midnight
|
|
57 |
if (i == 0) {
|
55
|
58 |
element->setDrawTopLine(true);
|
45
|
59 |
}
|
|
60 |
timeLinesLayout->addItem(element);
|
|
61 |
}
|
|
62 |
timeLinesLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
|
|
63 |
timeLinesLayout->setSpacing(0.0);
|
|
64 |
|
|
65 |
setLayout(timeLinesLayout);
|
|
66 |
}
|
|
67 |
|
55
|
68 |
|
|
69 |
/*!
|
|
70 |
\brief Destructor
|
|
71 |
*/
|
45
|
72 |
CalenDayContainer::~CalenDayContainer()
|
|
73 |
{
|
|
74 |
}
|
|
75 |
|
55
|
76 |
|
|
77 |
/*
|
|
78 |
\reimp
|
|
79 |
*/
|
45
|
80 |
void CalenDayContainer::itemAdded( int index, HbAbstractViewItem *item,
|
|
81 |
bool animate )
|
|
82 |
{
|
|
83 |
Q_UNUSED( index )
|
|
84 |
Q_UNUSED( item )
|
|
85 |
Q_UNUSED( animate )
|
|
86 |
}
|
|
87 |
|
55
|
88 |
|
|
89 |
/*
|
|
90 |
\reimp
|
|
91 |
*/
|
45
|
92 |
void CalenDayContainer::reset()
|
|
93 |
{
|
|
94 |
// remove absorbers if exist
|
|
95 |
if (mAbsorbers.count())
|
|
96 |
{
|
|
97 |
qDeleteAll(mAbsorbers);
|
|
98 |
mAbsorbers.clear();
|
|
99 |
}
|
|
100 |
|
|
101 |
// shrink event area when all-day events available after reset
|
|
102 |
getTimedEventLayoutValues(mLayoutValues);
|
|
103 |
|
|
104 |
// position need to be maintained while changing model
|
|
105 |
QPointF position(pos());
|
|
106 |
HbAbstractItemContainer::reset();
|
|
107 |
setPos( position );
|
|
108 |
}
|
|
109 |
|
55
|
110 |
|
|
111 |
/*
|
|
112 |
\reimp
|
|
113 |
*/
|
45
|
114 |
void CalenDayContainer::itemRemoved( HbAbstractViewItem *item, bool animate )
|
|
115 |
{
|
|
116 |
Q_UNUSED( item )
|
|
117 |
Q_UNUSED( animate )
|
|
118 |
}
|
|
119 |
|
55
|
120 |
|
|
121 |
/*
|
|
122 |
\reimp
|
|
123 |
*/
|
45
|
124 |
void CalenDayContainer::viewResized (const QSizeF &size)
|
|
125 |
{
|
|
126 |
resize(size);
|
|
127 |
if (!mGeometryUpdated) {
|
|
128 |
mGeometryUpdated = true;
|
|
129 |
updateGeometry();
|
|
130 |
}
|
|
131 |
}
|
|
132 |
|
55
|
133 |
|
|
134 |
/*
|
|
135 |
\reimp
|
|
136 |
*/
|
45
|
137 |
HbAbstractViewItem * CalenDayContainer::createDefaultPrototype() const
|
|
138 |
{
|
55
|
139 |
CalenDayItem *calendarViewItem = new CalenDayItem(this);
|
45
|
140 |
return calendarViewItem;
|
|
141 |
}
|
|
142 |
|
55
|
143 |
|
|
144 |
/*
|
|
145 |
\reimp
|
|
146 |
*/
|
45
|
147 |
void CalenDayContainer::setItemModelIndex(HbAbstractViewItem *item,
|
|
148 |
const QModelIndex &index)
|
|
149 |
{
|
|
150 |
QVariant variant = index.data( CalenDayEntry );
|
|
151 |
AgendaEntry entry = variant.value<AgendaEntry>();
|
|
152 |
|
|
153 |
if (entry.isTimedEntry()) {
|
|
154 |
updateTimedEventGeometry( item, index );
|
|
155 |
item->setParentItem(this);
|
|
156 |
}
|
|
157 |
else if( entry.type() == AgendaEntry::TypeEvent ){
|
|
158 |
updateAllDayEventGeometry( item, index );
|
|
159 |
item->setParentItem(this);
|
|
160 |
}
|
|
161 |
else {
|
|
162 |
item->setVisible(false);
|
|
163 |
}
|
|
164 |
|
|
165 |
// last item
|
|
166 |
if (index.row() == index.model()->rowCount() - 1) {
|
|
167 |
createTouchEventAbsorbers();
|
|
168 |
}
|
|
169 |
|
|
170 |
HbAbstractItemContainer::setItemModelIndex(item, index);
|
|
171 |
}
|
|
172 |
|
55
|
173 |
|
|
174 |
// TODO: updateTimedEventGeometry and updateAllDayEventGeometry
|
|
175 |
// methods are very similar and probably can be merged to avoid
|
|
176 |
// code duplication
|
|
177 |
/*!
|
|
178 |
\brief Set size and position of singe timed event widget (bubble)
|
|
179 |
\a item bubble widget
|
|
180 |
\a index pointing item data in model
|
|
181 |
*/
|
45
|
182 |
void CalenDayContainer::updateTimedEventGeometry(HbAbstractViewItem *item,
|
|
183 |
const QModelIndex &index)
|
|
184 |
{
|
|
185 |
//safety check
|
|
186 |
if ( !mInfo ) {
|
|
187 |
return;
|
|
188 |
}
|
|
189 |
|
|
190 |
QVariant variant = index.data( CalenDayEntry );
|
|
191 |
AgendaEntry entry = variant.value<AgendaEntry>();
|
|
192 |
|
|
193 |
//1. get 'virtual' event position from DayInfo
|
|
194 |
//TODO: k.g.: Day Info should store model index instead of keeping redundant data
|
|
195 |
SCalenApptInfo apptInfo;
|
|
196 |
apptInfo.iIndex = index;
|
|
197 |
|
|
198 |
QDateTime start;
|
|
199 |
QDateTime end;
|
|
200 |
QDateTime currentDate;
|
|
201 |
currentDate = static_cast<const CalenDayModel*>(index.model())->modelDate();
|
|
202 |
CalenDayUtils::instance()->getEventValidStartEndTime( start, end, entry,
|
|
203 |
currentDate );
|
|
204 |
apptInfo.iStartTime = start;
|
|
205 |
apptInfo.iEndTime = end;
|
|
206 |
|
|
207 |
TCalenInstanceId id = TCalenInstanceId::nullInstanceId();
|
|
208 |
id.mEntryLocalUid = index.row(); //index.row() - temporary ID
|
|
209 |
id.mInstanceTime = apptInfo.iStartTime;
|
|
210 |
apptInfo.iId = id;
|
|
211 |
apptInfo.iAllDay = 0;
|
|
212 |
apptInfo.iColor = 0xffff;
|
|
213 |
|
|
214 |
int startSlot, endSlot, columnIdx, columns;
|
|
215 |
mInfo->GetLocation( apptInfo, startSlot, endSlot, columnIdx, columns );
|
|
216 |
|
|
217 |
|
|
218 |
//2. set timed event's geometry
|
|
219 |
qreal eventStartX(mLayoutValues.eventAreaX );
|
|
220 |
qreal eventStartY(0.0);
|
|
221 |
qreal eventWidth(mLayoutValues.eventAreaWidth);
|
|
222 |
qreal eventHeight(0.0);
|
|
223 |
|
|
224 |
//event's startY/height
|
|
225 |
eventStartY = startSlot * mLayoutValues.slotHeight;
|
|
226 |
eventHeight = (endSlot - startSlot) * mLayoutValues.slotHeight;
|
|
227 |
|
|
228 |
//event's startX/width
|
|
229 |
eventWidth /= columns;
|
|
230 |
|
|
231 |
//In case when eventWidth will be smaller then 3.0un we need to
|
|
232 |
//make spacings between events smaller.
|
|
233 |
//Check whether it's possible to shring them so the bubbles
|
|
234 |
//width can stay at 3.0un (time stripe + frame margins).
|
|
235 |
qreal minWidth = 3.0 * mLayoutValues.unitInPixels;
|
|
236 |
if(eventWidth - mLayoutValues.eventMargin < minWidth){
|
|
237 |
|
|
238 |
//Calculate new margin value
|
|
239 |
//from totalMarginSpace we need to subtract
|
|
240 |
//mLayoutValues.eventMargin because first margin is always 1.5un
|
|
241 |
qreal totalMarginSpace = mLayoutValues.eventAreaWidth - minWidth * columns - mLayoutValues.eventMargin;
|
|
242 |
qreal newMarginValue = totalMarginSpace / (columns - 1);
|
|
243 |
|
|
244 |
//check if we managed to pack all the events into space we have
|
|
245 |
if(newMarginValue > 0){
|
|
246 |
|
|
247 |
eventWidth = minWidth;
|
|
248 |
}
|
|
249 |
else{
|
|
250 |
//there's not enough space
|
|
251 |
//new minWidth it's 1.5un (time stripe only)
|
|
252 |
minWidth = 1.5 * mLayoutValues.unitInPixels;
|
|
253 |
totalMarginSpace = mLayoutValues.eventAreaWidth - minWidth * columns - mLayoutValues.eventMargin;
|
|
254 |
newMarginValue = totalMarginSpace / (columns - 1);
|
|
255 |
eventWidth = minWidth;
|
|
256 |
}
|
|
257 |
|
|
258 |
//First column margin should be always 1.5un (mLayoutValues.eventMargin)
|
|
259 |
eventStartX += columnIdx * (eventWidth + newMarginValue) + mLayoutValues.eventMargin;
|
|
260 |
}
|
|
261 |
else{
|
|
262 |
//add margins between the event
|
|
263 |
eventStartX += columnIdx * eventWidth + mLayoutValues.eventMargin;
|
|
264 |
eventWidth -= mLayoutValues.eventMargin;
|
|
265 |
}
|
|
266 |
|
|
267 |
QRectF eventGeometry( eventStartX, eventStartY, eventWidth, eventHeight );
|
55
|
268 |
item->setGeometry(eventGeometry);
|
|
269 |
}
|
45
|
270 |
|
|
271 |
|
55
|
272 |
// TODO: updateTimedEventGeometry and updateAllDayEventGeometry
|
|
273 |
// methods are very similar and probably can be merged to avoid
|
|
274 |
// code duplication
|
|
275 |
/*!
|
|
276 |
\brief Set size and position of singe all-day event widget (bubble)
|
|
277 |
\a item bubble widget
|
|
278 |
\a index pointing item data in model
|
|
279 |
*/
|
45
|
280 |
void CalenDayContainer::updateAllDayEventGeometry(HbAbstractViewItem *item,
|
|
281 |
const QModelIndex &index)
|
|
282 |
{
|
|
283 |
//safety check
|
|
284 |
if ( !mInfo ) {
|
|
285 |
return;
|
|
286 |
}
|
|
287 |
|
|
288 |
QVariant variant = index.data( CalenDayEntry );
|
|
289 |
AgendaEntry entry = variant.value<AgendaEntry>();
|
|
290 |
|
|
291 |
//1. get 'virtual' event position from DayInfo
|
|
292 |
//TODO: k.g.: Day Info should store model index instead of keeping redundant data
|
|
293 |
SCalenApptInfo apptInfo;
|
|
294 |
apptInfo.iIndex = index;
|
|
295 |
|
|
296 |
|
|
297 |
QDateTime start;
|
|
298 |
QDateTime end;
|
|
299 |
QDateTime currentDate;
|
|
300 |
currentDate = static_cast<const CalenDayModel*>(index.model())->modelDate();
|
|
301 |
CalenDayUtils::instance()->getEventValidStartEndTime( start, end, entry,
|
|
302 |
currentDate );
|
|
303 |
apptInfo.iStartTime = start;
|
|
304 |
apptInfo.iEndTime = end;
|
|
305 |
|
|
306 |
TCalenInstanceId id = TCalenInstanceId::nullInstanceId();
|
|
307 |
id.mEntryLocalUid = index.row(); //index.row() - temporary ID
|
|
308 |
id.mInstanceTime = apptInfo.iStartTime;
|
|
309 |
apptInfo.iId = id;
|
|
310 |
apptInfo.iAllDay = true;
|
|
311 |
apptInfo.iColor = 0xffff;
|
|
312 |
|
|
313 |
int startSlot, endSlot, columnIdx, columns;
|
|
314 |
mInfo->GetLocation( apptInfo, startSlot, endSlot, columnIdx, columns );
|
|
315 |
|
|
316 |
//2. set timed event's geometry
|
|
317 |
qreal eventStartX(0.0);
|
|
318 |
qreal eventStartY(0.0);
|
|
319 |
qreal eventWidth(mLayoutValues.eventAreaX);
|
|
320 |
qreal eventHeight = (endSlot - startSlot) * mLayoutValues.slotHeight;
|
|
321 |
|
|
322 |
|
|
323 |
//event's startX/width
|
|
324 |
if ( columns > 1 ) {
|
|
325 |
eventWidth /= columns;
|
|
326 |
eventStartX += columnIdx * eventWidth + mLayoutValues.eventMargin;
|
|
327 |
//add margins between the event
|
|
328 |
eventWidth -= mLayoutValues.eventMargin;
|
|
329 |
} else {
|
|
330 |
eventStartX += mLayoutValues.eventMargin;
|
|
331 |
eventWidth -= mLayoutValues.eventMargin;
|
|
332 |
}
|
|
333 |
|
|
334 |
QRectF eventGeometry( eventStartX, eventStartY, eventWidth, eventHeight );
|
|
335 |
item->setGeometry(eventGeometry);
|
|
336 |
|
|
337 |
}
|
|
338 |
|
|
339 |
|
55
|
340 |
/*!
|
|
341 |
\brief Gets event layout values
|
|
342 |
\a layoutValues structure to be filled with layout data
|
|
343 |
*/
|
45
|
344 |
void CalenDayContainer::getTimedEventLayoutValues(LayoutValues& layoutValues)
|
|
345 |
{
|
|
346 |
// get the width of content area
|
|
347 |
qreal contentWidth = CalenDayUtils::instance()->contentWidth();
|
|
348 |
//1.time column width -> eventAreaX[out]
|
|
349 |
HbStyle style;
|
|
350 |
HbDeviceProfile deviceProfile;
|
|
351 |
layoutValues.unitInPixels = deviceProfile.unitValue();
|
|
352 |
|
|
353 |
if ( mInfo && mInfo->AlldayCount())
|
55
|
354 |
{
|
|
355 |
// adccoriding to ui spec all-day event area should take
|
|
356 |
// 1/4 of content area
|
|
357 |
layoutValues.eventAreaX = contentWidth / 4;
|
45
|
358 |
}
|
|
359 |
else
|
|
360 |
{
|
|
361 |
layoutValues.eventAreaX = 0;
|
|
362 |
}
|
|
363 |
|
|
364 |
//2. event area width -> eventAreaWidth[out]
|
|
365 |
qreal emptyRightColumnWidth(0.0);
|
|
366 |
emptyRightColumnWidth = 6.0 * layoutValues.unitInPixels; //pix (according to UI spec)
|
|
367 |
layoutValues.eventAreaWidth = contentWidth - emptyRightColumnWidth - layoutValues.eventAreaX ;
|
|
368 |
//3. margins between the overlapping events -> eventMargin[out]
|
|
369 |
layoutValues.eventMargin = 1.5 * layoutValues.unitInPixels;
|
|
370 |
//4. half-hour slot'h height -> slotHeight[out]
|
|
371 |
//curent slot height corresponds to half an hour
|
|
372 |
layoutValues.slotHeight =
|
|
373 |
CalenDayUtils::instance()->hourElementHeight() / 2;
|
|
374 |
|
|
375 |
// 8.2 un (min. touchable event) from layout guide
|
55
|
376 |
// used to check should we create absorber over some overlapping region
|
45
|
377 |
layoutValues.maxColumns = layoutValues.eventAreaWidth / (8.2 * layoutValues.unitInPixels);
|
|
378 |
}
|
|
379 |
|
55
|
380 |
|
|
381 |
/*!
|
|
382 |
\brief Sets day's info structer to the container.
|
|
383 |
\a dayInfo day's info data
|
|
384 |
*/
|
45
|
385 |
void CalenDayContainer::setDayInfo( CalenDayInfo* dayInfo )
|
|
386 |
{
|
|
387 |
mInfo = dayInfo;
|
|
388 |
}
|
|
389 |
|
|
390 |
// -----------------------------------------------------------------------------
|
55
|
391 |
// setDate()
|
|
392 |
// Sets date to the container. Changes according to model which is connected to given view.
|
45
|
393 |
// -----------------------------------------------------------------------------
|
|
394 |
//
|
55
|
395 |
void CalenDayContainer::setDate(const QDate &date)
|
|
396 |
{
|
|
397 |
mDate = date;
|
|
398 |
}
|
|
399 |
|
|
400 |
// -----------------------------------------------------------------------------
|
|
401 |
// date()
|
|
402 |
// Returns date of the container.
|
|
403 |
// -----------------------------------------------------------------------------
|
|
404 |
//
|
|
405 |
const QDate &CalenDayContainer::date() const
|
|
406 |
{
|
|
407 |
return mDate;
|
|
408 |
}
|
|
409 |
|
|
410 |
/*!
|
|
411 |
\brief Slot handles layout switch.
|
|
412 |
\a orientation current device orientation
|
|
413 |
*/
|
45
|
414 |
void CalenDayContainer::orientationChanged(Qt::Orientation orientation)
|
|
415 |
{
|
|
416 |
getTimedEventLayoutValues(mLayoutValues);
|
|
417 |
|
|
418 |
Q_UNUSED( orientation )
|
|
419 |
QList<HbAbstractViewItem *> items = this->items();
|
|
420 |
int count(items.count());
|
|
421 |
for (int i = 0; i < count; i++) {
|
|
422 |
QModelIndex modelIndex = items[i]->modelIndex();
|
|
423 |
if (modelIndex.isValid()) {
|
|
424 |
QVariant variant = modelIndex.data(CalenDayEntry);
|
|
425 |
AgendaEntry entry = variant.value<AgendaEntry> ();
|
|
426 |
if (entry.isTimedEntry()) {
|
|
427 |
updateTimedEventGeometry(items[i], modelIndex);
|
|
428 |
}
|
|
429 |
}
|
|
430 |
}
|
|
431 |
|
|
432 |
createTouchEventAbsorbers();
|
|
433 |
}
|
|
434 |
|
55
|
435 |
|
|
436 |
/*!
|
|
437 |
\brief Creates absorbers which prevent touching to small items
|
|
438 |
According to UI spec items smaller than 8.2 un are untouchable
|
|
439 |
*/
|
45
|
440 |
void CalenDayContainer::createTouchEventAbsorbers()
|
|
441 |
{
|
|
442 |
// remove absorbers if exist
|
|
443 |
if (mAbsorbers.count())
|
|
444 |
{
|
|
445 |
qDeleteAll(mAbsorbers);
|
|
446 |
mAbsorbers.clear();
|
|
447 |
}
|
|
448 |
|
55
|
449 |
//create absorber for all-day events
|
|
450 |
Qt::Orientation orientation = CalenDayUtils::instance()->orientation();
|
|
451 |
int allDayCount = mInfo->AlldayCount();
|
|
452 |
|
|
453 |
if ((orientation == Qt::Vertical && allDayCount > 1) ||
|
|
454 |
(orientation == Qt::Horizontal && allDayCount > 2))
|
|
455 |
{
|
|
456 |
TouchEventAbsorber* absorber = crateAbsorberBetweenSlots(0, 0, true);
|
|
457 |
mAbsorbers.append(absorber);
|
|
458 |
}
|
|
459 |
|
|
460 |
|
|
461 |
// create absorbers for timed events
|
45
|
462 |
const QList<CalenTimeRegion>& regionList = mInfo->RegionList();
|
|
463 |
|
|
464 |
for(int i=0; i < regionList.count(); i++)
|
|
465 |
{
|
|
466 |
if(regionList[i].iColumns.count() > mLayoutValues.maxColumns )
|
|
467 |
{
|
|
468 |
TouchEventAbsorber* absorber =
|
55
|
469 |
crateAbsorberBetweenSlots(regionList[i].iStartSlot, regionList[i].iEndSlot, false);
|
45
|
470 |
|
|
471 |
mAbsorbers.append(absorber);
|
|
472 |
}
|
|
473 |
}
|
|
474 |
|
|
475 |
}
|
|
476 |
|
55
|
477 |
|
|
478 |
/*!
|
|
479 |
\brief Creates single absorber in given location
|
|
480 |
\a startSlot absorber area starts from there
|
|
481 |
\a endSlot absobrber area ends here
|
|
482 |
\a forAllDayEvents if true absorber in all-day events area is created
|
|
483 |
*/
|
45
|
484 |
TouchEventAbsorber *CalenDayContainer::crateAbsorberBetweenSlots
|
55
|
485 |
(int startSlot, int endSlot, bool forAllDayEvents)
|
45
|
486 |
{
|
|
487 |
TouchEventAbsorber *absorber = new TouchEventAbsorber(this);
|
|
488 |
absorber->setZValue(1000);
|
|
489 |
absorber->setVisible(true);
|
55
|
490 |
if (!forAllDayEvents)
|
|
491 |
{
|
|
492 |
absorber->setGeometry( mLayoutValues.eventAreaX, // x
|
|
493 |
startSlot * mLayoutValues.slotHeight, // y
|
|
494 |
mLayoutValues.eventAreaWidth, // w
|
|
495 |
(endSlot-startSlot) * mLayoutValues.slotHeight ); // h
|
|
496 |
}
|
|
497 |
else
|
|
498 |
{
|
|
499 |
absorber->setGeometry(0, 0, mLayoutValues.eventAreaX,
|
|
500 |
48 * mLayoutValues.slotHeight);
|
|
501 |
}
|
45
|
502 |
|
|
503 |
return absorber;
|
|
504 |
}
|
|
505 |
|
|
506 |
|
55
|
507 |
/*!
|
|
508 |
\brief Handles tap event on overlapping area
|
|
509 |
Currently it leads to Agenda View - as described in UI spec
|
|
510 |
\a event qt gesture event
|
|
511 |
*/
|
45
|
512 |
void TouchEventAbsorber::gestureEvent(QGestureEvent *event)
|
|
513 |
{
|
|
514 |
QTapGesture *tapGesture = qobject_cast<QTapGesture*> (event->gesture(
|
|
515 |
Qt::TapGesture));
|
|
516 |
|
|
517 |
if (tapGesture && tapGesture->state() == Qt::GestureFinished)
|
|
518 |
{
|
|
519 |
CalenDayView* dayView = static_cast<CalenDayView*>
|
|
520 |
(CalenDayUtils::instance()->mainWindow()->currentView());
|
|
521 |
|
|
522 |
dayView->changeView(ECalenAgendaView);
|
|
523 |
}
|
|
524 |
}
|
|
525 |
|
55
|
526 |
/*!
|
|
527 |
\brief Constructor
|
|
528 |
*/
|
45
|
529 |
TouchEventAbsorber::TouchEventAbsorber(QGraphicsItem *parent) : HbWidget(parent)
|
|
530 |
{
|
|
531 |
#ifdef _DEBUG
|
|
532 |
setFlag(QGraphicsItem::ItemHasNoContents, false);
|
|
533 |
#endif
|
|
534 |
grabGesture(Qt::TapGesture);
|
|
535 |
}
|
|
536 |
|
55
|
537 |
|
|
538 |
/*!
|
|
539 |
\brief Destructor
|
|
540 |
|
|
541 |
Sets container initial geometry, creates hours area widgets.
|
|
542 |
*/
|
45
|
543 |
TouchEventAbsorber::~TouchEventAbsorber()
|
|
544 |
{
|
55
|
545 |
|
45
|
546 |
}
|
|
547 |
|
55
|
548 |
|
|
549 |
/*!
|
|
550 |
\brief Used for debugging purposes to see absorbers areas
|
|
551 |
Not active in release builds!
|
|
552 |
|
|
553 |
*/
|
45
|
554 |
#ifdef _DEBUG
|
|
555 |
void TouchEventAbsorber::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|
556 |
QWidget *widget)
|
|
557 |
{
|
|
558 |
Q_UNUSED(option)
|
|
559 |
Q_UNUSED(widget)
|
|
560 |
|
|
561 |
painter->save();
|
|
562 |
QPen pen;
|
|
563 |
pen.setWidth(2);
|
|
564 |
pen.setColor(Qt::red);
|
|
565 |
painter->setPen(pen);
|
|
566 |
painter->drawRect(boundingRect());
|
|
567 |
painter->restore();
|
|
568 |
}
|
|
569 |
#endif
|
|
570 |
// End of File
|