diff options
Diffstat (limited to 'framework/domain/messageparser.h')
-rw-r--r-- | framework/domain/messageparser.h | 72 |
1 files changed, 64 insertions, 8 deletions
diff --git a/framework/domain/messageparser.h b/framework/domain/messageparser.h index 3e0255df..b3d7537d 100644 --- a/framework/domain/messageparser.h +++ b/framework/domain/messageparser.h | |||
@@ -29,41 +29,45 @@ | |||
29 | #include <memory> | 29 | #include <memory> |
30 | #include <MimeTreeParser/MessagePart> | 30 | #include <MimeTreeParser/MessagePart> |
31 | 31 | ||
32 | namespace MimeTreeParser { | ||
33 | class NodeHelper; | ||
34 | }; | ||
35 | class QAbstractItemModel; | 32 | class QAbstractItemModel; |
36 | 33 | ||
34 | class Parser; | ||
35 | class Part; | ||
36 | typedef std::shared_ptr<Part> PartPtr; | ||
37 | class Content; | ||
38 | typedef std::shared_ptr<Content> ContentPtr; | ||
39 | class MessagePartPrivate; | ||
40 | |||
37 | class MessageParser : public QObject | 41 | class MessageParser : public QObject |
38 | { | 42 | { |
39 | Q_OBJECT | 43 | Q_OBJECT |
40 | Q_PROPERTY (QVariant message READ message WRITE setMessage) | 44 | Q_PROPERTY (QVariant message READ message WRITE setMessage) |
41 | Q_PROPERTY (QString html READ html NOTIFY htmlChanged) | 45 | Q_PROPERTY (QString html READ html NOTIFY htmlChanged) |
42 | Q_PROPERTY (QAbstractItemModel* partTree READ partTree NOTIFY htmlChanged) | 46 | Q_PROPERTY (QAbstractItemModel* partTree READ partTree NOTIFY htmlChanged) |
47 | Q_PROPERTY (QAbstractItemModel* newTree READ newTree NOTIFY htmlChanged) | ||
43 | 48 | ||
44 | public: | 49 | public: |
45 | explicit MessageParser(QObject *parent = Q_NULLPTR); | 50 | explicit MessageParser(QObject *parent = Q_NULLPTR); |
51 | ~MessageParser(); | ||
46 | 52 | ||
47 | QString html() const; | 53 | QString html() const; |
48 | 54 | ||
49 | QVariant message() const; | 55 | QVariant message() const; |
50 | void setMessage(const QVariant &to); | 56 | void setMessage(const QVariant &to); |
51 | QAbstractItemModel *partTree() const; | 57 | QAbstractItemModel *partTree() const; |
58 | QAbstractItemModel *newTree() const; | ||
52 | 59 | ||
53 | signals: | 60 | signals: |
54 | void htmlChanged(); | 61 | void htmlChanged(); |
55 | 62 | ||
56 | private: | 63 | private: |
57 | QSharedPointer<MimeTreeParser::MessagePart> mPartTree; | 64 | std::unique_ptr<MessagePartPrivate> d; |
58 | QString mHtml; | ||
59 | QMap<QByteArray, QUrl> mEmbeddedPartMap; | ||
60 | std::shared_ptr<MimeTreeParser::NodeHelper> mNodeHelper; | ||
61 | }; | 65 | }; |
62 | 66 | ||
63 | class PartModel : public QAbstractItemModel { | 67 | class PartModel : public QAbstractItemModel { |
64 | Q_OBJECT | 68 | Q_OBJECT |
65 | public: | 69 | public: |
66 | PartModel(QSharedPointer<MimeTreeParser::MessagePart> partTree, QMap<QByteArray, QUrl> embeddedPartMap); | 70 | PartModel(QSharedPointer<MimeTreeParser::MessagePart> partTree, std::shared_ptr<Parser> parser); |
67 | 71 | ||
68 | public: | 72 | public: |
69 | enum Roles { | 73 | enum Roles { |
@@ -86,5 +90,57 @@ public: | |||
86 | private: | 90 | private: |
87 | QSharedPointer<MimeTreeParser::MessagePart> mPartTree; | 91 | QSharedPointer<MimeTreeParser::MessagePart> mPartTree; |
88 | QMap<QByteArray, QUrl> mEmbeddedPartMap; | 92 | QMap<QByteArray, QUrl> mEmbeddedPartMap; |
93 | std::shared_ptr<Parser> mParser; | ||
94 | }; | ||
95 | |||
96 | |||
97 | class NewContentModel : public QAbstractItemModel { | ||
98 | Q_OBJECT | ||
99 | public: | ||
100 | NewContentModel (const PartPtr &part); | ||
101 | |||
102 | public: | ||
103 | enum Roles { | ||
104 | TypeRole = Qt::UserRole + 1, | ||
105 | ContentRole, | ||
106 | IsEmbededRole, | ||
107 | SecurityLevelRole | ||
108 | }; | ||
109 | |||
110 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; | ||
111 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
112 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; | ||
113 | QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; | ||
114 | int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
115 | int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
116 | |||
117 | private: | ||
118 | const PartPtr &mPart; | ||
119 | }; | ||
120 | |||
121 | class NewModel : public QAbstractItemModel { | ||
122 | Q_OBJECT | ||
123 | public: | ||
124 | NewModel(std::shared_ptr<Parser> parser); | ||
125 | |||
126 | public: | ||
127 | enum Roles { | ||
128 | TypeRole = Qt::UserRole + 1, | ||
129 | ContentsRole, | ||
130 | IsEmbededRole, | ||
131 | SecurityLevelRole | ||
132 | }; | ||
133 | |||
134 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; | ||
135 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
136 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; | ||
137 | QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; | ||
138 | int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
139 | int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
140 | |||
141 | private: | ||
142 | std::shared_ptr<Parser> mParser; | ||
143 | QVector<PartPtr> mParts; | ||
144 | QMap<Part *, std::shared_ptr<NewContentModel>> mContentMap; | ||
89 | }; | 145 | }; |
90 | 146 | ||