calendarui/views/dayview/src/calendaycontentscrollarea.cpp
changeset 57 bb2d3e476f29
parent 55 2c54b51f39c4
child 63 a3cb48f6c889
--- a/calendarui/views/dayview/src/calendaycontentscrollarea.cpp	Mon Jul 26 13:54:38 2010 +0530
+++ b/calendarui/views/dayview/src/calendaycontentscrollarea.cpp	Mon Aug 09 18:30:52 2010 +0530
@@ -26,6 +26,25 @@
 #include "calendaycontentscrollarea.h"
 #include "calendayutils.h"
 
+// Constants
+/*!
+ Default timeout for scrolling between days [ms]
+ */
+const int KCalenScrollDaysTimeout = 600;
+
+/*!
+ Value [%] defines how long (depending on content area width) should horizontal
+ pan gesture be to change day to previous/next.
+ If the gesture is shorter - current view is not changed.
+ */
+const int KCalenHScrollMoveParam = 30;  //!< Percentage
+
+/*!
+ Value [degree] defines the max. angle of swipe gesture which should change day.
+ */
+const qreal KCalenSwipeAngle = 30;
+
+
 /*!
  \class CalenDayContentScrollArea
  \brief Scrollable container class for content widgets.
@@ -213,7 +232,7 @@
             mStartPosition = contentWidget()->pos();
             
             qreal swipeAngle = swipeGesture->sceneSwipeAngle();
-            if (CalenDayUtils::instance()->isHorizontalSwipe(swipeAngle)) {
+            if (isHorizontalSwipe(swipeAngle)) {
                 if (QSwipeGesture::Left == 
                     swipeGesture->sceneHorizontalDirection()) {
                     mMoveDirection = ECalenScrollToNext;
@@ -372,6 +391,23 @@
 }
 
 /*!
+ \brief isHorizontalSwipe
+ 
+ \return TRUE if horizontal swipe was recognized (angle in specific range)
+ */
+bool CalenDayContentScrollArea::isHorizontalSwipe(qreal angle) const
+{
+    bool isHSwipe = false;
+    if ((angle < KCalenSwipeAngle) || 
+        ((angle > 180 - KCalenSwipeAngle) && (angle < 180 + KCalenSwipeAngle)) ||
+        (angle > 360 - KCalenSwipeAngle)) {
+        isHSwipe = true;
+    }
+    
+    return isHSwipe;
+}
+
+/*!
  \brief Slot which is called when moving of scroll area is finished.
  
  Resets internal isMoving flag.