23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
25 |
25 |
26 #include "hbgestures_p.h" |
26 #include "hbgestures_p.h" |
27 #include "hbgesturerecognizers_p.h" |
27 #include "hbgesturerecognizers_p.h" |
|
28 |
|
29 #include "hbtapgesture.h" |
28 #include "hbpangesture.h" |
30 #include "hbpangesture.h" |
29 #include "hbtapgesture.h" |
|
30 #include "hbtapandholdgesture.h" |
31 #include "hbtapandholdgesture.h" |
|
32 #include "hbswipegesture.h" |
31 #include "hbpinchgesture.h" |
33 #include "hbpinchgesture.h" |
32 #include "hbswipegesture.h" |
|
33 |
34 |
34 #include <QGesture> |
35 #include <QGesture> |
35 #include <QTime> |
|
36 #include <QGraphicsObject> |
36 #include <QGraphicsObject> |
|
37 #include <QDebug> |
37 |
38 |
38 //#define RECOGNIZERS_DEBUG |
39 //#define RECOGNIZERS_DEBUG |
39 #ifdef RECOGNIZERS_DEBUG |
40 #ifdef RECOGNIZERS_DEBUG |
40 #define DEBUG qDebug |
41 #define DEBUG qDebug |
41 #else |
42 #else |
42 #define DEBUG if (0) qDebug |
43 #define DEBUG if (0) qDebug |
43 #endif |
44 #endif |
|
45 |
|
46 #define GESTURE_D(Class, ptr) Class##Private * const d = static_cast<Class *>(ptr)->d_func() |
44 |
47 |
45 //////////////////////////////////////////////////////////////////////////// |
48 //////////////////////////////////////////////////////////////////////////// |
46 // Pan gesture |
49 // Pan gesture |
47 //////////////////////////////////////////////////////////////////////////// |
50 //////////////////////////////////////////////////////////////////////////// |
48 |
51 |
96 // This HbPanGestureRecognizer works only as a small stub layer |
99 // This HbPanGestureRecognizer works only as a small stub layer |
97 // for QT gesture framework's gesture recognizers. The reason for |
100 // for QT gesture framework's gesture recognizers. The reason for |
98 // this is to enable testability within logic classes. |
101 // this is to enable testability within logic classes. |
99 // QGesture contains gesture state, which cannot be modified by |
102 // QGesture contains gesture state, which cannot be modified by |
100 // anything else, but QGestureManager itself. |
103 // anything else, but QGestureManager itself. |
101 return HbPanGestureLogic::recognize(state->state(), static_cast<HbPanGesture *>(state), watched, event, QTime::currentTime()); |
104 GESTURE_D(HbPanGesture, state); |
|
105 Q_ASSERT(d->mTime.isValid()); |
|
106 return HbPanGestureLogic::recognize(state->state(), static_cast<HbPanGesture *>(state), watched, event, d->mTime.elapsed()); |
102 } |
107 } |
103 |
108 |
104 /*! |
109 /*! |
105 \internal |
110 \internal |
106 \brief |
111 \brief |
107 \return |
112 \return |
108 |
113 |
109 */ |
114 */ |
110 void HbPanGestureRecognizer::reset(QGesture *state) |
115 void HbPanGestureRecognizer::reset(QGesture *state) |
111 { |
116 { |
|
117 GESTURE_D(HbPanGesture, state); |
|
118 d->mTime.restart(); |
112 HbPanGestureLogic::resetGesture(static_cast<HbPanGesture *>(state)); |
119 HbPanGestureLogic::resetGesture(static_cast<HbPanGesture *>(state)); |
113 QGestureRecognizer::reset(state); |
120 QGestureRecognizer::reset(state); |
114 } |
121 } |
115 |
122 |
116 //////////////////////////////////////////////////////////////////////////// |
123 //////////////////////////////////////////////////////////////////////////// |
365 // This HbSwipeGestureRecognizer works only as a small stub layer |
372 // This HbSwipeGestureRecognizer works only as a small stub layer |
366 // for QT gesture framework's gesture recognizers. The reason for |
373 // for QT gesture framework's gesture recognizers. The reason for |
367 // this is to enable testability within logic classes. |
374 // this is to enable testability within logic classes. |
368 // QGesture contains gesture state, which cannot be modified by |
375 // QGesture contains gesture state, which cannot be modified by |
369 // anything else, but QGestureManager itself. |
376 // anything else, but QGestureManager itself. |
370 return HbSwipeGestureLogic::recognize(state->state(), static_cast<HbSwipeGesture *>(state), watched, event, QTime::currentTime()); |
377 GESTURE_D(HbSwipeGesture, state); |
|
378 Q_ASSERT(d->mTime.isValid()); |
|
379 return HbSwipeGestureLogic::recognize(state->state(), static_cast<HbSwipeGesture *>(state), watched, event, d->mTime.elapsed()); |
371 } |
380 } |
372 |
381 |
373 /*! |
382 /*! |
374 \internal |
383 \internal |
375 \brief |
384 \brief |
376 \return |
385 \return |
377 |
386 |
378 */ |
387 */ |
379 void HbSwipeGestureRecognizer::reset(QGesture *state) |
388 void HbSwipeGestureRecognizer::reset(QGesture *state) |
380 { |
389 { |
|
390 GESTURE_D(HbSwipeGesture, state); |
|
391 d->mTime.restart(); |
381 HbSwipeGestureLogic::resetGesture(static_cast<HbSwipeGesture *>(state)); |
392 HbSwipeGestureLogic::resetGesture(static_cast<HbSwipeGesture *>(state)); |
382 QGestureRecognizer::reset(state); |
393 QGestureRecognizer::reset(state); |
383 } |
394 } |