| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qgesture.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
| 24 | ** | - | ||||||||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
| 35 | ** | - | ||||||||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | #include "qgesture.h" | - | ||||||||||||||||||
| 41 | #include "private/qgesture_p.h" | - | ||||||||||||||||||
| 42 | #include "private/qstandardgestures_p.h" | - | ||||||||||||||||||
| 43 | #include "qgraphicsview.h" | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | #include <private/qdebug_p.h> | - | ||||||||||||||||||
| 46 | #ifndef QT_NO_GESTURES | - | ||||||||||||||||||
| 47 | - | |||||||||||||||||||
| 48 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | /*! | - | ||||||||||||||||||
| 51 | \class QGesture | - | ||||||||||||||||||
| 52 | \since 4.6 | - | ||||||||||||||||||
| 53 | \ingroup gestures | - | ||||||||||||||||||
| 54 | \inmodule QtWidgets | - | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | \brief The QGesture class represents a gesture, containing properties that | - | ||||||||||||||||||
| 57 | describe the corresponding user input. | - | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | Gesture objects are not constructed directly by developers. They are created by | - | ||||||||||||||||||
| 60 | the QGestureRecognizer object that is registered with the application; see | - | ||||||||||||||||||
| 61 | QGestureRecognizer::registerRecognizer(). | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | For an overview of gesture handling in Qt and information on using gestures | - | ||||||||||||||||||
| 64 | in your applications, see the \l{Gestures in Widgets and Graphics View} document. | - | ||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | \section1 Gesture Properties | - | ||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | The class has a list of properties that can be queried by the user to get | - | ||||||||||||||||||
| 69 | some gesture-specific arguments. For example, the pinch gesture has a scale | - | ||||||||||||||||||
| 70 | factor that is exposed as a property. | - | ||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | Developers of custom gesture recognizers can add additional properties in | - | ||||||||||||||||||
| 73 | order to provide additional information about a gesture. This can be done | - | ||||||||||||||||||
| 74 | by adding new dynamic properties to a QGesture object, or by subclassing | - | ||||||||||||||||||
| 75 | the QGesture class (or one of its subclasses). | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | \section1 Lifecycle of a Gesture Object | - | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | A QGesture instance is implicitly created when needed and is owned by Qt. | - | ||||||||||||||||||
| 80 | Developers should never destroy them or store them for later use as Qt may | - | ||||||||||||||||||
| 81 | destroy particular instances of them and create new ones to replace them. | - | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | The registered gesture recognizer monitors the input events for the target | - | ||||||||||||||||||
| 84 | object via its \l{QGestureRecognizer::}{recognize()} function, updating the | - | ||||||||||||||||||
| 85 | properties of the gesture object as required. | - | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | The gesture object may be delivered to the target object in a QGestureEvent if | - | ||||||||||||||||||
| 88 | the corresponding gesture is active or has just been canceled. Each event that | - | ||||||||||||||||||
| 89 | is delivered contains a list of gesture objects, since support for more than | - | ||||||||||||||||||
| 90 | one gesture may be enabled for the target object. Due to the way events are | - | ||||||||||||||||||
| 91 | handled in Qt, gesture events may be filtered by other objects. | - | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | \sa QGestureEvent, QGestureRecognizer | - | ||||||||||||||||||
| 94 | */ | - | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | /*! | - | ||||||||||||||||||
| 97 | Constructs a new gesture object with the given \a parent. | - | ||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | QGesture objects are created by gesture recognizers in the | - | ||||||||||||||||||
| 100 | QGestureRecognizer::create() function. | - | ||||||||||||||||||
| 101 | */ | - | ||||||||||||||||||
| 102 | QGesture::QGesture(QObject *parent) | - | ||||||||||||||||||
| 103 | : QObject(*new QGesturePrivate, parent) | - | ||||||||||||||||||
| 104 | { | - | ||||||||||||||||||
| 105 | d_func()->gestureType = Qt::CustomGesture; | - | ||||||||||||||||||
| 106 | } never executed: end of block | 0 | ||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | /*! | - | ||||||||||||||||||
| 109 | \internal | - | ||||||||||||||||||
| 110 | */ | - | ||||||||||||||||||
| 111 | QGesture::QGesture(QGesturePrivate &dd, QObject *parent) | - | ||||||||||||||||||
| 112 | : QObject(dd, parent) | - | ||||||||||||||||||
| 113 | { | - | ||||||||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | /*! | - | ||||||||||||||||||
| 117 | Destroys the gesture object. | - | ||||||||||||||||||
| 118 | */ | - | ||||||||||||||||||
| 119 | QGesture::~QGesture() | - | ||||||||||||||||||
| 120 | { | - | ||||||||||||||||||
| 121 | } | - | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | /*! | - | ||||||||||||||||||
| 124 | \property QGesture::state | - | ||||||||||||||||||
| 125 | \brief the current state of the gesture | - | ||||||||||||||||||
| 126 | */ | - | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | /*! | - | ||||||||||||||||||
| 129 | \property QGesture::gestureType | - | ||||||||||||||||||
| 130 | \brief the type of the gesture | - | ||||||||||||||||||
| 131 | */ | - | ||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | /*! | - | ||||||||||||||||||
| 134 | \property QGesture::hotSpot | - | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | \brief The point that is used to find the receiver for the gesture event. | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | The hot-spot is a point in the global coordinate system, use | - | ||||||||||||||||||
| 139 | QWidget::mapFromGlobal() or QGestureEvent::mapToGraphicsScene() to get a | - | ||||||||||||||||||
| 140 | local hot-spot. | - | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | The hot-spot should be set by the gesture recognizer to allow gesture event | - | ||||||||||||||||||
| 143 | delivery to a QGraphicsObject. | - | ||||||||||||||||||
| 144 | */ | - | ||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | /*! | - | ||||||||||||||||||
| 147 | \property QGesture::hasHotSpot | - | ||||||||||||||||||
| 148 | \brief whether the gesture has a hot-spot | - | ||||||||||||||||||
| 149 | */ | - | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | Qt::GestureType QGesture::gestureType() const | - | ||||||||||||||||||
| 152 | { | - | ||||||||||||||||||
| 153 | return d_func()->gestureType; never executed: return d_func()->gestureType; | 0 | ||||||||||||||||||
| 154 | } | - | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | Qt::GestureState QGesture::state() const | - | ||||||||||||||||||
| 157 | { | - | ||||||||||||||||||
| 158 | return d_func()->state; never executed: return d_func()->state; | 0 | ||||||||||||||||||
| 159 | } | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | QPointF QGesture::hotSpot() const | - | ||||||||||||||||||
| 162 | { | - | ||||||||||||||||||
| 163 | return d_func()->hotSpot; never executed: return d_func()->hotSpot; | 0 | ||||||||||||||||||
| 164 | } | - | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | void QGesture::setHotSpot(const QPointF &value) | - | ||||||||||||||||||
| 167 | { | - | ||||||||||||||||||
| 168 | Q_D(QGesture); | - | ||||||||||||||||||
| 169 | d->hotSpot = value; | - | ||||||||||||||||||
| 170 | d->isHotSpotSet = true; | - | ||||||||||||||||||
| 171 | } never executed: end of block | 0 | ||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | bool QGesture::hasHotSpot() const | - | ||||||||||||||||||
| 174 | { | - | ||||||||||||||||||
| 175 | return d_func()->isHotSpotSet; never executed: return d_func()->isHotSpotSet; | 0 | ||||||||||||||||||
| 176 | } | - | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | void QGesture::unsetHotSpot() | - | ||||||||||||||||||
| 179 | { | - | ||||||||||||||||||
| 180 | d_func()->isHotSpotSet = false; | - | ||||||||||||||||||
| 181 | } never executed: end of block | 0 | ||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | /*! | - | ||||||||||||||||||
| 184 | \property QGesture::gestureCancelPolicy | - | ||||||||||||||||||
| 185 | \brief the policy for deciding what happens on accepting a gesture | - | ||||||||||||||||||
| 186 | - | |||||||||||||||||||
| 187 | On accepting one gesture Qt can automatically cancel other gestures | - | ||||||||||||||||||
| 188 | that belong to other targets. The policy is normally set to not cancel | - | ||||||||||||||||||
| 189 | any other gestures and can be set to cancel all active gestures in the | - | ||||||||||||||||||
| 190 | context. For example for all child widgets. | - | ||||||||||||||||||
| 191 | */ | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | /*! | - | ||||||||||||||||||
| 194 | \enum QGesture::GestureCancelPolicy | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | This enum describes how accepting a gesture can cancel other gestures | - | ||||||||||||||||||
| 197 | automatically. | - | ||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | \value CancelNone On accepting this gesture no other gestures will be affected. | - | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | \value CancelAllInContext On accepting this gesture all gestures that are | - | ||||||||||||||||||
| 202 | active in the context (respecting the Qt::GestureFlag that were specified | - | ||||||||||||||||||
| 203 | when subscribed to the gesture) will be cancelled. | - | ||||||||||||||||||
| 204 | */ | - | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | void QGesture::setGestureCancelPolicy(GestureCancelPolicy policy) | - | ||||||||||||||||||
| 207 | { | - | ||||||||||||||||||
| 208 | Q_D(QGesture); | - | ||||||||||||||||||
| 209 | d->gestureCancelPolicy = static_cast<uint>(policy); | - | ||||||||||||||||||
| 210 | } never executed: end of block | 0 | ||||||||||||||||||
| 211 | - | |||||||||||||||||||
| 212 | QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const | - | ||||||||||||||||||
| 213 | { | - | ||||||||||||||||||
| 214 | Q_D(const QGesture); | - | ||||||||||||||||||
| 215 | return static_cast<GestureCancelPolicy>(d->gestureCancelPolicy); never executed: return static_cast<GestureCancelPolicy>(d->gestureCancelPolicy); | 0 | ||||||||||||||||||
| 216 | } | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | /*! | - | ||||||||||||||||||
| 219 | \class QPanGesture | - | ||||||||||||||||||
| 220 | \since 4.6 | - | ||||||||||||||||||
| 221 | \brief The QPanGesture class describes a panning gesture made by the user. | - | ||||||||||||||||||
| 222 | \ingroup gestures | - | ||||||||||||||||||
| 223 | \inmodule QtWidgets | - | ||||||||||||||||||
| 224 | - | |||||||||||||||||||
| 225 | \image pangesture.png | - | ||||||||||||||||||
| 226 | - | |||||||||||||||||||
| 227 | For an overview of gesture handling in Qt and information on using gestures | - | ||||||||||||||||||
| 228 | in your applications, see the \l{Gestures in Widgets and Graphics View} document. | - | ||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | \sa QPinchGesture, QSwipeGesture | - | ||||||||||||||||||
| 231 | */ | - | ||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | /*! | - | ||||||||||||||||||
| 234 | \property QPanGesture::lastOffset | - | ||||||||||||||||||
| 235 | \brief the last offset recorded for this gesture | - | ||||||||||||||||||
| 236 | - | |||||||||||||||||||
| 237 | The last offset contains the change in position of the user's input as | - | ||||||||||||||||||
| 238 | reported in the \l offset property when a previous gesture event was | - | ||||||||||||||||||
| 239 | delivered for this gesture. | - | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | If no previous event was delivered with information about this gesture | - | ||||||||||||||||||
| 242 | (i.e., this gesture object contains information about the first movement | - | ||||||||||||||||||
| 243 | in the gesture) then this property contains a zero size. | - | ||||||||||||||||||
| 244 | */ | - | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | /*! | - | ||||||||||||||||||
| 247 | \property QPanGesture::offset | - | ||||||||||||||||||
| 248 | \brief the total offset from the first input position to the current input | - | ||||||||||||||||||
| 249 | position | - | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | The offset measures the total change in position of the user's input | - | ||||||||||||||||||
| 252 | covered by the gesture on the input device. | - | ||||||||||||||||||
| 253 | */ | - | ||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | /*! | - | ||||||||||||||||||
| 256 | \property QPanGesture::delta | - | ||||||||||||||||||
| 257 | \brief the offset from the previous input position to the current input | - | ||||||||||||||||||
| 258 | - | |||||||||||||||||||
| 259 | This is essentially the same as the difference between offset() and | - | ||||||||||||||||||
| 260 | lastOffset(). | - | ||||||||||||||||||
| 261 | */ | - | ||||||||||||||||||
| 262 | - | |||||||||||||||||||
| 263 | /*! | - | ||||||||||||||||||
| 264 | \property QPanGesture::acceleration | - | ||||||||||||||||||
| 265 | \brief the acceleration in the motion of the touch point for this gesture | - | ||||||||||||||||||
| 266 | */ | - | ||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | /*! | - | ||||||||||||||||||
| 269 | \property QPanGesture::horizontalVelocity | - | ||||||||||||||||||
| 270 | \brief the horizontal component of the motion of the touch point for this | - | ||||||||||||||||||
| 271 | gesture | - | ||||||||||||||||||
| 272 | \since 4.7.1 | - | ||||||||||||||||||
| 273 | \internal | - | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | \sa verticalVelocity, acceleration | - | ||||||||||||||||||
| 276 | */ | - | ||||||||||||||||||
| 277 | - | |||||||||||||||||||
| 278 | /*! | - | ||||||||||||||||||
| 279 | \property QPanGesture::verticalVelocity | - | ||||||||||||||||||
| 280 | \brief the vertical component of the motion of the touch point for this | - | ||||||||||||||||||
| 281 | gesture | - | ||||||||||||||||||
| 282 | \since 4.7.1 | - | ||||||||||||||||||
| 283 | \internal | - | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | \sa horizontalVelocity, acceleration | - | ||||||||||||||||||
| 286 | */ | - | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | /*! | - | ||||||||||||||||||
| 289 | \internal | - | ||||||||||||||||||
| 290 | */ | - | ||||||||||||||||||
| 291 | QPanGesture::QPanGesture(QObject *parent) | - | ||||||||||||||||||
| 292 | : QGesture(*new QPanGesturePrivate, parent) | - | ||||||||||||||||||
| 293 | { | - | ||||||||||||||||||
| 294 | d_func()->gestureType = Qt::PanGesture; | - | ||||||||||||||||||
| 295 | } never executed: end of block | 0 | ||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | /*! | - | ||||||||||||||||||
| 298 | Destructor. | - | ||||||||||||||||||
| 299 | */ | - | ||||||||||||||||||
| 300 | QPanGesture::~QPanGesture() | - | ||||||||||||||||||
| 301 | { | - | ||||||||||||||||||
| 302 | } | - | ||||||||||||||||||
| 303 | - | |||||||||||||||||||
| 304 | QPointF QPanGesture::lastOffset() const | - | ||||||||||||||||||
| 305 | { | - | ||||||||||||||||||
| 306 | return d_func()->lastOffset; never executed: return d_func()->lastOffset; | 0 | ||||||||||||||||||
| 307 | } | - | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | QPointF QPanGesture::offset() const | - | ||||||||||||||||||
| 310 | { | - | ||||||||||||||||||
| 311 | return d_func()->offset; never executed: return d_func()->offset; | 0 | ||||||||||||||||||
| 312 | } | - | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | QPointF QPanGesture::delta() const | - | ||||||||||||||||||
| 315 | { | - | ||||||||||||||||||
| 316 | Q_D(const QPanGesture); | - | ||||||||||||||||||
| 317 | return d->offset - d->lastOffset; never executed: return d->offset - d->lastOffset; | 0 | ||||||||||||||||||
| 318 | } | - | ||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | qreal QPanGesture::acceleration() const | - | ||||||||||||||||||
| 321 | { | - | ||||||||||||||||||
| 322 | return d_func()->acceleration; never executed: return d_func()->acceleration; | 0 | ||||||||||||||||||
| 323 | } | - | ||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | void QPanGesture::setLastOffset(const QPointF &value) | - | ||||||||||||||||||
| 326 | { | - | ||||||||||||||||||
| 327 | d_func()->lastOffset = value; | - | ||||||||||||||||||
| 328 | } never executed: end of block | 0 | ||||||||||||||||||
| 329 | - | |||||||||||||||||||
| 330 | void QPanGesture::setOffset(const QPointF &value) | - | ||||||||||||||||||
| 331 | { | - | ||||||||||||||||||
| 332 | d_func()->offset = value; | - | ||||||||||||||||||
| 333 | } never executed: end of block | 0 | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | void QPanGesture::setAcceleration(qreal value) | - | ||||||||||||||||||
| 336 | { | - | ||||||||||||||||||
| 337 | d_func()->acceleration = value; | - | ||||||||||||||||||
| 338 | } never executed: end of block | 0 | ||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | /*! | - | ||||||||||||||||||
| 341 | \class QPinchGesture | - | ||||||||||||||||||
| 342 | \since 4.6 | - | ||||||||||||||||||
| 343 | \brief The QPinchGesture class describes a pinch gesture made by the user. | - | ||||||||||||||||||
| 344 | \ingroup touch | - | ||||||||||||||||||
| 345 | \ingroup gestures | - | ||||||||||||||||||
| 346 | \inmodule QtWidgets | - | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | A pinch gesture is a form of touch user input in which the user typically | - | ||||||||||||||||||
| 349 | touches two points on the input device with a thumb and finger, before moving | - | ||||||||||||||||||
| 350 | them closer together or further apart to change the scale factor, zoom, or level | - | ||||||||||||||||||
| 351 | of detail of the user interface. | - | ||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 | For an overview of gesture handling in Qt and information on using gestures | - | ||||||||||||||||||
| 354 | in your applications, see the \l{Gestures in Widgets and Graphics View} document. | - | ||||||||||||||||||
| 355 | - | |||||||||||||||||||
| 356 | \image pinchgesture.png | - | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | Instead of repeatedly applying the same pinching gesture, the user may | - | ||||||||||||||||||
| 359 | continue to touch the input device in one place, and apply a second touch | - | ||||||||||||||||||
| 360 | to a new point, continuing the gesture. When this occurs, gesture events | - | ||||||||||||||||||
| 361 | will continue to be delivered to the target object, containing an instance | - | ||||||||||||||||||
| 362 | of QPinchGesture in the Qt::GestureUpdated state. | - | ||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | \sa QPanGesture, QSwipeGesture | - | ||||||||||||||||||
| 365 | */ | - | ||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | /*! | - | ||||||||||||||||||
| 368 | \enum QPinchGesture::ChangeFlag | - | ||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | This enum describes the changes that can occur to the properties of | - | ||||||||||||||||||
| 371 | the gesture object. | - | ||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | \value ScaleFactorChanged The scale factor held by scaleFactor changed. | - | ||||||||||||||||||
| 374 | \value RotationAngleChanged The rotation angle held by rotationAngle changed. | - | ||||||||||||||||||
| 375 | \value CenterPointChanged The center point held by centerPoint changed. | - | ||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 | \sa changeFlags, totalChangeFlags | - | ||||||||||||||||||
| 378 | */ | - | ||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | /*! | - | ||||||||||||||||||
| 381 | \property QPinchGesture::totalChangeFlags | - | ||||||||||||||||||
| 382 | \brief the property of the gesture that has change | - | ||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | This property indicates which of the other properties has changed since the | - | ||||||||||||||||||
| 385 | gesture has started. You can use this information to determine which aspect | - | ||||||||||||||||||
| 386 | of your user interface needs to be updated. | - | ||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | \sa changeFlags, scaleFactor, rotationAngle, centerPoint | - | ||||||||||||||||||
| 389 | */ | - | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | /*! | - | ||||||||||||||||||
| 392 | \property QPinchGesture::changeFlags | - | ||||||||||||||||||
| 393 | \brief the property of the gesture that has changed in the current step | - | ||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | This property indicates which of the other properties has changed since | - | ||||||||||||||||||
| 396 | the previous gesture event included information about this gesture. You | - | ||||||||||||||||||
| 397 | can use this information to determine which aspect of your user interface | - | ||||||||||||||||||
| 398 | needs to be updated. | - | ||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | \sa totalChangeFlags, scaleFactor, rotationAngle, centerPoint | - | ||||||||||||||||||
| 401 | */ | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | /*! | - | ||||||||||||||||||
| 404 | \property QPinchGesture::totalScaleFactor | - | ||||||||||||||||||
| 405 | \brief the total scale factor | - | ||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | The total scale factor measures the total change in scale factor from the | - | ||||||||||||||||||
| 408 | original value to the current scale factor. | - | ||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | \sa scaleFactor, lastScaleFactor | - | ||||||||||||||||||
| 411 | */ | - | ||||||||||||||||||
| 412 | /*! | - | ||||||||||||||||||
| 413 | \property QPinchGesture::lastScaleFactor | - | ||||||||||||||||||
| 414 | \brief the last scale factor recorded for this gesture | - | ||||||||||||||||||
| 415 | - | |||||||||||||||||||
| 416 | The last scale factor contains the scale factor reported in the | - | ||||||||||||||||||
| 417 | \l scaleFactor property when a previous gesture event included | - | ||||||||||||||||||
| 418 | information about this gesture. | - | ||||||||||||||||||
| 419 | - | |||||||||||||||||||
| 420 | If no previous event was delivered with information about this gesture | - | ||||||||||||||||||
| 421 | (i.e., this gesture object contains information about the first movement | - | ||||||||||||||||||
| 422 | in the gesture) then this property contains zero. | - | ||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | \sa scaleFactor, totalScaleFactor | - | ||||||||||||||||||
| 425 | */ | - | ||||||||||||||||||
| 426 | /*! | - | ||||||||||||||||||
| 427 | \property QPinchGesture::scaleFactor | - | ||||||||||||||||||
| 428 | \brief the current scale factor | - | ||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | The scale factor measures the scale factor associated with the distance | - | ||||||||||||||||||
| 431 | between two of the user's inputs on a touch device. | - | ||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | \sa totalScaleFactor, lastScaleFactor | - | ||||||||||||||||||
| 434 | */ | - | ||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | /*! | - | ||||||||||||||||||
| 437 | \property QPinchGesture::totalRotationAngle | - | ||||||||||||||||||
| 438 | \brief the total angle covered by the gesture | - | ||||||||||||||||||
| 439 | - | |||||||||||||||||||
| 440 | This total angle measures the complete angle covered by the gesture. Usually, this | - | ||||||||||||||||||
| 441 | is equal to the value held by the \l rotationAngle property, except in the case where | - | ||||||||||||||||||
| 442 | the user performs multiple rotations by removing and repositioning one of the touch | - | ||||||||||||||||||
| 443 | points, as described above. In this case, the total angle will be the sum of the | - | ||||||||||||||||||
| 444 | rotation angles for the multiple stages of the gesture. | - | ||||||||||||||||||
| 445 | - | |||||||||||||||||||
| 446 | \sa rotationAngle, lastRotationAngle | - | ||||||||||||||||||
| 447 | */ | - | ||||||||||||||||||
| 448 | /*! | - | ||||||||||||||||||
| 449 | \property QPinchGesture::lastRotationAngle | - | ||||||||||||||||||
| 450 | \brief the last reported angle covered by the gesture motion | - | ||||||||||||||||||
| 451 | - | |||||||||||||||||||
| 452 | The last rotation angle is the angle as reported in the \l rotationAngle property | - | ||||||||||||||||||
| 453 | when a previous gesture event was delivered for this gesture. | - | ||||||||||||||||||
| 454 | - | |||||||||||||||||||
| 455 | \sa rotationAngle, totalRotationAngle | - | ||||||||||||||||||
| 456 | */ | - | ||||||||||||||||||
| 457 | /*! | - | ||||||||||||||||||
| 458 | \property QPinchGesture::rotationAngle | - | ||||||||||||||||||
| 459 | \brief the angle covered by the gesture motion | - | ||||||||||||||||||
| 460 | - | |||||||||||||||||||
| 461 | \sa totalRotationAngle, lastRotationAngle | - | ||||||||||||||||||
| 462 | */ | - | ||||||||||||||||||
| 463 | - | |||||||||||||||||||
| 464 | /*! | - | ||||||||||||||||||
| 465 | \property QPinchGesture::startCenterPoint | - | ||||||||||||||||||
| 466 | \brief the starting position of the center point | - | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | \sa centerPoint, lastCenterPoint | - | ||||||||||||||||||
| 469 | */ | - | ||||||||||||||||||
| 470 | /*! | - | ||||||||||||||||||
| 471 | \property QPinchGesture::lastCenterPoint | - | ||||||||||||||||||
| 472 | \brief the last position of the center point recorded for this gesture | - | ||||||||||||||||||
| 473 | - | |||||||||||||||||||
| 474 | \sa centerPoint, startCenterPoint | - | ||||||||||||||||||
| 475 | */ | - | ||||||||||||||||||
| 476 | /*! | - | ||||||||||||||||||
| 477 | \property QPinchGesture::centerPoint | - | ||||||||||||||||||
| 478 | \brief the current center point | - | ||||||||||||||||||
| 479 | - | |||||||||||||||||||
| 480 | The center point is the midpoint between the two input points in the gesture. | - | ||||||||||||||||||
| 481 | - | |||||||||||||||||||
| 482 | \sa startCenterPoint, lastCenterPoint | - | ||||||||||||||||||
| 483 | */ | - | ||||||||||||||||||
| 484 | - | |||||||||||||||||||
| 485 | /*! | - | ||||||||||||||||||
| 486 | \internal | - | ||||||||||||||||||
| 487 | */ | - | ||||||||||||||||||
| 488 | QPinchGesture::QPinchGesture(QObject *parent) | - | ||||||||||||||||||
| 489 | : QGesture(*new QPinchGesturePrivate, parent) | - | ||||||||||||||||||
| 490 | { | - | ||||||||||||||||||
| 491 | d_func()->gestureType = Qt::PinchGesture; | - | ||||||||||||||||||
| 492 | } never executed: end of block | 0 | ||||||||||||||||||
| 493 | - | |||||||||||||||||||
| 494 | /*! | - | ||||||||||||||||||
| 495 | Destructor. | - | ||||||||||||||||||
| 496 | */ | - | ||||||||||||||||||
| 497 | QPinchGesture::~QPinchGesture() | - | ||||||||||||||||||
| 498 | { | - | ||||||||||||||||||
| 499 | } | - | ||||||||||||||||||
| 500 | - | |||||||||||||||||||
| 501 | QPinchGesture::ChangeFlags QPinchGesture::totalChangeFlags() const | - | ||||||||||||||||||
| 502 | { | - | ||||||||||||||||||
| 503 | return d_func()->totalChangeFlags; never executed: return d_func()->totalChangeFlags; | 0 | ||||||||||||||||||
| 504 | } | - | ||||||||||||||||||
| 505 | - | |||||||||||||||||||
| 506 | void QPinchGesture::setTotalChangeFlags(QPinchGesture::ChangeFlags value) | - | ||||||||||||||||||
| 507 | { | - | ||||||||||||||||||
| 508 | d_func()->totalChangeFlags = value; | - | ||||||||||||||||||
| 509 | } never executed: end of block | 0 | ||||||||||||||||||
| 510 | - | |||||||||||||||||||
| 511 | QPinchGesture::ChangeFlags QPinchGesture::changeFlags() const | - | ||||||||||||||||||
| 512 | { | - | ||||||||||||||||||
| 513 | return d_func()->changeFlags; never executed: return d_func()->changeFlags; | 0 | ||||||||||||||||||
| 514 | } | - | ||||||||||||||||||
| 515 | - | |||||||||||||||||||
| 516 | void QPinchGesture::setChangeFlags(QPinchGesture::ChangeFlags value) | - | ||||||||||||||||||
| 517 | { | - | ||||||||||||||||||
| 518 | d_func()->changeFlags = value; | - | ||||||||||||||||||
| 519 | } never executed: end of block | 0 | ||||||||||||||||||
| 520 | - | |||||||||||||||||||
| 521 | QPointF QPinchGesture::startCenterPoint() const | - | ||||||||||||||||||
| 522 | { | - | ||||||||||||||||||
| 523 | return d_func()->startCenterPoint; never executed: return d_func()->startCenterPoint; | 0 | ||||||||||||||||||
| 524 | } | - | ||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | QPointF QPinchGesture::lastCenterPoint() const | - | ||||||||||||||||||
| 527 | { | - | ||||||||||||||||||
| 528 | return d_func()->lastCenterPoint; never executed: return d_func()->lastCenterPoint; | 0 | ||||||||||||||||||
| 529 | } | - | ||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 | QPointF QPinchGesture::centerPoint() const | - | ||||||||||||||||||
| 532 | { | - | ||||||||||||||||||
| 533 | return d_func()->centerPoint; never executed: return d_func()->centerPoint; | 0 | ||||||||||||||||||
| 534 | } | - | ||||||||||||||||||
| 535 | - | |||||||||||||||||||
| 536 | void QPinchGesture::setStartCenterPoint(const QPointF &value) | - | ||||||||||||||||||
| 537 | { | - | ||||||||||||||||||
| 538 | d_func()->startCenterPoint = value; | - | ||||||||||||||||||
| 539 | } never executed: end of block | 0 | ||||||||||||||||||
| 540 | - | |||||||||||||||||||
| 541 | void QPinchGesture::setLastCenterPoint(const QPointF &value) | - | ||||||||||||||||||
| 542 | { | - | ||||||||||||||||||
| 543 | d_func()->lastCenterPoint = value; | - | ||||||||||||||||||
| 544 | } never executed: end of block | 0 | ||||||||||||||||||
| 545 | - | |||||||||||||||||||
| 546 | void QPinchGesture::setCenterPoint(const QPointF &value) | - | ||||||||||||||||||
| 547 | { | - | ||||||||||||||||||
| 548 | d_func()->centerPoint = value; | - | ||||||||||||||||||
| 549 | } never executed: end of block | 0 | ||||||||||||||||||
| 550 | - | |||||||||||||||||||
| 551 | - | |||||||||||||||||||
| 552 | qreal QPinchGesture::totalScaleFactor() const | - | ||||||||||||||||||
| 553 | { | - | ||||||||||||||||||
| 554 | return d_func()->totalScaleFactor; never executed: return d_func()->totalScaleFactor; | 0 | ||||||||||||||||||
| 555 | } | - | ||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | qreal QPinchGesture::lastScaleFactor() const | - | ||||||||||||||||||
| 558 | { | - | ||||||||||||||||||
| 559 | return d_func()->lastScaleFactor; never executed: return d_func()->lastScaleFactor; | 0 | ||||||||||||||||||
| 560 | } | - | ||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | qreal QPinchGesture::scaleFactor() const | - | ||||||||||||||||||
| 563 | { | - | ||||||||||||||||||
| 564 | return d_func()->scaleFactor; never executed: return d_func()->scaleFactor; | 0 | ||||||||||||||||||
| 565 | } | - | ||||||||||||||||||
| 566 | - | |||||||||||||||||||
| 567 | void QPinchGesture::setTotalScaleFactor(qreal value) | - | ||||||||||||||||||
| 568 | { | - | ||||||||||||||||||
| 569 | d_func()->totalScaleFactor = value; | - | ||||||||||||||||||
| 570 | } never executed: end of block | 0 | ||||||||||||||||||
| 571 | - | |||||||||||||||||||
| 572 | void QPinchGesture::setLastScaleFactor(qreal value) | - | ||||||||||||||||||
| 573 | { | - | ||||||||||||||||||
| 574 | d_func()->lastScaleFactor = value; | - | ||||||||||||||||||
| 575 | } never executed: end of block | 0 | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | void QPinchGesture::setScaleFactor(qreal value) | - | ||||||||||||||||||
| 578 | { | - | ||||||||||||||||||
| 579 | d_func()->scaleFactor = value; | - | ||||||||||||||||||
| 580 | } never executed: end of block | 0 | ||||||||||||||||||
| 581 | - | |||||||||||||||||||
| 582 | - | |||||||||||||||||||
| 583 | qreal QPinchGesture::totalRotationAngle() const | - | ||||||||||||||||||
| 584 | { | - | ||||||||||||||||||
| 585 | return d_func()->totalRotationAngle; never executed: return d_func()->totalRotationAngle; | 0 | ||||||||||||||||||
| 586 | } | - | ||||||||||||||||||
| 587 | - | |||||||||||||||||||
| 588 | qreal QPinchGesture::lastRotationAngle() const | - | ||||||||||||||||||
| 589 | { | - | ||||||||||||||||||
| 590 | return d_func()->lastRotationAngle; never executed: return d_func()->lastRotationAngle; | 0 | ||||||||||||||||||
| 591 | } | - | ||||||||||||||||||
| 592 | - | |||||||||||||||||||
| 593 | qreal QPinchGesture::rotationAngle() const | - | ||||||||||||||||||
| 594 | { | - | ||||||||||||||||||
| 595 | return d_func()->rotationAngle; never executed: return d_func()->rotationAngle; | 0 | ||||||||||||||||||
| 596 | } | - | ||||||||||||||||||
| 597 | - | |||||||||||||||||||
| 598 | void QPinchGesture::setTotalRotationAngle(qreal value) | - | ||||||||||||||||||
| 599 | { | - | ||||||||||||||||||
| 600 | d_func()->totalRotationAngle = value; | - | ||||||||||||||||||
| 601 | } never executed: end of block | 0 | ||||||||||||||||||
| 602 | - | |||||||||||||||||||
| 603 | void QPinchGesture::setLastRotationAngle(qreal value) | - | ||||||||||||||||||
| 604 | { | - | ||||||||||||||||||
| 605 | d_func()->lastRotationAngle = value; | - | ||||||||||||||||||
| 606 | } never executed: end of block | 0 | ||||||||||||||||||
| 607 | - | |||||||||||||||||||
| 608 | void QPinchGesture::setRotationAngle(qreal value) | - | ||||||||||||||||||
| 609 | { | - | ||||||||||||||||||
| 610 | d_func()->rotationAngle = value; | - | ||||||||||||||||||
| 611 | } never executed: end of block | 0 | ||||||||||||||||||
| 612 | - | |||||||||||||||||||
| 613 | /*! | - | ||||||||||||||||||
| 614 | \class QSwipeGesture | - | ||||||||||||||||||
| 615 | \since 4.6 | - | ||||||||||||||||||
| 616 | \brief The QSwipeGesture class describes a swipe gesture made by the user. | - | ||||||||||||||||||
| 617 | \ingroup gestures | - | ||||||||||||||||||
| 618 | \inmodule QtWidgets | - | ||||||||||||||||||
| 619 | - | |||||||||||||||||||
| 620 | \image swipegesture.png | - | ||||||||||||||||||
| 621 | - | |||||||||||||||||||
| 622 | For an overview of gesture handling in Qt and information on using gestures | - | ||||||||||||||||||
| 623 | in your applications, see the \l{Gestures in Widgets and Graphics View} document. | - | ||||||||||||||||||
| 624 | - | |||||||||||||||||||
| 625 | \sa QPanGesture, QPinchGesture | - | ||||||||||||||||||
| 626 | */ | - | ||||||||||||||||||
| 627 | - | |||||||||||||||||||
| 628 | /*! | - | ||||||||||||||||||
| 629 | \enum QSwipeGesture::SwipeDirection | - | ||||||||||||||||||
| 630 | - | |||||||||||||||||||
| 631 | This enum describes the possible directions for the gesture's motion | - | ||||||||||||||||||
| 632 | along the horizontal and vertical axes. | - | ||||||||||||||||||
| 633 | - | |||||||||||||||||||
| 634 | \value NoDirection The gesture had no motion associated with it on a particular axis. | - | ||||||||||||||||||
| 635 | \value Left The gesture involved a horizontal motion to the left. | - | ||||||||||||||||||
| 636 | \value Right The gesture involved a horizontal motion to the right. | - | ||||||||||||||||||
| 637 | \value Up The gesture involved an upward vertical motion. | - | ||||||||||||||||||
| 638 | \value Down The gesture involved a downward vertical motion. | - | ||||||||||||||||||
| 639 | */ | - | ||||||||||||||||||
| 640 | - | |||||||||||||||||||
| 641 | /*! | - | ||||||||||||||||||
| 642 | \property QSwipeGesture::horizontalDirection | - | ||||||||||||||||||
| 643 | \brief the horizontal direction of the gesture | - | ||||||||||||||||||
| 644 | - | |||||||||||||||||||
| 645 | If the gesture has a horizontal component, the horizontal direction | - | ||||||||||||||||||
| 646 | is either Left or Right; otherwise, it is NoDirection. | - | ||||||||||||||||||
| 647 | - | |||||||||||||||||||
| 648 | \sa verticalDirection, swipeAngle | - | ||||||||||||||||||
| 649 | */ | - | ||||||||||||||||||
| 650 | - | |||||||||||||||||||
| 651 | /*! | - | ||||||||||||||||||
| 652 | \property QSwipeGesture::verticalDirection | - | ||||||||||||||||||
| 653 | \brief the vertical direction of the gesture | - | ||||||||||||||||||
| 654 | - | |||||||||||||||||||
| 655 | If the gesture has a vertical component, the vertical direction | - | ||||||||||||||||||
| 656 | is either Up or Down; otherwise, it is NoDirection. | - | ||||||||||||||||||
| 657 | - | |||||||||||||||||||
| 658 | \sa horizontalDirection, swipeAngle | - | ||||||||||||||||||
| 659 | */ | - | ||||||||||||||||||
| 660 | - | |||||||||||||||||||
| 661 | /*! | - | ||||||||||||||||||
| 662 | \property QSwipeGesture::swipeAngle | - | ||||||||||||||||||
| 663 | \brief the angle of the motion associated with the gesture | - | ||||||||||||||||||
| 664 | - | |||||||||||||||||||
| 665 | If the gesture has either a horizontal or vertical component, the | - | ||||||||||||||||||
| 666 | swipe angle describes the angle between the direction of motion and the | - | ||||||||||||||||||
| 667 | x-axis as defined using the standard widget | - | ||||||||||||||||||
| 668 | \l{Coordinate System}{coordinate system}. | - | ||||||||||||||||||
| 669 | - | |||||||||||||||||||
| 670 | \sa horizontalDirection, verticalDirection | - | ||||||||||||||||||
| 671 | */ | - | ||||||||||||||||||
| 672 | - | |||||||||||||||||||
| 673 | /*! | - | ||||||||||||||||||
| 674 | \property QSwipeGesture::velocity | - | ||||||||||||||||||
| 675 | \since 4.7.1 | - | ||||||||||||||||||
| 676 | \internal | - | ||||||||||||||||||
| 677 | */ | - | ||||||||||||||||||
| 678 | - | |||||||||||||||||||
| 679 | /*! | - | ||||||||||||||||||
| 680 | \internal | - | ||||||||||||||||||
| 681 | */ | - | ||||||||||||||||||
| 682 | QSwipeGesture::QSwipeGesture(QObject *parent) | - | ||||||||||||||||||
| 683 | : QGesture(*new QSwipeGesturePrivate, parent) | - | ||||||||||||||||||
| 684 | { | - | ||||||||||||||||||
| 685 | d_func()->gestureType = Qt::SwipeGesture; | - | ||||||||||||||||||
| 686 | } never executed: end of block | 0 | ||||||||||||||||||
| 687 | - | |||||||||||||||||||
| 688 | /*! | - | ||||||||||||||||||
| 689 | Destructor. | - | ||||||||||||||||||
| 690 | */ | - | ||||||||||||||||||
| 691 | QSwipeGesture::~QSwipeGesture() | - | ||||||||||||||||||
| 692 | { | - | ||||||||||||||||||
| 693 | } | - | ||||||||||||||||||
| 694 | - | |||||||||||||||||||
| 695 | QSwipeGesture::SwipeDirection QSwipeGesture::horizontalDirection() const | - | ||||||||||||||||||
| 696 | { | - | ||||||||||||||||||
| 697 | Q_D(const QSwipeGesture); | - | ||||||||||||||||||
| 698 | if (d->swipeAngle < 0 || d->swipeAngle == 90 || d->swipeAngle == 270)
| 0 | ||||||||||||||||||
| 699 | return QSwipeGesture::NoDirection; never executed: return QSwipeGesture::NoDirection; | 0 | ||||||||||||||||||
| 700 | else if (d->swipeAngle < 90 || d->swipeAngle > 270)
| 0 | ||||||||||||||||||
| 701 | return QSwipeGesture::Right; never executed: return QSwipeGesture::Right; | 0 | ||||||||||||||||||
| 702 | else | - | ||||||||||||||||||
| 703 | return QSwipeGesture::Left; never executed: return QSwipeGesture::Left; | 0 | ||||||||||||||||||
| 704 | } | - | ||||||||||||||||||
| 705 | - | |||||||||||||||||||
| 706 | QSwipeGesture::SwipeDirection QSwipeGesture::verticalDirection() const | - | ||||||||||||||||||
| 707 | { | - | ||||||||||||||||||
| 708 | Q_D(const QSwipeGesture); | - | ||||||||||||||||||
| 709 | if (d->swipeAngle <= 0 || d->swipeAngle == 180)
| 0 | ||||||||||||||||||
| 710 | return QSwipeGesture::NoDirection; never executed: return QSwipeGesture::NoDirection; | 0 | ||||||||||||||||||
| 711 | else if (d->swipeAngle < 180)
| 0 | ||||||||||||||||||
| 712 | return QSwipeGesture::Up; never executed: return QSwipeGesture::Up; | 0 | ||||||||||||||||||
| 713 | else | - | ||||||||||||||||||
| 714 | return QSwipeGesture::Down; never executed: return QSwipeGesture::Down; | 0 | ||||||||||||||||||
| 715 | } | - | ||||||||||||||||||
| 716 | - | |||||||||||||||||||
| 717 | qreal QSwipeGesture::swipeAngle() const | - | ||||||||||||||||||
| 718 | { | - | ||||||||||||||||||
| 719 | return d_func()->swipeAngle; never executed: return d_func()->swipeAngle; | 0 | ||||||||||||||||||
| 720 | } | - | ||||||||||||||||||
| 721 | - | |||||||||||||||||||
| 722 | void QSwipeGesture::setSwipeAngle(qreal value) | - | ||||||||||||||||||
| 723 | { | - | ||||||||||||||||||
| 724 | d_func()->swipeAngle = value; | - | ||||||||||||||||||
| 725 | } never executed: end of block | 0 | ||||||||||||||||||
| 726 | - | |||||||||||||||||||
| 727 | /*! | - | ||||||||||||||||||
| 728 | \class QTapGesture | - | ||||||||||||||||||
| 729 | \since 4.6 | - | ||||||||||||||||||
| 730 | \brief The QTapGesture class describes a tap gesture made by the user. | - | ||||||||||||||||||
| 731 | \ingroup gestures | - | ||||||||||||||||||
| 732 | \inmodule QtWidgets | - | ||||||||||||||||||
| 733 | - | |||||||||||||||||||
| 734 | For an overview of gesture handling in Qt and information on using gestures | - | ||||||||||||||||||
| 735 | in your applications, see the \l{Gestures in Widgets and Graphics View} document. | - | ||||||||||||||||||
| 736 | - | |||||||||||||||||||
| 737 | \sa QPanGesture, QPinchGesture | - | ||||||||||||||||||
| 738 | */ | - | ||||||||||||||||||
| 739 | - | |||||||||||||||||||
| 740 | /*! | - | ||||||||||||||||||
| 741 | \property QTapGesture::position | - | ||||||||||||||||||
| 742 | \brief the position of the tap | - | ||||||||||||||||||
| 743 | */ | - | ||||||||||||||||||
| 744 | - | |||||||||||||||||||
| 745 | /*! | - | ||||||||||||||||||
| 746 | \internal | - | ||||||||||||||||||
| 747 | */ | - | ||||||||||||||||||
| 748 | QTapGesture::QTapGesture(QObject *parent) | - | ||||||||||||||||||
| 749 | : QGesture(*new QTapGesturePrivate, parent) | - | ||||||||||||||||||
| 750 | { | - | ||||||||||||||||||
| 751 | d_func()->gestureType = Qt::TapGesture; | - | ||||||||||||||||||
| 752 | } never executed: end of block | 0 | ||||||||||||||||||
| 753 | - | |||||||||||||||||||
| 754 | /*! | - | ||||||||||||||||||
| 755 | Destructor. | - | ||||||||||||||||||
| 756 | */ | - | ||||||||||||||||||
| 757 | QTapGesture::~QTapGesture() | - | ||||||||||||||||||
| 758 | { | - | ||||||||||||||||||
| 759 | } | - | ||||||||||||||||||
| 760 | - | |||||||||||||||||||
| 761 | QPointF QTapGesture::position() const | - | ||||||||||||||||||
| 762 | { | - | ||||||||||||||||||
| 763 | return d_func()->position; never executed: return d_func()->position; | 0 | ||||||||||||||||||
| 764 | } | - | ||||||||||||||||||
| 765 | - | |||||||||||||||||||
| 766 | void QTapGesture::setPosition(const QPointF &value) | - | ||||||||||||||||||
| 767 | { | - | ||||||||||||||||||
| 768 | d_func()->position = value; | - | ||||||||||||||||||
| 769 | } never executed: end of block | 0 | ||||||||||||||||||
| 770 | /*! | - | ||||||||||||||||||
| 771 | \class QTapAndHoldGesture | - | ||||||||||||||||||
| 772 | \since 4.6 | - | ||||||||||||||||||
| 773 | \brief The QTapAndHoldGesture class describes a tap-and-hold (aka LongTap) | - | ||||||||||||||||||
| 774 | gesture made by the user. | - | ||||||||||||||||||
| 775 | \ingroup gestures | - | ||||||||||||||||||
| 776 | \inmodule QtWidgets | - | ||||||||||||||||||
| 777 | - | |||||||||||||||||||
| 778 | For an overview of gesture handling in Qt and information on using gestures | - | ||||||||||||||||||
| 779 | in your applications, see the \l{Gestures in Widgets and Graphics View} document. | - | ||||||||||||||||||
| 780 | - | |||||||||||||||||||
| 781 | \sa QPanGesture, QPinchGesture | - | ||||||||||||||||||
| 782 | */ | - | ||||||||||||||||||
| 783 | - | |||||||||||||||||||
| 784 | /*! | - | ||||||||||||||||||
| 785 | \property QTapAndHoldGesture::position | - | ||||||||||||||||||
| 786 | \brief the position of the tap | - | ||||||||||||||||||
| 787 | */ | - | ||||||||||||||||||
| 788 | - | |||||||||||||||||||
| 789 | /*! | - | ||||||||||||||||||
| 790 | \internal | - | ||||||||||||||||||
| 791 | */ | - | ||||||||||||||||||
| 792 | QTapAndHoldGesture::QTapAndHoldGesture(QObject *parent) | - | ||||||||||||||||||
| 793 | : QGesture(*new QTapAndHoldGesturePrivate, parent) | - | ||||||||||||||||||
| 794 | { | - | ||||||||||||||||||
| 795 | d_func()->gestureType = Qt::TapAndHoldGesture; | - | ||||||||||||||||||
| 796 | } never executed: end of block | 0 | ||||||||||||||||||
| 797 | - | |||||||||||||||||||
| 798 | /*! | - | ||||||||||||||||||
| 799 | Destructor. | - | ||||||||||||||||||
| 800 | */ | - | ||||||||||||||||||
| 801 | QTapAndHoldGesture::~QTapAndHoldGesture() | - | ||||||||||||||||||
| 802 | { | - | ||||||||||||||||||
| 803 | } | - | ||||||||||||||||||
| 804 | - | |||||||||||||||||||
| 805 | QPointF QTapAndHoldGesture::position() const | - | ||||||||||||||||||
| 806 | { | - | ||||||||||||||||||
| 807 | return d_func()->position; never executed: return d_func()->position; | 0 | ||||||||||||||||||
| 808 | } | - | ||||||||||||||||||
| 809 | - | |||||||||||||||||||
| 810 | void QTapAndHoldGesture::setPosition(const QPointF &value) | - | ||||||||||||||||||
| 811 | { | - | ||||||||||||||||||
| 812 | d_func()->position = value; | - | ||||||||||||||||||
| 813 | } never executed: end of block | 0 | ||||||||||||||||||
| 814 | - | |||||||||||||||||||
| 815 | /*! | - | ||||||||||||||||||
| 816 | Set the timeout, in milliseconds, before the gesture triggers. | - | ||||||||||||||||||
| 817 | - | |||||||||||||||||||
| 818 | The recognizer will detect a touch down and if \a msecs | - | ||||||||||||||||||
| 819 | later the touch is still down, it will trigger the QTapAndHoldGesture. | - | ||||||||||||||||||
| 820 | The default value is 700 milliseconds. | - | ||||||||||||||||||
| 821 | */ | - | ||||||||||||||||||
| 822 | // static | - | ||||||||||||||||||
| 823 | void QTapAndHoldGesture::setTimeout(int msecs) | - | ||||||||||||||||||
| 824 | { | - | ||||||||||||||||||
| 825 | QTapAndHoldGesturePrivate::Timeout = msecs; | - | ||||||||||||||||||
| 826 | } never executed: end of block | 0 | ||||||||||||||||||
| 827 | - | |||||||||||||||||||
| 828 | /*! | - | ||||||||||||||||||
| 829 | Gets the timeout, in milliseconds, before the gesture triggers. | - | ||||||||||||||||||
| 830 | - | |||||||||||||||||||
| 831 | The recognizer will detect a touch down and if timeout() | - | ||||||||||||||||||
| 832 | later the touch is still down, it will trigger the QTapAndHoldGesture. | - | ||||||||||||||||||
| 833 | The default value is 700 milliseconds. | - | ||||||||||||||||||
| 834 | */ | - | ||||||||||||||||||
| 835 | // static | - | ||||||||||||||||||
| 836 | int QTapAndHoldGesture::timeout() | - | ||||||||||||||||||
| 837 | { | - | ||||||||||||||||||
| 838 | return QTapAndHoldGesturePrivate::Timeout; never executed: return QTapAndHoldGesturePrivate::Timeout; | 0 | ||||||||||||||||||
| 839 | } | - | ||||||||||||||||||
| 840 | - | |||||||||||||||||||
| 841 | int QTapAndHoldGesturePrivate::Timeout = 700; // in ms | - | ||||||||||||||||||
| 842 | - | |||||||||||||||||||
| 843 | - | |||||||||||||||||||
| 844 | /*! | - | ||||||||||||||||||
| 845 | \class QGestureEvent | - | ||||||||||||||||||
| 846 | \since 4.6 | - | ||||||||||||||||||
| 847 | \ingroup events | - | ||||||||||||||||||
| 848 | \ingroup gestures | - | ||||||||||||||||||
| 849 | \inmodule QtWidgets | - | ||||||||||||||||||
| 850 | - | |||||||||||||||||||
| 851 | \brief The QGestureEvent class provides the description of triggered gestures. | - | ||||||||||||||||||
| 852 | - | |||||||||||||||||||
| 853 | The QGestureEvent class contains a list of gestures, which can be obtained using the | - | ||||||||||||||||||
| 854 | gestures() function. | - | ||||||||||||||||||
| 855 | - | |||||||||||||||||||
| 856 | The gestures are either active or canceled. A list of those that are currently being | - | ||||||||||||||||||
| 857 | executed can be obtained using the activeGestures() function. A list of those which | - | ||||||||||||||||||
| 858 | were previously active and have been canceled can be accessed using the | - | ||||||||||||||||||
| 859 | canceledGestures() function. A gesture might be canceled if the current window loses | - | ||||||||||||||||||
| 860 | focus, for example, or because of a timeout, or for other reasons. | - | ||||||||||||||||||
| 861 | - | |||||||||||||||||||
| 862 | If the event handler does not accept the event by calling the generic | - | ||||||||||||||||||
| 863 | QEvent::accept() function, all individual QGesture object that were not | - | ||||||||||||||||||
| 864 | accepted and in the Qt::GestureStarted state will be propagated up the | - | ||||||||||||||||||
| 865 | parent widget chain until a widget accepts them individually, by calling | - | ||||||||||||||||||
| 866 | QGestureEvent::accept() for each of them, or an event filter consumes the | - | ||||||||||||||||||
| 867 | event. | - | ||||||||||||||||||
| 868 | - | |||||||||||||||||||
| 869 | \section1 Further Reading | - | ||||||||||||||||||
| 870 | - | |||||||||||||||||||
| 871 | For an overview of gesture handling in Qt and information on using gestures | - | ||||||||||||||||||
| 872 | in your applications, see the \l{Gestures in Widgets and Graphics View} document. | - | ||||||||||||||||||
| 873 | - | |||||||||||||||||||
| 874 | \sa QGesture, QGestureRecognizer, | - | ||||||||||||||||||
| 875 | QWidget::grabGesture(), QGraphicsObject::grabGesture() | - | ||||||||||||||||||
| 876 | */ | - | ||||||||||||||||||
| 877 | - | |||||||||||||||||||
| 878 | /*! | - | ||||||||||||||||||
| 879 | Creates new QGestureEvent containing a list of \a gestures. | - | ||||||||||||||||||
| 880 | */ | - | ||||||||||||||||||
| 881 | QGestureEvent::QGestureEvent(const QList<QGesture *> &gestures) | - | ||||||||||||||||||
| 882 | : QEvent(QEvent::Gesture), m_gestures(gestures), m_widget(0) | - | ||||||||||||||||||
| 883 | - | |||||||||||||||||||
| 884 | { | - | ||||||||||||||||||
| 885 | } never executed: end of block | 0 | ||||||||||||||||||
| 886 | - | |||||||||||||||||||
| 887 | /*! | - | ||||||||||||||||||
| 888 | Destroys QGestureEvent. | - | ||||||||||||||||||
| 889 | */ | - | ||||||||||||||||||
| 890 | QGestureEvent::~QGestureEvent() | - | ||||||||||||||||||
| 891 | { | - | ||||||||||||||||||
| 892 | } | - | ||||||||||||||||||
| 893 | - | |||||||||||||||||||
| 894 | /*! | - | ||||||||||||||||||
| 895 | Returns all gestures that are delivered in the event. | - | ||||||||||||||||||
| 896 | */ | - | ||||||||||||||||||
| 897 | QList<QGesture *> QGestureEvent::gestures() const | - | ||||||||||||||||||
| 898 | { | - | ||||||||||||||||||
| 899 | return m_gestures; never executed: return m_gestures; | 0 | ||||||||||||||||||
| 900 | } | - | ||||||||||||||||||
| 901 | - | |||||||||||||||||||
| 902 | /*! | - | ||||||||||||||||||
| 903 | Returns a gesture object by \a type. | - | ||||||||||||||||||
| 904 | */ | - | ||||||||||||||||||
| 905 | QGesture *QGestureEvent::gesture(Qt::GestureType type) const | - | ||||||||||||||||||
| 906 | { | - | ||||||||||||||||||
| 907 | for (int i = 0; i < m_gestures.size(); ++i)
| 0 | ||||||||||||||||||
| 908 | if (m_gestures.at(i)->gestureType() == type)
| 0 | ||||||||||||||||||
| 909 | return m_gestures.at(i); never executed: return m_gestures.at(i); | 0 | ||||||||||||||||||
| 910 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 911 | } | - | ||||||||||||||||||
| 912 | - | |||||||||||||||||||
| 913 | /*! | - | ||||||||||||||||||
| 914 | Returns a list of active (not canceled) gestures. | - | ||||||||||||||||||
| 915 | */ | - | ||||||||||||||||||
| 916 | QList<QGesture *> QGestureEvent::activeGestures() const | - | ||||||||||||||||||
| 917 | { | - | ||||||||||||||||||
| 918 | QList<QGesture *> gestures; | - | ||||||||||||||||||
| 919 | foreach (QGesture *gesture, m_gestures) { | - | ||||||||||||||||||
| 920 | if (gesture->state() != Qt::GestureCanceled)
| 0 | ||||||||||||||||||
| 921 | gestures.append(gesture); never executed: gestures.append(gesture); | 0 | ||||||||||||||||||
| 922 | } never executed: end of block | 0 | ||||||||||||||||||
| 923 | return gestures; never executed: return gestures; | 0 | ||||||||||||||||||
| 924 | } | - | ||||||||||||||||||
| 925 | - | |||||||||||||||||||
| 926 | /*! | - | ||||||||||||||||||
| 927 | Returns a list of canceled gestures. | - | ||||||||||||||||||
| 928 | */ | - | ||||||||||||||||||
| 929 | QList<QGesture *> QGestureEvent::canceledGestures() const | - | ||||||||||||||||||
| 930 | { | - | ||||||||||||||||||
| 931 | QList<QGesture *> gestures; | - | ||||||||||||||||||
| 932 | foreach (QGesture *gesture, m_gestures) { | - | ||||||||||||||||||
| 933 | if (gesture->state() == Qt::GestureCanceled)
| 0 | ||||||||||||||||||
| 934 | gestures.append(gesture); never executed: gestures.append(gesture); | 0 | ||||||||||||||||||
| 935 | } never executed: end of block | 0 | ||||||||||||||||||
| 936 | return gestures; never executed: return gestures; | 0 | ||||||||||||||||||
| 937 | } | - | ||||||||||||||||||
| 938 | - | |||||||||||||||||||
| 939 | /*! | - | ||||||||||||||||||
| 940 | Sets the accept flag of the given \a gesture object to the specified \a value. | - | ||||||||||||||||||
| 941 | - | |||||||||||||||||||
| 942 | Setting the accept flag indicates that the event receiver wants the \a gesture. | - | ||||||||||||||||||
| 943 | Unwanted gestures may be propagated to the parent widget. | - | ||||||||||||||||||
| 944 | - | |||||||||||||||||||
| 945 | By default, gestures in events of type QEvent::Gesture are accepted, and | - | ||||||||||||||||||
| 946 | gestures in QEvent::GestureOverride events are ignored. | - | ||||||||||||||||||
| 947 | - | |||||||||||||||||||
| 948 | For convenience, the accept flag can also be set with | - | ||||||||||||||||||
| 949 | \l{QGestureEvent::accept()}{accept(gesture)}, and cleared with | - | ||||||||||||||||||
| 950 | \l{QGestureEvent::ignore()}{ignore(gesture)}. | - | ||||||||||||||||||
| 951 | */ | - | ||||||||||||||||||
| 952 | void QGestureEvent::setAccepted(QGesture *gesture, bool value) | - | ||||||||||||||||||
| 953 | { | - | ||||||||||||||||||
| 954 | if (gesture)
| 0 | ||||||||||||||||||
| 955 | setAccepted(gesture->gestureType(), value); never executed: setAccepted(gesture->gestureType(), value); | 0 | ||||||||||||||||||
| 956 | } never executed: end of block | 0 | ||||||||||||||||||
| 957 | - | |||||||||||||||||||
| 958 | /*! | - | ||||||||||||||||||
| 959 | Sets the accept flag of the given \a gesture object, the equivalent of calling | - | ||||||||||||||||||
| 960 | \l{QGestureEvent::setAccepted()}{setAccepted(gesture, true)}. | - | ||||||||||||||||||
| 961 | - | |||||||||||||||||||
| 962 | Setting the accept flag indicates that the event receiver wants the | - | ||||||||||||||||||
| 963 | gesture. Unwanted gestures may be propagated to the parent widget. | - | ||||||||||||||||||
| 964 | - | |||||||||||||||||||
| 965 | \sa QGestureEvent::ignore() | - | ||||||||||||||||||
| 966 | */ | - | ||||||||||||||||||
| 967 | void QGestureEvent::accept(QGesture *gesture) | - | ||||||||||||||||||
| 968 | { | - | ||||||||||||||||||
| 969 | if (gesture)
| 0 | ||||||||||||||||||
| 970 | setAccepted(gesture->gestureType(), true); never executed: setAccepted(gesture->gestureType(), true); | 0 | ||||||||||||||||||
| 971 | } never executed: end of block | 0 | ||||||||||||||||||
| 972 | - | |||||||||||||||||||
| 973 | /*! | - | ||||||||||||||||||
| 974 | Clears the accept flag parameter of the given \a gesture object, the equivalent | - | ||||||||||||||||||
| 975 | of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}. | - | ||||||||||||||||||
| 976 | - | |||||||||||||||||||
| 977 | Clearing the accept flag indicates that the event receiver does not | - | ||||||||||||||||||
| 978 | want the gesture. Unwanted gestures may be propagated to the parent widget. | - | ||||||||||||||||||
| 979 | - | |||||||||||||||||||
| 980 | \sa QGestureEvent::accept() | - | ||||||||||||||||||
| 981 | */ | - | ||||||||||||||||||
| 982 | void QGestureEvent::ignore(QGesture *gesture) | - | ||||||||||||||||||
| 983 | { | - | ||||||||||||||||||
| 984 | if (gesture)
| 0 | ||||||||||||||||||
| 985 | setAccepted(gesture->gestureType(), false); never executed: setAccepted(gesture->gestureType(), false); | 0 | ||||||||||||||||||
| 986 | } never executed: end of block | 0 | ||||||||||||||||||
| 987 | - | |||||||||||||||||||
| 988 | /*! | - | ||||||||||||||||||
| 989 | Returns \c true if the \a gesture is accepted; otherwise returns \c false. | - | ||||||||||||||||||
| 990 | */ | - | ||||||||||||||||||
| 991 | bool QGestureEvent::isAccepted(QGesture *gesture) const | - | ||||||||||||||||||
| 992 | { | - | ||||||||||||||||||
| 993 | return gesture ? isAccepted(gesture->gestureType()) : false; never executed: return gesture ? isAccepted(gesture->gestureType()) : false; | 0 | ||||||||||||||||||
| 994 | } | - | ||||||||||||||||||
| 995 | - | |||||||||||||||||||
| 996 | /*! | - | ||||||||||||||||||
| 997 | Sets the accept flag of the given \a gestureType object to the specified | - | ||||||||||||||||||
| 998 | \a value. | - | ||||||||||||||||||
| 999 | - | |||||||||||||||||||
| 1000 | Setting the accept flag indicates that the event receiver wants to receive | - | ||||||||||||||||||
| 1001 | gestures of the specified type, \a gestureType. Unwanted gestures may be | - | ||||||||||||||||||
| 1002 | propagated to the parent widget. | - | ||||||||||||||||||
| 1003 | - | |||||||||||||||||||
| 1004 | By default, gestures in events of type QEvent::Gesture are accepted, and | - | ||||||||||||||||||
| 1005 | gestures in QEvent::GestureOverride events are ignored. | - | ||||||||||||||||||
| 1006 | - | |||||||||||||||||||
| 1007 | For convenience, the accept flag can also be set with | - | ||||||||||||||||||
| 1008 | \l{QGestureEvent::accept()}{accept(gestureType)}, and cleared with | - | ||||||||||||||||||
| 1009 | \l{QGestureEvent::ignore()}{ignore(gestureType)}. | - | ||||||||||||||||||
| 1010 | */ | - | ||||||||||||||||||
| 1011 | void QGestureEvent::setAccepted(Qt::GestureType gestureType, bool value) | - | ||||||||||||||||||
| 1012 | { | - | ||||||||||||||||||
| 1013 | setAccepted(false); | - | ||||||||||||||||||
| 1014 | m_accepted[gestureType] = value; | - | ||||||||||||||||||
| 1015 | } never executed: end of block | 0 | ||||||||||||||||||
| 1016 | - | |||||||||||||||||||
| 1017 | /*! | - | ||||||||||||||||||
| 1018 | Sets the accept flag of the given \a gestureType, the equivalent of calling | - | ||||||||||||||||||
| 1019 | \l{QGestureEvent::setAccepted()}{setAccepted(gestureType, true)}. | - | ||||||||||||||||||
| 1020 | - | |||||||||||||||||||
| 1021 | Setting the accept flag indicates that the event receiver wants the | - | ||||||||||||||||||
| 1022 | gesture. Unwanted gestures may be propagated to the parent widget. | - | ||||||||||||||||||
| 1023 | - | |||||||||||||||||||
| 1024 | \sa QGestureEvent::ignore() | - | ||||||||||||||||||
| 1025 | */ | - | ||||||||||||||||||
| 1026 | void QGestureEvent::accept(Qt::GestureType gestureType) | - | ||||||||||||||||||
| 1027 | { | - | ||||||||||||||||||
| 1028 | setAccepted(gestureType, true); | - | ||||||||||||||||||
| 1029 | } never executed: end of block | 0 | ||||||||||||||||||
| 1030 | - | |||||||||||||||||||
| 1031 | /*! | - | ||||||||||||||||||
| 1032 | Clears the accept flag parameter of the given \a gestureType, the equivalent | - | ||||||||||||||||||
| 1033 | of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}. | - | ||||||||||||||||||
| 1034 | - | |||||||||||||||||||
| 1035 | Clearing the accept flag indicates that the event receiver does not | - | ||||||||||||||||||
| 1036 | want the gesture. Unwanted gestures may be propgated to the parent widget. | - | ||||||||||||||||||
| 1037 | - | |||||||||||||||||||
| 1038 | \sa QGestureEvent::accept() | - | ||||||||||||||||||
| 1039 | */ | - | ||||||||||||||||||
| 1040 | void QGestureEvent::ignore(Qt::GestureType gestureType) | - | ||||||||||||||||||
| 1041 | { | - | ||||||||||||||||||
| 1042 | setAccepted(gestureType, false); | - | ||||||||||||||||||
| 1043 | } never executed: end of block | 0 | ||||||||||||||||||
| 1044 | - | |||||||||||||||||||
| 1045 | /*! | - | ||||||||||||||||||
| 1046 | Returns \c true if the gesture of type \a gestureType is accepted; otherwise | - | ||||||||||||||||||
| 1047 | returns \c false. | - | ||||||||||||||||||
| 1048 | */ | - | ||||||||||||||||||
| 1049 | bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const | - | ||||||||||||||||||
| 1050 | { | - | ||||||||||||||||||
| 1051 | return m_accepted.value(gestureType, true); never executed: return m_accepted.value(gestureType, true); | 0 | ||||||||||||||||||
| 1052 | } | - | ||||||||||||||||||
| 1053 | - | |||||||||||||||||||
| 1054 | /*! | - | ||||||||||||||||||
| 1055 | \internal | - | ||||||||||||||||||
| 1056 | - | |||||||||||||||||||
| 1057 | Sets the widget for this event to the \a widget specified. | - | ||||||||||||||||||
| 1058 | */ | - | ||||||||||||||||||
| 1059 | void QGestureEvent::setWidget(QWidget *widget) | - | ||||||||||||||||||
| 1060 | { | - | ||||||||||||||||||
| 1061 | m_widget = widget; | - | ||||||||||||||||||
| 1062 | } never executed: end of block | 0 | ||||||||||||||||||
| 1063 | - | |||||||||||||||||||
| 1064 | /*! | - | ||||||||||||||||||
| 1065 | Returns the widget on which the event occurred. | - | ||||||||||||||||||
| 1066 | */ | - | ||||||||||||||||||
| 1067 | QWidget *QGestureEvent::widget() const | - | ||||||||||||||||||
| 1068 | { | - | ||||||||||||||||||
| 1069 | return m_widget; never executed: return m_widget; | 0 | ||||||||||||||||||
| 1070 | } | - | ||||||||||||||||||
| 1071 | - | |||||||||||||||||||
| 1072 | #ifndef QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||
| 1073 | /*! | - | ||||||||||||||||||
| 1074 | Returns the scene-local coordinates if the \a gesturePoint is inside a | - | ||||||||||||||||||
| 1075 | graphics view. | - | ||||||||||||||||||
| 1076 | - | |||||||||||||||||||
| 1077 | This functional might be useful when the gesture event is delivered to a | - | ||||||||||||||||||
| 1078 | QGraphicsObject to translate a point in screen coordinates to scene-local | - | ||||||||||||||||||
| 1079 | coordinates. | - | ||||||||||||||||||
| 1080 | - | |||||||||||||||||||
| 1081 | \sa QPointF::isNull() | - | ||||||||||||||||||
| 1082 | */ | - | ||||||||||||||||||
| 1083 | QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const | - | ||||||||||||||||||
| 1084 | { | - | ||||||||||||||||||
| 1085 | QWidget *w = widget(); | - | ||||||||||||||||||
| 1086 | if (w) // we get the viewport as widget, not the graphics view
| 0 | ||||||||||||||||||
| 1087 | w = w->parentWidget(); never executed: w = w->parentWidget(); | 0 | ||||||||||||||||||
| 1088 | QGraphicsView *view = qobject_cast<QGraphicsView*>(w); | - | ||||||||||||||||||
| 1089 | if (view) {
| 0 | ||||||||||||||||||
| 1090 | return view->mapToScene(view->mapFromGlobal(gesturePoint.toPoint())); never executed: return view->mapToScene(view->mapFromGlobal(gesturePoint.toPoint())); | 0 | ||||||||||||||||||
| 1091 | } | - | ||||||||||||||||||
| 1092 | return QPointF(); never executed: return QPointF(); | 0 | ||||||||||||||||||
| 1093 | } | - | ||||||||||||||||||
| 1094 | #endif //QT_NO_GRAPHICSVIEW | - | ||||||||||||||||||
| 1095 | - | |||||||||||||||||||
| 1096 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||
| 1097 | - | |||||||||||||||||||
| 1098 | static void formatGestureHeader(QDebug d, const char *className, const QGesture *gesture) | - | ||||||||||||||||||
| 1099 | { | - | ||||||||||||||||||
| 1100 | d << className << "(state="; | - | ||||||||||||||||||
| 1101 | QtDebugUtils::formatQEnum(d, gesture->state()); | - | ||||||||||||||||||
| 1102 | if (gesture->hasHotSpot()) {
| 0 | ||||||||||||||||||
| 1103 | d << ",hotSpot="; | - | ||||||||||||||||||
| 1104 | QtDebugUtils::formatQPoint(d, gesture->hotSpot()); | - | ||||||||||||||||||
| 1105 | } never executed: end of block | 0 | ||||||||||||||||||
| 1106 | } never executed: end of block | 0 | ||||||||||||||||||
| 1107 | - | |||||||||||||||||||
| 1108 | Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGesture *gesture) | - | ||||||||||||||||||
| 1109 | { | - | ||||||||||||||||||
| 1110 | QDebugStateSaver saver(d); | - | ||||||||||||||||||
| 1111 | d.nospace(); | - | ||||||||||||||||||
| 1112 | switch (gesture->gestureType()) { | - | ||||||||||||||||||
| 1113 | case Qt::TapGesture: never executed: case Qt::TapGesture: | 0 | ||||||||||||||||||
| 1114 | formatGestureHeader(d, "QTapGesture", gesture); | - | ||||||||||||||||||
| 1115 | d << ",position="; | - | ||||||||||||||||||
| 1116 | QtDebugUtils::formatQPoint(d, static_cast<const QTapGesture*>(gesture)->position()); | - | ||||||||||||||||||
| 1117 | d << ')'; | - | ||||||||||||||||||
| 1118 | break; never executed: break; | 0 | ||||||||||||||||||
| 1119 | case Qt::TapAndHoldGesture: { never executed: case Qt::TapAndHoldGesture: | 0 | ||||||||||||||||||
| 1120 | const QTapAndHoldGesture *tap = static_cast<const QTapAndHoldGesture*>(gesture); | - | ||||||||||||||||||
| 1121 | formatGestureHeader(d, "QTapAndHoldGesture", tap); | - | ||||||||||||||||||
| 1122 | d << ",position="; | - | ||||||||||||||||||
| 1123 | QtDebugUtils::formatQPoint(d, tap->position()); | - | ||||||||||||||||||
| 1124 | d << ",timeout=" << tap->timeout() << ')'; | - | ||||||||||||||||||
| 1125 | } | - | ||||||||||||||||||
| 1126 | break; never executed: break; | 0 | ||||||||||||||||||
| 1127 | case Qt::PanGesture: { never executed: case Qt::PanGesture: | 0 | ||||||||||||||||||
| 1128 | const QPanGesture *pan = static_cast<const QPanGesture*>(gesture); | - | ||||||||||||||||||
| 1129 | formatGestureHeader(d, "QPanGesture", pan); | - | ||||||||||||||||||
| 1130 | d << ",lastOffset="; | - | ||||||||||||||||||
| 1131 | QtDebugUtils::formatQPoint(d, pan->lastOffset()); | - | ||||||||||||||||||
| 1132 | d << pan->lastOffset(); | - | ||||||||||||||||||
| 1133 | d << ",offset="; | - | ||||||||||||||||||
| 1134 | QtDebugUtils::formatQPoint(d, pan->offset()); | - | ||||||||||||||||||
| 1135 | d << ",acceleration=" << pan->acceleration() << ",delta="; | - | ||||||||||||||||||
| 1136 | QtDebugUtils::formatQPoint(d, pan->delta()); | - | ||||||||||||||||||
| 1137 | d << ')'; | - | ||||||||||||||||||
| 1138 | } | - | ||||||||||||||||||
| 1139 | break; never executed: break; | 0 | ||||||||||||||||||
| 1140 | case Qt::PinchGesture: { never executed: case Qt::PinchGesture: | 0 | ||||||||||||||||||
| 1141 | const QPinchGesture *pinch = static_cast<const QPinchGesture*>(gesture); | - | ||||||||||||||||||
| 1142 | formatGestureHeader(d, "QPinchGesture", pinch); | - | ||||||||||||||||||
| 1143 | d << ",totalChangeFlags=" << pinch->totalChangeFlags() | - | ||||||||||||||||||
| 1144 | << ",changeFlags=" << pinch->changeFlags() << ",startCenterPoint="; | - | ||||||||||||||||||
| 1145 | QtDebugUtils::formatQPoint(d, pinch->startCenterPoint()); | - | ||||||||||||||||||
| 1146 | d << ",lastCenterPoint="; | - | ||||||||||||||||||
| 1147 | QtDebugUtils::formatQPoint(d, pinch->lastCenterPoint()); | - | ||||||||||||||||||
| 1148 | d << ",centerPoint="; | - | ||||||||||||||||||
| 1149 | QtDebugUtils::formatQPoint(d, pinch->centerPoint()); | - | ||||||||||||||||||
| 1150 | d << ",totalScaleFactor=" << pinch->totalScaleFactor() | - | ||||||||||||||||||
| 1151 | << ",lastScaleFactor=" << pinch->lastScaleFactor() | - | ||||||||||||||||||
| 1152 | << ",scaleFactor=" << pinch->scaleFactor() | - | ||||||||||||||||||
| 1153 | << ",totalRotationAngle=" << pinch->totalRotationAngle() | - | ||||||||||||||||||
| 1154 | << ",lastRotationAngle=" << pinch->lastRotationAngle() | - | ||||||||||||||||||
| 1155 | << ",rotationAngle=" << pinch->rotationAngle() << ')'; | - | ||||||||||||||||||
| 1156 | } | - | ||||||||||||||||||
| 1157 | break; never executed: break; | 0 | ||||||||||||||||||
| 1158 | case Qt::SwipeGesture: { never executed: case Qt::SwipeGesture: | 0 | ||||||||||||||||||
| 1159 | const QSwipeGesture *swipe = static_cast<const QSwipeGesture*>(gesture); | - | ||||||||||||||||||
| 1160 | formatGestureHeader(d, "QSwipeGesture", swipe); | - | ||||||||||||||||||
| 1161 | d << ",horizontalDirection="; | - | ||||||||||||||||||
| 1162 | QtDebugUtils::formatQEnum(d, swipe->horizontalDirection()); | - | ||||||||||||||||||
| 1163 | d << ",verticalDirection="; | - | ||||||||||||||||||
| 1164 | QtDebugUtils::formatQEnum(d, swipe->verticalDirection()); | - | ||||||||||||||||||
| 1165 | d << ",swipeAngle=" << swipe->swipeAngle() << ')'; | - | ||||||||||||||||||
| 1166 | } | - | ||||||||||||||||||
| 1167 | break; never executed: break; | 0 | ||||||||||||||||||
| 1168 | default: never executed: default: | 0 | ||||||||||||||||||
| 1169 | formatGestureHeader(d, "Custom gesture", gesture); | - | ||||||||||||||||||
| 1170 | d << ",type=" << gesture->gestureType() << ')'; | - | ||||||||||||||||||
| 1171 | break; never executed: break; | 0 | ||||||||||||||||||
| 1172 | } | - | ||||||||||||||||||
| 1173 | return d; never executed: return d; | 0 | ||||||||||||||||||
| 1174 | } | - | ||||||||||||||||||
| 1175 | - | |||||||||||||||||||
| 1176 | Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QGestureEvent *gestureEvent) | - | ||||||||||||||||||
| 1177 | { | - | ||||||||||||||||||
| 1178 | QDebugStateSaver saver(d); | - | ||||||||||||||||||
| 1179 | d.nospace(); | - | ||||||||||||||||||
| 1180 | d << "QGestureEvent(" << gestureEvent->gestures() << ')'; | - | ||||||||||||||||||
| 1181 | return d; never executed: return d; | 0 | ||||||||||||||||||
| 1182 | } | - | ||||||||||||||||||
| 1183 | - | |||||||||||||||||||
| 1184 | #endif // !QT_NO_DEBUG_STREAM | - | ||||||||||||||||||
| 1185 | QT_END_NAMESPACE | - | ||||||||||||||||||
| 1186 | - | |||||||||||||||||||
| 1187 | #include <moc_qgesture.cpp> | - | ||||||||||||||||||
| 1188 | - | |||||||||||||||||||
| 1189 | #endif // QT_NO_GESTURES | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |