51 \brief Constructor |
51 \brief Constructor |
52 |
52 |
53 Sets container initial geometry, creates hours area widgets. |
53 Sets container initial geometry, creates hours area widgets. |
54 \param parent Parent object |
54 \param parent Parent object |
55 */ |
55 */ |
56 CalenDayContainer::CalenDayContainer(QGraphicsItem *parent) : |
56 CalenDayContainer::CalenDayContainer(QGraphicsObject *parent) : |
57 HbAbstractItemContainer(parent), mGeometryUpdated(false), mInfo(0) |
57 HbAbstractItemContainer(parent), mGeometryUpdated(false), mInfo(0) |
58 { |
58 { |
|
59 mEventsPaneElements.clear(); |
59 getTimedEventLayoutValues(mLayoutValues); |
60 getTimedEventLayoutValues(mLayoutValues); |
60 |
61 |
61 QGraphicsLinearLayout* timeLinesLayout = new QGraphicsLinearLayout( |
62 QGraphicsLinearLayout* timeLinesLayout = new QGraphicsLinearLayout( |
62 Qt::Vertical, this); |
63 Qt::Vertical, this); |
63 for (int i = 0; i < KCalenHoursInDay; i++) { |
64 for (int i = 0; i < KCalenHoursInDay; i++) { |
65 // Draw top line at midnight |
66 // Draw top line at midnight |
66 if (i == 0) { |
67 if (i == 0) { |
67 element->setDrawTopLine(true); |
68 element->setDrawTopLine(true); |
68 } |
69 } |
69 timeLinesLayout->addItem(element); |
70 timeLinesLayout->addItem(element); |
|
71 mEventsPaneElements.append(element); |
70 } |
72 } |
71 timeLinesLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0); |
73 timeLinesLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0); |
72 timeLinesLayout->setSpacing(0.0); |
74 timeLinesLayout->setSpacing(0.0); |
73 |
75 |
74 setLayout(timeLinesLayout); |
76 setLayout(timeLinesLayout); |
432 void CalenDayContainer::setDate(const QDate &date) |
434 void CalenDayContainer::setDate(const QDate &date) |
433 { |
435 { |
434 mDate = date; |
436 mDate = date; |
435 } |
437 } |
436 |
438 |
437 // ----------------------------------------------------------------------------- |
|
438 // date() |
|
439 // Returns date of the container. |
|
440 // ----------------------------------------------------------------------------- |
|
441 // |
|
442 /*! |
439 /*! |
443 \brief Returns date of the container. |
440 \brief Returns date of the container. |
444 |
441 |
445 \sa date Date of container |
442 \sa date Date of container |
446 */ |
443 */ |
447 const QDate &CalenDayContainer::date() const |
444 const QDate &CalenDayContainer::date() const |
448 { |
445 { |
449 return mDate; |
446 return mDate; |
|
447 } |
|
448 |
|
449 /*! |
|
450 \brief Calculates date and time for scene position given by parameter. |
|
451 If date and time for given position cannot be calculated, invalid dateTime is returned. |
|
452 The accuracy of returned time is 30 minutes. |
|
453 |
|
454 \sa pos Position in scene. |
|
455 */ |
|
456 QDateTime CalenDayContainer::dateTimeAtPos(const QPointF &pos) |
|
457 { |
|
458 QPointF pointPos = mapFromScene(pos); |
|
459 QDateTime dateTime; |
|
460 int hour = -1; |
|
461 int minutes = 0; |
|
462 for (int i = 0; i < mEventsPaneElements.count(); i++) { |
|
463 QRectF paneGeometry = mEventsPaneElements.at(i)->geometry(); |
|
464 if (paneGeometry.contains(pointPos)) { |
|
465 hour = i; |
|
466 QRectF firstHalf(paneGeometry.left(), paneGeometry.top(), |
|
467 paneGeometry.width(), paneGeometry.height() / 2); |
|
468 if (firstHalf.contains(pointPos)) { |
|
469 minutes = 0; |
|
470 } |
|
471 else { |
|
472 minutes = 30; |
|
473 } |
|
474 break; |
|
475 } |
|
476 } |
|
477 |
|
478 if (hour >= 0) { |
|
479 dateTime.setDate(mDate); |
|
480 dateTime.setTime(QTime(hour, minutes)); |
|
481 } |
|
482 |
|
483 return dateTime; |
450 } |
484 } |
451 |
485 |
452 /*! |
486 /*! |
453 \brief Slot handles layout switch. |
487 \brief Slot handles layout switch. |
454 \a orientation current device orientation |
488 \a orientation current device orientation |
542 } |
576 } |
543 |
577 |
544 return absorber; |
578 return absorber; |
545 } |
579 } |
546 |
580 |
|
581 /*! |
|
582 \brief This slot is called when backround type of item changes. It maintains mFloatingItemsList. |
|
583 Thanks that scroll events are propagated only to items that might be interested in getting such |
|
584 information. |
|
585 |
|
586 \a item Pointer to the item that reported backround type change. |
|
587 */ |
|
588 void CalenDayContainer::updateFloatingItemsList(const CalenDayItem *item) |
|
589 { |
|
590 if(!item){ |
|
591 return; |
|
592 } |
|
593 |
|
594 bool isItemOnList = mFloatingItemsList.contains(item); |
|
595 |
|
596 switch(item->backgroundType()){ |
|
597 |
|
598 case CalenDayItem::EFloatingBackground: |
|
599 |
|
600 if(!isItemOnList){ |
|
601 connect(itemView(), SIGNAL(scrollPositionChanged(const QPointF&)), item, SLOT(scrollBackground(const QPointF&))); |
|
602 mFloatingItemsList.append(item); |
|
603 } |
|
604 break; |
|
605 |
|
606 case CalenDayItem::EStaticBackground: |
|
607 |
|
608 if(isItemOnList){ |
|
609 disconnect(itemView(), SIGNAL(scrollPositionChanged(const QPointF&)), item, SLOT(scrollBackground(const QPointF&))); |
|
610 mFloatingItemsList.removeOne(item); |
|
611 } |
|
612 break; |
|
613 } |
|
614 } |
|
615 |
547 |
616 |
548 /*! |
617 /*! |
549 \brief Handles tap event on overlapping area |
618 \brief Handles tap event on overlapping area |
550 Currently it leads to Agenda View - as described in UI spec |
619 Currently it leads to Agenda View - as described in UI spec |
551 \a event qt gesture event |
620 \a event qt gesture event |