Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlstringconverters.cpp |
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 QtQml 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 | #include "qqmlstringconverters_p.h" | - | ||||||||||||||||||||||||
41 | #include <private/qqmlglobal_p.h> | - | ||||||||||||||||||||||||
42 | - | |||||||||||||||||||||||||
43 | #include <QtCore/qpoint.h> | - | ||||||||||||||||||||||||
44 | #include <QtCore/qrect.h> | - | ||||||||||||||||||||||||
45 | #include <QtCore/qsize.h> | - | ||||||||||||||||||||||||
46 | #include <QtCore/qvariant.h> | - | ||||||||||||||||||||||||
47 | #include <QtCore/qdatetime.h> | - | ||||||||||||||||||||||||
48 | - | |||||||||||||||||||||||||
49 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
50 | - | |||||||||||||||||||||||||
51 | QVariant QQmlStringConverters::variantFromString(const QString &s) | - | ||||||||||||||||||||||||
52 | { | - | ||||||||||||||||||||||||
53 | if (s.isEmpty())
| 0-28 | ||||||||||||||||||||||||
54 | return QVariant(s); never executed: return QVariant(s); | 0 | ||||||||||||||||||||||||
55 | - | |||||||||||||||||||||||||
56 | bool ok = false; | - | ||||||||||||||||||||||||
57 | QRectF r = rectFFromString(s, &ok); | - | ||||||||||||||||||||||||
58 | if (ok) return QVariant(r); never executed: return QVariant(r);
| 0-28 | ||||||||||||||||||||||||
59 | QPointF p = pointFFromString(s, &ok); | - | ||||||||||||||||||||||||
60 | if (ok) return QVariant(p); executed 2 times by 1 test: return QVariant(p); Executed by:
| 2-26 | ||||||||||||||||||||||||
61 | QSizeF sz = sizeFFromString(s, &ok); | - | ||||||||||||||||||||||||
62 | if (ok) return QVariant(sz); never executed: return QVariant(sz);
| 0-26 | ||||||||||||||||||||||||
63 | - | |||||||||||||||||||||||||
64 | return QQml_valueTypeProvider()->createVariantFromString(s); executed 26 times by 6 tests: return QQml_valueTypeProvider()->createVariantFromString(s); Executed by:
| 26 | ||||||||||||||||||||||||
65 | } | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | QVariant QQmlStringConverters::variantFromString(const QString &s, int preferredType, bool *ok) | - | ||||||||||||||||||||||||
68 | { | - | ||||||||||||||||||||||||
69 | switch (preferredType) { | - | ||||||||||||||||||||||||
70 | case QMetaType::Int: executed 12 times by 1 test: case QMetaType::Int: Executed by:
| 12 | ||||||||||||||||||||||||
71 | return QVariant(int(qRound(s.toDouble(ok)))); executed 12 times by 1 test: return QVariant(int(qRound(s.toDouble(ok)))); Executed by:
| 12 | ||||||||||||||||||||||||
72 | case QMetaType::UInt: executed 4 times by 1 test: case QMetaType::UInt: Executed by:
| 4 | ||||||||||||||||||||||||
73 | return QVariant(uint(qRound(s.toDouble(ok)))); executed 4 times by 1 test: return QVariant(uint(qRound(s.toDouble(ok)))); Executed by:
| 4 | ||||||||||||||||||||||||
74 | #if QT_CONFIG(datestring) | - | ||||||||||||||||||||||||
75 | case QMetaType::QDate: executed 8 times by 1 test: case QMetaType::QDate: Executed by:
| 8 | ||||||||||||||||||||||||
76 | return QVariant::fromValue(dateFromString(s, ok)); executed 8 times by 1 test: return QVariant::fromValue(dateFromString(s, ok)); Executed by:
| 8 | ||||||||||||||||||||||||
77 | case QMetaType::QTime: executed 4 times by 1 test: case QMetaType::QTime: Executed by:
| 4 | ||||||||||||||||||||||||
78 | return QVariant::fromValue(timeFromString(s, ok)); executed 4 times by 1 test: return QVariant::fromValue(timeFromString(s, ok)); Executed by:
| 4 | ||||||||||||||||||||||||
79 | case QMetaType::QDateTime: executed 12 times by 1 test: case QMetaType::QDateTime: Executed by:
| 12 | ||||||||||||||||||||||||
80 | return QVariant::fromValue(dateTimeFromString(s, ok)); executed 12 times by 1 test: return QVariant::fromValue(dateTimeFromString(s, ok)); Executed by:
| 12 | ||||||||||||||||||||||||
81 | #endif // datestring | - | ||||||||||||||||||||||||
82 | case QMetaType::QPointF: executed 4 times by 1 test: case QMetaType::QPointF: Executed by:
| 4 | ||||||||||||||||||||||||
83 | return QVariant::fromValue(pointFFromString(s, ok)); executed 4 times by 1 test: return QVariant::fromValue(pointFFromString(s, ok)); Executed by:
| 4 | ||||||||||||||||||||||||
84 | case QMetaType::QPoint: executed 4 times by 1 test: case QMetaType::QPoint: Executed by:
| 4 | ||||||||||||||||||||||||
85 | return QVariant::fromValue(pointFFromString(s, ok).toPoint()); executed 4 times by 1 test: return QVariant::fromValue(pointFFromString(s, ok).toPoint()); Executed by:
| 4 | ||||||||||||||||||||||||
86 | case QMetaType::QSizeF: executed 4 times by 1 test: case QMetaType::QSizeF: Executed by:
| 4 | ||||||||||||||||||||||||
87 | return QVariant::fromValue(sizeFFromString(s, ok)); executed 4 times by 1 test: return QVariant::fromValue(sizeFFromString(s, ok)); Executed by:
| 4 | ||||||||||||||||||||||||
88 | case QMetaType::QSize: executed 4 times by 1 test: case QMetaType::QSize: Executed by:
| 4 | ||||||||||||||||||||||||
89 | return QVariant::fromValue(sizeFFromString(s, ok).toSize()); executed 4 times by 1 test: return QVariant::fromValue(sizeFFromString(s, ok).toSize()); Executed by:
| 4 | ||||||||||||||||||||||||
90 | case QMetaType::QRectF: executed 4 times by 1 test: case QMetaType::QRectF: Executed by:
| 4 | ||||||||||||||||||||||||
91 | return QVariant::fromValue(rectFFromString(s, ok)); executed 4 times by 1 test: return QVariant::fromValue(rectFFromString(s, ok)); Executed by:
| 4 | ||||||||||||||||||||||||
92 | case QMetaType::QRect: executed 4 times by 1 test: case QMetaType::QRect: Executed by:
| 4 | ||||||||||||||||||||||||
93 | return QVariant::fromValue(rectFFromString(s, ok).toRect()); executed 4 times by 1 test: return QVariant::fromValue(rectFFromString(s, ok).toRect()); Executed by:
| 4 | ||||||||||||||||||||||||
94 | default: executed 80806 times by 33 tests: default: Executed by:
| 80806 | ||||||||||||||||||||||||
95 | return QQml_valueTypeProvider()->createVariantFromString(preferredType, s, ok); executed 80806 times by 33 tests: return QQml_valueTypeProvider()->createVariantFromString(preferredType, s, ok); Executed by:
| 80806 | ||||||||||||||||||||||||
96 | } | - | ||||||||||||||||||||||||
97 | } | - | ||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||
99 | QVariant QQmlStringConverters::colorFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
100 | { | - | ||||||||||||||||||||||||
101 | return QQml_colorProvider()->colorFromString(s, ok); executed 154 times by 2 tests: return QQml_colorProvider()->colorFromString(s, ok); Executed by:
| 154 | ||||||||||||||||||||||||
102 | } | - | ||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||
104 | unsigned QQmlStringConverters::rgbaFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
105 | { | - | ||||||||||||||||||||||||
106 | return QQml_colorProvider()->rgbaFromString(s, ok); executed 36659 times by 83 tests: return QQml_colorProvider()->rgbaFromString(s, ok); Executed by:
| 36659 | ||||||||||||||||||||||||
107 | } | - | ||||||||||||||||||||||||
108 | - | |||||||||||||||||||||||||
109 | #if QT_CONFIG(datestring) | - | ||||||||||||||||||||||||
110 | QDate QQmlStringConverters::dateFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
111 | { | - | ||||||||||||||||||||||||
112 | QDate d = QDate::fromString(s, Qt::ISODate); | - | ||||||||||||||||||||||||
113 | if (ok) *ok = d.isValid(); executed 8 times by 1 test: *ok = d.isValid(); Executed by:
| 0-8 | ||||||||||||||||||||||||
114 | return d; executed 8 times by 1 test: return d; Executed by:
| 8 | ||||||||||||||||||||||||
115 | } | - | ||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||
117 | QTime QQmlStringConverters::timeFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
118 | { | - | ||||||||||||||||||||||||
119 | QTime t = QTime::fromString(s, Qt::ISODate); | - | ||||||||||||||||||||||||
120 | if (ok) *ok = t.isValid(); executed 4 times by 1 test: *ok = t.isValid(); Executed by:
| 0-4 | ||||||||||||||||||||||||
121 | return t; executed 4 times by 1 test: return t; Executed by:
| 4 | ||||||||||||||||||||||||
122 | } | - | ||||||||||||||||||||||||
123 | - | |||||||||||||||||||||||||
124 | QDateTime QQmlStringConverters::dateTimeFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
125 | { | - | ||||||||||||||||||||||||
126 | QDateTime d = QDateTime::fromString(s, Qt::ISODate); | - | ||||||||||||||||||||||||
127 | if (ok) *ok = d.isValid(); executed 104 times by 5 tests: *ok = d.isValid(); Executed by:
| 0-104 | ||||||||||||||||||||||||
128 | // V8 never parses a date string as local time. For consistency do the same here. | - | ||||||||||||||||||||||||
129 | if (d.timeSpec() == Qt::LocalTime)
| 8-96 | ||||||||||||||||||||||||
130 | d.setTimeSpec(Qt::UTC); executed 96 times by 5 tests: d.setTimeSpec(Qt::UTC); Executed by:
| 96 | ||||||||||||||||||||||||
131 | return d; executed 104 times by 5 tests: return d; Executed by:
| 104 | ||||||||||||||||||||||||
132 | } | - | ||||||||||||||||||||||||
133 | #endif // datestring | - | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | //expects input of "x,y" | - | ||||||||||||||||||||||||
136 | QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
137 | { | - | ||||||||||||||||||||||||
138 | if (s.count(QLatin1Char(',')) != 1) {
| 10-26 | ||||||||||||||||||||||||
139 | if (ok)
| 0-26 | ||||||||||||||||||||||||
140 | *ok = false; executed 26 times by 6 tests: *ok = false; Executed by:
| 26 | ||||||||||||||||||||||||
141 | return QPointF(); executed 26 times by 6 tests: return QPointF(); Executed by:
| 26 | ||||||||||||||||||||||||
142 | } | - | ||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | bool xGood, yGood; | - | ||||||||||||||||||||||||
145 | int index = s.indexOf(QLatin1Char(',')); | - | ||||||||||||||||||||||||
146 | qreal xCoord = s.leftRef(index).toDouble(&xGood); | - | ||||||||||||||||||||||||
147 | qreal yCoord = s.midRef(index+1).toDouble(&yGood); | - | ||||||||||||||||||||||||
148 | if (!xGood || !yGood) {
| 0-10 | ||||||||||||||||||||||||
149 | if (ok)
| 0 | ||||||||||||||||||||||||
150 | *ok = false; never executed: *ok = false; | 0 | ||||||||||||||||||||||||
151 | return QPointF(); never executed: return QPointF(); | 0 | ||||||||||||||||||||||||
152 | } | - | ||||||||||||||||||||||||
153 | - | |||||||||||||||||||||||||
154 | if (ok)
| 0-10 | ||||||||||||||||||||||||
155 | *ok = true; executed 10 times by 2 tests: *ok = true; Executed by:
| 10 | ||||||||||||||||||||||||
156 | return QPointF(xCoord, yCoord); executed 10 times by 2 tests: return QPointF(xCoord, yCoord); Executed by:
| 10 | ||||||||||||||||||||||||
157 | } | - | ||||||||||||||||||||||||
158 | - | |||||||||||||||||||||||||
159 | //expects input of "widthxheight" | - | ||||||||||||||||||||||||
160 | QSizeF QQmlStringConverters::sizeFFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
161 | { | - | ||||||||||||||||||||||||
162 | if (s.count(QLatin1Char('x')) != 1) {
| 24-26 | ||||||||||||||||||||||||
163 | if (ok)
| 0-26 | ||||||||||||||||||||||||
164 | *ok = false; executed 26 times by 6 tests: *ok = false; Executed by:
| 26 | ||||||||||||||||||||||||
165 | return QSizeF(); executed 26 times by 6 tests: return QSizeF(); Executed by:
| 26 | ||||||||||||||||||||||||
166 | } | - | ||||||||||||||||||||||||
167 | - | |||||||||||||||||||||||||
168 | bool wGood, hGood; | - | ||||||||||||||||||||||||
169 | int index = s.indexOf(QLatin1Char('x')); | - | ||||||||||||||||||||||||
170 | qreal width = s.leftRef(index).toDouble(&wGood); | - | ||||||||||||||||||||||||
171 | qreal height = s.midRef(index+1).toDouble(&hGood); | - | ||||||||||||||||||||||||
172 | if (!wGood || !hGood) {
| 0-24 | ||||||||||||||||||||||||
173 | if (ok)
| 0 | ||||||||||||||||||||||||
174 | *ok = false; never executed: *ok = false; | 0 | ||||||||||||||||||||||||
175 | return QSizeF(); never executed: return QSizeF(); | 0 | ||||||||||||||||||||||||
176 | } | - | ||||||||||||||||||||||||
177 | - | |||||||||||||||||||||||||
178 | if (ok)
| 0-24 | ||||||||||||||||||||||||
179 | *ok = true; executed 24 times by 2 tests: *ok = true; Executed by:
| 24 | ||||||||||||||||||||||||
180 | return QSizeF(width, height); executed 24 times by 2 tests: return QSizeF(width, height); Executed by:
| 24 | ||||||||||||||||||||||||
181 | } | - | ||||||||||||||||||||||||
182 | - | |||||||||||||||||||||||||
183 | //expects input of "x,y,widthxheight" //### use space instead of second comma? | - | ||||||||||||||||||||||||
184 | QRectF QQmlStringConverters::rectFFromString(const QString &s, bool *ok) | - | ||||||||||||||||||||||||
185 | { | - | ||||||||||||||||||||||||
186 | if (s.count(QLatin1Char(',')) != 2 || s.count(QLatin1Char('x')) != 1) {
| 0-28 | ||||||||||||||||||||||||
187 | if (ok)
| 0-28 | ||||||||||||||||||||||||
188 | *ok = false; executed 28 times by 7 tests: *ok = false; Executed by:
| 28 | ||||||||||||||||||||||||
189 | return QRectF(); executed 28 times by 7 tests: return QRectF(); Executed by:
| 28 | ||||||||||||||||||||||||
190 | } | - | ||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||
192 | bool xGood, yGood, wGood, hGood; | - | ||||||||||||||||||||||||
193 | int index = s.indexOf(QLatin1Char(',')); | - | ||||||||||||||||||||||||
194 | qreal x = s.leftRef(index).toDouble(&xGood); | - | ||||||||||||||||||||||||
195 | int index2 = s.indexOf(QLatin1Char(','), index+1); | - | ||||||||||||||||||||||||
196 | qreal y = s.midRef(index+1, index2-index-1).toDouble(&yGood); | - | ||||||||||||||||||||||||
197 | index = s.indexOf(QLatin1Char('x'), index2+1); | - | ||||||||||||||||||||||||
198 | qreal width = s.midRef(index2+1, index-index2-1).toDouble(&wGood); | - | ||||||||||||||||||||||||
199 | qreal height = s.midRef(index+1).toDouble(&hGood); | - | ||||||||||||||||||||||||
200 | if (!xGood || !yGood || !wGood || !hGood) {
| 0-8 | ||||||||||||||||||||||||
201 | if (ok)
| 0 | ||||||||||||||||||||||||
202 | *ok = false; never executed: *ok = false; | 0 | ||||||||||||||||||||||||
203 | return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||||||||||||||
204 | } | - | ||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||
206 | if (ok)
| 0-8 | ||||||||||||||||||||||||
207 | *ok = true; executed 8 times by 1 test: *ok = true; Executed by:
| 8 | ||||||||||||||||||||||||
208 | return QRectF(x, y, width, height); executed 8 times by 1 test: return QRectF(x, y, width, height); Executed by:
| 8 | ||||||||||||||||||||||||
209 | } | - | ||||||||||||||||||||||||
210 | - | |||||||||||||||||||||||||
211 | bool QQmlStringConverters::createFromString(int type, const QString &s, void *data, size_t n) | - | ||||||||||||||||||||||||
212 | { | - | ||||||||||||||||||||||||
213 | Q_ASSERT(data); | - | ||||||||||||||||||||||||
214 | - | |||||||||||||||||||||||||
215 | bool ok = false; | - | ||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||
217 | switch (type) { | - | ||||||||||||||||||||||||
218 | case QMetaType::Int: never executed: case QMetaType::Int: | 0 | ||||||||||||||||||||||||
219 | { | - | ||||||||||||||||||||||||
220 | Q_ASSERT(n >= sizeof(int)); | - | ||||||||||||||||||||||||
221 | int *p = reinterpret_cast<int *>(data); | - | ||||||||||||||||||||||||
222 | *p = int(qRound(s.toDouble(&ok))); | - | ||||||||||||||||||||||||
223 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
224 | } | - | ||||||||||||||||||||||||
225 | case QMetaType::UInt: never executed: case QMetaType::UInt: | 0 | ||||||||||||||||||||||||
226 | { | - | ||||||||||||||||||||||||
227 | Q_ASSERT(n >= sizeof(uint)); | - | ||||||||||||||||||||||||
228 | uint *p = reinterpret_cast<uint *>(data); | - | ||||||||||||||||||||||||
229 | *p = uint(qRound(s.toDouble(&ok))); | - | ||||||||||||||||||||||||
230 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
231 | } | - | ||||||||||||||||||||||||
232 | #if QT_CONFIG(datestring) | - | ||||||||||||||||||||||||
233 | case QMetaType::QDate: never executed: case QMetaType::QDate: | 0 | ||||||||||||||||||||||||
234 | { | - | ||||||||||||||||||||||||
235 | Q_ASSERT(n >= sizeof(QDate)); | - | ||||||||||||||||||||||||
236 | QDate *p = reinterpret_cast<QDate *>(data); | - | ||||||||||||||||||||||||
237 | *p = dateFromString(s, &ok); | - | ||||||||||||||||||||||||
238 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
239 | } | - | ||||||||||||||||||||||||
240 | case QMetaType::QTime: never executed: case QMetaType::QTime: | 0 | ||||||||||||||||||||||||
241 | { | - | ||||||||||||||||||||||||
242 | Q_ASSERT(n >= sizeof(QTime)); | - | ||||||||||||||||||||||||
243 | QTime *p = reinterpret_cast<QTime *>(data); | - | ||||||||||||||||||||||||
244 | *p = timeFromString(s, &ok); | - | ||||||||||||||||||||||||
245 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
246 | } | - | ||||||||||||||||||||||||
247 | case QMetaType::QDateTime: never executed: case QMetaType::QDateTime: | 0 | ||||||||||||||||||||||||
248 | { | - | ||||||||||||||||||||||||
249 | Q_ASSERT(n >= sizeof(QDateTime)); | - | ||||||||||||||||||||||||
250 | QDateTime *p = reinterpret_cast<QDateTime *>(data); | - | ||||||||||||||||||||||||
251 | *p = dateTimeFromString(s, &ok); | - | ||||||||||||||||||||||||
252 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
253 | } | - | ||||||||||||||||||||||||
254 | #endif // datestring | - | ||||||||||||||||||||||||
255 | case QMetaType::QPointF: never executed: case QMetaType::QPointF: | 0 | ||||||||||||||||||||||||
256 | { | - | ||||||||||||||||||||||||
257 | Q_ASSERT(n >= sizeof(QPointF)); | - | ||||||||||||||||||||||||
258 | QPointF *p = reinterpret_cast<QPointF *>(data); | - | ||||||||||||||||||||||||
259 | *p = pointFFromString(s, &ok); | - | ||||||||||||||||||||||||
260 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
261 | } | - | ||||||||||||||||||||||||
262 | case QMetaType::QPoint: never executed: case QMetaType::QPoint: | 0 | ||||||||||||||||||||||||
263 | { | - | ||||||||||||||||||||||||
264 | Q_ASSERT(n >= sizeof(QPoint)); | - | ||||||||||||||||||||||||
265 | QPoint *p = reinterpret_cast<QPoint *>(data); | - | ||||||||||||||||||||||||
266 | *p = pointFFromString(s, &ok).toPoint(); | - | ||||||||||||||||||||||||
267 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
268 | } | - | ||||||||||||||||||||||||
269 | case QMetaType::QSizeF: never executed: case QMetaType::QSizeF: | 0 | ||||||||||||||||||||||||
270 | { | - | ||||||||||||||||||||||||
271 | Q_ASSERT(n >= sizeof(QSizeF)); | - | ||||||||||||||||||||||||
272 | QSizeF *p = reinterpret_cast<QSizeF *>(data); | - | ||||||||||||||||||||||||
273 | *p = sizeFFromString(s, &ok); | - | ||||||||||||||||||||||||
274 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
275 | } | - | ||||||||||||||||||||||||
276 | case QMetaType::QSize: never executed: case QMetaType::QSize: | 0 | ||||||||||||||||||||||||
277 | { | - | ||||||||||||||||||||||||
278 | Q_ASSERT(n >= sizeof(QSize)); | - | ||||||||||||||||||||||||
279 | QSize *p = reinterpret_cast<QSize *>(data); | - | ||||||||||||||||||||||||
280 | *p = sizeFFromString(s, &ok).toSize(); | - | ||||||||||||||||||||||||
281 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
282 | } | - | ||||||||||||||||||||||||
283 | case QMetaType::QRectF: never executed: case QMetaType::QRectF: | 0 | ||||||||||||||||||||||||
284 | { | - | ||||||||||||||||||||||||
285 | Q_ASSERT(n >= sizeof(QRectF)); | - | ||||||||||||||||||||||||
286 | QRectF *p = reinterpret_cast<QRectF *>(data); | - | ||||||||||||||||||||||||
287 | *p = rectFFromString(s, &ok); | - | ||||||||||||||||||||||||
288 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
289 | } | - | ||||||||||||||||||||||||
290 | case QMetaType::QRect: never executed: case QMetaType::QRect: | 0 | ||||||||||||||||||||||||
291 | { | - | ||||||||||||||||||||||||
292 | Q_ASSERT(n >= sizeof(QRect)); | - | ||||||||||||||||||||||||
293 | QRect *p = reinterpret_cast<QRect *>(data); | - | ||||||||||||||||||||||||
294 | *p = rectFFromString(s, &ok).toRect(); | - | ||||||||||||||||||||||||
295 | return ok; never executed: return ok; | 0 | ||||||||||||||||||||||||
296 | } | - | ||||||||||||||||||||||||
297 | default: never executed: default: | 0 | ||||||||||||||||||||||||
298 | return QQml_valueTypeProvider()->createValueFromString(type, s, data, n); never executed: return QQml_valueTypeProvider()->createValueFromString(type, s, data, n); | 0 | ||||||||||||||||||||||||
299 | } | - | ||||||||||||||||||||||||
300 | } | - | ||||||||||||||||||||||||
301 | - | |||||||||||||||||||||||||
302 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |