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

switch EncapsulatedRfc822MessagePart to grantlee rendering

parent 2e3ac775
<table cellspacing="1" cellpadding="1" class="rfc822">
<tr class="rfc822H">
<td dir="{{block.dir}}">
{% if block.link %}
<a href="{{block.link}}">{% i18n "Encapsulated message" %}</a>
{% else %}
{% i18n "Encapsulated message" %}
{% endif %}
</td>
</tr>
<tr class="rfc822B">
<td>
{{msgHeader|safe}}
{{content|safe}}
</td>
</tr>
<tr class="rfc822H">
<td dir="{{block.dir}}">
{% i18n "End of encapsulated message" %}
</td>
</tr>
</table>
\ No newline at end of file
......@@ -92,50 +92,6 @@ void CryptoBlock::internalExit()
entered = false;
}
EncapsulatedRFC822Block::EncapsulatedRFC822Block(MimeTreeParser::HtmlWriter *writer, const MimeTreeParser::NodeHelper *nodeHelper, KMime::Content *node)
: mWriter(writer)
, mNodeHelper(nodeHelper)
, mNode(node)
{
internalEnter();
}
EncapsulatedRFC822Block::~EncapsulatedRFC822Block()
{
internalExit();
}
void EncapsulatedRFC822Block::internalEnter()
{
if (mWriter && !entered) {
QString text;
if (mNode) {
const QString href = mNodeHelper->asHREF(mNode, QStringLiteral("body"));
text = QStringLiteral("<a href=\"%1\">%2</a>").arg(href, i18n("Encapsulated message"));
} else {
text = i18n("Encapsulated message");
}
mWriter->queue(QStringLiteral("<table cellspacing=\"1\" cellpadding=\"1\" class=\"rfc822\">") +
QStringLiteral("<tr class=\"rfc822H\"><td dir=\"%1\">").arg(dir()) +
text +
QStringLiteral("</td></tr><tr class=\"rfc822B\"><td>"));
entered = true;
}
}
void EncapsulatedRFC822Block::internalExit()
{
if (!entered) {
return;
}
mWriter->queue(QStringLiteral("</td></tr>"
"<tr class=\"rfc822H\"><td dir=\"%1\">%2</td></tr>"
"</table>").arg(dir(), i18n("End of encapsulated message")));
entered = false;
}
EncryptedBlock::EncryptedBlock(MimeTreeParser::HtmlWriter *writer, const PartMetaData &block)
: mWriter(writer)
, mBlock(block)
......
......@@ -66,21 +66,6 @@ protected:
bool entered;
};
class EncapsulatedRFC822Block : public HTMLBlock
{
public:
EncapsulatedRFC822Block(MimeTreeParser::HtmlWriter *writer, const MimeTreeParser::NodeHelper *nodeHelper, KMime::Content *node);
virtual ~EncapsulatedRFC822Block();
private:
void internalEnter();
void internalExit();
HtmlWriter *mWriter;
const NodeHelper *mNodeHelper;
KMime::Content *mNode;
};
class EncryptedBlock : public HTMLBlock
{
public:
......
......@@ -1812,11 +1812,21 @@ void EncapsulatedRfc822MessagePart::html(bool decorate)
}
const HTMLBlock::Ptr aBlock(attachmentBlock());
const EncapsulatedRFC822Block block(mOtp->htmlWriter(), mOtp->nodeHelper(), mMessage.data());
writer->queue(mOtp->mSource->createMessageHeader(mMessage.data()));
renderInternalHtml(decorate);
mOtp->nodeHelper()->setPartMetaData(mNode, mMetaData);
Grantlee::Template t = getGrantleeTemplate(this, QStringLiteral("encapsulatedrfc822messagepart.html"));
Grantlee::Context c;
QObject block;
c.insert(QStringLiteral("block"), &block);
block.setProperty("dir", QApplication::isRightToLeft() ? QStringLiteral("rtl") : QStringLiteral("ltr"));
block.setProperty("link", mOtp->nodeHelper()->asHREF(mMessage.data(), QStringLiteral("body")));
c.insert(QStringLiteral("msgHeader"), mOtp->mSource->createMessageHeader(mMessage.data()));
c.insert(QStringLiteral("content"), internalContent());
const auto html = t->render(&c);
writer->queue(html);
}
QString EncapsulatedRfc822MessagePart::text() const
......
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