diff options
Diffstat (limited to 'framework/domain/messageparser.h')
-rw-r--r-- | framework/domain/messageparser.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/framework/domain/messageparser.h b/framework/domain/messageparser.h index 9469f2b5..b3d7537d 100644 --- a/framework/domain/messageparser.h +++ b/framework/domain/messageparser.h | |||
@@ -32,6 +32,10 @@ | |||
32 | class QAbstractItemModel; | 32 | class QAbstractItemModel; |
33 | 33 | ||
34 | class Parser; | 34 | class Parser; |
35 | class Part; | ||
36 | typedef std::shared_ptr<Part> PartPtr; | ||
37 | class Content; | ||
38 | typedef std::shared_ptr<Content> ContentPtr; | ||
35 | class MessagePartPrivate; | 39 | class MessagePartPrivate; |
36 | 40 | ||
37 | class MessageParser : public QObject | 41 | class MessageParser : public QObject |
@@ -40,6 +44,7 @@ class MessageParser : public QObject | |||
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); |
@@ -50,6 +55,7 @@ public: | |||
50 | QVariant message() const; | 55 | QVariant message() const; |
51 | void setMessage(const QVariant &to); | 56 | void setMessage(const QVariant &to); |
52 | QAbstractItemModel *partTree() const; | 57 | QAbstractItemModel *partTree() const; |
58 | QAbstractItemModel *newTree() const; | ||
53 | 59 | ||
54 | signals: | 60 | signals: |
55 | void htmlChanged(); | 61 | void htmlChanged(); |
@@ -87,3 +93,54 @@ private: | |||
87 | std::shared_ptr<Parser> mParser; | 93 | std::shared_ptr<Parser> mParser; |
88 | }; | 94 | }; |
89 | 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; | ||
145 | }; | ||
146 | |||