summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2011-10-10 11:58:12 (GMT)
committermread <qt-info@nokia.com>2011-10-10 12:23:08 (GMT)
commitae620eb773a5fd217de4766fc829e51417cb9e70 (patch)
tree8f1468cdc0f7fbb82a934b7370cc6a1b9aae5df2 /src/gui/styles
parent22d475e1ef32875c4933b2bb4c2830cb1bdd3266 (diff)
downloadQt-ae620eb773a5fd217de4766fc829e51417cb9e70.zip
Qt-ae620eb773a5fd217de4766fc829e51417cb9e70.tar.gz
Qt-ae620eb773a5fd217de4766fc829e51417cb9e70.tar.bz2
Converting from double to qreal in gui
There were a number of places in QtGui where doubles were used in expressions due to the use of floating point constants in the code. Many of these constants are now constructed as qreal, removing the use of double operations where unneeded. These changes have been limited to constants that have exactly the same value whether double or float, to ensure that precision errors are not introduced. This should not affect any of the desktop platforms where qreal is double. On Symbian, where qreal is float, appropriate autotests have been run. Task-number: QTBUG-4894 Reviewed-by: Sami Merila
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/qs60style.cpp8
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp10
2 files changed, 9 insertions, 9 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index eec2d15..59bd0dd 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -1679,7 +1679,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnGrafBarWaitAnim,
painter, progressRect, flags | orientationFlag | QS60StylePrivate::SF_Animation );
} else {
- const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? 1.0
+ const qreal progressFactor = (optionProgressBar->minimum == optionProgressBar->maximum) ? qreal(1.0)
: (qreal)optionProgressBar->progress / optionProgressBar->maximum;
const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget);
if (optionProgressBar->orientation == Qt::Horizontal) {
@@ -2010,7 +2010,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (focusFrame->widget() && focusFrame->widget()->hasEditFocus())
editFocus = true;
}
- const qreal opacity = editFocus ? 1 : 0.75; // Trial and error factors. Feel free to improve.
+ const qreal opacity = editFocus ? 1 : qreal(0.75); // Trial and error factors. Feel free to improve.
#else
const qreal opacity = 0.85;
#endif
@@ -2148,8 +2148,8 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorRadioButton: {
QRect buttonRect = option->rect;
//there is empty (a. 33%) space in svg graphics for radiobutton
- const qreal reduceWidth = (qreal)buttonRect.width() / 3.0;
- const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : 1.0;
+ const qreal reduceWidth = (qreal)buttonRect.width() / qreal(3.0);
+ const qreal rectWidth = (qreal)option->rect.width() != 0 ? option->rect.width() : qreal(1.0);
// Try to occupy the full area
const qreal scaler = 1 + (reduceWidth/rectWidth);
buttonRect.setWidth((int)((buttonRect.width()-reduceWidth) * scaler));
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 7d2ed2a..c066631 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -1247,20 +1247,20 @@ QPainterPath QRenderRule::borderClip(QRect r)
const QRectF rect(r);
const int *borders = border()->borders;
QPainterPath path;
- qreal curY = rect.y() + borders[TopEdge]/2.0;
+ qreal curY = rect.y() + borders[TopEdge]/qreal(2.0);
path.moveTo(rect.x() + tlr.width(), curY);
path.lineTo(rect.right() - trr.width(), curY);
- qreal curX = rect.right() - borders[RightEdge]/2.0;
+ qreal curX = rect.right() - borders[RightEdge]/qreal(2.0);
path.arcTo(curX - 2*trr.width() + borders[RightEdge], curY,
trr.width()*2 - borders[RightEdge], trr.height()*2 - borders[TopEdge], 90, -90);
path.lineTo(curX, rect.bottom() - brr.height());
- curY = rect.bottom() - borders[BottomEdge]/2.0;
+ curY = rect.bottom() - borders[BottomEdge]/qreal(2.0);
path.arcTo(curX - 2*brr.width() + borders[RightEdge], curY - 2*brr.height() + borders[BottomEdge],
brr.width()*2 - borders[RightEdge], brr.height()*2 - borders[BottomEdge], 0, -90);
path.lineTo(rect.x() + blr.width(), curY);
- curX = rect.left() + borders[LeftEdge]/2.0;
+ curX = rect.left() + borders[LeftEdge]/qreal(2.0);
path.arcTo(curX, rect.bottom() - 2*blr.height() + borders[BottomEdge]/2,
blr.width()*2 - borders[LeftEdge], blr.height()*2 - borders[BottomEdge], 270, -90);
@@ -3810,7 +3810,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (inverted)
reverse = !reverse;
const bool indeterminate = pb->minimum == pb->maximum;
- qreal fillRatio = indeterminate ? 0.50 : qreal(progress - minimum)/(maximum - minimum);
+ qreal fillRatio = indeterminate ? qreal(0.50) : qreal(progress - minimum)/(maximum - minimum);
int fillWidth = int(rect.width() * fillRatio);
int chunkWidth = fillWidth;
if (subRule.hasContentsSize()) {