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