From 026278f1cf0c692b8ba134c84c26da5bb8274d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Tue, 8 Nov 2016 16:11:02 +0100 Subject: Add AttachmentModel for viewer --- framework/domain/messageparser.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'framework/domain/messageparser.h') diff --git a/framework/domain/messageparser.h b/framework/domain/messageparser.h index 559fa6f9..203f7576 100644 --- a/framework/domain/messageparser.h +++ b/framework/domain/messageparser.h @@ -41,6 +41,7 @@ typedef std::shared_ptr ContentPtr; class MessagePartPrivate; class NewModelPrivate; +class AttachmentModelPrivate; class MessageParser : public QObject { @@ -49,6 +50,7 @@ class MessageParser : public QObject Q_PROPERTY (QString html READ html NOTIFY htmlChanged) Q_PROPERTY (QAbstractItemModel* partTree READ partTree NOTIFY htmlChanged) Q_PROPERTY (QAbstractItemModel* newTree READ newTree NOTIFY htmlChanged) + Q_PROPERTY (QAbstractItemModel* attachments READ attachments NOTIFY htmlChanged) public: explicit MessageParser(QObject *parent = Q_NULLPTR); @@ -60,6 +62,7 @@ public: void setMessage(const QVariant &to); QAbstractItemModel *partTree() const; QAbstractItemModel *newTree() const; + QAbstractItemModel *attachments() const; signals: void htmlChanged(); @@ -124,3 +127,28 @@ private: std::unique_ptr d; }; +class AttachmentModel : public QAbstractItemModel { + Q_OBJECT +public: + AttachmentModel(std::shared_ptr parser); + ~AttachmentModel(); + +public: + enum Roles { + TypeRole = Qt::UserRole + 1, + NameRole, + SizeRole, + IsEncryptedRole, + IsSignedRole + }; + + QHash roleNames() const Q_DECL_OVERRIDE; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; + QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; + int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; + +private: + std::unique_ptr d; +}; -- cgit v1.2.3