Add TB range to byte counters

pull/1/head
Timothy Pearson 9 lat temu
rodzic c903aeab54
commit 739a9d60ae

@ -29,20 +29,21 @@ class KNetStatsView;
class Statistics : public StatisticsBase
{
Q_OBJECT
public:
Statistics( KNetStatsView* parent = 0, const char *name = 0 );
Statistics(KNetStatsView* parent = 0, const char *name = 0);
/**
* Formats a numberic byte representation
* \param num The numeric representation
* \param decimal Decimal digits
* \param bytesufix Sufix for bytes
* \param ksufix Sufix for kilobytes
* \param msufix Sufix for megabytes
* \param decimal Decimal digits
* \param ksuffix Suffix for kilobytes
* \param msuffix Suffix for megabytes
* \param gsuffix Suffix for gigabytes
* \param tsuffix Suffix for terabytes
*/
static inline TQString byteFormat( double num, const char* ksuffix = " KB", const char* msuffix = " MB", const char* gsuffix = " GB");
static inline TQString byteFormat(double num, const char* ksuffix = " KB", const char* msuffix = " MB", const char* gsuffix = " GB", const char* tsuffix = " TB");
void show();
private:
@ -56,18 +57,22 @@ private slots:
void update();
};
TQString Statistics::byteFormat( double num, const char* ksuffix, const char* msuffix, const char* gsuffix ) {
TQString Statistics::byteFormat(double num, const char* ksuffix, const char* msuffix, const char* gsuffix, const char* tsuffix) {
const double ONE_KB = 1024.0;
const double ONE_MB = ONE_KB*ONE_KB;
const double ONE_GB = ONE_KB*ONE_KB*ONE_KB;
if ( num >= ONE_GB ) { // GB
return TQString::number( num/(ONE_GB), 'f', 1 ) + gsuffix;
const double ONE_TB = ONE_KB*ONE_KB*ONE_KB*ONE_KB;
if ( num >= ONE_TB ) { // TB
return TQString::number(num/(ONE_TB), 'f', 1) + tsuffix;
}
else if ( num >= ONE_GB ) { // GB
return TQString::number(num/(ONE_GB), 'f', 1) + gsuffix;
}
else if ( num >= ONE_MB ) { // MB
return TQString::number( num/(ONE_MB), 'f', 1 ) + msuffix;
return TQString::number(num/(ONE_MB), 'f', 1) + msuffix;
}
else { // KB
return TQString::number( num/ONE_KB, 'f', 1 ) + ksuffix;
return TQString::number(num/(ONE_KB), 'f', 1) + ksuffix;
}
}

Ładowanie…
Anuluj
Zapisz