Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickpincharea_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtSG module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
24 | ** | - | ||||||
25 | ** GNU General Public License Usage | - | ||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
35 | ** | - | ||||||
36 | ** $QT_END_LICENSE$ | - | ||||||
37 | ** | - | ||||||
38 | ****************************************************************************/ | - | ||||||
39 | - | |||||||
40 | #ifndef QQUICKPINCHAREA_H | - | ||||||
41 | #define QQUICKPINCHAREA_H | - | ||||||
42 | - | |||||||
43 | // | - | ||||||
44 | // W A R N I N G | - | ||||||
45 | // ------------- | - | ||||||
46 | // | - | ||||||
47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
48 | // implementation detail. This header file may change from version to | - | ||||||
49 | // version without notice, or even be removed. | - | ||||||
50 | // | - | ||||||
51 | // We mean it. | - | ||||||
52 | // | - | ||||||
53 | - | |||||||
54 | #include "qquickitem.h" | - | ||||||
55 | - | |||||||
56 | QT_BEGIN_NAMESPACE | - | ||||||
57 | - | |||||||
58 | class Q_AUTOTEST_EXPORT QQuickPinch : public QObject | - | ||||||
59 | { | - | ||||||
60 | Q_OBJECT | - | ||||||
61 | - | |||||||
62 | Q_PROPERTY(QQuickItem *target READ target WRITE setTarget RESET resetTarget) | - | ||||||
63 | Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged) | - | ||||||
64 | Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged) | - | ||||||
65 | Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged) | - | ||||||
66 | Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged) | - | ||||||
67 | Q_PROPERTY(Axis dragAxis READ axis WRITE setAxis NOTIFY dragAxisChanged) | - | ||||||
68 | Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged) | - | ||||||
69 | Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged) | - | ||||||
70 | Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged) | - | ||||||
71 | Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged) | - | ||||||
72 | Q_PROPERTY(bool active READ active NOTIFY activeChanged) | - | ||||||
73 | - | |||||||
74 | public: | - | ||||||
75 | QQuickPinch(); | - | ||||||
76 | - | |||||||
77 | QQuickItem *target() const { return m_target; } executed 190 times by 1 test: return m_target; Executed by:
| 190 | ||||||
78 | void setTarget(QQuickItem *target) { | - | ||||||
79 | if (target == m_target)
| 2-32 | ||||||
80 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||
81 | m_target = target; | - | ||||||
82 | Q_EMIT targetChanged(); | - | ||||||
83 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||
84 | void resetTarget() { | - | ||||||
85 | if (!m_target)
| 0 | ||||||
86 | return; never executed: return; | 0 | ||||||
87 | m_target = nullptr; | - | ||||||
88 | Q_EMIT targetChanged(); | - | ||||||
89 | } never executed: end of block | 0 | ||||||
90 | - | |||||||
91 | qreal minimumScale() const { return m_minScale; } executed 26 times by 1 test: return m_minScale; Executed by:
| 26 | ||||||
92 | void setMinimumScale(qreal s) { | - | ||||||
93 | if (s == m_minScale)
| 4-18 | ||||||
94 | return; executed 18 times by 2 tests: return; Executed by:
| 18 | ||||||
95 | m_minScale = s; | - | ||||||
96 | Q_EMIT minimumScaleChanged(); | - | ||||||
97 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||
98 | qreal maximumScale() const { return m_maxScale; } executed 26 times by 1 test: return m_maxScale; Executed by:
| 26 | ||||||
99 | void setMaximumScale(qreal s) { | - | ||||||
100 | if (s == m_maxScale)
| 2-20 | ||||||
101 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||
102 | m_maxScale = s; | - | ||||||
103 | Q_EMIT maximumScaleChanged(); | - | ||||||
104 | } executed 20 times by 2 tests: end of block Executed by:
| 20 | ||||||
105 | - | |||||||
106 | qreal minimumRotation() const { return m_minRotation; } executed 48 times by 1 test: return m_minRotation; Executed by:
| 48 | ||||||
107 | void setMinimumRotation(qreal r) { | - | ||||||
108 | if (r == m_minRotation)
| 2-12 | ||||||
109 | return; executed 12 times by 1 test: return; Executed by:
| 12 | ||||||
110 | m_minRotation = r; | - | ||||||
111 | Q_EMIT minimumRotationChanged(); | - | ||||||
112 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
113 | qreal maximumRotation() const { return m_maxRotation; } executed 48 times by 1 test: return m_maxRotation; Executed by:
| 48 | ||||||
114 | void setMaximumRotation(qreal r) { | - | ||||||
115 | if (r == m_maxRotation)
| 2-12 | ||||||
116 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||
117 | m_maxRotation = r; | - | ||||||
118 | Q_EMIT maximumRotationChanged(); | - | ||||||
119 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||
120 | - | |||||||
121 | enum Axis { NoDrag=0x00, XAxis=0x01, YAxis=0x02, XAndYAxis=0x03, XandYAxis=XAndYAxis }; | - | ||||||
122 | Q_ENUM(Axis) | - | ||||||
123 | Axis axis() const { return m_axis; } executed 68 times by 1 test: return m_axis; Executed by:
| 68 | ||||||
124 | void setAxis(Axis a) { | - | ||||||
125 | if (a == m_axis)
| 2-24 | ||||||
126 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||
127 | m_axis = a; | - | ||||||
128 | Q_EMIT dragAxisChanged(); | - | ||||||
129 | } executed 24 times by 1 test: end of block Executed by:
| 24 | ||||||
130 | - | |||||||
131 | qreal xmin() const { return m_xmin; } executed 26 times by 1 test: return m_xmin; Executed by:
| 26 | ||||||
132 | void setXmin(qreal x) { | - | ||||||
133 | if (x == m_xmin)
| 2-12 | ||||||
134 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||
135 | m_xmin = x; | - | ||||||
136 | Q_EMIT minimumXChanged(); | - | ||||||
137 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||
138 | qreal xmax() const { return m_xmax; } executed 28 times by 1 test: return m_xmax; Executed by:
| 28 | ||||||
139 | void setXmax(qreal x) { | - | ||||||
140 | if (x == m_xmax)
| 2-12 | ||||||
141 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||
142 | m_xmax = x; | - | ||||||
143 | Q_EMIT maximumXChanged(); | - | ||||||
144 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||
145 | qreal ymin() const { return m_ymin; } executed 26 times by 1 test: return m_ymin; Executed by:
| 26 | ||||||
146 | void setYmin(qreal y) { | - | ||||||
147 | if (y == m_ymin)
| 2-12 | ||||||
148 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||
149 | m_ymin = y; | - | ||||||
150 | Q_EMIT minimumYChanged(); | - | ||||||
151 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||
152 | qreal ymax() const { return m_ymax; } executed 26 times by 1 test: return m_ymax; Executed by:
| 26 | ||||||
153 | void setYmax(qreal y) { | - | ||||||
154 | if (y == m_ymax)
| 2-12 | ||||||
155 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||
156 | m_ymax = y; | - | ||||||
157 | Q_EMIT maximumYChanged(); | - | ||||||
158 | } executed 12 times by 1 test: end of block Executed by:
| 12 | ||||||
159 | - | |||||||
160 | bool active() const { return m_active; } never executed: return m_active; | 0 | ||||||
161 | void setActive(bool a) { | - | ||||||
162 | if (a == m_active)
| 2-28 | ||||||
163 | return; executed 2 times by 1 test: return; Executed by:
| 2 | ||||||
164 | m_active = a; | - | ||||||
165 | Q_EMIT activeChanged(); | - | ||||||
166 | } executed 28 times by 1 test: end of block Executed by:
| 28 | ||||||
167 | - | |||||||
168 | Q_SIGNALS: | - | ||||||
169 | void targetChanged(); | - | ||||||
170 | void minimumScaleChanged(); | - | ||||||
171 | void maximumScaleChanged(); | - | ||||||
172 | void minimumRotationChanged(); | - | ||||||
173 | void maximumRotationChanged(); | - | ||||||
174 | void dragAxisChanged(); | - | ||||||
175 | void minimumXChanged(); | - | ||||||
176 | void maximumXChanged(); | - | ||||||
177 | void minimumYChanged(); | - | ||||||
178 | void maximumYChanged(); | - | ||||||
179 | void activeChanged(); | - | ||||||
180 | - | |||||||
181 | private: | - | ||||||
182 | QQuickItem *m_target; | - | ||||||
183 | qreal m_minScale; | - | ||||||
184 | qreal m_maxScale; | - | ||||||
185 | qreal m_minRotation; | - | ||||||
186 | qreal m_maxRotation; | - | ||||||
187 | Axis m_axis; | - | ||||||
188 | qreal m_xmin; | - | ||||||
189 | qreal m_xmax; | - | ||||||
190 | qreal m_ymin; | - | ||||||
191 | qreal m_ymax; | - | ||||||
192 | bool m_active; | - | ||||||
193 | }; | - | ||||||
194 | - | |||||||
195 | class Q_AUTOTEST_EXPORT QQuickPinchEvent : public QObject | - | ||||||
196 | { | - | ||||||
197 | Q_OBJECT | - | ||||||
198 | - | |||||||
199 | Q_PROPERTY(QPointF center READ center) | - | ||||||
200 | Q_PROPERTY(QPointF startCenter READ startCenter) | - | ||||||
201 | Q_PROPERTY(QPointF previousCenter READ previousCenter) | - | ||||||
202 | Q_PROPERTY(qreal scale READ scale) | - | ||||||
203 | Q_PROPERTY(qreal previousScale READ previousScale) | - | ||||||
204 | Q_PROPERTY(qreal angle READ angle) | - | ||||||
205 | Q_PROPERTY(qreal previousAngle READ previousAngle) | - | ||||||
206 | Q_PROPERTY(qreal rotation READ rotation) | - | ||||||
207 | Q_PROPERTY(QPointF point1 READ point1) | - | ||||||
208 | Q_PROPERTY(QPointF startPoint1 READ startPoint1) | - | ||||||
209 | Q_PROPERTY(QPointF point2 READ point2) | - | ||||||
210 | Q_PROPERTY(QPointF startPoint2 READ startPoint2) | - | ||||||
211 | Q_PROPERTY(int pointCount READ pointCount) | - | ||||||
212 | Q_PROPERTY(bool accepted READ accepted WRITE setAccepted) | - | ||||||
213 | - | |||||||
214 | public: | - | ||||||
215 | QQuickPinchEvent(QPointF c, qreal s, qreal a, qreal r) | - | ||||||
216 | : QObject(), m_center(c), m_scale(s), m_angle(a), m_rotation(r) | - | ||||||
217 | , m_pointCount(0), m_accepted(true) {} executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
218 | - | |||||||
219 | QPointF center() const { return m_center; } executed 38 times by 1 test: return m_center; Executed by:
| 38 | ||||||
220 | QPointF startCenter() const { return m_startCenter; } never executed: return m_startCenter; | 0 | ||||||
221 | void setStartCenter(QPointF c) { m_startCenter = c; } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
222 | QPointF previousCenter() const { return m_lastCenter; } never executed: return m_lastCenter; | 0 | ||||||
223 | void setPreviousCenter(QPointF c) { m_lastCenter = c; } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
224 | qreal scale() const { return m_scale; } executed 38 times by 1 test: return m_scale; Executed by:
| 38 | ||||||
225 | qreal previousScale() const { return m_lastScale; } never executed: return m_lastScale; | 0 | ||||||
226 | void setPreviousScale(qreal s) { m_lastScale = s; } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
227 | qreal angle() const { return m_angle; } never executed: return m_angle; | 0 | ||||||
228 | qreal previousAngle() const { return m_lastAngle; } never executed: return m_lastAngle; | 0 | ||||||
229 | void setPreviousAngle(qreal a) { m_lastAngle = a; } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
230 | qreal rotation() const { return m_rotation; } never executed: return m_rotation; | 0 | ||||||
231 | QPointF point1() const { return m_point1; } never executed: return m_point1; | 0 | ||||||
232 | void setPoint1(QPointF p) { m_point1 = p; } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
233 | QPointF startPoint1() const { return m_startPoint1; } executed 4 times by 1 test: return m_startPoint1; Executed by:
| 4 | ||||||
234 | void setStartPoint1(QPointF p) { m_startPoint1 = p; } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
235 | QPointF point2() const { return m_point2; } never executed: return m_point2; | 0 | ||||||
236 | void setPoint2(QPointF p) { m_point2 = p; } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
237 | QPointF startPoint2() const { return m_startPoint2; } executed 4 times by 1 test: return m_startPoint2; Executed by:
| 4 | ||||||
238 | void setStartPoint2(QPointF p) { m_startPoint2 = p; } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||
239 | int pointCount() const { return m_pointCount; } executed 38 times by 1 test: return m_pointCount; Executed by:
| 38 | ||||||
240 | void setPointCount(int count) { m_pointCount = count; } executed 36 times by 1 test: end of block Executed by:
| 36 | ||||||
241 | - | |||||||
242 | bool accepted() const { return m_accepted; } executed 16 times by 1 test: return m_accepted; Executed by:
| 16 | ||||||
243 | void setAccepted(bool a) { m_accepted = a; } never executed: end of block | 0 | ||||||
244 | - | |||||||
245 | private: | - | ||||||
246 | QPointF m_center; | - | ||||||
247 | QPointF m_startCenter; | - | ||||||
248 | QPointF m_lastCenter; | - | ||||||
249 | qreal m_scale; | - | ||||||
250 | qreal m_lastScale; | - | ||||||
251 | qreal m_angle; | - | ||||||
252 | qreal m_lastAngle; | - | ||||||
253 | qreal m_rotation; | - | ||||||
254 | QPointF m_point1; | - | ||||||
255 | QPointF m_point2; | - | ||||||
256 | QPointF m_startPoint1; | - | ||||||
257 | QPointF m_startPoint2; | - | ||||||
258 | int m_pointCount; | - | ||||||
259 | bool m_accepted; | - | ||||||
260 | }; | - | ||||||
261 | - | |||||||
262 | - | |||||||
263 | class QQuickMouseEvent; | - | ||||||
264 | class QQuickPinchAreaPrivate; | - | ||||||
265 | class Q_AUTOTEST_EXPORT QQuickPinchArea : public QQuickItem | - | ||||||
266 | { | - | ||||||
267 | Q_OBJECT | - | ||||||
268 | - | |||||||
269 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) | - | ||||||
270 | Q_PROPERTY(QQuickPinch *pinch READ pinch CONSTANT) | - | ||||||
271 | - | |||||||
272 | public: | - | ||||||
273 | QQuickPinchArea(QQuickItem *parent=nullptr); | - | ||||||
274 | ~QQuickPinchArea(); | - | ||||||
275 | - | |||||||
276 | bool isEnabled() const; | - | ||||||
277 | void setEnabled(bool); | - | ||||||
278 | - | |||||||
279 | QQuickPinch *pinch(); | - | ||||||
280 | - | |||||||
281 | Q_SIGNALS: | - | ||||||
282 | void enabledChanged(); | - | ||||||
283 | void pinchStarted(QQuickPinchEvent *pinch); | - | ||||||
284 | void pinchUpdated(QQuickPinchEvent *pinch); | - | ||||||
285 | void pinchFinished(QQuickPinchEvent *pinch); | - | ||||||
286 | Q_REVISION(1) void smartZoom(QQuickPinchEvent *pinch); | - | ||||||
287 | - | |||||||
288 | protected: | - | ||||||
289 | bool childMouseEventFilter(QQuickItem *i, QEvent *e) override; | - | ||||||
290 | void touchEvent(QTouchEvent *event) override; | - | ||||||
291 | - | |||||||
292 | void geometryChanged(const QRectF &newGeometry, | - | ||||||
293 | const QRectF &oldGeometry) override; | - | ||||||
294 | void itemChange(ItemChange change, const ItemChangeData& value) override; | - | ||||||
295 | bool event(QEvent *) override; | - | ||||||
296 | - | |||||||
297 | private: | - | ||||||
298 | void clearPinch(); | - | ||||||
299 | void cancelPinch(); | - | ||||||
300 | void updatePinch(); | - | ||||||
301 | void updatePinchTarget(); | - | ||||||
302 | void handlePress(); | - | ||||||
303 | void handleRelease(); | - | ||||||
304 | - | |||||||
305 | private: | - | ||||||
306 | Q_DISABLE_COPY(QQuickPinchArea) | - | ||||||
307 | Q_DECLARE_PRIVATE(QQuickPinchArea) executed 748 times by 3 tests: return reinterpret_cast<QQuickPinchAreaPrivate *>(qGetPtrHelper(d_ptr)); Executed by:
never executed: return reinterpret_cast<const QQuickPinchAreaPrivate *>(qGetPtrHelper(d_ptr)); | 0-748 | ||||||
308 | }; | - | ||||||
309 | - | |||||||
310 | QT_END_NAMESPACE | - | ||||||
311 | - | |||||||
312 | QML_DECLARE_TYPE(QQuickPinch) | - | ||||||
313 | QML_DECLARE_TYPE(QQuickPinchEvent) | - | ||||||
314 | QML_DECLARE_TYPE(QQuickPinchArea) | - | ||||||
315 | - | |||||||
316 | #endif // QQUICKPINCHAREA_H | - | ||||||
317 | - | |||||||
Source code | Switch to Preprocessed file |