+QString DolphinDetailsView::itemSizeString(const QModelIndex& index, const KFileItem& item) const
+{
+ // The following code has been copied from KFileItemDelegate::Private::itemSize()
+ // Copyright (c) 2006-2007, 2008 Fredrik Höglund <fredrik@kde.org>
+ // Ideally this should be handled by KFileItemDelegate::sizeHint().
+ if (item.isFile()) {
+ return KGlobal::locale()->formatByteSize(item.size());
+ }
+
+ // Return the number of items in the directory
+ const QVariant value = index.data(KDirModel::ChildCountRole);
+ const int count = value.type() == QVariant::Int ? value.toInt() : KDirModel::ChildCountUnknown;
+
+ if (count == KDirModel::ChildCountUnknown) {
+ return QString();
+ }
+
+ return i18ncp("Items in a folder", "1 item", "%1 items", count);
+}
+