summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qcssparser.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-08-14 13:01:37 +0200
committerThierry Bastian <thierry.bastian@nokia.com>2009-08-14 13:03:51 +0200
commitb770651f19741907cd415ea9ad6e087cb32cc948 (patch)
treeecc163e8b33af66454b84ca7f9159d11d6f0cd91 /src/gui/text/qcssparser.cpp
parent51ce8a80acebc67ef09d506d89a2ee1972377877 (diff)
QVariant: added toFloat and toReal
Made better use of qreal all over the place. We were previously using QVariant::toDouble a lot. That is triggering unnecessary conversions between float and double on embedded. Reviewed-by: ogoffart
Diffstat (limited to 'src/gui/text/qcssparser.cpp')
-rw-r--r--src/gui/text/qcssparser.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index e0af6d22e9..181ec7e8cc 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -382,10 +382,7 @@ LengthData ValueExtractor::lengthValue(const Value& v)
if (data.unit != LengthData::None)
s.chop(2);
- bool ok;
- data.number = s.toDouble(&ok);
- if (!ok)
- data.number = 0;
+ data.number = s.toDouble();
return data;
}
@@ -711,7 +708,7 @@ static ColorData parseColorValue(Value v)
for (int i = 0; i < qMin(colorDigits.count(), 7); i += 2) {
if (colorDigits.at(i).type == Value::Percentage) {
- colorDigits[i].variant = colorDigits.at(i).variant.toDouble() * 255. / 100.;
+ colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (255. / 100.);
colorDigits[i].type = Value::Number;
} else if (colorDigits.at(i).type != Value::Number) {
return ColorData();
@@ -788,7 +785,7 @@ static BrushData parseBrushValue(const Value &v, const QPalette &pal)
ColorData cd = parseColorValue(color);
if(cd.type == ColorData::Role)
dependsOnThePalette = true;
- stops.append(QGradientStop(stop.variant.toDouble(), colorFromData(cd, pal)));
+ stops.append(QGradientStop(stop.variant.toReal(), colorFromData(cd, pal)));
} else {
parser.next();
Value value;
@@ -1079,8 +1076,8 @@ static bool setFontSizeFromValue(Value value, QFont *font, int *fontSizeAdjustme
if (s.endsWith(QLatin1String("pt"), Qt::CaseInsensitive)) {
s.chop(2);
value.variant = s;
- if (value.variant.convert(QVariant::Double)) {
- font->setPointSizeF(value.variant.toDouble());
+ if (value.variant.convert((QVariant::Type)qMetaTypeId<qreal>())) {
+ font->setPointSizeF(value.variant.toReal());
valid = true;
}
} else if (s.endsWith(QLatin1String("px"), Qt::CaseInsensitive)) {