--- a/calendarui/views/dayview/src/calendaycontentscrollarea.cpp Tue Jul 06 14:14:56 2010 +0300
+++ b/calendarui/views/dayview/src/calendaycontentscrollarea.cpp Wed Aug 18 09:47:38 2010 +0300
@@ -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.
@@ -44,12 +63,7 @@
CalenDayContentScrollArea::CalenDayContentScrollArea(QGraphicsItem *parent) :
HbScrollArea(parent), mPanDayDirection(ECalenPanNotSet), mIsMoving(false),
mMoveDirection(ECalenScrollNoDayChange)
-{
- // Set scroll settings
- setScrollDirections(Qt::Horizontal);
- setClampingStyle(StrictClamping);
- setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
-
+{
#ifdef CALENDAYVIEW_PANNING_ENABLED
grabGesture(Qt::PanGesture);
ungrabGesture(Qt::SwipeGesture);
@@ -61,6 +75,10 @@
// Get the width of content area and orientation of screen
mContentWidth = CalenDayUtils::instance()->contentWidth();
mOrientation = CalenDayUtils::instance()->orientation();
+
+ // Fix the width of scroll area
+ setMinimumWidth(mContentWidth);
+ setMaximumWidth(mContentWidth);
// Connect to main window's orientationChanged SIGNAL to handle orientation
// switching
@@ -214,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;
@@ -373,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.
@@ -402,7 +437,13 @@
// Update the width of content area
mContentWidth = CalenDayUtils::instance()->contentWidth();
mOrientation = orientation;
-
+
+ // Fix the width of scroll area
+ setMinimumWidth(mContentWidth);
+ setMaximumWidth(mContentWidth);
+
+ scrollToMiddleWidget();
+
// Reset flag related to moving
mPanDayDirection = ECalenPanNotSet;
mMoveDirection = ECalenScrollNoDayChange;