From: Eric Bollengier Date: Tue, 4 Aug 2009 11:26:07 +0000 (+0200) Subject: bat: cleanup job and mediainfo panel X-Git-Tag: Release-5.0.0~338^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0afa4c5d5cd5b513fa787f15c7b3cbf6df2e5e4d;p=bacula%2Fbacula bat: cleanup job and mediainfo panel --- diff --git a/bacula/src/qt-console/job/job.cpp b/bacula/src/qt-console/job/job.cpp index d9ef451ead..ec9ef8d122 100644 --- a/bacula/src/qt-console/job/job.cpp +++ b/bacula/src/qt-console/job/job.cpp @@ -197,52 +197,6 @@ void Job::populateText() } -// Need to use the fmtwidgetitem helper instead -static QString convertBytesSI(qint64 qfld) -{ - static const qint64 KB = Q_INT64_C(1000); - static const qint64 MB = (KB * KB); - static const qint64 GB = (MB * KB); - static const qint64 TB = (GB * KB); - static const qint64 PB = (TB * KB); - static const qint64 EB = (PB * KB); - - /* note: division is integer, so to have some decimals we divide for a - smaller unit (e.g. GB for a TB number and so on) */ - char suffix; - if (qfld >= EB) { - qfld /= PB; - suffix = 'E'; - } - else if (qfld >= PB) { - qfld /= TB; - suffix = 'P'; - } - else if (qfld >= TB) { - qfld /= GB; - suffix = 'T'; - } - else if (qfld >= GB) { - qfld /= MB; - suffix = 'G'; - } - else if (qfld >= MB) { - qfld /= KB; - suffix = 'M'; - } - else if (qfld >= KB) { - suffix = 'k'; /* SI uses lowercase k */ - } - else { - /* plain bytes, no need to reformat */ - return QString("%1 B").arg(qfld); - } - - /* having divided for a smaller unit, now we can safely convert to double and - use the extra room for decimals */ - return QString("%1 %2B").arg(qfld / 1000.0, 0, 'f', 2).arg(suffix); -} - /* * Populate the text in the window */ diff --git a/bacula/src/qt-console/mediainfo/mediainfo.cpp b/bacula/src/qt-console/mediainfo/mediainfo.cpp index ce2be03a15..f66a9b8366 100644 --- a/bacula/src/qt-console/mediainfo/mediainfo.cpp +++ b/bacula/src/qt-console/mediainfo/mediainfo.cpp @@ -31,6 +31,7 @@ #include #include #include "mediainfo.h" +#include "util/fmtwidgetitem.h" /* * A constructor @@ -48,52 +49,6 @@ MediaInfo::MediaInfo(QTreeWidgetItem *parentWidget, QString &mediaName) populateForm(); } -// Need to use the fmtwidgetitem helper instead -static QString convertBytesSI(qint64 qfld) -{ - static const qint64 KB = Q_INT64_C(1000); - static const qint64 MB = (KB * KB); - static const qint64 GB = (MB * KB); - static const qint64 TB = (GB * KB); - static const qint64 PB = (TB * KB); - static const qint64 EB = (PB * KB); - - /* note: division is integer, so to have some decimals we divide for a - smaller unit (e.g. GB for a TB number and so on) */ - char suffix; - if (qfld >= EB) { - qfld /= PB; - suffix = 'E'; - } - else if (qfld >= PB) { - qfld /= TB; - suffix = 'P'; - } - else if (qfld >= TB) { - qfld /= GB; - suffix = 'T'; - } - else if (qfld >= GB) { - qfld /= MB; - suffix = 'G'; - } - else if (qfld >= MB) { - qfld /= KB; - suffix = 'M'; - } - else if (qfld >= KB) { - suffix = 'k'; /* SI uses lowercase k */ - } - else { - /* plain bytes, no need to reformat */ - return QString("%1 B").arg(qfld); - } - - /* having divided for a smaller unit, now we can safely convert to double and - use the extra room for decimals */ - return QString("%1 %2B").arg(qfld / 1000.0, 0, 'f', 2).arg(suffix); -} - /* * Populate the text in the window */ diff --git a/bacula/src/qt-console/util/fmtwidgetitem.cpp b/bacula/src/qt-console/util/fmtwidgetitem.cpp index f149d81cd9..7871e8a9c4 100644 --- a/bacula/src/qt-console/util/fmtwidgetitem.cpp +++ b/bacula/src/qt-console/util/fmtwidgetitem.cpp @@ -88,7 +88,7 @@ Freeze::~Freeze() ItemFormatterBase::BYTES_CONVERSION ItemFormatterBase::cnvFlag(BYTES_CONVERSION_IEC); -QString ItemFormatterBase::convertBytesIEC(qint64 qfld) +QString convertBytesIEC(qint64 qfld) { static const qint64 KB = Q_INT64_C(1024); static const qint64 MB = (KB * KB); @@ -133,7 +133,7 @@ QString ItemFormatterBase::convertBytesIEC(qint64 qfld) return QString("%1 %2iB").arg(qfld / 1000.0, 0, 'f', 2).arg(suffix); } -QString ItemFormatterBase::convertBytesSI(qint64 qfld) +QString convertBytesSI(qint64 qfld) { static const qint64 KB = Q_INT64_C(1000); static const qint64 MB = (KB * KB); diff --git a/bacula/src/qt-console/util/fmtwidgetitem.h b/bacula/src/qt-console/util/fmtwidgetitem.h index af44c23100..896a0d32e2 100644 --- a/bacula/src/qt-console/util/fmtwidgetitem.h +++ b/bacula/src/qt-console/util/fmtwidgetitem.h @@ -47,6 +47,12 @@ class QBrush; */ QString convertJobStatus(const QString &sts); +/* bytes formatted as power-of-two with IEC suffixes (KiB, MiB, and so on) */ +QString convertBytesIEC(qint64 fld); + +/* bytes formatted as power-of-ten with SI suffixes (kB, MB, and so on) */ +QString convertBytesSI(qint64 fld); + /* * disable widget updating */ @@ -128,14 +134,6 @@ protected: /* sets the *optional* value used for sorting */ virtual void setSortValue(int index, const QVariant &value) = 0; -private: - - /* bytes formatted as power-of-two with IEC suffixes (KiB, MiB, and so on) */ - static QString convertBytesIEC(qint64 fld); - - /* bytes formatted as power-of-ten with SI suffixes (kB, MB, and so on) */ - static QString convertBytesSI(qint64 fld); - private: static BYTES_CONVERSION cnvFlag; }; diff --git a/bacula/technotes b/bacula/technotes index 769f961a08..c9bb4020df 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -4,6 +4,7 @@ General: 04Aug09 ebl bat: Go to the media info panel when double-click on job page or media list +ebl bat: cleanup job and mediainfo panel 03Aug09 ebl Add new media info panel to bat 02Aug09