summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2015-03-12 12:13:17 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2015-03-12 12:13:56 -0500
commit739a9d60ae3b8e0ff4df59d94519af2ed0919dac (patch)
tree85e66b5070fc2ebd42c34f51eedea5ebb798118b
parentc903aeab541d6a6d0c41f78d06917523c84c167d (diff)
downloadknetstats-739a9d60ae3b8e0ff4df59d94519af2ed0919dac.tar.gz
knetstats-739a9d60ae3b8e0ff4df59d94519af2ed0919dac.zip
Add TB range to byte counters
-rw-r--r--src/src/statistics.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/src/statistics.h b/src/src/statistics.h
index 637b965..a979961 100644
--- a/src/src/statistics.h
+++ b/src/src/statistics.h
@@ -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;
}
}