src/hbcore/gestures/hbswipegesture.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 6 c3690ec91ef8
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    28 #include "hbswipegesture_p.h"
    28 #include "hbswipegesture_p.h"
    29 #include "hbglobal_p.h"
    29 #include "hbglobal_p.h"
    30 #include <QPointF>
    30 #include <QPointF>
    31 #include <QVariant>
    31 #include <QVariant>
    32 
    32 
       
    33 /*!
       
    34     @hbcore
       
    35     \class HbSwipeGesture
       
    36 
       
    37     \brief HbSwipeGesture is an extension to Qt standard HbSwipeGesture
       
    38     \sa QSwipeGesture
       
    39 */
       
    40 
       
    41 const int KHbDirectionThreshold = 45; // degrees
       
    42 
       
    43 /*!
       
    44     \brief HbSwipeGesture constructor
       
    45     \param parent Owner for gesture
       
    46 */
    33 HbSwipeGesture::HbSwipeGesture(QObject *parent)
    47 HbSwipeGesture::HbSwipeGesture(QObject *parent)
    34     : QSwipeGesture(parent), d_ptr(new HbSwipeGesturePrivate)
    48     : QSwipeGesture(parent), d_ptr(new HbSwipeGesturePrivate)
    35 
    49 
    36 {   
    50 {   
    37     d_ptr->mSceneSwipeAngle = 0;
    51     d_ptr->mSceneSwipeAngle = 0;
    38 }
    52 }
    39 
    53 
       
    54 /*!
       
    55     \brief HbSwipeGesture constructor
       
    56     \param dd Private data
       
    57     \param parent Owner for gesture
       
    58 */
    40 HbSwipeGesture::HbSwipeGesture(HbSwipeGesturePrivate &dd, QObject *parent)
    59 HbSwipeGesture::HbSwipeGesture(HbSwipeGesturePrivate &dd, QObject *parent)
    41     : QSwipeGesture(parent), d_ptr(&dd)
    60     : QSwipeGesture(parent), d_ptr(&dd)
    42 {
    61 {
    43 
    62 
    44 }
    63 }
    45 
    64 
       
    65 /*!
       
    66     \brief HbSwipeGesture destructor
       
    67 */
    46 HbSwipeGesture::~HbSwipeGesture()
    68 HbSwipeGesture::~HbSwipeGesture()
    47 {
    69 {
    48     delete d_ptr;
    70     delete d_ptr;
    49 }
    71 }
    50 
    72 
       
    73 /*!
       
    74     \property sceneHorizontalDirection
       
    75     \brief Horizontal direction of swipe in scene coordinates.
       
    76 
       
    77     \sa QSwipeGesture::horizontalDirection()
       
    78 */
    51 QSwipeGesture::SwipeDirection HbSwipeGesture::sceneHorizontalDirection() const
    79 QSwipeGesture::SwipeDirection HbSwipeGesture::sceneHorizontalDirection() const
    52 {
    80 {
    53     if (d_ptr->mSceneSwipeAngle < 0 || d_ptr->mSceneSwipeAngle == 90 || d_ptr->mSceneSwipeAngle == 270)
    81     if ((d_ptr->mSceneSwipeAngle <= 90 - KHbDirectionThreshold && d_ptr->mSceneSwipeAngle >= 0) || d_ptr->mSceneSwipeAngle >= 270 + KHbDirectionThreshold)
       
    82         return QSwipeGesture::Right;
       
    83     else if (d_ptr->mSceneSwipeAngle >= 90 + KHbDirectionThreshold && d_ptr->mSceneSwipeAngle <= 270 - KHbDirectionThreshold)
       
    84         return QSwipeGesture::Left;
       
    85     else
    54         return QSwipeGesture::NoDirection;
    86         return QSwipeGesture::NoDirection;
    55     else if (d_ptr->mSceneSwipeAngle < 90 || d_ptr->mSceneSwipeAngle > 270)
    87 }
    56         return QSwipeGesture::Right;
    88 /*!
       
    89     \property sceneVerticalDirection
       
    90     \brief Vertical direction of swipe in scene coordinates.
       
    91     \sa QSwipeGesture::verticalDirection()
       
    92 */
       
    93 QSwipeGesture::SwipeDirection HbSwipeGesture::sceneVerticalDirection() const
       
    94 {    
       
    95     if (d_ptr->mSceneSwipeAngle < 180 - KHbDirectionThreshold && d_ptr->mSceneSwipeAngle > 0 + KHbDirectionThreshold)
       
    96         return QSwipeGesture::Up;
       
    97     else if (d_ptr->mSceneSwipeAngle > 180 + KHbDirectionThreshold && d_ptr->mSceneSwipeAngle < 360 - KHbDirectionThreshold)
       
    98         return QSwipeGesture::Down;
    57     else
    99     else
    58         return QSwipeGesture::Left;
   100         return QSwipeGesture::NoDirection;
    59 }
   101 }
    60 
   102 
    61 QSwipeGesture::SwipeDirection HbSwipeGesture::sceneVerticalDirection() const
   103 /*!
    62 {    
   104     \property sceneSwipeAngle
    63     if (d_ptr->mSceneSwipeAngle <= 0 || d_ptr->mSceneSwipeAngle == 180)
   105     \brief Angle for swipe in scene coordinates.
    64         return QSwipeGesture::NoDirection;
   106     \sa QSwipeGesture::swipeAngle()
    65     else if (d_ptr->mSceneSwipeAngle < 180)
   107 */
    66         return QSwipeGesture::Up;
       
    67     else
       
    68         return QSwipeGesture::Down;
       
    69 }
       
    70 
       
    71 qreal HbSwipeGesture::sceneSwipeAngle() const
   108 qreal HbSwipeGesture::sceneSwipeAngle() const
    72 {
   109 {
    73     return d_ptr->mSceneSwipeAngle;
   110     return d_ptr->mSceneSwipeAngle;
    74 }
   111 }
    75 
   112 
    80 
   117 
    81 
   118 
    82 /*!
   119 /*!
    83     \deprecated
   120     \deprecated
    84     \property speed
   121     \property speed
    85 
       
    86     Stores the speed of the swipe gesture in pixels per milliseconds.
       
    87 */
   122 */
    88 qreal HbSwipeGesture::speed() const
   123 qreal HbSwipeGesture::speed() const
    89 {    
   124 {    
    90     HB_DEPRECATED("HbSwipeGesture::speed is deprecated");
   125     HB_DEPRECATED("HbSwipeGesture::speed is deprecated");
    91     return 1;
   126     return 1;
    98 }
   133 }
    99 
   134 
   100 /*!
   135 /*!
   101     \deprecated
   136     \deprecated
   102     \property touchPointCount
   137     \property touchPointCount
   103 
       
   104     Stores the number of touchpoints used in the swipe
       
   105 
       
   106 */
   138 */
   107 int HbSwipeGesture::touchPointCount() const
   139 int HbSwipeGesture::touchPointCount() const
   108 {
   140 {
   109     HB_DEPRECATED("HbSwipeGesture::touchPointCount is deprecated");
   141     HB_DEPRECATED("HbSwipeGesture::touchPointCount is deprecated");
   110     return 0;
   142     return 0;