diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-08 18:36:35 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-08 18:36:35 +0200 |
| commit | 8c9480f6fc1b73b2f9ca5c1463a8ee10a579712d (patch) | |
| tree | 28d5880141380870d040481aeea0b6dab16852e4 /src/ioutil.cpp | |
| parent | 75deaa0c850d374f526102b0b38402b2632f9751 (diff) | |
| download | kristall-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.cpp | 20 |
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; +} |
