Changeset View
Changeset View
Standalone View
Standalone View
framework/domain/mimetreeparser/stringhtmlwriter.h
- This file was added.
1 | /* -*- c++ -*- | ||||
---|---|---|---|---|---|
2 | | ||||
3 | Copyright (c) 2016 Sandro Knauß <sknauss@kde.org> | ||||
4 | | ||||
5 | Kube is free software; you can redistribute it and/or modify it | ||||
6 | under the terms of the GNU General Public License, version 2, as | ||||
7 | published by the Free Software Foundation. | ||||
8 | | ||||
9 | Kube is distributed in the hope that it will be useful, but | ||||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU General Public License | ||||
15 | along with this program; if not, write to the Free Software | ||||
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
17 | | ||||
18 | In addition, as a special exception, the copyright holders give | ||||
19 | permission to link the code of this program with any edition of | ||||
20 | the Qt library by Trolltech AS, Norway (or with modified versions | ||||
21 | of Qt that use the same license as Qt), and distribute linked | ||||
22 | combinations including the two. You must obey the GNU General | ||||
23 | Public License in all respects for all of the code used other than | ||||
24 | Qt. If you modify this file, you may extend this exception to | ||||
25 | your version of the file, but you are not obligated to do so. If | ||||
26 | you do not wish to do so, delete this exception statement from | ||||
27 | your version. | ||||
28 | */ | ||||
29 | | ||||
30 | #ifndef __KUBE_FRAMEWORK_MAIL_STRINGHTMLWRITER_H__ | ||||
31 | #define __KUBE_FRAMEWORK_MAIL_STRINGHTMLWRITER_H__ | ||||
32 | | ||||
33 | #include <MimeTreeParser/HtmlWriter> | ||||
34 | | ||||
35 | #include <QFile> | ||||
36 | #include <QTextStream> | ||||
37 | | ||||
38 | class QString; | ||||
39 | | ||||
40 | class StringHtmlWriter : public MimeTreeParser::HtmlWriter | ||||
41 | { | ||||
42 | public: | ||||
43 | explicit StringHtmlWriter(); | ||||
44 | virtual ~StringHtmlWriter(); | ||||
45 | | ||||
46 | void begin(const QString &cssDefs) Q_DECL_OVERRIDE; | ||||
47 | void end() Q_DECL_OVERRIDE; | ||||
48 | void reset() Q_DECL_OVERRIDE; | ||||
49 | void write(const QString &str) Q_DECL_OVERRIDE; | ||||
50 | void queue(const QString &str) Q_DECL_OVERRIDE; | ||||
51 | void flush() Q_DECL_OVERRIDE; | ||||
52 | void embedPart(const QByteArray &contentId, const QString &url) Q_DECL_OVERRIDE; | ||||
53 | void extraHead(const QString &str) Q_DECL_OVERRIDE; | ||||
54 | | ||||
55 | QString html() const; | ||||
56 | QMap<QByteArray, QUrl> embeddedParts() const; | ||||
57 | private: | ||||
58 | void insertExtraHead(); | ||||
59 | void resolveCidUrls(); | ||||
60 | | ||||
61 | QString mHtml; | ||||
62 | QString mExtraHead; | ||||
63 | enum State { | ||||
64 | Begun, | ||||
65 | Queued, | ||||
66 | Ended | ||||
67 | } mState; | ||||
68 | QMap<QByteArray, QUrl> mEmbeddedPartMap; | ||||
69 | }; | ||||
70 | | ||||
71 | #endif // __MESSAGEVIEWER_FILEHTMLWRITER_H__ |