diff --git a/src/common/Helpers.cpp b/src/common/Helpers.cpp index 826790f4..655ae6c6 100644 --- a/src/common/Helpers.cpp +++ b/src/common/Helpers.cpp @@ -23,16 +23,18 @@ static QAbstractItemView::ScrollMode scrollMode() namespace qhelpers { -QString formatBytecount(const long bytecount) +QString formatBytecount(const uint64_t bytecount) { - if (bytecount == 0) + if (bytecount == 0) { return "0"; - const int exp = log(bytecount) / log(1000); + } + + const int exp = log(bytecount) / log(1024); constexpr char suffixes[] = {' ', 'k', 'M', 'G', 'T', 'P', 'E'}; QString str; QTextStream stream(&str); - stream << qSetRealNumberPrecision(3) << bytecount / pow(1000, exp) + stream << qSetRealNumberPrecision(3) << bytecount / pow(1024, exp) << ' ' << suffixes[exp] << 'B'; return stream.readAll(); } diff --git a/src/common/Helpers.h b/src/common/Helpers.h index 9275faea..d7c60419 100644 --- a/src/common/Helpers.h +++ b/src/common/Helpers.h @@ -21,7 +21,7 @@ class QMenu; class QPaintDevice; namespace qhelpers { -QString formatBytecount(const long bytecount); +QString formatBytecount(const uint64_t bytecount); void adjustColumns(QTreeView *tv, int columnCount, int padding); void adjustColumns(QTreeWidget *tw, int padding); bool selectFirstItem(QAbstractItemView *itemView);