Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit e7916cf7 authored by Sandro Knauß's avatar Sandro Knauß

move createMessageHeader to MessageViewer

Summary:
as we need to execute the function from within the renderer, the
best way that came into my mind, was to use functional methods.

Test Plan: run tests

Reviewers: #kde_pim, vkrause

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D8891
parent 66d1d9fb
......@@ -380,7 +380,7 @@ void DefaultRendererPrivate::render(const EncapsulatedRfc822MessagePart::Ptr &mp
block.setProperty("link",
mp->nodeHelper()->asHREF(mp->message().data(), QStringLiteral("body")));
c.insert(QStringLiteral("msgHeader"), mp->source()->createMessageHeader(mp->message().data()));
c.insert(QStringLiteral("msgHeader"), mCreateMessageHeader(mp->message().data()));
c.insert(QStringLiteral("content"), QVariant::fromValue<GrantleeCallback>([this, mp, htmlWriter](Grantlee::OutputStream *) {
renderSubParts(mp, htmlWriter);
}));
......@@ -1117,6 +1117,11 @@ void DefaultRenderer::setHtmlLoadExternal(bool htmlLoadExternal)
d->mHtmlLoadExternal = htmlLoadExternal;
}
void DefaultRenderer::setCreateMessageHeader(std::function<QString(KMime::Message*)> createMessageHeader)
{
d->mCreateMessageHeader = createMessageHeader;
}
void DefaultRenderer::render(const MimeTreeParser::MessagePart::Ptr &msgPart, HtmlWriter *writer)
{
d->mMsgPart = msgPart;
......
......@@ -22,6 +22,12 @@
#include <QSharedPointer>
#include <functional>
namespace KMime {
class Message;
}
namespace MimeTreeParser {
class MessagePart;
typedef QSharedPointer<MessagePart> MessagePartPtr;
......@@ -47,6 +53,7 @@ public:
void setShowSignatureDetails(bool showSignatureDetails);
void setLevelQuote(int levelQuote);
void setHtmlLoadExternal(bool htmlLoadExternal);
void setCreateMessageHeader(std::function<QString(KMime::Message*)>);
void render(const MimeTreeParser::MessagePartPtr &msgPart, HtmlWriter *writer);
private:
DefaultRendererPrivate *d;
......
......@@ -70,6 +70,8 @@ public:
CSSHelperBase *mCSSHelper = nullptr;
const MessagePartRendererFactory *mRendererFactory = nullptr;
const AttachmentStrategy *mAttachmentStrategy = nullptr;
std::function<QString(KMime::Message*)> mCreateMessageHeader;
int mLevelQuote = 1;
bool mShowEmoticons = false;
......
......@@ -151,6 +151,7 @@ void EmptySource::render(const MimeTreeParser::MessagePartPtr &msgPart, bool sho
auto renderer = DefaultRenderer(cssHelper());
renderer.setAttachmentStrategy(attachmentStrategy());
renderer.setCreateMessageHeader(std::bind(&EmptySource::createMessageHeader, this, std::placeholders::_1));
renderer.setHtmlLoadExternal(htmlLoadExternal());
renderer.setIsPrinting(isPrinting());
renderer.setLevelQuote(levelQuote());
......
......@@ -41,7 +41,7 @@ public:
MimeTreeParser::Util::HtmlMode preferredMode() const override;
void setAllowDecryption(bool allowDecryption);
const QTextCodec *overrideCodec() override;
QString createMessageHeader(KMime::Message *message) override;
virtual QString createMessageHeader(KMime::Message *message);
bool autoImportKeys() const override;
const MimeTreeParser::BodyPartFormatterFactory *bodyPartFormatterFactory() override;
......
......@@ -88,12 +88,6 @@ public:
return nullptr;
}
QString createMessageHeader(KMime::Message *message) override
{
Q_UNUSED(message);
return QString(); //do nothing
}
void render(const MessagePart::Ptr &msgPart, bool showOnlyOneMimePart) override
{
Q_UNUSED(msgPart);
......
......@@ -62,8 +62,6 @@ public:
/** The override codec that should be used for the mail */
virtual const QTextCodec *overrideCodec() = 0;
virtual QString createMessageHeader(KMime::Message *message) = 0;
/** should keys be imported automatically **/
virtual bool autoImportKeys() const = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment