src/hbcore/gestures/hbpangesture.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 6 c3690ec91ef8
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    31 #include <QPointF>
    31 #include <QPointF>
    32 #include <QVariant>
    32 #include <QVariant>
    33 #include <QDebug>
    33 #include <QDebug>
    34 
    34 
    35 /*!
    35 /*!
       
    36     @hbcore
    36     \class HbPanGesture
    37     \class HbPanGesture
    37 
    38 
    38     \brief HbPanGesture contains data and functionality for pan gesture.
    39     \brief HbPanGesture is an extension to Qt standard QPanGesture
       
    40     \sa QPanGesture
    39 */
    41 */
    40 
    42 
    41 /*!
    43 /*!
    42     \brief
    44     \brief HbPanGesture constructor
    43     \return
    45     \param parent Owner for gesture
    44 
    46 
    45 */
    47 */
    46 HbPanGesture::HbPanGesture(QObject *parent) : QPanGesture(parent), d_ptr(new HbPanGesturePrivate)
    48 HbPanGesture::HbPanGesture(QObject *parent) : QPanGesture(parent), d_ptr(new HbPanGesturePrivate)
    47 {
    49 {
    48     d_ptr->q_ptr = this;
    50     d_ptr->q_ptr = this;
    49 }
    51 }
    50 
    52 
    51 /*!
    53 /*!
    52     \brief
    54     \brief HbPanGesture constructor
    53     \return
    55     \param dd Private data
       
    56     \param parent Owner for gesture
    54 
    57 
    55 */
    58 */
    56 HbPanGesture::HbPanGesture( HbPanGesturePrivate &dd, QObject *parent )
    59 HbPanGesture::HbPanGesture( HbPanGesturePrivate &dd, QObject *parent )
    57     : QPanGesture(parent), d_ptr( &dd )
    60     : QPanGesture(parent), d_ptr( &dd )
    58 {
    61 {
    59     d_ptr->q_ptr = this;
    62     d_ptr->q_ptr = this;
    60 }
    63 }
    61 
    64 
    62 /*!
    65 /*!
    63     \brief
    66     \brief HbPanGesture destructor
    64     \return
       
    65 
       
    66 */
    67 */
    67 HbPanGesture::~HbPanGesture()
    68 HbPanGesture::~HbPanGesture()
    68 {
    69 {
    69     delete d_ptr;
    70     delete d_ptr;
    70 }
    71 }
    71 
    72 
    72 /*!
    73 /*!
    73     \brief
    74     \property startPos
    74     \return
    75     \brief Starting position for gesture in global coordinates.
    75 
    76     \sa HbPanGesture::sceneStartPos
    76 */
    77 */
    77 QPointF HbPanGesture::startPos() const
    78 QPointF HbPanGesture::startPos() const
    78 {
    79 {
    79     Q_D(const HbPanGesture);
    80     Q_D(const HbPanGesture);
    80     return d->mStartPos;
    81     return d->mStartPos;
    81 }
    82 }
    82 
    83 
    83 /*!
       
    84     \brief
       
    85     \return
       
    86 
       
    87 */
       
    88 void HbPanGesture::setStartPos(const QPointF &startPos)
    84 void HbPanGesture::setStartPos(const QPointF &startPos)
    89 {
    85 {
    90     Q_D(HbPanGesture);
    86     Q_D(HbPanGesture);
    91     d->mStartPos = startPos;
    87     d->mStartPos = startPos;
    92 }
    88 }
    93 
    89 
    94 /*!
    90 /*!
    95     \brief
    91     \property velocity
    96     \return
    92     \brief Panning velocity in global coordinates.
    97 
    93     \sa HbPanGesture::sceneVelocity
    98 */
    94 */
    99 QPointF HbPanGesture::velocity() const
    95 QPointF HbPanGesture::velocity() const
   100 {
    96 {
   101     Q_D(const HbPanGesture);
    97     Q_D(const HbPanGesture);
   102     return HbVelocityCalculator( d->mAxisX, d->mAxisY ).velocity(QTime::currentTime());
    98     return HbVelocityCalculator( d->mAxisX, d->mAxisY ).velocity(QTime::currentTime());
   103 }
    99 }
   104 
   100 
   105 /*!
       
   106     \brief
       
   107     \return
       
   108 
       
   109 */
       
   110 void HbPanGesture::setVelocity(const QPointF &)
   101 void HbPanGesture::setVelocity(const QPointF &)
   111 {
   102 {
   112     // Q_D(HbPanGesture);
   103     Q_ASSERT(false);
   113     // d->mVelocity = velocity;
       
   114 }
   104 }
   115 
   105 
   116 /*!
   106 /*!
   117     \brief
   107     \property sceneLastOffset
   118     \return
   108     \brief The total offset from start position to second last position in scene coordinates.
   119 
   109     \sa QPanGesture::lastOffset()
   120 */
   110 */
   121 QPointF HbPanGesture::sceneLastOffset() const
   111 QPointF HbPanGesture::sceneLastOffset() const
   122 {
   112 {
   123     Q_D(const HbPanGesture);
   113     Q_D(const HbPanGesture);
   124     return d->mSceneLastOffset;
   114     return d->mSceneLastOffset;
   125 }
   115 }
   126 
   116 
   127 /*!
       
   128     \brief
       
   129     \return
       
   130 
       
   131 */
       
   132 void HbPanGesture::setSceneLastOffset(const QPointF &lastOffset)
   117 void HbPanGesture::setSceneLastOffset(const QPointF &lastOffset)
   133 {
   118 {
   134     Q_D(HbPanGesture);
   119     Q_D(HbPanGesture);
   135     d->mSceneStartPos = lastOffset;
   120     d->mSceneStartPos = lastOffset;
   136 }
   121 }
   137 
   122 
   138 /*!
   123 /*!
   139     \brief
   124     \property sceneOffset
   140     \return
   125     \brief The total offset from start position to current position in scene coordinates.
   141 
   126     \sa QPanGesture::offset()
   142 */
   127 */
   143 QPointF HbPanGesture::sceneOffset() const
   128 QPointF HbPanGesture::sceneOffset() const
   144 {
   129 {
   145     Q_D(const HbPanGesture);
   130     Q_D(const HbPanGesture);
   146     return d->mSceneOffset;
   131     return d->mSceneOffset;
   147 }
   132 }
   148 
   133 
   149 /*!
       
   150     \brief
       
   151     \return
       
   152 
       
   153 */
       
   154 void HbPanGesture::setSceneOffset(const QPointF &offset)
   134 void HbPanGesture::setSceneOffset(const QPointF &offset)
   155 {
   135 {
   156     Q_D(HbPanGesture);
   136     Q_D(HbPanGesture);
   157     d->mSceneOffset = offset;
   137     d->mSceneOffset = offset;
   158 }
   138 }
   159 
   139 
   160 /*!
   140 /*!
   161     \brief
   141     \property sceneStartPos
   162     \return
   142     \brief Starting position for gesture in scene coordinates.
   163 
   143     \sa HbPanGesture::startPos()
   164 */
   144 */
   165 QPointF HbPanGesture::sceneStartPos() const
   145 QPointF HbPanGesture::sceneStartPos() const
   166 {
   146 {
   167     Q_D(const HbPanGesture);
   147     Q_D(const HbPanGesture);
   168     return d->mSceneStartPos;
   148     return d->mSceneStartPos;
   169 }
   149 }
   170 
   150 
   171 /*!
       
   172     \brief
       
   173     \return
       
   174 
       
   175 */
       
   176 void HbPanGesture::setSceneStartPos(const QPointF &startPos)
   151 void HbPanGesture::setSceneStartPos(const QPointF &startPos)
   177 {
   152 {
   178     Q_D(HbPanGesture);
   153     Q_D(HbPanGesture);
   179     d->mSceneStartPos = startPos;
   154     d->mSceneStartPos = startPos;
   180 }
   155 }
   181 
   156 
   182 /*!
   157 /*!
   183     \brief
   158     \property sceneVelocity
   184     \return
   159     \brief Panning velocity in scene coordinates.
   185 
   160     \sa HbPanGesture::velocity()
   186 */
   161 */
   187 QPointF HbPanGesture::sceneVelocity() const
   162 QPointF HbPanGesture::sceneVelocity() const
   188 {
   163 {
   189     Q_D(const HbPanGesture);
   164     Q_D(const HbPanGesture);
   190     return HbVelocityCalculator(d->mSceneAxisX, d->mSceneAxisY).velocity( d->mLastTimeStamp );
   165     return HbVelocityCalculator(d->mSceneAxisX, d->mSceneAxisY).velocity( d->mLastTimeStamp );
   191 }
   166 }
   192 
   167 
   193 /*!
   168 /*!
   194     \brief
   169     \property sceneAcceleration
   195     \return
   170     \brief Panning acceleration in scene coordinates.
   196 
   171     \sa QPanGesture::acceleration()
   197 */
   172 */
   198 QPointF HbPanGesture::sceneAcceleration() const
   173 QPointF HbPanGesture::sceneAcceleration() const
   199 {
   174 {
   200     //Q_D(const HbPanGesture);
       
   201     //return d->mSceneAcceleration;
       
   202     return QPointF(0,0);
   175     return QPointF(0,0);
   203 }
   176 }
   204 
   177 
   205 /*!
   178 /*!
   206     \brief
   179     \property sceneDelta
   207     \return
   180     \brief Distance between last two points in scene coordinates.
   208 
   181     \sa QPanGesture::delta()
   209 */
   182 */
   210 QPointF HbPanGesture::sceneDelta() const
   183 QPointF HbPanGesture::sceneDelta() const
   211 {
   184 {
   212     Q_D(const HbPanGesture);
   185     Q_D(const HbPanGesture);
   213     return d->mSceneOffset - d->mSceneLastOffset;
   186     return d->mSceneOffset - d->mSceneLastOffset;