summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2015-03-12 12:13:17 -0500
committerSlávek Banko <slavek.banko@axis.cz>2015-03-12 18:18:44 +0100
commit18d4f32754a7495a1644905d6534a8813a53f7a8 (patch)
tree85e66b5070fc2ebd42c34f51eedea5ebb798118b
parentb8063fc2f49dc62e661114e2eddb7b0c7b4293e1 (diff)
downloadknetstats-18d4f32754a7495a1644905d6534a8813a53f7a8.tar.gz
knetstats-18d4f32754a7495a1644905d6534a8813a53f7a8.zip
Add TB range to byte counters
(cherry picked from commit 739a9d60ae3b8e0ff4df59d94519af2ed0919dac)
-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;
}
}