summaryrefslogtreecommitdiff
path: root/backend.cpp
diff options
context:
space:
mode:
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();