equal
deleted
inserted
replaced
24 |
24 |
25 // User includes |
25 // User includes |
26 #include "calendaycontentscrollarea.h" |
26 #include "calendaycontentscrollarea.h" |
27 #include "calendayutils.h" |
27 #include "calendayutils.h" |
28 |
28 |
|
29 // Constants |
|
30 /*! |
|
31 Default timeout for scrolling between days [ms] |
|
32 */ |
|
33 const int KCalenScrollDaysTimeout = 600; |
|
34 |
|
35 /*! |
|
36 Value [%] defines how long (depending on content area width) should horizontal |
|
37 pan gesture be to change day to previous/next. |
|
38 If the gesture is shorter - current view is not changed. |
|
39 */ |
|
40 const int KCalenHScrollMoveParam = 30; //!< Percentage |
|
41 |
|
42 /*! |
|
43 Value [degree] defines the max. angle of swipe gesture which should change day. |
|
44 */ |
|
45 const qreal KCalenSwipeAngle = 30; |
|
46 |
|
47 |
29 /*! |
48 /*! |
30 \class CalenDayContentScrollArea |
49 \class CalenDayContentScrollArea |
31 \brief Scrollable container class for content widgets. |
50 \brief Scrollable container class for content widgets. |
32 |
51 |
33 It handles horizontal scrolling and swipe or pan gestures. |
52 It handles horizontal scrolling and swipe or pan gestures. |
211 qobject_cast<HbSwipeGesture *> (event->gesture(Qt::SwipeGesture))) { |
230 qobject_cast<HbSwipeGesture *> (event->gesture(Qt::SwipeGesture))) { |
212 if (swipeGesture->state() == Qt::GestureStarted) { |
231 if (swipeGesture->state() == Qt::GestureStarted) { |
213 mStartPosition = contentWidget()->pos(); |
232 mStartPosition = contentWidget()->pos(); |
214 |
233 |
215 qreal swipeAngle = swipeGesture->sceneSwipeAngle(); |
234 qreal swipeAngle = swipeGesture->sceneSwipeAngle(); |
216 if (CalenDayUtils::instance()->isHorizontalSwipe(swipeAngle)) { |
235 if (isHorizontalSwipe(swipeAngle)) { |
217 if (QSwipeGesture::Left == |
236 if (QSwipeGesture::Left == |
218 swipeGesture->sceneHorizontalDirection()) { |
237 swipeGesture->sceneHorizontalDirection()) { |
219 mMoveDirection = ECalenScrollToNext; |
238 mMoveDirection = ECalenScrollToNext; |
220 moveTo(QPointF((-mStartPosition.x() + mContentWidth), |
239 moveTo(QPointF((-mStartPosition.x() + mContentWidth), |
221 -mStartPosition.y()), KCalenScrollDaysTimeout); |
240 -mStartPosition.y()), KCalenScrollDaysTimeout); |
370 emit scrollAreaMoveStarted(mMoveDirection); |
389 emit scrollAreaMoveStarted(mMoveDirection); |
371 } |
390 } |
372 } |
391 } |
373 |
392 |
374 /*! |
393 /*! |
|
394 \brief isHorizontalSwipe |
|
395 |
|
396 \return TRUE if horizontal swipe was recognized (angle in specific range) |
|
397 */ |
|
398 bool CalenDayContentScrollArea::isHorizontalSwipe(qreal angle) const |
|
399 { |
|
400 bool isHSwipe = false; |
|
401 if ((angle < KCalenSwipeAngle) || |
|
402 ((angle > 180 - KCalenSwipeAngle) && (angle < 180 + KCalenSwipeAngle)) || |
|
403 (angle > 360 - KCalenSwipeAngle)) { |
|
404 isHSwipe = true; |
|
405 } |
|
406 |
|
407 return isHSwipe; |
|
408 } |
|
409 |
|
410 /*! |
375 \brief Slot which is called when moving of scroll area is finished. |
411 \brief Slot which is called when moving of scroll area is finished. |
376 |
412 |
377 Resets internal isMoving flag. |
413 Resets internal isMoving flag. |
378 */ |
414 */ |
379 void CalenDayContentScrollArea::moveFinished() |
415 void CalenDayContentScrollArea::moveFinished() |