summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-07-22 11:19:32 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-07-22 11:29:58 (GMT)
commit336954fb9b990c6d7c44ed3a8d676a6e21b2057f (patch)
tree3d29f3aae74abd76d24e19d98a1ac3f1d42638d3 /src/gui/styles
parent3a8968dd2aab9c4e40ed34222f557bec6a98349e (diff)
downloadQt-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/styles')
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp7
-rw-r--r--src/gui/styles/qgtkstyle.cpp4
2 files changed, 5 insertions, 6 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)