[SCM] Kaboom - Debian KDE 3->4 migration tool branch, master, updated. 2f5f754715b78e054cdb7c61f71cb32c02b85bd8
George Kiagiadakis
gkiagia-guest at alioth.debian.org
Sat Mar 7 00:59:39 UTC 2009
The following commit has been merged in the master branch:
commit 2f5f754715b78e054cdb7c61f71cb32c02b85bd8
Author: George Kiagiadakis <gkiagia at users.sourceforge.net>
Date: Sat Mar 7 02:53:14 2009 +0200
Make ProgressWidget safe to use with quint64 values > INT_MAX.
If the max value is > INT_MAX, we have to do all the percentage calculations
in ProgressWidget, because QProgressBar can only handle ints.
diff --git a/diroperations/progresswidget.cpp b/diroperations/progresswidget.cpp
index a173957..0a24653 100644
--- a/diroperations/progresswidget.cpp
+++ b/diroperations/progresswidget.cpp
@@ -18,9 +18,10 @@
#include <QVBoxLayout>
#include <QLabel>
#include <QProgressBar>
+#include <climits>
ProgressWidget::ProgressWidget(QWidget *parent)
- : QWidget(parent)
+ : QWidget(parent), m_overflow(false), m_max(0)
{
QVBoxLayout *layout = new QVBoxLayout(this);
@@ -38,11 +39,15 @@ void ProgressWidget::setLabelText(const QString & text)
void ProgressWidget::setMaximum(quint64 max)
{
- m_progressBar->setMaximum(max);
+ m_overflow = (max > INT_MAX);
+ m_max = max;
+ m_progressBar->setMaximum(m_overflow ? 100 : static_cast<int>(max));
}
void ProgressWidget::setValue(quint64 value)
{
- m_progressBar->setValue(value);
+ if ( m_overflow )
+ value = static_cast<int>((double(value) / double(m_max)) * 100);
+ m_progressBar->setValue(static_cast<int>(value));
}
diff --git a/diroperations/progresswidget.h b/diroperations/progresswidget.h
index 6491fcd..090b1fa 100644
--- a/diroperations/progresswidget.h
+++ b/diroperations/progresswidget.h
@@ -34,6 +34,8 @@ public:
private:
QLabel *m_label;
QProgressBar *m_progressBar;
+ bool m_overflow;
+ quint64 m_max;
};
#endif
--
Kaboom - Debian KDE 3->4 migration tool
More information about the pkg-kde-commits
mailing list