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();
|
return item.sharedByCurrentUser();
|
||||||
case UserVisiblePathRole:
|
case UserVisiblePathRole:
|
||||||
return item.userVisiblePath();
|
return item.userVisiblePath();
|
||||||
case FileTypeRole:
|
case FileTypeStringRole:
|
||||||
return item.fileTypeString();
|
return item.fileTypeString();
|
||||||
|
case FileSizeStringRole:
|
||||||
|
return _locale.formattedDataSize(item.documentSize());
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -138,7 +140,8 @@ QHash<int, QByteArray> FileProviderMaterialisedItemsModel::roleNames() const
|
||||||
{ SharedRole, "shared" },
|
{ SharedRole, "shared" },
|
||||||
{ SharedByCurrentUserRole, "sharedByCurrentUser" },
|
{ SharedByCurrentUserRole, "sharedByCurrentUser" },
|
||||||
{ UserVisiblePathRole, "userVisiblePath" },
|
{ UserVisiblePathRole, "userVisiblePath" },
|
||||||
{ FileTypeRole, "fileType" },
|
{ FileTypeStringRole, "fileTypeString" },
|
||||||
|
{ FileSizeStringRole, "fileSizeString" },
|
||||||
});
|
});
|
||||||
return roleNames;
|
return roleNames;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#include "gui/macOS/fileprovideritemmetadata.h"
|
#include "gui/macOS/fileprovideritemmetadata.h"
|
||||||
|
|
||||||
|
@ -60,7 +61,8 @@ public:
|
||||||
SharedRole,
|
SharedRole,
|
||||||
SharedByCurrentUserRole,
|
SharedByCurrentUserRole,
|
||||||
UserVisiblePathRole,
|
UserVisiblePathRole,
|
||||||
FileTypeRole,
|
FileTypeStringRole,
|
||||||
|
FileSizeStringRole,
|
||||||
};
|
};
|
||||||
Q_ENUM(Roles)
|
Q_ENUM(Roles)
|
||||||
|
|
||||||
|
@ -80,6 +82,7 @@ public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVector<FileProviderItemMetadata> _items;
|
QVector<FileProviderItemMetadata> _items;
|
||||||
|
QLocale _locale;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Mac
|
} // namespace Mac
|
||||||
|
|
|
@ -32,9 +32,9 @@ Item {
|
||||||
required property string domainIdentifier
|
required property string domainIdentifier
|
||||||
required property string fileName
|
required property string fileName
|
||||||
required property string userVisiblePath
|
required property string userVisiblePath
|
||||||
required property string fileType
|
required property string fileTypeString
|
||||||
|
|
||||||
required property size documentSize
|
required property string fileSizeString
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: internalLayout
|
id: internalLayout
|
||||||
|
@ -73,12 +73,12 @@ Item {
|
||||||
|
|
||||||
EnforcedPlainTextLabel {
|
EnforcedPlainTextLabel {
|
||||||
id: fileSizeLabel
|
id: fileSizeLabel
|
||||||
text: root.documentSize
|
text: root.fileSizeString
|
||||||
}
|
}
|
||||||
|
|
||||||
EnforcedPlainTextLabel {
|
EnforcedPlainTextLabel {
|
||||||
id: fileTypeLabel
|
id: fileTypeLabel
|
||||||
text: root.fileType
|
text: root.fileTypeString
|
||||||
color: Style.ncSecondaryTextColor
|
color: Style.ncSecondaryTextColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue