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