aboutsummaryrefslogtreecommitdiff
path: root/src/ioutil.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-08 18:36:35 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-08 18:36:35 +0200
commit8c9480f6fc1b73b2f9ca5c1463a8ee10a579712d (patch)
tree28d5880141380870d040481aeea0b6dab16852e4 /src/ioutil.cpp
parent75deaa0c850d374f526102b0b38402b2632f9751 (diff)
downloadkristall-8c9480f6fc1b73b2f9ca5c1463a8ee10a579712d.tar.gz
Improves gopher map rendering with icons and monospace font, adds status bar with more infos, fixes file dialog for older qt versions.
Diffstat (limited to 'src/ioutil.cpp')
-rw-r--r--src/ioutil.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ioutil.cpp b/src/ioutil.cpp
index 047a901..00caba6 100644
--- a/src/ioutil.cpp
+++ b/src/ioutil.cpp
@@ -14,3 +14,23 @@ bool IoUtil::writeAll(QIODevice &dst, QByteArray const & src)
return true;
}
+
+QString IoUtil::size_human(qint64 size)
+{
+ if(size < 1024)
+ return QString("%1 B").arg(size);
+
+ float num = size;
+ QStringList list;
+ list << "KB" << "MB" << "GB" << "TB";
+
+ QStringListIterator i(list);
+ QString unit("B");
+
+ while(num >= 1024.0 && i.hasNext())
+ {
+ unit = i.next();
+ num /= 1024.0;
+ }
+ return QString().setNum(num,'f',2)+" "+unit;
+}