diff -r a949c2543c15 -r ea672fcb0ea0 calendarui/views/src/calendayview.cpp --- a/calendarui/views/src/calendayview.cpp Fri May 14 15:51:09 2010 +0300 +++ b/calendarui/views/src/calendayview.cpp Thu May 27 12:51:15 2010 +0300 @@ -19,6 +19,8 @@ #include #include #include +#include +#include // User includes #include "calendayview.h" @@ -41,6 +43,7 @@ mActionTaken(false) { // No implementation yet + grabGesture(Qt::SwipeGesture); } // ---------------------------------------------------------------------------- @@ -168,66 +171,22 @@ return mDocLoader; } -// ---------------------------------------------------------------------------- -// CalenDayView::handleLocaleChange -// Rest of the details are commented in the header -// ---------------------------------------------------------------------------- -// -void CalenDayView::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - // TODO: Remove these after gestures are available - mTapPoint = event->pos(); - event->accept(); -} - -// ---------------------------------------------------------------------------- -// CalenDayView::handleLocaleChange -// Rest of the details are commented in the header -// ---------------------------------------------------------------------------- -// -void CalenDayView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +/* + Function to listen for gestures +*/ +void CalenDayView::gestureEvent(QGestureEvent *event) { - // TODO: Remove these after gestures are available - QPointF curPos = event->pos(); - if (abs(curPos.y() - mTapPoint.y()) > 20) { - event->accept(); - return; - } - if (curPos.x() - mTapPoint.x() > 50) { - mTapPoint = QPointF(0, 0); - mServices.IssueCommandL(ECalenShowPrevDay); - mActionTaken = true; - } else if (curPos.x() - mTapPoint.x() < -50) { - mTapPoint = QPointF(0, 0); - mServices.IssueCommandL(ECalenShowNextDay); - mActionTaken = true; - } - event->accept(); -} - -// ---------------------------------------------------------------------------- -// CCalenDayView::eventFilter -// Rest of the details are commented in the header -// ---------------------------------------------------------------------------- -// -bool CalenDayView::eventFilter(QObject *source, QEvent *event) -{ - // TODO : remove this line after gestures are available - mActionTaken = false; - Q_UNUSED(source) - if (event->type() == QEvent::GraphicsSceneMousePress) { - QGraphicsSceneMouseEvent *mouseEvent = static_cast(event); - mousePressEvent(mouseEvent); - } else if (event->type() == QEvent::GraphicsSceneMouseMove) { - QGraphicsSceneMouseEvent *mouseEvent = static_cast(event); - mouseMoveEvent(mouseEvent); - } - if (mActionTaken) { - // Swipe gesture has been enforced. - // Do not pass the event to the source - return true; - } - return false; + if(HbSwipeGesture *gesture = qobject_cast(event->gesture(Qt::SwipeGesture))) { + if (gesture->state() == Qt::GestureStarted) { + if(QSwipeGesture::Left == gesture->horizontalDirection()) { + mServices.IssueCommandL(ECalenShowNextDay); + event->accept(Qt::SwipeGesture); + } else if(QSwipeGesture::Right == gesture->horizontalDirection()) { + mServices.IssueCommandL(ECalenShowPrevDay); + event->accept(Qt::SwipeGesture); + } + } + } } // ----------------------------------------------------------------------------