From 0c8424b2da76710a7903835c14347836e4e9e76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Wed, 9 Nov 2016 12:44:18 +0100 Subject: add IconRole for Attachments --- components/package/contents/ui/MailViewer.qml | 5 +++++ framework/domain/attachmentmodel.cpp | 6 +++++- framework/domain/messageparser.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/package/contents/ui/MailViewer.qml b/components/package/contents/ui/MailViewer.qml index d7581470..ecffa866 100644 --- a/components/package/contents/ui/MailViewer.qml +++ b/components/package/contents/ui/MailViewer.qml @@ -76,6 +76,11 @@ Item { title: "Type" width: 60 } + TableViewColumn { + role: "icon" + title: "Icon" + width: 60 + } TableViewColumn { role: "size" title: "Size" diff --git a/framework/domain/attachmentmodel.cpp b/framework/domain/attachmentmodel.cpp index 35e94e2e..e98c6fc0 100644 --- a/framework/domain/attachmentmodel.cpp +++ b/framework/domain/attachmentmodel.cpp @@ -20,6 +20,7 @@ #include "messageparser.h" #include "mimetreeparser/interface.h" +#include #include QString sizeHuman(const Content::Ptr &content) @@ -36,7 +37,7 @@ QString sizeHuman(const Content::Ptr &content) unit = i.next(); num /= 1024.0; } - + if (unit == "Bytes") { return QString().setNum(num) + " " + unit; } else { @@ -76,6 +77,7 @@ QHash AttachmentModel::roleNames() const roles[TypeRole] = "type"; roles[NameRole] = "name"; roles[SizeRole] = "size"; + roles[IconRole] = "icon"; roles[IsEncryptedRole] = "encrypted"; roles[IsSignedRole] = "signed"; return roles; @@ -111,6 +113,8 @@ QVariant AttachmentModel::data(const QModelIndex &index, int role) const return content->mailMime()->mimetype().name(); case NameRole: return entry->mailMime()->filename(); + case IconRole: + return QIcon::fromTheme(content->mailMime()->mimetype().iconName()); case SizeRole: return sizeHuman(content); case IsEncryptedRole: diff --git a/framework/domain/messageparser.h b/framework/domain/messageparser.h index 203f7576..036cff7d 100644 --- a/framework/domain/messageparser.h +++ b/framework/domain/messageparser.h @@ -136,6 +136,7 @@ public: public: enum Roles { TypeRole = Qt::UserRole + 1, + IconRole, NameRole, SizeRole, IsEncryptedRole, -- cgit v1.2.3