summaryrefslogtreecommitdiff
path: root/backend.cpp
diff options
context:
space:
mode:
authorAndreas Loibl <andreas@andreas-loibl.de>2011-10-02 22:16:11 +0200
committerAndreas Loibl <andreas@andreas-loibl.de>2011-10-02 22:16:11 +0200
commitecb5cc2be5527e84ae29239ec8fa789c3ee8587e (patch)
tree4c7c59827ea325c1999daa9160877b764c079756 /backend.cpp
parent17dd2d0281bf750768bb9820a677806980380c10 (diff)
downloadacritoxinstaller-ecb5cc2be5527e84ae29239ec8fa789c3ee8587e.zip
acritoxinstaller-ecb5cc2be5527e84ae29239ec8fa789c3ee8587e.tar.gz
use ListItems with formatted size info in frontend
Diffstat (limited to 'backend.cpp')
-rw-r--r--backend.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/backend.cpp b/backend.cpp
index 7580d19..977aaac 100644
--- a/backend.cpp
+++ b/backend.cpp
@@ -2,6 +2,7 @@
#include <QDebug>
#include <QTime>
#include <stdlib.h>
+#include <math.h>
#include "config.h"
Backend* Backend::_instance;
@@ -231,6 +232,19 @@ QString Backend::cleanUsername(const QString &username)
return result.replace(QRegExp("[^a-zA-Z0-9-_.]"), "");
}
+QString Backend::sizeToString(qlonglong size)
+{
+ float fSize = size;
+ int i = 0;
+ const char* units[] = {"B", "kB", "MB", "GB", "TB"};
+ while (fSize > 1024) {
+ fSize /= 1024.0;
+ i++;
+ }
+ fSize = round((fSize)*100)/100;
+ return QString::number(fSize)+" "+ units[i];
+}
+
void Backend::slotProcessExited()
{
emit processExited();