Qt 4.8
qtesttouch.h
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 QtTest 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 #ifndef QTESTTOUCH_H
43 #define QTESTTOUCH_H
44 
45 #if 0
46 // inform syncqt
47 #pragma qt_no_master_include
48 #endif
49 
50 #include <QtTest/qtest_global.h>
51 #include <QtTest/qtestassert.h>
52 #include <QtTest/qtestsystem.h>
53 #include <QtTest/qtestspontaneevent.h>
54 
55 #include <QtCore/qmap.h>
56 #include <QtGui/qevent.h>
57 #include <QtGui/qwidget.h>
58 
60 
62 
63 QT_MODULE(Test)
64 
66  QTouchEvent::DeviceType deviceType,
67  const QList<QTouchEvent::TouchPoint> &touchPoints);
68 
69 namespace QTest
70 {
71 
73  {
74  public:
76  {
77  commit();
78  points.clear();
79  }
80  QTouchEventSequence& press(int touchId, const QPoint &pt, QWidget *widget = 0)
81  {
82  QTouchEvent::TouchPoint &p = point(touchId);
85  return *this;
86  }
87  QTouchEventSequence& move(int touchId, const QPoint &pt, QWidget *widget = 0)
88  {
89  QTouchEvent::TouchPoint &p = point(touchId);
92  return *this;
93  }
94  QTouchEventSequence& release(int touchId, const QPoint &pt, QWidget *widget = 0)
95  {
96  QTouchEvent::TouchPoint &p = point(touchId);
99  return *this;
100  }
102  {
103  QTouchEvent::TouchPoint &p = point(touchId);
105  return *this;
106  }
107 
108  private:
110  : targetWidget(widget), deviceType(aDeviceType)
111  {
112  }
114  void operator=(const QTouchEventSequence&);
115 
117  {
118  if (!points.contains(touchId))
119  points[touchId] = QTouchEvent::TouchPoint(touchId);
120  return points[touchId];
121  }
123  {
124  if (widget)
125  return widget->mapToGlobal(pt);
126  return targetWidget ? targetWidget->mapToGlobal(pt) : pt;
127  }
128  void commit()
129  {
131  targetWidget = 0;
132  }
133 
138  };
139 
140  inline
143  {
145  }
146 
147 }
148 
150 
152 
153 #endif // QTESTTOUCH_H
void setScreenPos(const QPointF &screenPos)
Definition: qevent.cpp:4695
~QTouchEventSequence()
Commits this sequence of touch events and frees allocated resources.
Definition: qtesttouch.h:75
QTouchEvent::DeviceType deviceType
Definition: qtesttouch.h:136
void operator=(const QTouchEventSequence &)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QTouchEvent::TouchPoint & point(int touchId)
Definition: qtesttouch.h:116
QPointer< QWidget > widget
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
QTouchEventSequence & move(int touchId, const QPoint &pt, QWidget *widget=0)
Adds a move event for touchpoint touchId at position pt to this sequence and returns a reference to t...
Definition: qtesttouch.h:87
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
QPoint mapToScreen(QWidget *widget, const QPoint &pt)
Definition: qtesttouch.h:122
QList< T > values() const
Returns a list containing all the values in the map, in ascending order of their keys.
Definition: qmap.h:863
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
DeviceType
This enum represents the type of device that generated a QTouchEvent.
Definition: qevent.h:805
QTouchEventSequence(QWidget *widget, QTouchEvent::DeviceType aDeviceType)
Definition: qtesttouch.h:109
void setState(Qt::TouchPointStates state)
Definition: qevent.cpp:4671
NSWindow * window
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QTouchEventSequence & release(int touchId, const QPoint &pt, QWidget *widget=0)
Adds a release event for touchpoint touchId at position pt to this sequence and returns a reference t...
Definition: qtesttouch.h:94
QTouchEventSequence & press(int touchId, const QPoint &pt, QWidget *widget=0)
Adds a press event for touchpoint touchId at position pt to this sequence and returns a reference to ...
Definition: qtesttouch.h:80
friend QTouchEventSequence touchEvent(QWidget *, QTouchEvent::DeviceType)
Definition: qtesttouch.h:141
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744
The QTouchEventSequence class is used to simulate a sequence of touch events.
Definition: qtesttouch.h:72
QMap< int, QTouchEvent::TouchPoint > points
Definition: qtesttouch.h:134
QTouchEventSequence & stationary(int touchId)
Adds a stationary event for touchpoint touchId to this sequence and returns a reference to this QTouc...
Definition: qtesttouch.h:101
#define QT_END_HEADER
Definition: qglobal.h:137
The QTest namespace contains all the functions and declarations that are related to the QTestLib tool...
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.
Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, QTouchEvent::DeviceType deviceType, const QList< QTouchEvent::TouchPoint > &touchPoints)
void clear()
Removes all items from the map.
Definition: qmap.h:444