Warning: That file was not part of the compilation database. It may have many parsing errors.

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
59QT_BEGIN_HEADER
60
61QT_BEGIN_NAMESPACE
62
63QT_MODULE(Test)
64
65extern Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
66 QTouchEvent::DeviceType deviceType,
67 const QList<QTouchEvent::TouchPoint> &touchPoints);
68
69namespace QTest
70{
71
72 class QTouchEventSequence
73 {
74 public:
75 ~QTouchEventSequence()
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);
83 p.setScreenPos(mapToScreen(widget, pt));
84 p.setState(Qt::TouchPointPressed);
85 return *this;
86 }
87 QTouchEventSequence& move(int touchId, const QPoint &pt, QWidget *widget = 0)
88 {
89 QTouchEvent::TouchPoint &p = point(touchId);
90 p.setScreenPos(mapToScreen(widget, pt));
91 p.setState(Qt::TouchPointMoved);
92 return *this;
93 }
94 QTouchEventSequence& release(int touchId, const QPoint &pt, QWidget *widget = 0)
95 {
96 QTouchEvent::TouchPoint &p = point(touchId);
97 p.setScreenPos(mapToScreen(widget, pt));
98 p.setState(Qt::TouchPointReleased);
99 return *this;
100 }
101 QTouchEventSequence& stationary(int touchId)
102 {
103 QTouchEvent::TouchPoint &p = point(touchId);
104 p.setState(Qt::TouchPointStationary);
105 return *this;
106 }
107
108 private:
109 QTouchEventSequence(QWidget *widget, QTouchEvent::DeviceType aDeviceType)
110 : targetWidget(widget), deviceType(aDeviceType)
111 {
112 }
113 QTouchEventSequence(const QTouchEventSequence &v);
114 void operator=(const QTouchEventSequence&);
115
116 QTouchEvent::TouchPoint &point(int touchId)
117 {
118 if (!points.contains(touchId))
119 points[touchId] = QTouchEvent::TouchPoint(touchId);
120 return points[touchId];
121 }
122 QPoint mapToScreen(QWidget *widget, const QPoint &pt)
123 {
124 if (widget)
125 return widget->mapToGlobal(pt);
126 return targetWidget ? targetWidget->mapToGlobal(pt) : pt;
127 }
128 void commit()
129 {
130 qt_translateRawTouchEvent(targetWidget, deviceType, points.values());
131 targetWidget = 0;
132 }
133
134 QMap<int, QTouchEvent::TouchPoint> points;
135 QWidget *targetWidget;
136 QTouchEvent::DeviceType deviceType;
137 friend QTouchEventSequence touchEvent(QWidget *, QTouchEvent::DeviceType);
138 };
139
140 inline
141 QTouchEventSequence touchEvent(QWidget *widget = 0,
142 QTouchEvent::DeviceType deviceType = QTouchEvent::TouchScreen)
143 {
144 return QTouchEventSequence(widget, deviceType);
145 }
146
147}
148
149QT_END_NAMESPACE
150
151QT_END_HEADER
152
153#endif // QTESTTOUCH_H
154

Warning: That file was not part of the compilation database. It may have many parsing errors.