OpenCoverage

qqmlstringconverters.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlstringconverters.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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-
49QT_BEGIN_NAMESPACE-
50-
51QVariant QQmlStringConverters::variantFromString(const QString &s)-
52{-
53 if (s.isEmpty())
s.isEmpty()Description
TRUEnever evaluated
FALSEevaluated 28 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
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);
okDescription
TRUEnever evaluated
FALSEevaluated 28 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
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:
  • tst_qqmlmetaobject
okDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qqmlmetaobject
FALSEevaluated 26 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
2-26
61 QSizeF sz = sizeFFromString(s, &ok);-
62 if (ok) return QVariant(sz);
never executed: return QVariant(sz);
okDescription
TRUEnever evaluated
FALSEevaluated 26 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
0-26
63-
64 return QQml_valueTypeProvider()->createVariantFromString(s);
executed 26 times by 6 tests: return QQml_valueTypeProvider()->createVariantFromString(s);
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
26
65}-
66-
67QVariant 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:
  • tst_qqmlecmascript
12
71 return QVariant(int(qRound(s.toDouble(ok))));
executed 12 times by 1 test: return QVariant(int(qRound(s.toDouble(ok))));
Executed by:
  • tst_qqmlecmascript
12
72 case QMetaType::UInt:
executed 4 times by 1 test: case QMetaType::UInt:
Executed by:
  • tst_qqmlecmascript
4
73 return QVariant(uint(qRound(s.toDouble(ok))));
executed 4 times by 1 test: return QVariant(uint(qRound(s.toDouble(ok))));
Executed by:
  • tst_qqmlecmascript
4
74#if QT_CONFIG(datestring)-
75 case QMetaType::QDate:
executed 8 times by 1 test: case QMetaType::QDate:
Executed by:
  • tst_qqmlecmascript
8
76 return QVariant::fromValue(dateFromString(s, ok));
executed 8 times by 1 test: return QVariant::fromValue(dateFromString(s, ok));
Executed by:
  • tst_qqmlecmascript
8
77 case QMetaType::QTime:
executed 4 times by 1 test: case QMetaType::QTime:
Executed by:
  • tst_qqmlecmascript
4
78 return QVariant::fromValue(timeFromString(s, ok));
executed 4 times by 1 test: return QVariant::fromValue(timeFromString(s, ok));
Executed by:
  • tst_qqmlecmascript
4
79 case QMetaType::QDateTime:
executed 12 times by 1 test: case QMetaType::QDateTime:
Executed by:
  • tst_qqmlecmascript
12
80 return QVariant::fromValue(dateTimeFromString(s, ok));
executed 12 times by 1 test: return QVariant::fromValue(dateTimeFromString(s, ok));
Executed by:
  • tst_qqmlecmascript
12
81#endif // datestring-
82 case QMetaType::QPointF:
executed 4 times by 1 test: case QMetaType::QPointF:
Executed by:
  • tst_qqmlecmascript
4
83 return QVariant::fromValue(pointFFromString(s, ok));
executed 4 times by 1 test: return QVariant::fromValue(pointFFromString(s, ok));
Executed by:
  • tst_qqmlecmascript
4
84 case QMetaType::QPoint:
executed 4 times by 1 test: case QMetaType::QPoint:
Executed by:
  • tst_qqmlecmascript
4
85 return QVariant::fromValue(pointFFromString(s, ok).toPoint());
executed 4 times by 1 test: return QVariant::fromValue(pointFFromString(s, ok).toPoint());
Executed by:
  • tst_qqmlecmascript
4
86 case QMetaType::QSizeF:
executed 4 times by 1 test: case QMetaType::QSizeF:
Executed by:
  • tst_qqmlecmascript
4
87 return QVariant::fromValue(sizeFFromString(s, ok));
executed 4 times by 1 test: return QVariant::fromValue(sizeFFromString(s, ok));
Executed by:
  • tst_qqmlecmascript
4
88 case QMetaType::QSize:
executed 4 times by 1 test: case QMetaType::QSize:
Executed by:
  • tst_qqmlecmascript
4
89 return QVariant::fromValue(sizeFFromString(s, ok).toSize());
executed 4 times by 1 test: return QVariant::fromValue(sizeFFromString(s, ok).toSize());
Executed by:
  • tst_qqmlecmascript
4
90 case QMetaType::QRectF:
executed 4 times by 1 test: case QMetaType::QRectF:
Executed by:
  • tst_qqmlecmascript
4
91 return QVariant::fromValue(rectFFromString(s, ok));
executed 4 times by 1 test: return QVariant::fromValue(rectFFromString(s, ok));
Executed by:
  • tst_qqmlecmascript
4
92 case QMetaType::QRect:
executed 4 times by 1 test: case QMetaType::QRect:
Executed by:
  • tst_qqmlecmascript
4
93 return QVariant::fromValue(rectFFromString(s, ok).toRect());
executed 4 times by 1 test: return QVariant::fromValue(rectFFromString(s, ok).toRect());
Executed by:
  • tst_qqmlecmascript
4
94 default:
executed 80806 times by 33 tests: default:
Executed by:
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsonbinding
  • tst_qqmlcomponent
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmllistmodel
  • tst_qqmlproperty
  • tst_qqmlvaluetypeproviders
  • tst_qquickaccessible
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickgridview
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicklistview
  • tst_qquickmousearea
  • tst_qquickmultipointtoucharea
  • tst_qquickpathview
  • ...
80806
95 return QQml_valueTypeProvider()->createVariantFromString(preferredType, s, ok);
executed 80806 times by 33 tests: return QQml_valueTypeProvider()->createVariantFromString(preferredType, s, ok);
Executed by:
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qjsonbinding
  • tst_qqmlcomponent
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmllistmodel
  • tst_qqmlproperty
  • tst_qqmlvaluetypeproviders
  • tst_qquickaccessible
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickdraghandler
  • tst_qquickdroparea
  • tst_qquickflickable
  • tst_qquickfocusscope
  • tst_qquickgridview
  • tst_qquickitem
  • tst_qquickitem2
  • tst_qquickitemlayer
  • tst_qquicklistview
  • tst_qquickmousearea
  • tst_qquickmultipointtoucharea
  • tst_qquickpathview
  • ...
80806
96 }-
97}-
98-
99QVariant 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:
  • tst_examples
  • tst_qqmlqt
154
102}-
103-
104unsigned 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:
  • tst_drawingmodes
  • tst_examples
  • tst_flickableinterop
  • tst_multipointtoucharea_interop
  • tst_qqmlbinding
  • tst_qqmlcomponent
  • tst_qqmlecmascript
  • tst_qqmlenginedebugservice
  • tst_qqmlincubator
  • tst_qqmlmetaobject
  • tst_qqmlqt
  • tst_qqmlsettings
  • tst_qqmltypeloader
  • tst_qqmlvaluetypeproviders
  • tst_qqmlvaluetypes
  • tst_qquickaccessible
  • tst_qquickage
  • tst_qquickanchors
  • tst_qquickangleddirection
  • tst_qquickanimatedsprite
  • tst_qquickanimationcontroller
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickcumulativedirection
  • tst_qquickcustomaffector
  • ...
36659
107}-
108-
109#if QT_CONFIG(datestring)-
110QDate 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:
  • tst_qqmlecmascript
okDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
0-8
114 return d;
executed 8 times by 1 test: return d;
Executed by:
  • tst_qqmlecmascript
8
115}-
116-
117QTime 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:
  • tst_qqmlecmascript
okDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
0-4
121 return t;
executed 4 times by 1 test: return t;
Executed by:
  • tst_qqmlecmascript
4
122}-
123-
124QDateTime 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:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qqmlqt
  • tst_qqmlsettings
okDescription
TRUEevaluated 104 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qqmlqt
  • tst_qqmlsettings
FALSEnever evaluated
0-104
128 // V8 never parses a date string as local time. For consistency do the same here.-
129 if (d.timeSpec() == Qt::LocalTime)
d.timeSpec() == Qt::LocalTimeDescription
TRUEevaluated 96 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qqmlqt
  • tst_qqmlsettings
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
8-96
130 d.setTimeSpec(Qt::UTC);
executed 96 times by 5 tests: d.setTimeSpec(Qt::UTC);
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qqmlqt
  • tst_qqmlsettings
96
131 return d;
executed 104 times by 5 tests: return d;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qqmlqt
  • tst_qqmlsettings
104
132}-
133#endif // datestring-
134-
135//expects input of "x,y"-
136QPointF QQmlStringConverters::pointFFromString(const QString &s, bool *ok)-
137{-
138 if (s.count(QLatin1Char(',')) != 1) {
s.count(QLatin1Char(',')) != 1Description
TRUEevaluated 26 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
10-26
139 if (ok)
okDescription
TRUEevaluated 26 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
FALSEnever evaluated
0-26
140 *ok = false;
executed 26 times by 6 tests: *ok = false;
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
26
141 return QPointF();
executed 26 times by 6 tests: return QPointF();
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
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) {
!xGoodDescription
TRUEnever evaluated
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
!yGoodDescription
TRUEnever evaluated
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
0-10
149 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
150 *ok = false;
never executed: *ok = false;
0
151 return QPointF();
never executed: return QPointF();
0
152 }-
153-
154 if (ok)
okDescription
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
FALSEnever evaluated
0-10
155 *ok = true;
executed 10 times by 2 tests: *ok = true;
Executed by:
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
10
156 return QPointF(xCoord, yCoord);
executed 10 times by 2 tests: return QPointF(xCoord, yCoord);
Executed by:
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
10
157}-
158-
159//expects input of "widthxheight"-
160QSizeF QQmlStringConverters::sizeFFromString(const QString &s, bool *ok)-
161{-
162 if (s.count(QLatin1Char('x')) != 1) {
s.count(QLatin1Char('x')) != 1Description
TRUEevaluated 26 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qquickimageprovider
24-26
163 if (ok)
okDescription
TRUEevaluated 26 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
FALSEnever evaluated
0-26
164 *ok = false;
executed 26 times by 6 tests: *ok = false;
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
26
165 return QSizeF();
executed 26 times by 6 tests: return QSizeF();
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
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) {
!wGoodDescription
TRUEnever evaluated
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qquickimageprovider
!hGoodDescription
TRUEnever evaluated
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qquickimageprovider
0-24
173 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
174 *ok = false;
never executed: *ok = false;
0
175 return QSizeF();
never executed: return QSizeF();
0
176 }-
177-
178 if (ok)
okDescription
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_qqmlecmascript
  • tst_qquickimageprovider
FALSEnever evaluated
0-24
179 *ok = true;
executed 24 times by 2 tests: *ok = true;
Executed by:
  • tst_qqmlecmascript
  • tst_qquickimageprovider
24
180 return QSizeF(width, height);
executed 24 times by 2 tests: return QSizeF(width, height);
Executed by:
  • tst_qqmlecmascript
  • tst_qquickimageprovider
24
181}-
182-
183//expects input of "x,y,widthxheight" //### use space instead of second comma?-
184QRectF QQmlStringConverters::rectFFromString(const QString &s, bool *ok)-
185{-
186 if (s.count(QLatin1Char(',')) != 2 || s.count(QLatin1Char('x')) != 1) {
s.count(QLatin1Char(',')) != 2Description
TRUEevaluated 28 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
s.count(QLatin1Char('x')) != 1Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
0-28
187 if (ok)
okDescription
TRUEevaluated 28 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
FALSEnever evaluated
0-28
188 *ok = false;
executed 28 times by 7 tests: *ok = false;
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
28
189 return QRectF();
executed 28 times by 7 tests: return QRectF();
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlecmascript
  • tst_qqmlmetaobject
  • tst_qquickanimations
  • tst_qquickimage
  • tst_qquickitem
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) {
!xGoodDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
!yGoodDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
!wGoodDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
!hGoodDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
0-8
201 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
202 *ok = false;
never executed: *ok = false;
0
203 return QRectF();
never executed: return QRectF();
0
204 }-
205-
206 if (ok)
okDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qqmlecmascript
FALSEnever evaluated
0-8
207 *ok = true;
executed 8 times by 1 test: *ok = true;
Executed by:
  • tst_qqmlecmascript
8
208 return QRectF(x, y, width, height);
executed 8 times by 1 test: return QRectF(x, y, width, height);
Executed by:
  • tst_qqmlecmascript
8
209}-
210-
211bool 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-
302QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0