From 9990148f2cafb8a9e37e8b6283e84837c2274940 Mon Sep 17 00:00:00 2001 From: Andrey Kvochko Date: Thu, 21 Sep 2017 16:08:28 +0300 Subject: [PATCH] Format size columns properly --- src/analyze/gui/objecttreemodel.cpp | 10 ++++++++-- src/analyze/gui/objecttreemodel.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/analyze/gui/objecttreemodel.cpp b/src/analyze/gui/objecttreemodel.cpp index b3fd264..bb2feaa 100644 --- a/src/analyze/gui/objecttreemodel.cpp +++ b/src/analyze/gui/objecttreemodel.cpp @@ -119,9 +119,15 @@ QVariant ObjectTreeModel::data(const QModelIndex& index, int role) const case InstanceCountColumn: return static_cast(row->allocations); case ShallowSizeColumn: - return static_cast(row->allocated); + if (role == SortRole) { + return static_cast(row->allocated); + } + return m_format.formatByteSize(row->allocated, 1, KFormat::JEDECBinaryDialect); case ReferencedSizeColumn: - return static_cast(row->referenced); + if (role == SortRole) { + return static_cast(row->referenced); + } + return m_format.formatByteSize(row->referenced, 1, KFormat::JEDECBinaryDialect); case GCNumColumn: return static_cast(row->gcNum); case NUM_COLUMNS: diff --git a/src/analyze/gui/objecttreemodel.h b/src/analyze/gui/objecttreemodel.h index 97229c1..d635d4f 100644 --- a/src/analyze/gui/objecttreemodel.h +++ b/src/analyze/gui/objecttreemodel.h @@ -86,6 +86,7 @@ private: int rowOf(const ObjectRowData* row) const; ObjectTreeData m_data; + KFormat m_format; }; #endif // OBJECTTREEMODEL_H -- 2.7.4