summaryrefslogtreecommitdiffstats
path: root/framework/mail/maillistmodel.cpp
diff options
context:
space:
mode:
authorSandro Knauß <sknauss@kde.org>2016-01-15 13:02:24 +0100
committerSandro Knauß <sknauss@kde.org>2016-01-15 13:02:24 +0100
commite8ce86ccdf23fad155cf4888cb4db657b99c8bd7 (patch)
tree5f7ea27cd3ec3ead3361b8ee9ccfdb4048a6d5d3 /framework/mail/maillistmodel.cpp
parent06201e4d405cef119207b528f76f8f993c09e527 (diff)
downloadkube-e8ce86ccdf23fad155cf4888cb4db657b99c8bd7.tar.gz
kube-e8ce86ccdf23fad155cf4888cb4db657b99c8bd7.zip
Render HTML directly to string and not via indirecton of a file
Diffstat (limited to 'framework/mail/maillistmodel.cpp')
-rw-r--r--framework/mail/maillistmodel.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/framework/mail/maillistmodel.cpp b/framework/mail/maillistmodel.cpp
index c37e2be4..d3b60187 100644
--- a/framework/mail/maillistmodel.cpp
+++ b/framework/mail/maillistmodel.cpp
@@ -1,6 +1,6 @@
1#include "maillistmodel.h" 1#include "maillistmodel.h"
2 2
3#include "filehtmlwriter.h" 3#include "stringhtmlwriter.h"
4#include "objecttreesource.h" 4#include "objecttreesource.h"
5 5
6#include <QFile> 6#include <QFile>
@@ -78,8 +78,7 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const
78 msg->parse(); 78 msg->parse();
79 79
80 // render the mail 80 // render the mail
81 const QString fname("/tmp/test.html"); 81 StringHtmlWriter htmlWriter;
82 FileHtmlWriter htmlWriter(fname);
83 QImage paintDevice; 82 QImage paintDevice;
84 MessageViewer::CSSHelper cssHelper(&paintDevice); 83 MessageViewer::CSSHelper cssHelper(&paintDevice);
85 MessageViewer::NodeHelper nodeHelper; 84 MessageViewer::NodeHelper nodeHelper;
@@ -92,16 +91,9 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const
92 otp.parseObjectTree(msg.data()); 91 otp.parseObjectTree(msg.data());
93 92
94 htmlWriter.queue(QStringLiteral("</body></html>")); 93 htmlWriter.queue(QStringLiteral("</body></html>"));
95 htmlWriter.flush();
96 htmlWriter.end(); 94 htmlWriter.end();
97 95
98 QFile file(fname); 96 return htmlWriter.html();
99 if (file.open(QFile::ReadOnly)) {
100 const auto content = file.readAll();
101 return content;
102 } else {
103 qWarning() << "Failed to open the file";
104 }
105 } else { 97 } else {
106 qWarning() << "Failed to open the file"; 98 qWarning() << "Failed to open the file";
107 } 99 }