Branch: master

739a9d60 2015-03-12 12:13:56 Timothy Pearson
Add TB range to byte counters
M src/src/statistics.h
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 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 @@
 	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;
 	}
 }