From eadbf920b5dffdf2d1548240c25ec2eaf835aad5 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 4 Nov 2011 21:54:01 +0100 Subject: Don't use mixed units in size-column of details-view This makes it tricky to compare the filesizes without adjusting the sort-order, so now all sizes in the size-column are shown in KiB or KB (dependent on the KLocale setting). BUG: 219932 FIXED-IN: 4.8.0 Related fixes: - Stay consistent with the rounding when using the KiB/KB unit in the statusbar. - Fix sorting-by-size issue for folders - Show "Unknown" in the size-column when the number of items cannot be determined. --- src/kitemviews/kfileitemmodel.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/kitemviews/kfileitemmodel.cpp') diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 4b026fea3..afc6decee 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -1032,12 +1032,22 @@ bool KFileItemModel::lessThan(const ItemData* a, const ItemData* b) const } case SizeRole: { - const KIO::filesize_t sizeA = itemA.size(); - const KIO::filesize_t sizeB = itemB.size(); - if (sizeA < sizeB) { - result = -1; - } else if (sizeA > sizeB) { - result = +1; + if (itemA.isDir()) { + Q_ASSERT(itemB.isDir()); // see "if (m_sortFoldersFirst || m_sortRole == SizeRole)" above + + const QVariant valueA = a->values.value("size"); + const QVariant valueB = b->values.value("size"); + + if (valueA.isNull()) { + result = -1; + } else if (valueB.isNull()) { + result = +1; + } else { + result = valueA.value() - valueB.value(); + } + } else { + Q_ASSERT(!itemB.isDir()); // see "if (m_sortFoldersFirst || m_sortRole == SizeRole)" above + result = itemA.size() - itemB.size(); } break; } -- cgit v1.3