Differential D8104 Diff 20291 messageviewer/src/messagepartthemes/default/plugins/attachmentmessagepartrenderer.cpp
Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/messagepartthemes/default/plugins/attachmentmessagepartrenderer.cpp
Show All 27 Lines | |||||
28 | 28 | | |||
29 | #include <MessageCore/StringUtil> | 29 | #include <MessageCore/StringUtil> | ||
30 | #include <MimeTreeParser/HtmlWriter> | 30 | #include <MimeTreeParser/HtmlWriter> | ||
31 | 31 | | |||
32 | #include <KIconLoader> | 32 | #include <KIconLoader> | ||
33 | #include <KLocalizedString> | 33 | #include <KLocalizedString> | ||
34 | #include <QUrl> | 34 | #include <QUrl> | ||
35 | 35 | | |||
36 | using namespace MessageViewer; | ||||
37 | | ||||
36 | AttachmentMessagePartRenderer::AttachmentMessagePartRenderer() | 38 | AttachmentMessagePartRenderer::AttachmentMessagePartRenderer() | ||
37 | { | 39 | { | ||
38 | } | 40 | } | ||
39 | 41 | | |||
40 | AttachmentMessagePartRenderer::~AttachmentMessagePartRenderer() | 42 | AttachmentMessagePartRenderer::~AttachmentMessagePartRenderer() | ||
41 | { | 43 | { | ||
42 | } | 44 | } | ||
43 | 45 | | |||
44 | bool AttachmentMessagePartRenderer::render(MimeTreeParser::DefaultRendererPrivate* drp, const MimeTreeParser::MessagePartPtr& msgPart, MimeTreeParser::HtmlWriter* htmlWriter) const | 46 | bool AttachmentMessagePartRenderer::render(const MimeTreeParser::MessagePartPtr& msgPart, MimeTreeParser::HtmlWriter* htmlWriter, RenderContext *context) const | ||
45 | { | 47 | { | ||
46 | auto mp = msgPart.dynamicCast<AttachmentMessagePart>(); | 48 | auto mp = msgPart.dynamicCast<AttachmentMessagePart>(); | ||
47 | if (!mp) { | 49 | if (!mp) { | ||
48 | return false; | 50 | return false; | ||
49 | } | 51 | } | ||
50 | 52 | | |||
51 | KMime::Content *node = mp->content(); | 53 | KMime::Content *node = mp->content(); | ||
52 | NodeHelper *nodeHelper = mp->mOtp->nodeHelper(); | 54 | NodeHelper *nodeHelper = mp->mOtp->nodeHelper(); | ||
53 | 55 | | |||
54 | if (mp->isHidden()) { | 56 | if (mp->isHidden()) { | ||
55 | return true; | 57 | return true; | ||
56 | } | 58 | } | ||
57 | 59 | | |||
58 | const auto tmpAsIcon = mp->asIcon(); | 60 | const auto tmpAsIcon = mp->asIcon(); | ||
59 | 61 | | |||
60 | if (tmpAsIcon == MimeTreeParser::NoIcon) { | 62 | if (tmpAsIcon == MimeTreeParser::NoIcon) { | ||
61 | return drp->renderWithFactory(QStringLiteral("MimeTreeParser::TextMessagePart"), mp, htmlWriter); | 63 | return context->renderWithFactory(QStringLiteral("MimeTreeParser::TextMessagePart"), mp, htmlWriter); | ||
62 | } | 64 | } | ||
63 | 65 | | |||
64 | Grantlee::Template t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral( | 66 | Grantlee::Template t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral( | ||
65 | ":/asiconpart.html")); | 67 | ":/asiconpart.html")); | ||
66 | Grantlee::Context c = MessageViewer::MessagePartRendererManager::self()->createContext(); | 68 | Grantlee::Context c = MessageViewer::MessagePartRendererManager::self()->createContext(); | ||
67 | QObject block; | 69 | QObject block; | ||
68 | c.insert(QStringLiteral("block"), &block); | 70 | c.insert(QStringLiteral("block"), &block); | ||
69 | 71 | | |||
70 | block.setProperty("showTextFrame", mp->showTextFrame()); | 72 | block.setProperty("showTextFrame", mp->showTextFrame()); | ||
71 | block.setProperty("label", | 73 | block.setProperty("label", | ||
72 | MessageCore::StringUtil::quoteHtmlChars(NodeHelper::fileName(node), true)); | 74 | MessageCore::StringUtil::quoteHtmlChars(NodeHelper::fileName(node), true)); | ||
73 | block.setProperty("comment", | 75 | block.setProperty("comment", | ||
74 | MessageCore::StringUtil::quoteHtmlChars(node->contentDescription()-> | 76 | MessageCore::StringUtil::quoteHtmlChars(node->contentDescription()-> | ||
75 | asUnicodeString(), true)); | 77 | asUnicodeString(), true)); | ||
76 | block.setProperty("link", nodeHelper->asHREF(node, QStringLiteral("body"))); | 78 | block.setProperty("link", nodeHelper->asHREF(node, QStringLiteral("body"))); | ||
77 | block.setProperty("showLink", mp->showLink()); | 79 | block.setProperty("showLink", mp->showLink()); | ||
78 | block.setProperty("dir", drp->alignText()); | 80 | block.setProperty("dir", alignText()); | ||
79 | block.setProperty("iconSize", | 81 | block.setProperty("iconSize", | ||
80 | MessageViewer::MessagePartRendererManager::self()->iconCurrentSize()); | 82 | MessageViewer::MessagePartRendererManager::self()->iconCurrentSize()); | ||
81 | block.setProperty("inline", (tmpAsIcon == MimeTreeParser::IconInline)); | 83 | block.setProperty("inline", (tmpAsIcon == MimeTreeParser::IconInline)); | ||
82 | 84 | | |||
83 | QString iconPath; | 85 | QString iconPath; | ||
84 | if (tmpAsIcon == MimeTreeParser::IconInline) { | 86 | if (tmpAsIcon == MimeTreeParser::IconInline) { | ||
85 | iconPath = nodeHelper->writeNodeToTempFile(node); | 87 | iconPath = nodeHelper->writeNodeToTempFile(node); | ||
86 | } else { | 88 | } else { | ||
Show All 35 Lines |