mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 15:06:08 +03:00
Display file sizes as nicely formatted string in file provider file delegate
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
643d30a3d5
commit
f22bf9e527
3 changed files with 13 additions and 7 deletions
|
@ -98,8 +98,10 @@ QVariant FileProviderMaterialisedItemsModel::data(const QModelIndex &index, int
|
|||
return item.sharedByCurrentUser();
|
||||
case UserVisiblePathRole:
|
||||
return item.userVisiblePath();
|
||||
case FileTypeRole:
|
||||
case FileTypeStringRole:
|
||||
return item.fileTypeString();
|
||||
case FileSizeStringRole:
|
||||
return _locale.formattedDataSize(item.documentSize());
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -138,7 +140,8 @@ QHash<int, QByteArray> FileProviderMaterialisedItemsModel::roleNames() const
|
|||
{ SharedRole, "shared" },
|
||||
{ SharedByCurrentUserRole, "sharedByCurrentUser" },
|
||||
{ UserVisiblePathRole, "userVisiblePath" },
|
||||
{ FileTypeRole, "fileType" },
|
||||
{ FileTypeStringRole, "fileTypeString" },
|
||||
{ FileSizeStringRole, "fileSizeString" },
|
||||
});
|
||||
return roleNames;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QLocale>
|
||||
|
||||
#include "gui/macOS/fileprovideritemmetadata.h"
|
||||
|
||||
|
@ -60,7 +61,8 @@ public:
|
|||
SharedRole,
|
||||
SharedByCurrentUserRole,
|
||||
UserVisiblePathRole,
|
||||
FileTypeRole,
|
||||
FileTypeStringRole,
|
||||
FileSizeStringRole,
|
||||
};
|
||||
Q_ENUM(Roles)
|
||||
|
||||
|
@ -80,6 +82,7 @@ public slots:
|
|||
|
||||
private:
|
||||
QVector<FileProviderItemMetadata> _items;
|
||||
QLocale _locale;
|
||||
};
|
||||
|
||||
} // namespace Mac
|
||||
|
|
|
@ -32,9 +32,9 @@ Item {
|
|||
required property string domainIdentifier
|
||||
required property string fileName
|
||||
required property string userVisiblePath
|
||||
required property string fileType
|
||||
required property string fileTypeString
|
||||
|
||||
required property size documentSize
|
||||
required property string fileSizeString
|
||||
|
||||
RowLayout {
|
||||
id: internalLayout
|
||||
|
@ -73,12 +73,12 @@ Item {
|
|||
|
||||
EnforcedPlainTextLabel {
|
||||
id: fileSizeLabel
|
||||
text: root.documentSize
|
||||
text: root.fileSizeString
|
||||
}
|
||||
|
||||
EnforcedPlainTextLabel {
|
||||
id: fileTypeLabel
|
||||
text: root.fileType
|
||||
text: root.fileTypeString
|
||||
color: Style.ncSecondaryTextColor
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue