summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
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/graphicsview
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/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp16
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp4
-rw-r--r--src/gui/graphicsview/qgridlayoutengine.cpp8
-rw-r--r--src/gui/graphicsview/qsimplex_p.cpp2
6 files changed, 17 insertions, 17 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 9092593..cb7349c 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -8868,7 +8868,7 @@ QPainterPath QGraphicsEllipseItem::shape() const
return path;
if (d->spanAngle != 360 * 16) {
path.moveTo(d->rect.center());
- path.arcTo(d->rect, d->startAngle / 16.0, d->spanAngle / 16.0);
+ path.arcTo(d->rect, d->startAngle / qreal(16.0), d->spanAngle / qreal(16.0));
} else {
path.addEllipse(d->rect);
}
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 867880c..d652f25 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4304,7 +4304,7 @@ static void _q_paintItem(QGraphicsItem *item, QPainter *painter,
QGraphicsWidget *widgetItem = static_cast<QGraphicsWidget *>(item);
QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(widgetItem);
const qreal windowOpacity = (proxy && proxy->widget() && useWindowOpacity)
- ? proxy->widget()->windowOpacity() : 1.0;
+ ? proxy->widget()->windowOpacity() : qreal(1.0);
const qreal oldPainterOpacity = painter->opacity();
if (qFuzzyIsNull(windowOpacity))
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 548f79f..d2e21fb 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -298,7 +298,7 @@ inline int q_round_bound(qreal d) //### (int)(qreal) INT_MAX != INT_MAX for sing
return INT_MIN;
else if (d >= (qreal) INT_MAX)
return INT_MAX;
- return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1);
+ return d >= 0.0 ? int(d + qreal(0.5)) : int(d - int(d-1) + qreal(0.5)) + int(d-1);
}
void QGraphicsViewPrivate::translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent)
@@ -1830,14 +1830,14 @@ void QGraphicsView::centerOn(const QPointF &pos)
qint64 horizontal = 0;
horizontal += horizontalScrollBar()->minimum();
horizontal += horizontalScrollBar()->maximum();
- horizontal -= int(viewPoint.x() - width / 2.0);
+ horizontal -= int(viewPoint.x() - width / qreal(2.0));
horizontalScrollBar()->setValue(horizontal);
} else {
- horizontalScrollBar()->setValue(int(viewPoint.x() - width / 2.0));
+ horizontalScrollBar()->setValue(int(viewPoint.x() - width / qreal(2.0)));
}
}
if (!d->topIndent)
- verticalScrollBar()->setValue(int(viewPoint.y() - height / 2.0));
+ verticalScrollBar()->setValue(int(viewPoint.y() - height / qreal(2.0)));
d->lastCenterPoint = oldCenterPoint;
}
@@ -1886,22 +1886,22 @@ void QGraphicsView::ensureVisible(const QRectF &rect, int xmargin, int ymargin)
if (viewRect.left() <= left + xmargin) {
// need to scroll from the left
if (!d->leftIndent)
- horizontalScrollBar()->setValue(int(viewRect.left() - xmargin - 0.5));
+ horizontalScrollBar()->setValue(int(viewRect.left() - xmargin - qreal(0.5)));
}
if (viewRect.right() >= right - xmargin) {
// need to scroll from the right
if (!d->leftIndent)
- horizontalScrollBar()->setValue(int(viewRect.right() - width + xmargin + 0.5));
+ horizontalScrollBar()->setValue(int(viewRect.right() - width + xmargin + qreal(0.5)));
}
if (viewRect.top() <= top + ymargin) {
// need to scroll from the top
if (!d->topIndent)
- verticalScrollBar()->setValue(int(viewRect.top() - ymargin - 0.5));
+ verticalScrollBar()->setValue(int(viewRect.top() - ymargin - qreal(0.5)));
}
if (viewRect.bottom() >= bottom - ymargin) {
// need to scroll from the bottom
if (!d->topIndent)
- verticalScrollBar()->setValue(int(viewRect.bottom() - height + ymargin + 0.5));
+ verticalScrollBar()->setValue(int(viewRect.bottom() - height + ymargin + qreal(0.5)));
}
}
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
index ca6713b..ec79a2f 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ b/src/gui/graphicsview/qgraphicswidget_p.cpp
@@ -482,8 +482,8 @@ static QSizeF closestAcceptableSize(const QSizeF &proposed,
minw = maxw;
minh = maxh;
}
- middlew = minw + (maxw - minw)/2.0;
- middleh = minh + (maxh - minh)/2.0;
+ middlew = minw + (maxw - minw)/qreal(2.0);
+ middleh = minh + (maxh - minh)/qreal(2.0);
min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget);
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp
index 66b4a5b..5c61435 100644
--- a/src/gui/graphicsview/qgridlayoutengine.cpp
+++ b/src/gui/graphicsview/qgridlayoutengine.cpp
@@ -84,7 +84,7 @@ static qreal fixedDescent(qreal descent, qreal ascent, qreal targetSize)
Q_ASSERT(targetSize >= ascent + descent);
qreal extra = targetSize - (ascent + descent);
- return descent + (extra / 2.0);
+ return descent + (extra / qreal(2.0));
}
static qreal compare(const QGridLayoutBox &box1, const QGridLayoutBox &box2, int which)
@@ -292,9 +292,9 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz
int stretch = stretches[start + i];
if (sumStretches == 0) {
if (hasIgnoreFlag) {
- factors[i] = (stretch < 0) ? 1.0 : 0.0;
+ factors[i] = (stretch < 0) ? qreal(1.0) : qreal(0.0);
} else {
- factors[i] = (stretch < 0) ? sizes[i] : 0.0;
+ factors[i] = (stretch < 0) ? sizes[i] : qreal(0.0);
}
} else if (stretch == sumStretches) {
factors[i] = 1.0;
@@ -373,7 +373,7 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz
for (int i = 0; i < n; ++i) {
if (newSizes[i] < 0.0) {
- qreal delta = (sumFactors == 0.0) ? 0.0
+ qreal delta = (sumFactors == 0.0) ? qreal(0.0)
: sumCurrentAvailable * factors[i] / sumFactors;
newSizes[i] = sizes[i] + delta;
}
diff --git a/src/gui/graphicsview/qsimplex_p.cpp b/src/gui/graphicsview/qsimplex_p.cpp
index eb8bcb8..1b45d9d 100644
--- a/src/gui/graphicsview/qsimplex_p.cpp
+++ b/src/gui/graphicsview/qsimplex_p.cpp
@@ -486,7 +486,7 @@ bool QSimplex::iterate()
// Normalize Pivot Row
qreal pivot = valueAt(pivotRow, pivotColumn);
if (pivot != 1.0)
- combineRows(pivotRow, pivotRow, (1.0 - pivot) / pivot);
+ combineRows(pivotRow, pivotRow, (qreal(1.0) - pivot) / pivot);
// Update other rows
for (int row=0; row < rows; ++row) {