Improve the file delegate
- cleaner code - supports stopping downloads - utilises the mimetype in order to display an icon - better size formatting - tooltips
This commit is contained in:
@@ -610,7 +610,7 @@ void Controller::openOrCreateDirectChat(NeoChatUser *user)
|
||||
|
||||
QString Controller::formatByteSize(double size, int precision) const
|
||||
{
|
||||
return KFormat().formatByteSize(size, precision);
|
||||
return QLocale().formattedDataSize(size, precision);
|
||||
}
|
||||
|
||||
QString Controller::formatDuration(quint64 msecs, KFormat::DurationFormatOptions options) const
|
||||
|
||||
@@ -37,6 +37,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
|
||||
roles[HighlightRole] = "isHighlighted";
|
||||
roles[SpecialMarksRole] = "marks";
|
||||
roles[LongOperationRole] = "progressInfo";
|
||||
roles[FileMimetypeIcon] = "fileMimetypeIcon";
|
||||
roles[AnnotationRole] = "annotation";
|
||||
roles[EventResolvedTypeRole] = "eventResolvedType";
|
||||
roles[ReplyRole] = "reply";
|
||||
@@ -536,6 +537,15 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
||||
return m_currentRoom->isEventHighlighted(&evt);
|
||||
}
|
||||
|
||||
if (role == FileMimetypeIcon) {
|
||||
auto e = eventCast<const RoomMessageEvent>(&evt);
|
||||
if (!e || !e->hasFileContent()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
return e->content()->fileInfo()->mimeType.iconName();
|
||||
}
|
||||
|
||||
if (role == SpecialMarksRole) {
|
||||
if (isPending) {
|
||||
return pendingIt->deliveryStatus();
|
||||
|
||||
@@ -30,6 +30,8 @@ public:
|
||||
UserMarkerRole,
|
||||
FormattedBodyRole,
|
||||
|
||||
FileMimetypeIcon,
|
||||
|
||||
ReplyRole,
|
||||
|
||||
ShowAuthorRole,
|
||||
|
||||
Reference in New Issue
Block a user