Qt 4.8
qgesture.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui 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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qgesture.h"
43 #include "private/qgesture_p.h"
44 #include "private/qstandardgestures_p.h"
45 
46 #ifndef QT_NO_GESTURES
47 
49 
105  : QObject(*new QGesturePrivate, parent)
106 {
107  d_func()->gestureType = Qt::CustomGesture;
108 }
109 
114  : QObject(dd, parent)
115 {
116 }
117 
122 {
123 }
124 
166 {
167  return d_func()->gestureType;
168 }
169 
171 {
172  return d_func()->state;
173 }
174 
176 {
177  return d_func()->hotSpot;
178 }
179 
180 void QGesture::setHotSpot(const QPointF &value)
181 {
182  Q_D(QGesture);
183  d->hotSpot = value;
184  d->isHotSpotSet = true;
185 }
186 
187 bool QGesture::hasHotSpot() const
188 {
189  return d_func()->isHotSpotSet;
190 }
191 
193 {
194  d_func()->isHotSpotSet = false;
195 }
196 
227 {
228  Q_D(QGesture);
229  d->gestureCancelPolicy = static_cast<uint>(policy);
230 }
231 
233 {
234  Q_D(const QGesture);
235  return static_cast<GestureCancelPolicy>(d->gestureCancelPolicy);
236 }
237 
332  : QGesture(*new QPanGesturePrivate, parent)
333 {
334  d_func()->gestureType = Qt::PanGesture;
335 }
336 
337 
339 {
340  return d_func()->lastOffset;
341 }
342 
344 {
345  return d_func()->offset;
346 }
347 
349 {
350  Q_D(const QPanGesture);
351  return d->offset - d->lastOffset;
352 }
353 
355 {
356  return d_func()->acceleration;
357 }
358 
360 {
361  d_func()->lastOffset = value;
362 }
363 
364 void QPanGesture::setOffset(const QPointF &value)
365 {
366  d_func()->offset = value;
367 }
368 
370 {
371  d_func()->acceleration = value;
372 }
373 
561  : QGesture(*new QPinchGesturePrivate, parent)
562 {
563  d_func()->gestureType = Qt::PinchGesture;
564 }
565 
566 QPinchGesture::ChangeFlags QPinchGesture::totalChangeFlags() const
567 {
568  return d_func()->totalChangeFlags;
569 }
570 
571 void QPinchGesture::setTotalChangeFlags(QPinchGesture::ChangeFlags value)
572 {
573  d_func()->totalChangeFlags = value;
574 }
575 
576 QPinchGesture::ChangeFlags QPinchGesture::changeFlags() const
577 {
578  return d_func()->changeFlags;
579 }
580 
581 void QPinchGesture::setChangeFlags(QPinchGesture::ChangeFlags value)
582 {
583  d_func()->changeFlags = value;
584 }
585 
587 {
588  return d_func()->startCenterPoint;
589 }
590 
592 {
593  return d_func()->lastCenterPoint;
594 }
595 
597 {
598  return d_func()->centerPoint;
599 }
600 
602 {
603  d_func()->startCenterPoint = value;
604 }
605 
607 {
608  d_func()->lastCenterPoint = value;
609 }
610 
612 {
613  d_func()->centerPoint = value;
614 }
615 
616 
618 {
619  return d_func()->totalScaleFactor;
620 }
621 
623 {
624  return d_func()->lastScaleFactor;
625 }
626 
628 {
629  return d_func()->scaleFactor;
630 }
631 
633 {
634  d_func()->totalScaleFactor = value;
635 }
636 
638 {
639  d_func()->lastScaleFactor = value;
640 }
641 
643 {
644  d_func()->scaleFactor = value;
645 }
646 
647 
649 {
650  return d_func()->totalRotationAngle;
651 }
652 
654 {
655  return d_func()->lastRotationAngle;
656 }
657 
659 {
660  return d_func()->rotationAngle;
661 }
662 
664 {
665  d_func()->totalRotationAngle = value;
666 }
667 
669 {
670  d_func()->lastRotationAngle = value;
671 }
672 
674 {
675  d_func()->rotationAngle = value;
676 }
677 
762  : QGesture(*new QSwipeGesturePrivate, parent)
763 {
764  d_func()->gestureType = Qt::SwipeGesture;
765 }
766 
768 {
769  Q_D(const QSwipeGesture);
770  if (d->swipeAngle < 0 || d->swipeAngle == 90 || d->swipeAngle == 270)
772  else if (d->swipeAngle < 90 || d->swipeAngle > 270)
773  return QSwipeGesture::Right;
774  else
775  return QSwipeGesture::Left;
776 }
777 
779 {
780  Q_D(const QSwipeGesture);
781  if (d->swipeAngle <= 0 || d->swipeAngle == 180)
783  else if (d->swipeAngle < 180)
784  return QSwipeGesture::Up;
785  else
786  return QSwipeGesture::Down;
787 }
788 
790 {
791  return d_func()->swipeAngle;
792 }
793 
795 {
796  d_func()->swipeAngle = value;
797 }
798 
826  : QGesture(*new QTapGesturePrivate, parent)
827 {
828  d_func()->gestureType = Qt::TapGesture;
829 }
830 
832 {
833  return d_func()->position;
834 }
835 
837 {
838  d_func()->position = value;
839 }
868  : QGesture(*new QTapAndHoldGesturePrivate, parent)
869 {
871 }
872 
874 {
875  return d_func()->position;
876 }
877 
879 {
880  d_func()->position = value;
881 }
882 
890 // static
892 {
894 }
895 
903 // static
905 {
907 }
908 
909 int QTapAndHoldGesturePrivate::Timeout = 700; // in ms
910 
912 
913 #include <moc_qgesture.cpp>
914 
915 #endif // QT_NO_GESTURES
QPointF position() const
double d
Definition: qnumeric_p.h:62
The QPanGesture class describes a panning gesture made by the user.
Definition: qgesture.h:107
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setCenterPoint(const QPointF &value)
Definition: qgesture.cpp:611
qreal lastRotationAngle() const
qreal totalRotationAngle() const
void setLastScaleFactor(qreal value)
Definition: qgesture.cpp:637
QPointF startCenterPoint() const
QTapAndHoldGesture(QObject *parent=0)
Definition: qgesture.cpp:867
bool hasHotSpot() const
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QPointF position() const
QTapGesture(QObject *parent=0)
Definition: qgesture.cpp:825
void setChangeFlags(ChangeFlags value)
Definition: qgesture.cpp:581
static int timeout()
Gets the timeout, in milliseconds, before the gesture triggers.
Definition: qgesture.cpp:904
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_D(Class)
Definition: qglobal.h:2482
qreal acceleration() const
QPointF lastCenterPoint() const
qreal lastScaleFactor() const
qreal totalScaleFactor() const
GestureCancelPolicy
This enum describes how accepting a gesture can cancel other gestures automatically.
Definition: qgesture.h:88
QPointF delta() const
ChangeFlags changeFlags() const
void setTotalScaleFactor(qreal value)
Definition: qgesture.cpp:632
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
qreal scaleFactor() const
qreal swipeAngle() const
QPanGesture(QObject *parent=0)
Definition: qgesture.cpp:331
qreal rotationAngle() const
void setLastRotationAngle(qreal value)
Definition: qgesture.cpp:668
QPointF offset() const
QPinchGesture(QObject *parent=0)
Definition: qgesture.cpp:560
Qt::GestureState state() const
void setScaleFactor(qreal value)
Definition: qgesture.cpp:642
unsigned int uint
Definition: qglobal.h:996
SwipeDirection horizontalDirection() const
SwipeDirection verticalDirection() const
void setOffset(const QPointF &value)
Definition: qgesture.cpp:364
void setPosition(const QPointF &pos)
Definition: qgesture.cpp:836
QPointF hotSpot() const
GestureType
Definition: qnamespace.h:1759
ChangeFlags totalChangeFlags() const
GestureCancelPolicy gestureCancelPolicy() const
void unsetHotSpot()
Definition: qgesture.cpp:192
Qt::GestureType gestureType() const
~QGesture()
Destroys the gesture object.
Definition: qgesture.cpp:121
void setLastOffset(const QPointF &value)
Definition: qgesture.cpp:359
The QGesture class represents a gesture, containing properties that describe the corresponding user i...
Definition: qgesture.h:64
QSwipeGesture(QObject *parent=0)
Definition: qgesture.cpp:761
Qt::GestureType gestureType
the type of the gesture
Definition: qgesture.h:70
void setHotSpot(const QPointF &value)
Definition: qgesture.cpp:180
QPointF lastOffset() const
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
QGesture(QObject *parent=0)
Constructs a new gesture object with the given parent.
Definition: qgesture.cpp:104
QPointF centerPoint() const
void setGestureCancelPolicy(GestureCancelPolicy policy)
Definition: qgesture.cpp:226
void setTotalRotationAngle(qreal value)
Definition: qgesture.cpp:663
static void setTimeout(int msecs)
Set the timeout, in milliseconds, before the gesture triggers.
Definition: qgesture.cpp:891
void setSwipeAngle(qreal value)
Definition: qgesture.cpp:794
void setLastCenterPoint(const QPointF &value)
Definition: qgesture.cpp:606
The QSwipeGesture class describes a swipe gesture made by the user.
Definition: qgesture.h:207
SwipeDirection
This enum describes the possible directions for the gesture&#39;s motion along the horizontal and vertica...
Definition: qgesture.h:219
void setAcceleration(qreal value)
Definition: qgesture.cpp:369
GestureState
Definition: qnamespace.h:1750
void setStartCenterPoint(const QPointF &value)
Definition: qgesture.cpp:601
void setPosition(const QPointF &pos)
Definition: qgesture.cpp:878
void setTotalChangeFlags(ChangeFlags value)
Definition: qgesture.cpp:571
void setRotationAngle(qreal value)
Definition: qgesture.cpp:673