Differential D8170 Diff 20723 messageviewer/src/messagepartthemes/default/plugins/attachmentmessagepartrenderer.cpp
Changeset View
Changeset View
Standalone View
Standalone View
messageviewer/src/messagepartthemes/default/plugins/attachmentmessagepartrenderer.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
45 | bool AttachmentMessagePartRenderer::render(const MimeTreeParser::MessagePartPtr &msgPart, MimeTreeParser::HtmlWriter *htmlWriter, RenderContext *context) const | 45 | bool AttachmentMessagePartRenderer::render(const MimeTreeParser::MessagePartPtr &msgPart, MimeTreeParser::HtmlWriter *htmlWriter, RenderContext *context) const | ||
46 | { | 46 | { | ||
47 | auto mp = msgPart.dynamicCast<AttachmentMessagePart>(); | 47 | auto mp = msgPart.dynamicCast<AttachmentMessagePart>(); | ||
48 | if (!mp) { | 48 | if (!mp) { | ||
49 | return false; | 49 | return false; | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | KMime::Content *node = mp->content(); | 52 | KMime::Content *node = mp->content(); | ||
53 | NodeHelper *nodeHelper = mp->mOtp->nodeHelper(); | | |||
54 | | ||||
55 | if (mp->isHidden()) { | 53 | if (mp->isHidden()) { | ||
56 | return true; | 54 | return true; | ||
57 | } | 55 | } | ||
58 | 56 | | |||
59 | const auto tmpAsIcon = mp->asIcon(); | 57 | const auto tmpAsIcon = mp->asIcon(); | ||
60 | 58 | | |||
61 | if (tmpAsIcon == MimeTreeParser::NoIcon) { | 59 | if (tmpAsIcon == MimeTreeParser::NoIcon) { | ||
62 | return context->renderWithFactory(QStringLiteral("MimeTreeParser::TextMessagePart"), mp, htmlWriter); | 60 | return context->renderWithFactory(QStringLiteral("MimeTreeParser::TextMessagePart"), mp, htmlWriter); | ||
63 | } | 61 | } | ||
64 | 62 | | |||
65 | Grantlee::Template t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral( | 63 | Grantlee::Template t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral( | ||
66 | ":/asiconpart.html")); | 64 | ":/asiconpart.html")); | ||
67 | Grantlee::Context c = MessageViewer::MessagePartRendererManager::self()->createContext(); | 65 | Grantlee::Context c = MessageViewer::MessagePartRendererManager::self()->createContext(); | ||
68 | c.insert(QStringLiteral("block"), msgPart.data()); | 66 | c.insert(QStringLiteral("block"), msgPart.data()); | ||
69 | 67 | | |||
70 | msgPart->setProperty("inline", (tmpAsIcon == MimeTreeParser::IconInline)); | 68 | msgPart->setProperty("inline", (tmpAsIcon == MimeTreeParser::IconInline)); | ||
71 | 69 | | |||
72 | QString iconPath; | 70 | QString iconPath; | ||
73 | if (tmpAsIcon == MimeTreeParser::IconInline) { | 71 | if (tmpAsIcon == MimeTreeParser::IconInline) { | ||
74 | iconPath = nodeHelper->writeNodeToTempFile(node); | 72 | iconPath = mp->temporaryFilePath(); | ||
75 | } else { | 73 | } else { | ||
76 | iconPath = MessageViewer::Util::iconPathForContent(node, KIconLoader::Desktop); | 74 | iconPath = MessageViewer::Util::iconPathForContent(node, KIconLoader::Desktop); | ||
77 | if (iconPath.right(14) == QLatin1String("mime_empty.png")) { | 75 | if (iconPath.right(14) == QLatin1String("mime_empty.png")) { | ||
78 | nodeHelper->magicSetType(node); | 76 | NodeHelper::magicSetType(node); | ||
79 | iconPath = MessageViewer::Util::iconPathForContent(node, KIconLoader::Desktop); | 77 | iconPath = MessageViewer::Util::iconPathForContent(node, KIconLoader::Desktop); | ||
80 | } | 78 | } | ||
81 | } | 79 | } | ||
82 | msgPart->setProperty("iconPath", QUrl::fromLocalFile(iconPath).url()); | 80 | msgPart->setProperty("iconPath", QUrl::fromLocalFile(iconPath).url()); | ||
83 | 81 | | |||
84 | Grantlee::OutputStream s(htmlWriter->stream()); | 82 | Grantlee::OutputStream s(htmlWriter->stream()); | ||
85 | t->render(&s, &c); | 83 | t->render(&s, &c); | ||
86 | return true; | 84 | return true; | ||
87 | } | 85 | } |