use formattedDataSize for displaying sizes

This commit is contained in:
alison wright 2019-11-09 15:30:23 -05:00
parent 9c094fb094
commit 8975d15683
2 changed files with 6 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QLocale>
#include <QMetaEnum> #include <QMetaEnum>
#include <algorithm> #include <algorithm>
@ -172,6 +173,10 @@ static inline T orThrow(Option<T> opt, Error err) {
} }
} }
static inline QString toBinSize(qint64 bytes) {
return QLocale().formattedDataSize(bytes, 2, QLocale::DataSizeSIFormat);
}
static inline QDebug operator<<(QDebug debug, std::string const &t) { static inline QDebug operator<<(QDebug debug, std::string const &t) {
debug << QString::fromStdString(t); debug << QString::fromStdString(t);
return debug; return debug;

View File

@ -195,7 +195,7 @@ namespace Arc {
switch(col) { switch(col) {
case Column::Size: case Column::Size:
if(auto file = node->getFile()) { if(auto file = node->getFile()) {
return QVariant{QString::number(file->size())}; return QVariant{toBinSize(file->size())};
} }
break; break;
case Column::Type: case Column::Type: