diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-23 21:00:50 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-23 21:00:50 +0200 |
commit | 31bf3102fe8f8cdd3f1448f0f22f182d0c2820d2 (patch) | |
tree | b5b508c3f065e0f51c8ce40aaf97d7070b5f9ef5 /framework/src/domain/mime/messageparser.h | |
parent | 1948369d4da2d0bc23b6af93683982b0e65d4992 (diff) | |
download | kube-31bf3102fe8f8cdd3f1448f0f22f182d0c2820d2.tar.gz kube-31bf3102fe8f8cdd3f1448f0f22f182d0c2820d2.zip |
Moved MIME related stuff to a mime subdir
Diffstat (limited to 'framework/src/domain/mime/messageparser.h')
-rw-r--r-- | framework/src/domain/mime/messageparser.h | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/framework/src/domain/mime/messageparser.h b/framework/src/domain/mime/messageparser.h new file mode 100644 index 00000000..de4d8838 --- /dev/null +++ b/framework/src/domain/mime/messageparser.h | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include <QObject> | ||
23 | #include <QString> | ||
24 | #include <QStringList> | ||
25 | |||
26 | #include <QAbstractItemModel> | ||
27 | #include <QModelIndex> | ||
28 | |||
29 | #include <memory> | ||
30 | |||
31 | class QAbstractItemModel; | ||
32 | |||
33 | class Parser; | ||
34 | class MessagePartPrivate; | ||
35 | |||
36 | class NewModelPrivate; | ||
37 | class AttachmentModelPrivate; | ||
38 | |||
39 | class MessageParser : public QObject | ||
40 | { | ||
41 | Q_OBJECT | ||
42 | Q_PROPERTY (QVariant message READ message WRITE setMessage) | ||
43 | Q_PROPERTY (QAbstractItemModel* newTree READ newTree NOTIFY htmlChanged) | ||
44 | Q_PROPERTY (QAbstractItemModel* attachments READ attachments NOTIFY htmlChanged) | ||
45 | |||
46 | public: | ||
47 | explicit MessageParser(QObject *parent = Q_NULLPTR); | ||
48 | ~MessageParser(); | ||
49 | |||
50 | QVariant message() const; | ||
51 | void setMessage(const QVariant &to); | ||
52 | QAbstractItemModel *newTree() const; | ||
53 | QAbstractItemModel *attachments() const; | ||
54 | |||
55 | signals: | ||
56 | void htmlChanged(); | ||
57 | |||
58 | private: | ||
59 | std::unique_ptr<MessagePartPrivate> d; | ||
60 | }; | ||
61 | |||
62 | class NewModel : public QAbstractItemModel { | ||
63 | Q_OBJECT | ||
64 | public: | ||
65 | NewModel(std::shared_ptr<Parser> parser); | ||
66 | ~NewModel(); | ||
67 | |||
68 | public: | ||
69 | enum Roles { | ||
70 | TypeRole = Qt::UserRole + 1, | ||
71 | ContentsRole, | ||
72 | ContentRole, | ||
73 | IsComplexHtmlContentRole, | ||
74 | IsEmbededRole, | ||
75 | SecurityLevelRole, | ||
76 | EncryptionErrorType, | ||
77 | EncryptionErrorString | ||
78 | }; | ||
79 | |||
80 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; | ||
81 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
82 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; | ||
83 | QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; | ||
84 | int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
85 | int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
86 | |||
87 | private: | ||
88 | std::unique_ptr<NewModelPrivate> d; | ||
89 | }; | ||
90 | |||
91 | class AttachmentModel : public QAbstractItemModel { | ||
92 | Q_OBJECT | ||
93 | public: | ||
94 | AttachmentModel(std::shared_ptr<Parser> parser); | ||
95 | ~AttachmentModel(); | ||
96 | |||
97 | public: | ||
98 | enum Roles { | ||
99 | TypeRole = Qt::UserRole + 1, | ||
100 | IconRole, | ||
101 | NameRole, | ||
102 | SizeRole, | ||
103 | IsEncryptedRole, | ||
104 | IsSignedRole | ||
105 | }; | ||
106 | |||
107 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; | ||
108 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
109 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; | ||
110 | QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE; | ||
111 | int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
112 | int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||
113 | |||
114 | private: | ||
115 | std::unique_ptr<AttachmentModelPrivate> d; | ||
116 | }; | ||