diff options
author | Andreas Loibl <andreas@andreas-loibl.de> | 2011-10-02 22:16:11 +0200 |
---|---|---|
committer | Andreas Loibl <andreas@andreas-loibl.de> | 2011-10-02 22:16:11 +0200 |
commit | ecb5cc2be5527e84ae29239ec8fa789c3ee8587e (patch) | |
tree | 4c7c59827ea325c1999daa9160877b764c079756 /backend.cpp | |
parent | 17dd2d0281bf750768bb9820a677806980380c10 (diff) | |
download | acritoxinstaller-ecb5cc2be5527e84ae29239ec8fa789c3ee8587e.zip acritoxinstaller-ecb5cc2be5527e84ae29239ec8fa789c3ee8587e.tar.gz |
use ListItems with formatted size info in frontend
Diffstat (limited to 'backend.cpp')
-rw-r--r-- | backend.cpp | 14 |
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(); |