diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-22 11:19:32 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-07-22 11:29:58 (GMT) |
commit | 336954fb9b990c6d7c44ed3a8d676a6e21b2057f (patch) | |
tree | 3d29f3aae74abd76d24e19d98a1ac3f1d42638d3 /src/gui | |
parent | 3a8968dd2aab9c4e40ed34222f557bec6a98349e (diff) | |
download | Qt-336954fb9b990c6d7c44ed3a8d676a6e21b2057f.zip Qt-336954fb9b990c6d7c44ed3a8d676a6e21b2057f.tar.gz Qt-336954fb9b990c6d7c44ed3a8d676a6e21b2057f.tar.bz2 |
Simplify the computation of the QProgressBar progress.
This is also a work around for a bug in gcc on powerpc (embedded-linux)
Task-number: 258358
Reviewed-by: jbache
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/styles/qcleanlooksstyle.cpp | 7 | ||||
-rw-r--r-- | src/gui/styles/qgtkstyle.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/qprogressbar.cpp | 4 |
3 files changed, 7 insertions, 8 deletions
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 01f19c6..779fbc2 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -1745,10 +1745,9 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o int maxWidth = rect.width() - 4; int minWidth = 4; - qint64 progress = (qint64)qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar - double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth); - int progressBarWidth = (int(vc6_workaround) > minWidth ) ? int(vc6_workaround) : minWidth; - int width = indeterminate ? maxWidth : progressBarWidth; + int progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar + int progressBarWidth = qMax(minWidth, (progress - bar->minimum) * maxWidth / qMax(1, bar->maximum - bar->minimum)); + int width = indeterminate ? maxWidth : progressBarWidth; bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; if (inverted) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index b6ef4c9..2ba151e 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -2075,8 +2075,8 @@ void QGtkStyle::drawControl(ControlElement element, } if (vertical) rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height - const int progressIndicatorPos = static_cast<int>((bar->progress - qint64(bar->minimum)) / - qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * rect.width()); + const int progressIndicatorPos = (bar->progress - bar->minimum) * rect.width() / + qMax(1, bar->maximum - bar->minimum); if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width()) leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height()); if (vertical) diff --git a/src/gui/widgets/qprogressbar.cpp b/src/gui/widgets/qprogressbar.cpp index d168028..846f127 100644 --- a/src/gui/widgets/qprogressbar.cpp +++ b/src/gui/widgets/qprogressbar.cpp @@ -447,7 +447,7 @@ QString QProgressBar::text() const || (d->value == INT_MIN && d->minimum == INT_MIN)) return QString(); - qint64 totalSteps = qint64(d->maximum) - qint64(d->minimum); + int totalSteps = d->maximum - d->minimum; QString result = d->format; result.replace(QLatin1String("%m"), QString::number(totalSteps)); @@ -461,7 +461,7 @@ QString QProgressBar::text() const return result; } - int progress = int(((qreal(d->value) - qreal(d->minimum)) * 100.0) / totalSteps); + int progress = (d->value - d->minimum) * 100 / totalSteps; result.replace(QLatin1String("%p"), QString::number(progress)); return result; } |