Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/util/qquickglobal.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Copyright (C) 2016 BasysKom GmbH. | - | ||||||||||||||||||||||||
5 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
6 | ** | - | ||||||||||||||||||||||||
7 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||||||||||||||
8 | ** | - | ||||||||||||||||||||||||
9 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||||||||
10 | ** Commercial License Usage | - | ||||||||||||||||||||||||
11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
12 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
15 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
16 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
17 | ** | - | ||||||||||||||||||||||||
18 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
20 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||||||||
21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||||||||
22 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||||||||
23 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||||||||
24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||||||||
25 | ** | - | ||||||||||||||||||||||||
26 | ** GNU General Public License Usage | - | ||||||||||||||||||||||||
27 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||||||||
28 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||||||||
29 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||||||||
30 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||||||||
31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||||||||
32 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||||||||
33 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||||||||
34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||||||||
35 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||||||||
36 | ** | - | ||||||||||||||||||||||||
37 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
38 | ** | - | ||||||||||||||||||||||||
39 | ****************************************************************************/ | - | ||||||||||||||||||||||||
40 | - | |||||||||||||||||||||||||
41 | #include <private/qquickvaluetypes_p.h> | - | ||||||||||||||||||||||||
42 | #include <private/qquickapplication_p.h> | - | ||||||||||||||||||||||||
43 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||||||||
44 | #include <private/qv8engine_p.h> | - | ||||||||||||||||||||||||
45 | - | |||||||||||||||||||||||||
46 | #include <QtGui/QGuiApplication> | - | ||||||||||||||||||||||||
47 | #include <QtGui/qdesktopservices.h> | - | ||||||||||||||||||||||||
48 | #include <QtGui/qfontdatabase.h> | - | ||||||||||||||||||||||||
49 | #include <QtGui/qstylehints.h> | - | ||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||
51 | #include <private/qv4engine_p.h> | - | ||||||||||||||||||||||||
52 | #include <private/qv4object_p.h> | - | ||||||||||||||||||||||||
53 | - | |||||||||||||||||||||||||
54 | #ifdef Q_CC_MSVC | - | ||||||||||||||||||||||||
55 | // MSVC2010 warns about 'unused variable t', even if it's used in t->~T() | - | ||||||||||||||||||||||||
56 | # pragma warning( disable : 4189 ) | - | ||||||||||||||||||||||||
57 | #endif | - | ||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||
59 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
60 | - | |||||||||||||||||||||||||
61 | class QQuickColorProvider : public QQmlColorProvider | - | ||||||||||||||||||||||||
62 | { | - | ||||||||||||||||||||||||
63 | public: | - | ||||||||||||||||||||||||
64 | QVariant colorFromString(const QString &s, bool *ok) override | - | ||||||||||||||||||||||||
65 | { | - | ||||||||||||||||||||||||
66 | QColor c(s); | - | ||||||||||||||||||||||||
67 | if (c.isValid()) {
| 12-142 | ||||||||||||||||||||||||
68 | if (ok) *ok = true; executed 142 times by 2 tests: *ok = true; Executed by:
| 0-142 | ||||||||||||||||||||||||
69 | return QVariant(c); executed 142 times by 2 tests: return QVariant(c); Executed by:
| 142 | ||||||||||||||||||||||||
70 | } | - | ||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | if (ok) *ok = false; executed 12 times by 1 test: *ok = false; Executed by:
| 0-12 | ||||||||||||||||||||||||
73 | return QVariant(); executed 12 times by 1 test: return QVariant(); Executed by:
| 12 | ||||||||||||||||||||||||
74 | } | - | ||||||||||||||||||||||||
75 | - | |||||||||||||||||||||||||
76 | unsigned rgbaFromString(const QString &s, bool *ok) override | - | ||||||||||||||||||||||||
77 | { | - | ||||||||||||||||||||||||
78 | QColor c(s); | - | ||||||||||||||||||||||||
79 | if (c.isValid()) {
| 2-36657 | ||||||||||||||||||||||||
80 | if (ok) *ok = true; executed 36657 times by 83 tests: *ok = true; Executed by:
| 0-36657 | ||||||||||||||||||||||||
81 | return c.rgba(); executed 36657 times by 83 tests: return c.rgba(); Executed by:
| 36657 | ||||||||||||||||||||||||
82 | } | - | ||||||||||||||||||||||||
83 | - | |||||||||||||||||||||||||
84 | if (ok) *ok = false; executed 2 times by 1 test: *ok = false; Executed by:
| 0-2 | ||||||||||||||||||||||||
85 | return 0; executed 2 times by 1 test: return 0; Executed by:
| 2 | ||||||||||||||||||||||||
86 | } | - | ||||||||||||||||||||||||
87 | - | |||||||||||||||||||||||||
88 | QString stringFromRgba(unsigned rgba) | - | ||||||||||||||||||||||||
89 | { | - | ||||||||||||||||||||||||
90 | QColor c(QColor::fromRgba(rgba)); | - | ||||||||||||||||||||||||
91 | if (c.isValid()) {
| 0 | ||||||||||||||||||||||||
92 | return QVariant(c).toString(); never executed: return QVariant(c).toString(); | 0 | ||||||||||||||||||||||||
93 | } | - | ||||||||||||||||||||||||
94 | - | |||||||||||||||||||||||||
95 | return QString(); never executed: return QString(); | 0 | ||||||||||||||||||||||||
96 | } | - | ||||||||||||||||||||||||
97 | - | |||||||||||||||||||||||||
98 | QVariant fromRgbF(double r, double g, double b, double a) override | - | ||||||||||||||||||||||||
99 | { | - | ||||||||||||||||||||||||
100 | return QVariant(QColor::fromRgbF(r, g, b, a)); executed 1484 times by 13 tests: return QVariant(QColor::fromRgbF(r, g, b, a)); Executed by:
| 1484 | ||||||||||||||||||||||||
101 | } | - | ||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||
103 | QVariant fromHslF(double h, double s, double l, double a) override | - | ||||||||||||||||||||||||
104 | { | - | ||||||||||||||||||||||||
105 | return QVariant(QColor::fromHslF(h, s, l, a)); executed 430 times by 3 tests: return QVariant(QColor::fromHslF(h, s, l, a)); Executed by:
| 430 | ||||||||||||||||||||||||
106 | } | - | ||||||||||||||||||||||||
107 | - | |||||||||||||||||||||||||
108 | QVariant fromHsvF(double h, double s, double v, double a) override | - | ||||||||||||||||||||||||
109 | { | - | ||||||||||||||||||||||||
110 | return QVariant(QColor::fromHsvF(h, s, v, a)); executed 8 times by 1 test: return QVariant(QColor::fromHsvF(h, s, v, a)); Executed by:
| 8 | ||||||||||||||||||||||||
111 | } | - | ||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||
113 | QVariant lighter(const QVariant &var, qreal factor) override | - | ||||||||||||||||||||||||
114 | { | - | ||||||||||||||||||||||||
115 | QColor color = var.value<QColor>(); | - | ||||||||||||||||||||||||
116 | color = color.lighter(int(qRound(factor*100.))); | - | ||||||||||||||||||||||||
117 | return QVariant::fromValue(color); executed 6 times by 1 test: return QVariant::fromValue(color); Executed by:
| 6 | ||||||||||||||||||||||||
118 | } | - | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | QVariant darker(const QVariant &var, qreal factor) override | - | ||||||||||||||||||||||||
121 | { | - | ||||||||||||||||||||||||
122 | QColor color = var.value<QColor>(); | - | ||||||||||||||||||||||||
123 | color = color.darker(int(qRound(factor*100.))); | - | ||||||||||||||||||||||||
124 | return QVariant::fromValue(color); executed 184 times by 2 tests: return QVariant::fromValue(color); Executed by:
| 184 | ||||||||||||||||||||||||
125 | } | - | ||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||
127 | QVariant tint(const QVariant &baseVar, const QVariant &tintVar) override | - | ||||||||||||||||||||||||
128 | { | - | ||||||||||||||||||||||||
129 | QColor tintColor = tintVar.value<QColor>(); | - | ||||||||||||||||||||||||
130 | - | |||||||||||||||||||||||||
131 | int tintAlpha = tintColor.alpha(); | - | ||||||||||||||||||||||||
132 | if (tintAlpha == 0xFF) {
| 2-28 | ||||||||||||||||||||||||
133 | return tintVar; executed 2 times by 1 test: return tintVar; Executed by:
| 2 | ||||||||||||||||||||||||
134 | } else if (tintAlpha == 0x00) {
| 2-26 | ||||||||||||||||||||||||
135 | return baseVar; executed 2 times by 1 test: return baseVar; Executed by:
| 2 | ||||||||||||||||||||||||
136 | } | - | ||||||||||||||||||||||||
137 | - | |||||||||||||||||||||||||
138 | // tint the base color and return the final color | - | ||||||||||||||||||||||||
139 | QColor baseColor = baseVar.value<QColor>(); | - | ||||||||||||||||||||||||
140 | qreal a = tintColor.alphaF(); | - | ||||||||||||||||||||||||
141 | qreal inv_a = 1.0 - a; | - | ||||||||||||||||||||||||
142 | - | |||||||||||||||||||||||||
143 | qreal r = tintColor.redF() * a + baseColor.redF() * inv_a; | - | ||||||||||||||||||||||||
144 | qreal g = tintColor.greenF() * a + baseColor.greenF() * inv_a; | - | ||||||||||||||||||||||||
145 | qreal b = tintColor.blueF() * a + baseColor.blueF() * inv_a; | - | ||||||||||||||||||||||||
146 | - | |||||||||||||||||||||||||
147 | return QVariant::fromValue(QColor::fromRgbF(r, g, b, a + inv_a * baseColor.alphaF())); executed 26 times by 2 tests: return QVariant::fromValue(QColor::fromRgbF(r, g, b, a + inv_a * baseColor.alphaF())); Executed by:
| 26 | ||||||||||||||||||||||||
148 | } | - | ||||||||||||||||||||||||
149 | }; | - | ||||||||||||||||||||||||
150 | - | |||||||||||||||||||||||||
151 | - | |||||||||||||||||||||||||
152 | // Note: The functions in this class provide handling only for the types | - | ||||||||||||||||||||||||
153 | // that the QML engine will currently actually call them for, so many | - | ||||||||||||||||||||||||
154 | // appear incompletely implemented. For some functions, the implementation | - | ||||||||||||||||||||||||
155 | // would be obvious, but for others (particularly create and createFromString) | - | ||||||||||||||||||||||||
156 | // the exact semantics are unknown. For this reason unused functionality | - | ||||||||||||||||||||||||
157 | // has been omitted. | - | ||||||||||||||||||||||||
158 | - | |||||||||||||||||||||||||
159 | class QQuickValueTypeProvider : public QQmlValueTypeProvider | - | ||||||||||||||||||||||||
160 | { | - | ||||||||||||||||||||||||
161 | public: | - | ||||||||||||||||||||||||
162 | - | |||||||||||||||||||||||||
163 | #if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) | - | ||||||||||||||||||||||||
164 | #define ASSERT_VALID_SIZE(size, min) Q_UNUSED(size) | - | ||||||||||||||||||||||||
165 | #else | - | ||||||||||||||||||||||||
166 | #define ASSERT_VALID_SIZE(size, min) Q_ASSERT(size >= min) | - | ||||||||||||||||||||||||
167 | #endif | - | ||||||||||||||||||||||||
168 | - | |||||||||||||||||||||||||
169 | static QVector2D vector2DFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
170 | { | - | ||||||||||||||||||||||||
171 | if (s.count(QLatin1Char(',')) == 1) {
| 2-20 | ||||||||||||||||||||||||
172 | int index = s.indexOf(QLatin1Char(',')); | - | ||||||||||||||||||||||||
173 | - | |||||||||||||||||||||||||
174 | bool xGood, yGood; | - | ||||||||||||||||||||||||
175 | float xCoord = s.leftRef(index).toFloat(&xGood); | - | ||||||||||||||||||||||||
176 | float yCoord = s.midRef(index + 1).toFloat(&yGood); | - | ||||||||||||||||||||||||
177 | - | |||||||||||||||||||||||||
178 | if (xGood && yGood) {
| 0-2 | ||||||||||||||||||||||||
179 | if (ok) *ok = true; executed 2 times by 1 test: *ok = true; Executed by:
| 0-2 | ||||||||||||||||||||||||
180 | return QVector2D(xCoord, yCoord); executed 2 times by 1 test: return QVector2D(xCoord, yCoord); Executed by:
| 2 | ||||||||||||||||||||||||
181 | } | - | ||||||||||||||||||||||||
182 | } never executed: end of block | 0 | ||||||||||||||||||||||||
183 | - | |||||||||||||||||||||||||
184 | if (ok) *ok = false; executed 20 times by 5 tests: *ok = false; Executed by:
| 0-20 | ||||||||||||||||||||||||
185 | return QVector2D(); executed 20 times by 5 tests: return QVector2D(); Executed by:
| 20 | ||||||||||||||||||||||||
186 | } | - | ||||||||||||||||||||||||
187 | - | |||||||||||||||||||||||||
188 | static QVector3D vector3DFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
189 | { | - | ||||||||||||||||||||||||
190 | if (s.count(QLatin1Char(',')) == 2) {
| 6-20 | ||||||||||||||||||||||||
191 | int index = s.indexOf(QLatin1Char(',')); | - | ||||||||||||||||||||||||
192 | int index2 = s.indexOf(QLatin1Char(','), index+1); | - | ||||||||||||||||||||||||
193 | - | |||||||||||||||||||||||||
194 | bool xGood, yGood, zGood; | - | ||||||||||||||||||||||||
195 | float xCoord = s.leftRef(index).toFloat(&xGood); | - | ||||||||||||||||||||||||
196 | float yCoord = s.midRef(index + 1, index2 - index - 1).toFloat(&yGood); | - | ||||||||||||||||||||||||
197 | float zCoord = s.midRef(index2 + 1).toFloat(&zGood); | - | ||||||||||||||||||||||||
198 | - | |||||||||||||||||||||||||
199 | if (xGood && yGood && zGood) {
| 0-6 | ||||||||||||||||||||||||
200 | if (ok) *ok = true; executed 6 times by 2 tests: *ok = true; Executed by:
| 0-6 | ||||||||||||||||||||||||
201 | return QVector3D(xCoord, yCoord, zCoord); executed 6 times by 2 tests: return QVector3D(xCoord, yCoord, zCoord); Executed by:
| 6 | ||||||||||||||||||||||||
202 | } | - | ||||||||||||||||||||||||
203 | } never executed: end of block | 0 | ||||||||||||||||||||||||
204 | - | |||||||||||||||||||||||||
205 | if (ok) *ok = false; executed 20 times by 5 tests: *ok = false; Executed by:
| 0-20 | ||||||||||||||||||||||||
206 | return QVector3D(); executed 20 times by 5 tests: return QVector3D(); Executed by:
| 20 | ||||||||||||||||||||||||
207 | } | - | ||||||||||||||||||||||||
208 | - | |||||||||||||||||||||||||
209 | static QVector4D vector4DFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
210 | { | - | ||||||||||||||||||||||||
211 | if (s.count(QLatin1Char(',')) == 3) {
| 2-20 | ||||||||||||||||||||||||
212 | int index = s.indexOf(QLatin1Char(',')); | - | ||||||||||||||||||||||||
213 | int index2 = s.indexOf(QLatin1Char(','), index+1); | - | ||||||||||||||||||||||||
214 | int index3 = s.indexOf(QLatin1Char(','), index2+1); | - | ||||||||||||||||||||||||
215 | - | |||||||||||||||||||||||||
216 | bool xGood, yGood, zGood, wGood; | - | ||||||||||||||||||||||||
217 | float xCoord = s.leftRef(index).toFloat(&xGood); | - | ||||||||||||||||||||||||
218 | float yCoord = s.midRef(index + 1, index2 - index - 1).toFloat(&yGood); | - | ||||||||||||||||||||||||
219 | float zCoord = s.midRef(index2 + 1, index3 - index2 - 1).toFloat(&zGood); | - | ||||||||||||||||||||||||
220 | float wCoord = s.midRef(index3 + 1).toFloat(&wGood); | - | ||||||||||||||||||||||||
221 | - | |||||||||||||||||||||||||
222 | if (xGood && yGood && zGood && wGood) {
| 0-2 | ||||||||||||||||||||||||
223 | if (ok) *ok = true; executed 2 times by 1 test: *ok = true; Executed by:
| 0-2 | ||||||||||||||||||||||||
224 | return QVector4D(xCoord, yCoord, zCoord, wCoord); executed 2 times by 1 test: return QVector4D(xCoord, yCoord, zCoord, wCoord); Executed by:
| 2 | ||||||||||||||||||||||||
225 | } | - | ||||||||||||||||||||||||
226 | } never executed: end of block | 0 | ||||||||||||||||||||||||
227 | - | |||||||||||||||||||||||||
228 | if (ok) *ok = false; executed 20 times by 5 tests: *ok = false; Executed by:
| 0-20 | ||||||||||||||||||||||||
229 | return QVector4D(); executed 20 times by 5 tests: return QVector4D(); Executed by:
| 20 | ||||||||||||||||||||||||
230 | } | - | ||||||||||||||||||||||||
231 | - | |||||||||||||||||||||||||
232 | static QQuaternion quaternionFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
233 | { | - | ||||||||||||||||||||||||
234 | if (s.count(QLatin1Char(',')) == 3) {
| 2-20 | ||||||||||||||||||||||||
235 | int index = s.indexOf(QLatin1Char(',')); | - | ||||||||||||||||||||||||
236 | int index2 = s.indexOf(QLatin1Char(','), index+1); | - | ||||||||||||||||||||||||
237 | int index3 = s.indexOf(QLatin1Char(','), index2+1); | - | ||||||||||||||||||||||||
238 | - | |||||||||||||||||||||||||
239 | bool sGood, xGood, yGood, zGood; | - | ||||||||||||||||||||||||
240 | qreal sCoord = s.leftRef(index).toDouble(&sGood); | - | ||||||||||||||||||||||||
241 | qreal xCoord = s.midRef(index+1, index2-index-1).toDouble(&xGood); | - | ||||||||||||||||||||||||
242 | qreal yCoord = s.midRef(index2+1, index3-index2-1).toDouble(&yGood); | - | ||||||||||||||||||||||||
243 | qreal zCoord = s.midRef(index3+1).toDouble(&zGood); | - | ||||||||||||||||||||||||
244 | - | |||||||||||||||||||||||||
245 | if (sGood && xGood && yGood && zGood) {
| 0-2 | ||||||||||||||||||||||||
246 | if (ok) *ok = true; executed 2 times by 1 test: *ok = true; Executed by:
| 0-2 | ||||||||||||||||||||||||
247 | return QQuaternion(sCoord, xCoord, yCoord, zCoord); executed 2 times by 1 test: return QQuaternion(sCoord, xCoord, yCoord, zCoord); Executed by:
| 2 | ||||||||||||||||||||||||
248 | } | - | ||||||||||||||||||||||||
249 | } never executed: end of block | 0 | ||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||
251 | if (ok) *ok = false; executed 20 times by 5 tests: *ok = false; Executed by:
| 0-20 | ||||||||||||||||||||||||
252 | return QQuaternion(); executed 20 times by 5 tests: return QQuaternion(); Executed by:
| 20 | ||||||||||||||||||||||||
253 | } | - | ||||||||||||||||||||||||
254 | - | |||||||||||||||||||||||||
255 | static QMatrix4x4 matrix4x4FromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
256 | { | - | ||||||||||||||||||||||||
257 | if (s.count(QLatin1Char(',')) == 15) {
| 2-20 | ||||||||||||||||||||||||
258 | float matValues[16]; | - | ||||||||||||||||||||||||
259 | bool vOK = true; | - | ||||||||||||||||||||||||
260 | QStringRef mutableStr(&s); | - | ||||||||||||||||||||||||
261 | for (int i = 0; vOK && i < 16; ++i) {
| 0-34 | ||||||||||||||||||||||||
262 | int cidx = mutableStr.indexOf(QLatin1Char(',')); | - | ||||||||||||||||||||||||
263 | matValues[i] = mutableStr.left(cidx).toDouble(&vOK); | - | ||||||||||||||||||||||||
264 | mutableStr = mutableStr.mid(cidx + 1); | - | ||||||||||||||||||||||||
265 | } executed 32 times by 1 test: end of block Executed by:
| 32 | ||||||||||||||||||||||||
266 | - | |||||||||||||||||||||||||
267 | if (vOK) {
| 0-2 | ||||||||||||||||||||||||
268 | if (ok) *ok = true; executed 2 times by 1 test: *ok = true; Executed by:
| 0-2 | ||||||||||||||||||||||||
269 | return QMatrix4x4(matValues); executed 2 times by 1 test: return QMatrix4x4(matValues); Executed by:
| 2 | ||||||||||||||||||||||||
270 | } | - | ||||||||||||||||||||||||
271 | } never executed: end of block | 0 | ||||||||||||||||||||||||
272 | - | |||||||||||||||||||||||||
273 | if (ok) *ok = false; executed 20 times by 5 tests: *ok = false; Executed by:
| 0-20 | ||||||||||||||||||||||||
274 | return QMatrix4x4(); executed 20 times by 5 tests: return QMatrix4x4(); Executed by:
| 20 | ||||||||||||||||||||||||
275 | } | - | ||||||||||||||||||||||||
276 | - | |||||||||||||||||||||||||
277 | static QFont fontFromObject(QQmlV4Handle object, QV4::ExecutionEngine *v4, bool *ok) | - | ||||||||||||||||||||||||
278 | { | - | ||||||||||||||||||||||||
279 | if (ok)
| 0-60 | ||||||||||||||||||||||||
280 | *ok = false; executed 60 times by 3 tests: *ok = false; Executed by:
| 60 | ||||||||||||||||||||||||
281 | QFont retn; | - | ||||||||||||||||||||||||
282 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
283 | QV4::ScopedObject obj(scope, object); | - | ||||||||||||||||||||||||
284 | if (!obj) {
| 0-60 | ||||||||||||||||||||||||
285 | if (ok)
| 0 | ||||||||||||||||||||||||
286 | *ok = false; never executed: *ok = false; | 0 | ||||||||||||||||||||||||
287 | return retn; never executed: return retn; | 0 | ||||||||||||||||||||||||
288 | } | - | ||||||||||||||||||||||||
289 | - | |||||||||||||||||||||||||
290 | QV4::ScopedString s(scope); | - | ||||||||||||||||||||||||
291 | - | |||||||||||||||||||||||||
292 | QV4::ScopedValue vbold(scope, obj->get((s = v4->newString(QStringLiteral("bold"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
293 | QV4::ScopedValue vcap(scope, obj->get((s = v4->newString(QStringLiteral("capitalization"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
294 | QV4::ScopedValue vfam(scope, obj->get((s = v4->newString(QStringLiteral("family"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
295 | QV4::ScopedValue vstyle(scope, obj->get((s = v4->newString(QStringLiteral("styleName"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
296 | QV4::ScopedValue vital(scope, obj->get((s = v4->newString(QStringLiteral("italic"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
297 | QV4::ScopedValue vlspac(scope, obj->get((s = v4->newString(QStringLiteral("letterSpacing"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
298 | QV4::ScopedValue vpixsz(scope, obj->get((s = v4->newString(QStringLiteral("pixelSize"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
299 | QV4::ScopedValue vpntsz(scope, obj->get((s = v4->newString(QStringLiteral("pointSize"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
300 | QV4::ScopedValue vstrk(scope, obj->get((s = v4->newString(QStringLiteral("strikeout"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
301 | QV4::ScopedValue vundl(scope, obj->get((s = v4->newString(QStringLiteral("underline"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
302 | QV4::ScopedValue vweight(scope, obj->get((s = v4->newString(QStringLiteral("weight"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
303 | QV4::ScopedValue vwspac(scope, obj->get((s = v4->newString(QStringLiteral("wordSpacing"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
304 | QV4::ScopedValue vhint(scope, obj->get((s = v4->newString(QStringLiteral("hintingPreference"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
305 | QV4::ScopedValue vkerning(scope, obj->get((s = v4->newString(QStringLiteral("kerning"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
306 | QV4::ScopedValue vshaping(scope, obj->get((s = v4->newString(QStringLiteral("preferShaping"))))); executed 60 times by 3 tests: return qstring_literal_temp; Executed by:
| 60 | ||||||||||||||||||||||||
307 | - | |||||||||||||||||||||||||
308 | // pull out the values, set ok to true if at least one valid field is given. | - | ||||||||||||||||||||||||
309 | if (vbold->isBoolean()) {
| 0-60 | ||||||||||||||||||||||||
310 | retn.setBold(vbold->booleanValue()); | - | ||||||||||||||||||||||||
311 | if (ok) *ok = true; never executed: *ok = true;
| 0 | ||||||||||||||||||||||||
312 | } never executed: end of block | 0 | ||||||||||||||||||||||||
313 | if (vcap->isInt32()) {
| 0-60 | ||||||||||||||||||||||||
314 | retn.setCapitalization(static_cast<QFont::Capitalization>(vcap->integerValue())); | - | ||||||||||||||||||||||||
315 | if (ok) *ok = true; never executed: *ok = true;
| 0 | ||||||||||||||||||||||||
316 | } never executed: end of block | 0 | ||||||||||||||||||||||||
317 | if (vfam->isString()) {
| 8-52 | ||||||||||||||||||||||||
318 | retn.setFamily(vfam->toQString()); | - | ||||||||||||||||||||||||
319 | if (ok) *ok = true; executed 52 times by 2 tests: *ok = true; Executed by:
| 0-52 | ||||||||||||||||||||||||
320 | } executed 52 times by 2 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||
321 | if (vstyle->isString()) {
| 0-60 | ||||||||||||||||||||||||
322 | retn.setStyleName(vstyle->toQString()); | - | ||||||||||||||||||||||||
323 | if (ok) *ok = true; never executed: *ok = true;
| 0 | ||||||||||||||||||||||||
324 | } never executed: end of block | 0 | ||||||||||||||||||||||||
325 | if (vital->isBoolean()) {
| 24-36 | ||||||||||||||||||||||||
326 | retn.setItalic(vital->booleanValue()); | - | ||||||||||||||||||||||||
327 | if (ok) *ok = true; executed 24 times by 2 tests: *ok = true; Executed by:
| 0-24 | ||||||||||||||||||||||||
328 | } executed 24 times by 2 tests: end of block Executed by:
| 24 | ||||||||||||||||||||||||
329 | if (vlspac->isNumber()) {
| 0-60 | ||||||||||||||||||||||||
330 | retn.setLetterSpacing(QFont::AbsoluteSpacing, vlspac->asDouble()); | - | ||||||||||||||||||||||||
331 | if (ok) *ok = true; never executed: *ok = true;
| 0 | ||||||||||||||||||||||||
332 | } never executed: end of block | 0 | ||||||||||||||||||||||||
333 | if (vpixsz->isInt32()) {
| 6-54 | ||||||||||||||||||||||||
334 | retn.setPixelSize(vpixsz->integerValue()); | - | ||||||||||||||||||||||||
335 | if (ok) *ok = true; executed 6 times by 1 test: *ok = true; Executed by:
| 0-6 | ||||||||||||||||||||||||
336 | } executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
337 | if (vpntsz->isNumber()) {
| 8-52 | ||||||||||||||||||||||||
338 | retn.setPointSize(vpntsz->asDouble()); | - | ||||||||||||||||||||||||
339 | if (ok) *ok = true; executed 52 times by 2 tests: *ok = true; Executed by:
| 0-52 | ||||||||||||||||||||||||
340 | } executed 52 times by 2 tests: end of block Executed by:
| 52 | ||||||||||||||||||||||||
341 | if (vstrk->isBoolean()) {
| 0-60 | ||||||||||||||||||||||||
342 | retn.setStrikeOut(vstrk->booleanValue()); | - | ||||||||||||||||||||||||
343 | if (ok) *ok = true; never executed: *ok = true;
| 0 | ||||||||||||||||||||||||
344 | } never executed: end of block | 0 | ||||||||||||||||||||||||
345 | if (vundl->isBoolean()) {
| 0-60 | ||||||||||||||||||||||||
346 | retn.setUnderline(vundl->booleanValue()); | - | ||||||||||||||||||||||||
347 | if (ok) *ok = true; never executed: *ok = true;
| 0 | ||||||||||||||||||||||||
348 | } never executed: end of block | 0 | ||||||||||||||||||||||||
349 | if (vweight->isInt32()) {
| 20-40 | ||||||||||||||||||||||||
350 | retn.setWeight(static_cast<QFont::Weight>(vweight->integerValue())); | - | ||||||||||||||||||||||||
351 | if (ok) *ok = true; executed 40 times by 2 tests: *ok = true; Executed by:
| 0-40 | ||||||||||||||||||||||||
352 | } executed 40 times by 2 tests: end of block Executed by:
| 40 | ||||||||||||||||||||||||
353 | if (vwspac->isNumber()) {
| 0-60 | ||||||||||||||||||||||||
354 | retn.setWordSpacing(vwspac->asDouble()); | - | ||||||||||||||||||||||||
355 | if (ok) *ok = true; never executed: *ok = true;
| 0 | ||||||||||||||||||||||||
356 | } never executed: end of block | 0 | ||||||||||||||||||||||||
357 | if (vhint->isInt32()) {
| 0-60 | ||||||||||||||||||||||||
358 | retn.setHintingPreference(static_cast<QFont::HintingPreference>(vhint->integerValue())); | - | ||||||||||||||||||||||||
359 | if (ok) *ok = true; never executed: *ok = true;
| 0 | ||||||||||||||||||||||||
360 | } never executed: end of block | 0 | ||||||||||||||||||||||||
361 | if (vkerning->isBoolean()) {
| 0-60 | ||||||||||||||||||||||||
362 | retn.setKerning(vkerning->booleanValue()); | - | ||||||||||||||||||||||||
363 | if (ok) *ok = true; never executed: *ok = true;
| 0 | ||||||||||||||||||||||||
364 | } never executed: end of block | 0 | ||||||||||||||||||||||||
365 | if (vshaping->isBoolean()) {
| 0-60 | ||||||||||||||||||||||||
366 | bool enable = vshaping->booleanValue(); | - | ||||||||||||||||||||||||
367 | if (enable)
| 0 | ||||||||||||||||||||||||
368 | retn.setStyleStrategy(static_cast<QFont::StyleStrategy>(retn.styleStrategy() & ~QFont::PreferNoShaping)); never executed: retn.setStyleStrategy(static_cast<QFont::StyleStrategy>(retn.styleStrategy() & ~QFont::PreferNoShaping)); | 0 | ||||||||||||||||||||||||
369 | else | - | ||||||||||||||||||||||||
370 | retn.setStyleStrategy(static_cast<QFont::StyleStrategy>(retn.styleStrategy() | QFont::PreferNoShaping)); never executed: retn.setStyleStrategy(static_cast<QFont::StyleStrategy>(retn.styleStrategy() | QFont::PreferNoShaping)); | 0 | ||||||||||||||||||||||||
371 | } | - | ||||||||||||||||||||||||
372 | - | |||||||||||||||||||||||||
373 | return retn; executed 60 times by 3 tests: return retn; Executed by:
| 60 | ||||||||||||||||||||||||
374 | } | - | ||||||||||||||||||||||||
375 | - | |||||||||||||||||||||||||
376 | static QMatrix4x4 matrix4x4FromObject(QQmlV4Handle object, QV4::ExecutionEngine *v4, bool *ok) | - | ||||||||||||||||||||||||
377 | { | - | ||||||||||||||||||||||||
378 | if (ok)
| 0-18 | ||||||||||||||||||||||||
379 | *ok = false; executed 18 times by 2 tests: *ok = false; Executed by:
| 18 | ||||||||||||||||||||||||
380 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
381 | QV4::ScopedArrayObject array(scope, object); | - | ||||||||||||||||||||||||
382 | if (!array)
| 2-16 | ||||||||||||||||||||||||
383 | return QMatrix4x4(); executed 2 times by 1 test: return QMatrix4x4(); Executed by:
| 2 | ||||||||||||||||||||||||
384 | - | |||||||||||||||||||||||||
385 | if (array->getLength() != 16)
| 2-14 | ||||||||||||||||||||||||
386 | return QMatrix4x4(); executed 2 times by 1 test: return QMatrix4x4(); Executed by:
| 2 | ||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||
388 | float matVals[16]; | - | ||||||||||||||||||||||||
389 | QV4::ScopedValue v(scope); | - | ||||||||||||||||||||||||
390 | for (quint32 i = 0; i < 16; ++i) {
| 14-224 | ||||||||||||||||||||||||
391 | v = array->get(i); | - | ||||||||||||||||||||||||
392 | if (!v->isNumber())
| 0-224 | ||||||||||||||||||||||||
393 | return QMatrix4x4(); never executed: return QMatrix4x4(); | 0 | ||||||||||||||||||||||||
394 | matVals[i] = v->asDouble(); | - | ||||||||||||||||||||||||
395 | } executed 224 times by 2 tests: end of block Executed by:
| 224 | ||||||||||||||||||||||||
396 | - | |||||||||||||||||||||||||
397 | if (ok) *ok = true; executed 14 times by 2 tests: *ok = true; Executed by:
| 0-14 | ||||||||||||||||||||||||
398 | return QMatrix4x4(matVals); executed 14 times by 2 tests: return QMatrix4x4(matVals); Executed by:
| 14 | ||||||||||||||||||||||||
399 | } | - | ||||||||||||||||||||||||
400 | - | |||||||||||||||||||||||||
401 | const QMetaObject *getMetaObjectForMetaType(int type) override | - | ||||||||||||||||||||||||
402 | { | - | ||||||||||||||||||||||||
403 | switch (type) { | - | ||||||||||||||||||||||||
404 | case QMetaType::QColor: executed 3248 times by 20 tests: case QMetaType::QColor: Executed by:
| 3248 | ||||||||||||||||||||||||
405 | return &QQuickColorValueType::staticMetaObject; executed 3248 times by 20 tests: return &QQuickColorValueType::staticMetaObject; Executed by:
| 3248 | ||||||||||||||||||||||||
406 | case QMetaType::QFont: executed 6131 times by 24 tests: case QMetaType::QFont: Executed by:
| 6131 | ||||||||||||||||||||||||
407 | return &QQuickFontValueType::staticMetaObject; executed 6131 times by 24 tests: return &QQuickFontValueType::staticMetaObject; Executed by:
| 6131 | ||||||||||||||||||||||||
408 | case QMetaType::QVector2D: executed 228 times by 3 tests: case QMetaType::QVector2D: Executed by:
| 228 | ||||||||||||||||||||||||
409 | return &QQuickVector2DValueType::staticMetaObject; executed 228 times by 3 tests: return &QQuickVector2DValueType::staticMetaObject; Executed by:
| 228 | ||||||||||||||||||||||||
410 | case QMetaType::QVector3D: executed 2512 times by 9 tests: case QMetaType::QVector3D: Executed by:
| 2512 | ||||||||||||||||||||||||
411 | return &QQuickVector3DValueType::staticMetaObject; executed 2512 times by 9 tests: return &QQuickVector3DValueType::staticMetaObject; Executed by:
| 2512 | ||||||||||||||||||||||||
412 | case QMetaType::QVector4D: executed 280 times by 3 tests: case QMetaType::QVector4D: Executed by:
| 280 | ||||||||||||||||||||||||
413 | return &QQuickVector4DValueType::staticMetaObject; executed 280 times by 3 tests: return &QQuickVector4DValueType::staticMetaObject; Executed by:
| 280 | ||||||||||||||||||||||||
414 | case QMetaType::QQuaternion: executed 124 times by 3 tests: case QMetaType::QQuaternion: Executed by:
| 124 | ||||||||||||||||||||||||
415 | return &QQuickQuaternionValueType::staticMetaObject; executed 124 times by 3 tests: return &QQuickQuaternionValueType::staticMetaObject; Executed by:
| 124 | ||||||||||||||||||||||||
416 | case QMetaType::QMatrix4x4: executed 338 times by 4 tests: case QMetaType::QMatrix4x4: Executed by:
| 338 | ||||||||||||||||||||||||
417 | return &QQuickMatrix4x4ValueType::staticMetaObject; executed 338 times by 4 tests: return &QQuickMatrix4x4ValueType::staticMetaObject; Executed by:
| 338 | ||||||||||||||||||||||||
418 | default: executed 334581 times by 123 tests: default: Executed by:
| 334581 | ||||||||||||||||||||||||
419 | break; executed 334581 times by 123 tests: break; Executed by:
| 334581 | ||||||||||||||||||||||||
420 | } | - | ||||||||||||||||||||||||
421 | - | |||||||||||||||||||||||||
422 | return nullptr; executed 334581 times by 123 tests: return nullptr; Executed by:
| 334581 | ||||||||||||||||||||||||
423 | } | - | ||||||||||||||||||||||||
424 | - | |||||||||||||||||||||||||
425 | bool init(int type, QVariant& dst) override | - | ||||||||||||||||||||||||
426 | { | - | ||||||||||||||||||||||||
427 | switch (type) { | - | ||||||||||||||||||||||||
428 | case QMetaType::QColor: executed 198 times by 11 tests: case QMetaType::QColor: Executed by:
| 198 | ||||||||||||||||||||||||
429 | dst.setValue<QColor>(QColor()); | - | ||||||||||||||||||||||||
430 | return true; executed 198 times by 11 tests: return true; Executed by:
| 198 | ||||||||||||||||||||||||
431 | case QMetaType::QFont: executed 24 times by 3 tests: case QMetaType::QFont: Executed by:
| 24 | ||||||||||||||||||||||||
432 | dst.setValue<QFont>(QFont()); | - | ||||||||||||||||||||||||
433 | return true; executed 24 times by 3 tests: return true; Executed by:
| 24 | ||||||||||||||||||||||||
434 | case QMetaType::QVector2D: executed 12 times by 1 test: case QMetaType::QVector2D: Executed by:
| 12 | ||||||||||||||||||||||||
435 | dst.setValue<QVector2D>(QVector2D()); | - | ||||||||||||||||||||||||
436 | return true; executed 12 times by 1 test: return true; Executed by:
| 12 | ||||||||||||||||||||||||
437 | case QMetaType::QVector3D: executed 10 times by 1 test: case QMetaType::QVector3D: Executed by:
| 10 | ||||||||||||||||||||||||
438 | dst.setValue<QVector3D>(QVector3D()); | - | ||||||||||||||||||||||||
439 | return true; executed 10 times by 1 test: return true; Executed by:
| 10 | ||||||||||||||||||||||||
440 | case QMetaType::QVector4D: executed 14 times by 1 test: case QMetaType::QVector4D: Executed by:
| 14 | ||||||||||||||||||||||||
441 | dst.setValue<QVector4D>(QVector4D()); | - | ||||||||||||||||||||||||
442 | return true; executed 14 times by 1 test: return true; Executed by:
| 14 | ||||||||||||||||||||||||
443 | case QMetaType::QQuaternion: executed 8 times by 1 test: case QMetaType::QQuaternion: Executed by:
| 8 | ||||||||||||||||||||||||
444 | dst.setValue<QQuaternion>(QQuaternion()); | - | ||||||||||||||||||||||||
445 | return true; executed 8 times by 1 test: return true; Executed by:
| 8 | ||||||||||||||||||||||||
446 | case QMetaType::QMatrix4x4: executed 16 times by 1 test: case QMetaType::QMatrix4x4: Executed by:
| 16 | ||||||||||||||||||||||||
447 | dst.setValue<QMatrix4x4>(QMatrix4x4()); | - | ||||||||||||||||||||||||
448 | return true; executed 16 times by 1 test: return true; Executed by:
| 16 | ||||||||||||||||||||||||
449 | default: break; never executed: break; never executed: default: | 0 | ||||||||||||||||||||||||
450 | } | - | ||||||||||||||||||||||||
451 | - | |||||||||||||||||||||||||
452 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
453 | } | - | ||||||||||||||||||||||||
454 | - | |||||||||||||||||||||||||
455 | bool create(int type, int argc, const void *argv[], QVariant *v) override | - | ||||||||||||||||||||||||
456 | { | - | ||||||||||||||||||||||||
457 | switch (type) { | - | ||||||||||||||||||||||||
458 | case QMetaType::QFont: // must specify via js-object. never executed: case QMetaType::QFont: | 0 | ||||||||||||||||||||||||
459 | break; never executed: break; | 0 | ||||||||||||||||||||||||
460 | case QMetaType::QVector2D: executed 52 times by 3 tests: case QMetaType::QVector2D: Executed by:
| 52 | ||||||||||||||||||||||||
461 | if (argc == 1) {
| 0-52 | ||||||||||||||||||||||||
462 | const float *xy = reinterpret_cast<const float*>(argv[0]); | - | ||||||||||||||||||||||||
463 | QVector2D v2(xy[0], xy[1]); | - | ||||||||||||||||||||||||
464 | *v = QVariant(v2); | - | ||||||||||||||||||||||||
465 | return true; executed 52 times by 3 tests: return true; Executed by:
| 52 | ||||||||||||||||||||||||
466 | } | - | ||||||||||||||||||||||||
467 | break; never executed: break; | 0 | ||||||||||||||||||||||||
468 | case QMetaType::QVector3D: executed 84 times by 5 tests: case QMetaType::QVector3D: Executed by:
| 84 | ||||||||||||||||||||||||
469 | if (argc == 1) {
| 0-84 | ||||||||||||||||||||||||
470 | const float *xyz = reinterpret_cast<const float*>(argv[0]); | - | ||||||||||||||||||||||||
471 | QVector3D v3(xyz[0], xyz[1], xyz[2]); | - | ||||||||||||||||||||||||
472 | *v = QVariant(v3); | - | ||||||||||||||||||||||||
473 | return true; executed 84 times by 5 tests: return true; Executed by:
| 84 | ||||||||||||||||||||||||
474 | } | - | ||||||||||||||||||||||||
475 | break; never executed: break; | 0 | ||||||||||||||||||||||||
476 | case QMetaType::QVector4D: executed 78 times by 3 tests: case QMetaType::QVector4D: Executed by:
| 78 | ||||||||||||||||||||||||
477 | if (argc == 1) {
| 0-78 | ||||||||||||||||||||||||
478 | const float *xyzw = reinterpret_cast<const float*>(argv[0]); | - | ||||||||||||||||||||||||
479 | QVector4D v4(xyzw[0], xyzw[1], xyzw[2], xyzw[3]); | - | ||||||||||||||||||||||||
480 | *v = QVariant(v4); | - | ||||||||||||||||||||||||
481 | return true; executed 78 times by 3 tests: return true; Executed by:
| 78 | ||||||||||||||||||||||||
482 | } | - | ||||||||||||||||||||||||
483 | break; never executed: break; | 0 | ||||||||||||||||||||||||
484 | case QMetaType::QQuaternion: executed 18 times by 2 tests: case QMetaType::QQuaternion: Executed by:
| 18 | ||||||||||||||||||||||||
485 | if (argc == 1) {
| 0-18 | ||||||||||||||||||||||||
486 | const qreal *sxyz = reinterpret_cast<const qreal*>(argv[0]); | - | ||||||||||||||||||||||||
487 | QQuaternion q(sxyz[0], sxyz[1], sxyz[2], sxyz[3]); | - | ||||||||||||||||||||||||
488 | *v = QVariant(q); | - | ||||||||||||||||||||||||
489 | return true; executed 18 times by 2 tests: return true; Executed by:
| 18 | ||||||||||||||||||||||||
490 | } | - | ||||||||||||||||||||||||
491 | break; never executed: break; | 0 | ||||||||||||||||||||||||
492 | case QMetaType::QMatrix4x4: executed 56 times by 4 tests: case QMetaType::QMatrix4x4: Executed by:
| 56 | ||||||||||||||||||||||||
493 | if (argc == 0) {
| 0-56 | ||||||||||||||||||||||||
494 | QMatrix4x4 m; | - | ||||||||||||||||||||||||
495 | *v = QVariant(m); | - | ||||||||||||||||||||||||
496 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
497 | } else if (argc == 1) {
| 0-56 | ||||||||||||||||||||||||
498 | const qreal *vals = reinterpret_cast<const qreal*>(argv[0]); | - | ||||||||||||||||||||||||
499 | QMatrix4x4 m(vals[0], vals[1], vals[2], vals[3], | - | ||||||||||||||||||||||||
500 | vals[4], vals[5], vals[6], vals[7], | - | ||||||||||||||||||||||||
501 | vals[8], vals[9], vals[10], vals[11], | - | ||||||||||||||||||||||||
502 | vals[12], vals[13], vals[14], vals[15]); | - | ||||||||||||||||||||||||
503 | *v = QVariant(m); | - | ||||||||||||||||||||||||
504 | return true; executed 56 times by 4 tests: return true; Executed by:
| 56 | ||||||||||||||||||||||||
505 | } | - | ||||||||||||||||||||||||
506 | break; never executed: break; | 0 | ||||||||||||||||||||||||
507 | default: break; never executed: break; never executed: default: | 0 | ||||||||||||||||||||||||
508 | } | - | ||||||||||||||||||||||||
509 | - | |||||||||||||||||||||||||
510 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
511 | } | - | ||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||
513 | template<typename T> | - | ||||||||||||||||||||||||
514 | bool createFromStringTyped(void *data, size_t dataSize, T initValue) | - | ||||||||||||||||||||||||
515 | { | - | ||||||||||||||||||||||||
516 | ASSERT_VALID_SIZE(dataSize, sizeof(T)); | - | ||||||||||||||||||||||||
517 | T *t = reinterpret_cast<T *>(data); | - | ||||||||||||||||||||||||
518 | new (t) T(initValue); | - | ||||||||||||||||||||||||
519 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
520 | } | - | ||||||||||||||||||||||||
521 | - | |||||||||||||||||||||||||
522 | bool createFromString(int type, const QString &s, void *data, size_t dataSize) override | - | ||||||||||||||||||||||||
523 | { | - | ||||||||||||||||||||||||
524 | bool ok = false; | - | ||||||||||||||||||||||||
525 | - | |||||||||||||||||||||||||
526 | switch (type) { | - | ||||||||||||||||||||||||
527 | case QMetaType::QColor: never executed: case QMetaType::QColor: | 0 | ||||||||||||||||||||||||
528 | return createFromStringTyped<QColor>(data, dataSize, QColor(s)); never executed: return createFromStringTyped<QColor>(data, dataSize, QColor(s)); | 0 | ||||||||||||||||||||||||
529 | case QMetaType::QVector2D: never executed: case QMetaType::QVector2D: | 0 | ||||||||||||||||||||||||
530 | return createFromStringTyped<QVector2D>(data, dataSize, vector2DFromString(s, &ok)); never executed: return createFromStringTyped<QVector2D>(data, dataSize, vector2DFromString(s, &ok)); | 0 | ||||||||||||||||||||||||
531 | case QMetaType::QVector3D: never executed: case QMetaType::QVector3D: | 0 | ||||||||||||||||||||||||
532 | return createFromStringTyped<QVector3D>(data, dataSize, vector3DFromString(s, &ok)); never executed: return createFromStringTyped<QVector3D>(data, dataSize, vector3DFromString(s, &ok)); | 0 | ||||||||||||||||||||||||
533 | case QMetaType::QVector4D: never executed: case QMetaType::QVector4D: | 0 | ||||||||||||||||||||||||
534 | return createFromStringTyped<QVector4D>(data, dataSize, vector4DFromString(s, &ok)); never executed: return createFromStringTyped<QVector4D>(data, dataSize, vector4DFromString(s, &ok)); | 0 | ||||||||||||||||||||||||
535 | case QMetaType::QQuaternion: never executed: case QMetaType::QQuaternion: | 0 | ||||||||||||||||||||||||
536 | return createFromStringTyped<QQuaternion>(data, dataSize, quaternionFromString(s, &ok)); never executed: return createFromStringTyped<QQuaternion>(data, dataSize, quaternionFromString(s, &ok)); | 0 | ||||||||||||||||||||||||
537 | case QMetaType::QMatrix4x4: never executed: case QMetaType::QMatrix4x4: | 0 | ||||||||||||||||||||||||
538 | return createFromStringTyped<QMatrix4x4>(data, dataSize, matrix4x4FromString(s, &ok)); never executed: return createFromStringTyped<QMatrix4x4>(data, dataSize, matrix4x4FromString(s, &ok)); | 0 | ||||||||||||||||||||||||
539 | default: break; never executed: break; never executed: default: | 0 | ||||||||||||||||||||||||
540 | } | - | ||||||||||||||||||||||||
541 | - | |||||||||||||||||||||||||
542 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
543 | } | - | ||||||||||||||||||||||||
544 | - | |||||||||||||||||||||||||
545 | bool createStringFrom(int type, const void *data, QString *s) override | - | ||||||||||||||||||||||||
546 | { | - | ||||||||||||||||||||||||
547 | if (type == QMetaType::QColor) {
| 0 | ||||||||||||||||||||||||
548 | const QColor *color = reinterpret_cast<const QColor *>(data); | - | ||||||||||||||||||||||||
549 | new (s) QString(QVariant(*color).toString()); | - | ||||||||||||||||||||||||
550 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
551 | } | - | ||||||||||||||||||||||||
552 | - | |||||||||||||||||||||||||
553 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
554 | } | - | ||||||||||||||||||||||||
555 | - | |||||||||||||||||||||||||
556 | bool variantFromString(const QString &s, QVariant *v) override | - | ||||||||||||||||||||||||
557 | { | - | ||||||||||||||||||||||||
558 | QColor c(s); | - | ||||||||||||||||||||||||
559 | if (c.isValid()) {
| 6-20 | ||||||||||||||||||||||||
560 | *v = QVariant::fromValue(c); | - | ||||||||||||||||||||||||
561 | return true; executed 6 times by 2 tests: return true; Executed by:
| 6 | ||||||||||||||||||||||||
562 | } | - | ||||||||||||||||||||||||
563 | - | |||||||||||||||||||||||||
564 | bool ok = false; | - | ||||||||||||||||||||||||
565 | - | |||||||||||||||||||||||||
566 | QVector2D v2 = vector2DFromString(s, &ok); | - | ||||||||||||||||||||||||
567 | if (ok) {
| 0-20 | ||||||||||||||||||||||||
568 | *v = QVariant::fromValue(v2); | - | ||||||||||||||||||||||||
569 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
570 | } | - | ||||||||||||||||||||||||
571 | - | |||||||||||||||||||||||||
572 | QVector3D v3 = vector3DFromString(s, &ok); | - | ||||||||||||||||||||||||
573 | if (ok) {
| 0-20 | ||||||||||||||||||||||||
574 | *v = QVariant::fromValue(v3); | - | ||||||||||||||||||||||||
575 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
576 | } | - | ||||||||||||||||||||||||
577 | - | |||||||||||||||||||||||||
578 | QVector4D v4 = vector4DFromString(s, &ok); | - | ||||||||||||||||||||||||
579 | if (ok) {
| 0-20 | ||||||||||||||||||||||||
580 | *v = QVariant::fromValue(v4); | - | ||||||||||||||||||||||||
581 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
582 | } | - | ||||||||||||||||||||||||
583 | - | |||||||||||||||||||||||||
584 | QQuaternion q = quaternionFromString(s, &ok); | - | ||||||||||||||||||||||||
585 | if (ok) {
| 0-20 | ||||||||||||||||||||||||
586 | *v = QVariant::fromValue(q); | - | ||||||||||||||||||||||||
587 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
588 | } | - | ||||||||||||||||||||||||
589 | - | |||||||||||||||||||||||||
590 | QMatrix4x4 m = matrix4x4FromString(s, &ok); | - | ||||||||||||||||||||||||
591 | if (ok) {
| 0-20 | ||||||||||||||||||||||||
592 | *v = QVariant::fromValue(m); | - | ||||||||||||||||||||||||
593 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
594 | } | - | ||||||||||||||||||||||||
595 | - | |||||||||||||||||||||||||
596 | return false; executed 20 times by 5 tests: return false; Executed by:
| 20 | ||||||||||||||||||||||||
597 | } | - | ||||||||||||||||||||||||
598 | - | |||||||||||||||||||||||||
599 | bool variantFromString(int type, const QString &s, QVariant *v) override | - | ||||||||||||||||||||||||
600 | { | - | ||||||||||||||||||||||||
601 | bool ok = false; | - | ||||||||||||||||||||||||
602 | - | |||||||||||||||||||||||||
603 | switch (type) { | - | ||||||||||||||||||||||||
604 | case QMetaType::QColor: executed 80748 times by 27 tests: case QMetaType::QColor: Executed by:
| 80748 | ||||||||||||||||||||||||
605 | { | - | ||||||||||||||||||||||||
606 | QColor c(s); | - | ||||||||||||||||||||||||
607 | *v = QVariant::fromValue(c); | - | ||||||||||||||||||||||||
608 | return true; executed 80748 times by 27 tests: return true; Executed by:
| 80748 | ||||||||||||||||||||||||
609 | } | - | ||||||||||||||||||||||||
610 | case QMetaType::QVector2D: executed 2 times by 1 test: case QMetaType::QVector2D: Executed by:
| 2 | ||||||||||||||||||||||||
611 | { | - | ||||||||||||||||||||||||
612 | *v = QVariant::fromValue(vector2DFromString(s, &ok)); | - | ||||||||||||||||||||||||
613 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
614 | } | - | ||||||||||||||||||||||||
615 | case QMetaType::QVector3D: executed 6 times by 2 tests: case QMetaType::QVector3D: Executed by:
| 6 | ||||||||||||||||||||||||
616 | { | - | ||||||||||||||||||||||||
617 | *v = QVariant::fromValue(vector3DFromString(s, &ok)); | - | ||||||||||||||||||||||||
618 | return true; executed 6 times by 2 tests: return true; Executed by:
| 6 | ||||||||||||||||||||||||
619 | } | - | ||||||||||||||||||||||||
620 | case QMetaType::QVector4D: executed 2 times by 1 test: case QMetaType::QVector4D: Executed by:
| 2 | ||||||||||||||||||||||||
621 | { | - | ||||||||||||||||||||||||
622 | *v = QVariant::fromValue(vector4DFromString(s, &ok)); | - | ||||||||||||||||||||||||
623 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
624 | } | - | ||||||||||||||||||||||||
625 | case QMetaType::QQuaternion: executed 2 times by 1 test: case QMetaType::QQuaternion: Executed by:
| 2 | ||||||||||||||||||||||||
626 | { | - | ||||||||||||||||||||||||
627 | *v = QVariant::fromValue(quaternionFromString(s, &ok)); | - | ||||||||||||||||||||||||
628 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
629 | } | - | ||||||||||||||||||||||||
630 | case QMetaType::QMatrix4x4: executed 2 times by 1 test: case QMetaType::QMatrix4x4: Executed by:
| 2 | ||||||||||||||||||||||||
631 | { | - | ||||||||||||||||||||||||
632 | *v = QVariant::fromValue(matrix4x4FromString(s, &ok)); | - | ||||||||||||||||||||||||
633 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
634 | } | - | ||||||||||||||||||||||||
635 | default: executed 40 times by 6 tests: default: Executed by:
| 40 | ||||||||||||||||||||||||
636 | break; executed 40 times by 6 tests: break; Executed by:
| 40 | ||||||||||||||||||||||||
637 | } | - | ||||||||||||||||||||||||
638 | - | |||||||||||||||||||||||||
639 | return false; executed 40 times by 6 tests: return false; Executed by:
| 40 | ||||||||||||||||||||||||
640 | } | - | ||||||||||||||||||||||||
641 | - | |||||||||||||||||||||||||
642 | bool variantFromJsObject(int type, QQmlV4Handle object, QV4::ExecutionEngine *v4, QVariant *v) override | - | ||||||||||||||||||||||||
643 | { | - | ||||||||||||||||||||||||
644 | QV4::Scope scope(v4); | - | ||||||||||||||||||||||||
645 | #ifndef QT_NO_DEBUG | - | ||||||||||||||||||||||||
646 | QV4::ScopedObject obj(scope, object); | - | ||||||||||||||||||||||||
647 | Q_ASSERT(obj); | - | ||||||||||||||||||||||||
648 | #endif | - | ||||||||||||||||||||||||
649 | bool ok = false; | - | ||||||||||||||||||||||||
650 | switch (type) { | - | ||||||||||||||||||||||||
651 | case QMetaType::QFont: executed 60 times by 3 tests: case QMetaType::QFont: Executed by:
| 60 | ||||||||||||||||||||||||
652 | *v = QVariant::fromValue(fontFromObject(object, v4, &ok)); | - | ||||||||||||||||||||||||
653 | break; executed 60 times by 3 tests: break; Executed by:
| 60 | ||||||||||||||||||||||||
654 | case QMetaType::QMatrix4x4: executed 18 times by 2 tests: case QMetaType::QMatrix4x4: Executed by:
| 18 | ||||||||||||||||||||||||
655 | *v = QVariant::fromValue(matrix4x4FromObject(object, v4, &ok)); | - | ||||||||||||||||||||||||
656 | default: break; executed 18 times by 2 tests: break; Executed by:
code before this statement executed 18 times by 2 tests: default: Executed by:
executed 18 times by 2 tests: default: Executed by:
| 18 | ||||||||||||||||||||||||
657 | } | - | ||||||||||||||||||||||||
658 | - | |||||||||||||||||||||||||
659 | return ok; executed 78 times by 3 tests: return ok; Executed by:
| 78 | ||||||||||||||||||||||||
660 | } | - | ||||||||||||||||||||||||
661 | - | |||||||||||||||||||||||||
662 | template<typename T> | - | ||||||||||||||||||||||||
663 | bool typedEqual(const void *lhs, const QVariant& rhs) | - | ||||||||||||||||||||||||
664 | { | - | ||||||||||||||||||||||||
665 | return (*(reinterpret_cast<const T *>(lhs)) == rhs.value<T>()); executed 474 times by 12 tests: return (*(reinterpret_cast<const T *>(lhs)) == rhs.value<T>()); Executed by:
| 474 | ||||||||||||||||||||||||
666 | } | - | ||||||||||||||||||||||||
667 | - | |||||||||||||||||||||||||
668 | bool equal(int type, const void *lhs, const QVariant &rhs) override | - | ||||||||||||||||||||||||
669 | { | - | ||||||||||||||||||||||||
670 | switch (type) { | - | ||||||||||||||||||||||||
671 | case QMetaType::QColor: executed 278 times by 11 tests: case QMetaType::QColor: Executed by:
| 278 | ||||||||||||||||||||||||
672 | return typedEqual<QColor>(lhs, rhs); executed 278 times by 11 tests: return typedEqual<QColor>(lhs, rhs); Executed by:
| 278 | ||||||||||||||||||||||||
673 | case QMetaType::QFont: executed 52 times by 3 tests: case QMetaType::QFont: Executed by:
| 52 | ||||||||||||||||||||||||
674 | return typedEqual<QFont>(lhs, rhs); executed 52 times by 3 tests: return typedEqual<QFont>(lhs, rhs); Executed by:
| 52 | ||||||||||||||||||||||||
675 | case QMetaType::QVector2D: executed 30 times by 1 test: case QMetaType::QVector2D: Executed by:
| 30 | ||||||||||||||||||||||||
676 | return typedEqual<QVector2D>(lhs, rhs); executed 30 times by 1 test: return typedEqual<QVector2D>(lhs, rhs); Executed by:
| 30 | ||||||||||||||||||||||||
677 | case QMetaType::QVector3D: executed 26 times by 1 test: case QMetaType::QVector3D: Executed by:
| 26 | ||||||||||||||||||||||||
678 | return typedEqual<QVector3D>(lhs, rhs); executed 26 times by 1 test: return typedEqual<QVector3D>(lhs, rhs); Executed by:
| 26 | ||||||||||||||||||||||||
679 | case QMetaType::QVector4D: executed 32 times by 1 test: case QMetaType::QVector4D: Executed by:
| 32 | ||||||||||||||||||||||||
680 | return typedEqual<QVector4D>(lhs, rhs); executed 32 times by 1 test: return typedEqual<QVector4D>(lhs, rhs); Executed by:
| 32 | ||||||||||||||||||||||||
681 | case QMetaType::QQuaternion: executed 18 times by 1 test: case QMetaType::QQuaternion: Executed by:
| 18 | ||||||||||||||||||||||||
682 | return typedEqual<QQuaternion>(lhs, rhs); executed 18 times by 1 test: return typedEqual<QQuaternion>(lhs, rhs); Executed by:
| 18 | ||||||||||||||||||||||||
683 | case QMetaType::QMatrix4x4: executed 38 times by 1 test: case QMetaType::QMatrix4x4: Executed by:
| 38 | ||||||||||||||||||||||||
684 | return typedEqual<QMatrix4x4>(lhs, rhs); executed 38 times by 1 test: return typedEqual<QMatrix4x4>(lhs, rhs); Executed by:
| 38 | ||||||||||||||||||||||||
685 | default: break; never executed: break; never executed: default: | 0 | ||||||||||||||||||||||||
686 | } | - | ||||||||||||||||||||||||
687 | - | |||||||||||||||||||||||||
688 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
689 | } | - | ||||||||||||||||||||||||
690 | - | |||||||||||||||||||||||||
691 | template<typename T> | - | ||||||||||||||||||||||||
692 | bool typedStore(const void *src, void *dst, size_t dstSize) | - | ||||||||||||||||||||||||
693 | { | - | ||||||||||||||||||||||||
694 | ASSERT_VALID_SIZE(dstSize, sizeof(T)); | - | ||||||||||||||||||||||||
695 | const T *srcT = reinterpret_cast<const T *>(src); | - | ||||||||||||||||||||||||
696 | T *dstT = reinterpret_cast<T *>(dst); | - | ||||||||||||||||||||||||
697 | new (dstT) T(*srcT); | - | ||||||||||||||||||||||||
698 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
699 | } | - | ||||||||||||||||||||||||
700 | - | |||||||||||||||||||||||||
701 | bool store(int type, const void *src, void *dst, size_t dstSize) override | - | ||||||||||||||||||||||||
702 | { | - | ||||||||||||||||||||||||
703 | Q_UNUSED(dstSize); | - | ||||||||||||||||||||||||
704 | switch (type) { | - | ||||||||||||||||||||||||
705 | case QMetaType::QColor: executed 27769 times by 82 tests: case QMetaType::QColor: Executed by:
| 27769 | ||||||||||||||||||||||||
706 | { | - | ||||||||||||||||||||||||
707 | Q_ASSERT(dstSize >= sizeof(QColor)); | - | ||||||||||||||||||||||||
708 | const QRgb *rgb = reinterpret_cast<const QRgb *>(src); | - | ||||||||||||||||||||||||
709 | QColor *color = reinterpret_cast<QColor *>(dst); | - | ||||||||||||||||||||||||
710 | new (color) QColor(QColor::fromRgba(*rgb)); | - | ||||||||||||||||||||||||
711 | return true; executed 27769 times by 82 tests: return true; Executed by:
| 27769 | ||||||||||||||||||||||||
712 | } | - | ||||||||||||||||||||||||
713 | default: break; never executed: break; never executed: default: | 0 | ||||||||||||||||||||||||
714 | } | - | ||||||||||||||||||||||||
715 | - | |||||||||||||||||||||||||
716 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
717 | } | - | ||||||||||||||||||||||||
718 | - | |||||||||||||||||||||||||
719 | template<typename T> | - | ||||||||||||||||||||||||
720 | bool typedRead(const QVariant& src, int dstType, void *dst) | - | ||||||||||||||||||||||||
721 | { | - | ||||||||||||||||||||||||
722 | T *dstT = reinterpret_cast<T *>(dst); | - | ||||||||||||||||||||||||
723 | if (src.type() == static_cast<uint>(dstType)) {
| 168-948 | ||||||||||||||||||||||||
724 | *dstT = src.value<T>(); | - | ||||||||||||||||||||||||
725 | } else { executed 948 times by 12 tests: end of block Executed by:
| 948 | ||||||||||||||||||||||||
726 | *dstT = T(); | - | ||||||||||||||||||||||||
727 | } executed 168 times by 3 tests: end of block Executed by:
| 168 | ||||||||||||||||||||||||
728 | return true; executed 1116 times by 12 tests: return true; Executed by:
| 1116 | ||||||||||||||||||||||||
729 | } | - | ||||||||||||||||||||||||
730 | - | |||||||||||||||||||||||||
731 | bool read(const QVariant &src, void *dst, int dstType) override | - | ||||||||||||||||||||||||
732 | { | - | ||||||||||||||||||||||||
733 | switch (dstType) { | - | ||||||||||||||||||||||||
734 | case QMetaType::QColor: executed 556 times by 11 tests: case QMetaType::QColor: Executed by:
| 556 | ||||||||||||||||||||||||
735 | return typedRead<QColor>(src, dstType, dst); executed 556 times by 11 tests: return typedRead<QColor>(src, dstType, dst); Executed by:
| 556 | ||||||||||||||||||||||||
736 | case QMetaType::QFont: executed 256 times by 3 tests: case QMetaType::QFont: Executed by:
| 256 | ||||||||||||||||||||||||
737 | return typedRead<QFont>(src, dstType, dst); executed 256 times by 3 tests: return typedRead<QFont>(src, dstType, dst); Executed by:
| 256 | ||||||||||||||||||||||||
738 | case QMetaType::QVector2D: executed 56 times by 1 test: case QMetaType::QVector2D: Executed by:
| 56 | ||||||||||||||||||||||||
739 | return typedRead<QVector2D>(src, dstType, dst); executed 56 times by 1 test: return typedRead<QVector2D>(src, dstType, dst); Executed by:
| 56 | ||||||||||||||||||||||||
740 | case QMetaType::QVector3D: executed 44 times by 1 test: case QMetaType::QVector3D: Executed by:
| 44 | ||||||||||||||||||||||||
741 | return typedRead<QVector3D>(src, dstType, dst); executed 44 times by 1 test: return typedRead<QVector3D>(src, dstType, dst); Executed by:
| 44 | ||||||||||||||||||||||||
742 | case QMetaType::QVector4D: executed 80 times by 1 test: case QMetaType::QVector4D: Executed by:
| 80 | ||||||||||||||||||||||||
743 | return typedRead<QVector4D>(src, dstType, dst); executed 80 times by 1 test: return typedRead<QVector4D>(src, dstType, dst); Executed by:
| 80 | ||||||||||||||||||||||||
744 | case QMetaType::QQuaternion: executed 42 times by 1 test: case QMetaType::QQuaternion: Executed by:
| 42 | ||||||||||||||||||||||||
745 | return typedRead<QQuaternion>(src, dstType, dst); executed 42 times by 1 test: return typedRead<QQuaternion>(src, dstType, dst); Executed by:
| 42 | ||||||||||||||||||||||||
746 | case QMetaType::QMatrix4x4: executed 82 times by 1 test: case QMetaType::QMatrix4x4: Executed by:
| 82 | ||||||||||||||||||||||||
747 | return typedRead<QMatrix4x4>(src, dstType, dst); executed 82 times by 1 test: return typedRead<QMatrix4x4>(src, dstType, dst); Executed by:
| 82 | ||||||||||||||||||||||||
748 | default: break; never executed: break; never executed: default: | 0 | ||||||||||||||||||||||||
749 | } | - | ||||||||||||||||||||||||
750 | - | |||||||||||||||||||||||||
751 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
752 | } | - | ||||||||||||||||||||||||
753 | - | |||||||||||||||||||||||||
754 | template<typename T> | - | ||||||||||||||||||||||||
755 | bool typedWrite(const void *src, QVariant& dst) | - | ||||||||||||||||||||||||
756 | { | - | ||||||||||||||||||||||||
757 | const T *srcT = reinterpret_cast<const T *>(src); | - | ||||||||||||||||||||||||
758 | if (dst.value<T>() != *srcT) {
| 16-458 | ||||||||||||||||||||||||
759 | dst = *srcT; | - | ||||||||||||||||||||||||
760 | return true; executed 458 times by 11 tests: return true; Executed by:
| 458 | ||||||||||||||||||||||||
761 | } | - | ||||||||||||||||||||||||
762 | return false; executed 16 times by 4 tests: return false; Executed by:
| 16 | ||||||||||||||||||||||||
763 | } | - | ||||||||||||||||||||||||
764 | - | |||||||||||||||||||||||||
765 | bool write(int type, const void *src, QVariant& dst) override | - | ||||||||||||||||||||||||
766 | { | - | ||||||||||||||||||||||||
767 | switch (type) { | - | ||||||||||||||||||||||||
768 | case QMetaType::QColor: executed 278 times by 11 tests: case QMetaType::QColor: Executed by:
| 278 | ||||||||||||||||||||||||
769 | return typedWrite<QColor>(src, dst); executed 278 times by 11 tests: return typedWrite<QColor>(src, dst); Executed by:
| 278 | ||||||||||||||||||||||||
770 | case QMetaType::QFont: executed 52 times by 3 tests: case QMetaType::QFont: Executed by:
| 52 | ||||||||||||||||||||||||
771 | return typedWrite<QFont>(src, dst); executed 52 times by 3 tests: return typedWrite<QFont>(src, dst); Executed by:
| 52 | ||||||||||||||||||||||||
772 | case QMetaType::QVector2D: executed 30 times by 1 test: case QMetaType::QVector2D: Executed by:
| 30 | ||||||||||||||||||||||||
773 | return typedWrite<QVector2D>(src, dst); executed 30 times by 1 test: return typedWrite<QVector2D>(src, dst); Executed by:
| 30 | ||||||||||||||||||||||||
774 | case QMetaType::QVector3D: executed 26 times by 1 test: case QMetaType::QVector3D: Executed by:
| 26 | ||||||||||||||||||||||||
775 | return typedWrite<QVector3D>(src, dst); executed 26 times by 1 test: return typedWrite<QVector3D>(src, dst); Executed by:
| 26 | ||||||||||||||||||||||||
776 | case QMetaType::QVector4D: executed 32 times by 1 test: case QMetaType::QVector4D: Executed by:
| 32 | ||||||||||||||||||||||||
777 | return typedWrite<QVector4D>(src, dst); executed 32 times by 1 test: return typedWrite<QVector4D>(src, dst); Executed by:
| 32 | ||||||||||||||||||||||||
778 | case QMetaType::QQuaternion: executed 18 times by 1 test: case QMetaType::QQuaternion: Executed by:
| 18 | ||||||||||||||||||||||||
779 | return typedWrite<QQuaternion>(src, dst); executed 18 times by 1 test: return typedWrite<QQuaternion>(src, dst); Executed by:
| 18 | ||||||||||||||||||||||||
780 | case QMetaType::QMatrix4x4: executed 38 times by 1 test: case QMetaType::QMatrix4x4: Executed by:
| 38 | ||||||||||||||||||||||||
781 | return typedWrite<QMatrix4x4>(src, dst); executed 38 times by 1 test: return typedWrite<QMatrix4x4>(src, dst); Executed by:
| 38 | ||||||||||||||||||||||||
782 | default: break; never executed: break; never executed: default: | 0 | ||||||||||||||||||||||||
783 | } | - | ||||||||||||||||||||||||
784 | - | |||||||||||||||||||||||||
785 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
786 | } | - | ||||||||||||||||||||||||
787 | #undef ASSERT_VALID_SIZE | - | ||||||||||||||||||||||||
788 | }; | - | ||||||||||||||||||||||||
789 | - | |||||||||||||||||||||||||
790 | - | |||||||||||||||||||||||||
791 | class QQuickGuiProvider : public QQmlGuiProvider | - | ||||||||||||||||||||||||
792 | { | - | ||||||||||||||||||||||||
793 | public: | - | ||||||||||||||||||||||||
794 | QQuickApplication *application(QObject *parent) override | - | ||||||||||||||||||||||||
795 | { | - | ||||||||||||||||||||||||
796 | return new QQuickApplication(parent); executed 12 times by 4 tests: return new QQuickApplication(parent); Executed by:
| 12 | ||||||||||||||||||||||||
797 | } | - | ||||||||||||||||||||||||
798 | - | |||||||||||||||||||||||||
799 | #if QT_CONFIG(im) | - | ||||||||||||||||||||||||
800 | QInputMethod *inputMethod() override | - | ||||||||||||||||||||||||
801 | { | - | ||||||||||||||||||||||||
802 | QInputMethod *im = qGuiApp->inputMethod(); | - | ||||||||||||||||||||||||
803 | QQmlEngine::setObjectOwnership(im, QQmlEngine::CppOwnership); | - | ||||||||||||||||||||||||
804 | return im; executed 40 times by 2 tests: return im; Executed by:
| 40 | ||||||||||||||||||||||||
805 | } | - | ||||||||||||||||||||||||
806 | #endif | - | ||||||||||||||||||||||||
807 | - | |||||||||||||||||||||||||
808 | QStyleHints *styleHints() override | - | ||||||||||||||||||||||||
809 | { | - | ||||||||||||||||||||||||
810 | QStyleHints *sh = qGuiApp->styleHints(); | - | ||||||||||||||||||||||||
811 | QQmlEngine::setObjectOwnership(sh, QQmlEngine::CppOwnership); | - | ||||||||||||||||||||||||
812 | return sh; executed 2 times by 1 test: return sh; Executed by:
| 2 | ||||||||||||||||||||||||
813 | } | - | ||||||||||||||||||||||||
814 | - | |||||||||||||||||||||||||
815 | QStringList fontFamilies() override | - | ||||||||||||||||||||||||
816 | { | - | ||||||||||||||||||||||||
817 | QFontDatabase database; | - | ||||||||||||||||||||||||
818 | return database.families(); executed 4 times by 2 tests: return database.families(); Executed by:
| 4 | ||||||||||||||||||||||||
819 | } | - | ||||||||||||||||||||||||
820 | - | |||||||||||||||||||||||||
821 | bool openUrlExternally(QUrl &url) override | - | ||||||||||||||||||||||||
822 | { | - | ||||||||||||||||||||||||
823 | #ifndef QT_NO_DESKTOPSERVICES | - | ||||||||||||||||||||||||
824 | return QDesktopServices::openUrl(url); executed 8 times by 1 test: return QDesktopServices::openUrl(url); Executed by:
| 8 | ||||||||||||||||||||||||
825 | #else | - | ||||||||||||||||||||||||
826 | Q_UNUSED(url); | - | ||||||||||||||||||||||||
827 | return false; | - | ||||||||||||||||||||||||
828 | #endif | - | ||||||||||||||||||||||||
829 | } | - | ||||||||||||||||||||||||
830 | - | |||||||||||||||||||||||||
831 | QString pluginName() const override | - | ||||||||||||||||||||||||
832 | { | - | ||||||||||||||||||||||||
833 | return QGuiApplication::platformName(); executed 2 times by 1 test: return QGuiApplication::platformName(); Executed by:
| 2 | ||||||||||||||||||||||||
834 | } | - | ||||||||||||||||||||||||
835 | }; | - | ||||||||||||||||||||||||
836 | - | |||||||||||||||||||||||||
837 | - | |||||||||||||||||||||||||
838 | static QQuickValueTypeProvider *getValueTypeProvider() | - | ||||||||||||||||||||||||
839 | { | - | ||||||||||||||||||||||||
840 | static QQuickValueTypeProvider valueTypeProvider; | - | ||||||||||||||||||||||||
841 | return &valueTypeProvider; executed 462 times by 132 tests: return &valueTypeProvider; Executed by:
| 462 | ||||||||||||||||||||||||
842 | } | - | ||||||||||||||||||||||||
843 | - | |||||||||||||||||||||||||
844 | static QQuickColorProvider *getColorProvider() | - | ||||||||||||||||||||||||
845 | { | - | ||||||||||||||||||||||||
846 | static QQuickColorProvider colorProvider; | - | ||||||||||||||||||||||||
847 | return &colorProvider; executed 374 times by 132 tests: return &colorProvider; Executed by:
| 374 | ||||||||||||||||||||||||
848 | } | - | ||||||||||||||||||||||||
849 | - | |||||||||||||||||||||||||
850 | static QQuickGuiProvider *getGuiProvider() | - | ||||||||||||||||||||||||
851 | { | - | ||||||||||||||||||||||||
852 | static QQuickGuiProvider guiProvider; | - | ||||||||||||||||||||||||
853 | return &guiProvider; executed 374 times by 132 tests: return &guiProvider; Executed by:
| 374 | ||||||||||||||||||||||||
854 | } | - | ||||||||||||||||||||||||
855 | - | |||||||||||||||||||||||||
856 | void QQuick_initializeProviders() | - | ||||||||||||||||||||||||
857 | { | - | ||||||||||||||||||||||||
858 | QQml_addValueTypeProvider(getValueTypeProvider()); | - | ||||||||||||||||||||||||
859 | QQml_setColorProvider(getColorProvider()); | - | ||||||||||||||||||||||||
860 | QQml_setGuiProvider(getGuiProvider()); | - | ||||||||||||||||||||||||
861 | } executed 374 times by 132 tests: end of block Executed by:
| 374 | ||||||||||||||||||||||||
862 | - | |||||||||||||||||||||||||
863 | void QQuick_deinitializeProviders() | - | ||||||||||||||||||||||||
864 | { | - | ||||||||||||||||||||||||
865 | QQml_removeValueTypeProvider(getValueTypeProvider()); | - | ||||||||||||||||||||||||
866 | QQml_setColorProvider(nullptr); // technically, another plugin may have overridden our providers | - | ||||||||||||||||||||||||
867 | QQml_setGuiProvider(nullptr); // but we cannot handle that case in a sane way. | - | ||||||||||||||||||||||||
868 | } executed 88 times by 3 tests: end of block Executed by:
| 88 | ||||||||||||||||||||||||
869 | - | |||||||||||||||||||||||||
870 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |