summaryrefslogtreecommitdiffstats
path: root/framework/domain/messageparser.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/domain/messageparser.h')
-rw-r--r--framework/domain/messageparser.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/framework/domain/messageparser.h b/framework/domain/messageparser.h
index 72b55a5a..ac14fad9 100644
--- a/framework/domain/messageparser.h
+++ b/framework/domain/messageparser.h
@@ -22,17 +22,24 @@
22#include <QObject> 22#include <QObject>
23#include <QString> 23#include <QString>
24#include <QStringList> 24#include <QStringList>
25
26#include <QAbstractItemModel>
27#include <QModelIndex>
28
25#include <memory> 29#include <memory>
30#include <MimeTreeParser/MessagePart>
26 31
27namespace MimeTreeParser { 32namespace MimeTreeParser {
28 class NodeHelper; 33 class NodeHelper;
29}; 34};
35class QAbstractItemModel;
30 36
31class MessageParser : public QObject 37class MessageParser : public QObject
32{ 38{
33 Q_OBJECT 39 Q_OBJECT
34 Q_PROPERTY (QVariant message READ message WRITE setMessage) 40 Q_PROPERTY (QVariant message READ message WRITE setMessage)
35 Q_PROPERTY (QString html READ html NOTIFY htmlChanged) 41 Q_PROPERTY (QString html READ html NOTIFY htmlChanged)
42 Q_PROPERTY (QAbstractItemModel* partTree READ partTree NOTIFY htmlChanged)
36 43
37public: 44public:
38 explicit MessageParser(QObject *parent = Q_NULLPTR); 45 explicit MessageParser(QObject *parent = Q_NULLPTR);
@@ -41,11 +48,42 @@ public:
41 48
42 QVariant message() const; 49 QVariant message() const;
43 void setMessage(const QVariant &to); 50 void setMessage(const QVariant &to);
51 QAbstractItemModel *partTree() const;
44 52
45signals: 53signals:
46 void htmlChanged(); 54 void htmlChanged();
47 55
48private: 56private:
57 QSharedPointer<MimeTreeParser::MessagePart> mPartTree;
49 QString mHtml; 58 QString mHtml;
59 QMap<QByteArray, QUrl> mEmbeddedPartMap;
50 std::shared_ptr<MimeTreeParser::NodeHelper> mNodeHelper; 60 std::shared_ptr<MimeTreeParser::NodeHelper> mNodeHelper;
51}; 61};
62
63class PartModel : public QAbstractItemModel {
64 Q_OBJECT
65public:
66 PartModel(QSharedPointer<MimeTreeParser::MessagePart> partTree, QMap<QByteArray, QUrl> embeddedPartMap);
67
68public:
69 enum Roles {
70 Text = Qt::UserRole + 1,
71 IsHtml,
72 IsEncrypted,
73 IsAttachment,
74 HasContent,
75 Type
76 };
77
78 QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
79 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
80 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
81 QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE;
82 int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
83 int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
84
85private:
86 QSharedPointer<MimeTreeParser::MessagePart> mPartTree;
87 QMap<QByteArray, QUrl> mEmbeddedPartMap;
88};
89