src/hbcore/gestures/hbtapgesture.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
       
    26 #include "hbgestures_p.h"
    26 #include "hbtapgesture.h"
    27 #include "hbtapgesture.h"
       
    28 #include "hbtapgesture_p.h"
       
    29 
    27 #include <QPointF>
    30 #include <QPointF>
    28 #include <QVariant>
    31 #include <QVariant>
       
    32 #include <QDebug>
    29 
    33 
    30 class HbTapGesturePrivate
    34 //#define TAPGESTURE_DEBUG
       
    35 #ifndef TAPGESTURE_DEBUG
       
    36 # define DEBUG if (0) qDebug
       
    37 #else
       
    38 # define DEBUG qDebug
       
    39 #endif
       
    40 
       
    41 
       
    42 HbTapGesturePrivate::HbTapGesturePrivate(): mTapStyleHint(HbTapGesture::Tap), mTimerId(0)
    31 {
    43 {
    32 public:
    44 }
    33     QPointF mStartPos;
    45 
    34 };
    46 /*!
       
    47    @proto
       
    48    @hbcore
       
    49    \class HbTapGesture
       
    50 
       
    51    \brief HbTapGesture is an extension to Qt standard QTapGesture.
       
    52 
       
    53    HbTapGesture extends QTapGesture with additional information related
       
    54    to the tap gesture, but most important use for HbTapGesture is
       
    55    in widgets needing both tap and tap-and-hold. HbTapGesture
       
    56    provides both -- use of Qt::TapAndHoldGesture
       
    57    in conjunction with Qt::TapGesture in the same widget makes it
       
    58    difficult to handle state updates and finishes in the widget.
       
    59    HbTapGesture::tapStylehint() can be used to query whether
       
    60    the tap was a normal tap, or tap-and-hold at the time of Qt::GestureUpdated
       
    61    of Qt::GestureFinished. A gesture update will be sent at the time
       
    62    when the tap-and-hold timer triggers. No updates are sent
       
    63    of the finger movement during the tap.
       
    64 
       
    65    \sa QTapGesture, HbTapGesture::TapStyleHint
       
    66 
       
    67 */
    35 
    68 
    36 HbTapGesture::HbTapGesture(QObject *parent)
    69 HbTapGesture::HbTapGesture(QObject *parent)
    37     : QTapGesture(parent), d_ptr(new HbTapGesturePrivate)
    70     : QTapGesture(parent), d_ptr(new HbTapGesturePrivate)
    38 {
    71 {
    39 
    72     DEBUG() << "Creating" << this;
    40 }
    73 }
    41 
    74 
    42 HbTapGesture::HbTapGesture( HbTapGesturePrivate &dd, QObject *parent )
    75 HbTapGesture::HbTapGesture( HbTapGesturePrivate &dd, QObject *parent )
    43     : QTapGesture(parent), d_ptr( &dd )
    76     : QTapGesture(parent), d_ptr( &dd )
    44 {
    77 {
    45 
    78     DEBUG() << "Creating" << this;
    46 }
    79 }
    47 
       
    48 
       
    49 
    80 
    50 HbTapGesture::~HbTapGesture()
    81 HbTapGesture::~HbTapGesture()
    51 {
    82 {
       
    83     DEBUG() << "Deleting" << this;
    52     delete d_ptr;
    84     delete d_ptr;
    53 }
    85 }
    54 
    86 
    55 /*!
    87 /*!
    56 
    88 
    68 void HbTapGesture::setStartPos(const QPointF &startPos)
   100 void HbTapGesture::setStartPos(const QPointF &startPos)
    69 {
   101 {
    70     Q_D(HbTapGesture);
   102     Q_D(HbTapGesture);
    71     d->mStartPos = startPos;
   103     d->mStartPos = startPos;
    72 }
   104 }
       
   105 
       
   106 /*!
       
   107 
       
   108     \property sceneStartPos
       
   109 
       
   110     Stores the starting position of the tap gesture in scene coordinates.
       
   111 
       
   112 */
       
   113 QPointF HbTapGesture::sceneStartPos() const
       
   114 {
       
   115     Q_D(const HbTapGesture);
       
   116     return d->mSceneStartPos;
       
   117 }
       
   118 
       
   119 void HbTapGesture::setSceneStartPos(const QPointF &startPos)
       
   120 {
       
   121     Q_D(HbTapGesture);
       
   122     d->mSceneStartPos = startPos;
       
   123 }
       
   124 
       
   125 /*!
       
   126 
       
   127     \property startPos
       
   128 
       
   129     Stores the starting position of the tap gesture in scene coordinates.
       
   130 
       
   131 */
       
   132 QPointF HbTapGesture::scenePosition() const
       
   133 {
       
   134     Q_D(const HbTapGesture);
       
   135     return d->mScenePosition;
       
   136 }
       
   137 
       
   138 void HbTapGesture::setScenePosition(const QPointF &startPos)
       
   139 {
       
   140     Q_D(HbTapGesture);
       
   141     d->mScenePosition = startPos;
       
   142 }
       
   143 
       
   144 /*!
       
   145     \property tapStyleHint
       
   146 
       
   147     TapStyleHint is by default Tap and in case of long press, the gesture
       
   148     update event is sent and TapStyleHint changed to TapAndHold.
       
   149 */
       
   150 HbTapGesture::TapStyleHint HbTapGesture::tapStyleHint() const
       
   151 {
       
   152     Q_D(const HbTapGesture);
       
   153     return d->mTapStyleHint;
       
   154 }