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

move more rendering specific parts to MessageViewer

Summary: there are more renderer specific settings inside ObjectTreeSource.

Test Plan: run tests

Reviewers: #kde_pim, vkrause

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D8890
parent 69411a52
......@@ -67,11 +67,31 @@ public:
return false;
}
bool isPrinting() const override
{
return false;
}
bool htmlLoadExternal() const override
{
return false;
}
bool showExpandQuotesMark() const override
{
return mShowExpandQuotesMark;
}
bool showOnlyOneMimePart() const override
{
return false;
}
bool showSignatureDetails() const override
{
return false;
}
int levelQuote() const override
{
return mLevelQuote;
......
......@@ -404,10 +404,9 @@ void DefaultRendererPrivate::render(const HtmlMessagePart::Ptr &mp, HtmlWriter *
auto preferredMode = mp->source()->preferredMode();
bool isHtmlPreferred = (preferredMode == MimeTreeParser::Util::Html) || (preferredMode == MimeTreeParser::Util::MultipartHtml);
const bool isPrinting = mp->source()->isPrinting();
block.setProperty("htmlMail", isHtmlPreferred);
block.setProperty("loadExternal", mp->source()->htmlLoadExternal());
block.setProperty("isPrinting", isPrinting);
block.setProperty("loadExternal", htmlLoadExternal());
block.setProperty("isPrinting", isPrinting());
{
QString extraHead;
//laurent: FIXME port to async method webengine
......@@ -518,7 +517,7 @@ void DefaultRendererPrivate::renderSigned(const SignedMessagePart::Ptr &mp, Html
block.setProperty("inProgress", metaData.inProgress);
block.setProperty("errorText", metaData.errorText);
block.setProperty("detailHeader", mp->source()->showSignatureDetails());
block.setProperty("detailHeader", showSignatureDetails());
block.setProperty("printing", false);
block.setProperty("addr", metaData.signerMailAddresses.join(QLatin1Char(',')));
block.setProperty("technicalProblem", metaData.technicalProblem);
......@@ -1039,6 +1038,17 @@ bool DefaultRendererPrivate::showEmoticons() const
return mShowEmoticons;
}
bool DefaultRendererPrivate::isPrinting() const
{
return mIsPrinting;
}
bool DefaultRendererPrivate::htmlLoadExternal() const
{
return mHtmlLoadExternal;
}
bool DefaultRendererPrivate::showExpandQuotesMark() const
{
return mShowExpandQuotesMark;
......@@ -1049,6 +1059,11 @@ bool DefaultRendererPrivate::showOnlyOneMimePart() const
return mShowOnlyOneMimePart;
}
bool DefaultRendererPrivate::showSignatureDetails() const
{
return mShowSignatureDetails;
}
int DefaultRendererPrivate::levelQuote() const
{
return mLevelQuote;
......@@ -1079,16 +1094,31 @@ void DefaultRenderer::setShowEmoticons(bool showEmoticons)
d->mShowEmoticons = showEmoticons;
}
void DefaultRenderer::setIsPrinting(bool isPrinting)
{
d->mIsPrinting = isPrinting;
}
void DefaultRenderer::setShowExpandQuotesMark(bool showExpandQuotesMark)
{
d->mShowExpandQuotesMark = showExpandQuotesMark;
}
void DefaultRenderer::setShowSignatureDetails(bool showSignatureDetails)
{
d->mShowSignatureDetails = showSignatureDetails;
}
void DefaultRenderer::setLevelQuote(int levelQuote)
{
d->mLevelQuote = levelQuote;
}
void DefaultRenderer::setHtmlLoadExternal(bool htmlLoadExternal)
{
d->mHtmlLoadExternal = htmlLoadExternal;
}
void DefaultRenderer::render(const MimeTreeParser::MessagePart::Ptr &msgPart, HtmlWriter *writer)
{
d->mMsgPart = msgPart;
......
......@@ -42,8 +42,11 @@ public:
void setShowOnlyOneMimePart(bool onlyOneMimePart);
void setAttachmentStrategy(const AttachmentStrategy *strategy);
void setShowEmoticons(bool showEmoticons);
void setIsPrinting(bool isPrinting);
void setShowExpandQuotesMark(bool showExpandQuotesMark);
void setShowSignatureDetails(bool showSignatureDetails);
void setLevelQuote(int levelQuote);
void setHtmlLoadExternal(bool htmlLoadExternal);
void render(const MimeTreeParser::MessagePartPtr &msgPart, HtmlWriter *writer);
private:
DefaultRendererPrivate *d;
......
......@@ -59,20 +59,25 @@ public:
bool isHiddenHint(const MimeTreeParser::MessagePart::Ptr &msgPart) override;
MimeTreeParser::IconType displayHint(const MimeTreeParser::MessagePart::Ptr &msgPart) override;
bool showEmoticons() const override;
bool isPrinting() const override;
bool htmlLoadExternal() const override;
bool showExpandQuotesMark() const override;
bool showOnlyOneMimePart() const override;
bool showSignatureDetails() const override;
int levelQuote() const override;
MimeTreeParser::MessagePart::Ptr mMsgPart;
CSSHelperBase *mCSSHelper = nullptr;
const MessagePartRendererFactory *mRendererFactory = nullptr;
const AttachmentStrategy *mAttachmentStrategy = nullptr;
int mLevelQuote = 1;
bool mShowEmoticons = false;
bool mIsPrinting = false;
bool mHtmlLoadExternal = false;
bool mShowExpandQuotesMark = false;
bool mShowOnlyOneMimePart = false;
bool mShowSignatureDetails = false;
};
}
#endif
......@@ -65,8 +65,11 @@ public:
virtual bool isHiddenHint(const MimeTreeParser::MessagePart::Ptr &msgPart) = 0;
virtual MimeTreeParser::IconType displayHint(const MimeTreeParser::MessagePart::Ptr &msgPart) = 0;
virtual bool showEmoticons() const = 0;
virtual bool isPrinting() const = 0;
virtual bool htmlLoadExternal() const = 0;
virtual bool showExpandQuotesMark() const = 0;
virtual bool showOnlyOneMimePart() const = 0;
virtual bool showSignatureDetails() const = 0;
virtual int levelQuote() const = 0;
protected:
......
......@@ -151,10 +151,13 @@ void EmptySource::render(const MimeTreeParser::MessagePartPtr &msgPart, bool sho
auto renderer = DefaultRenderer(cssHelper());
renderer.setAttachmentStrategy(attachmentStrategy());
renderer.setHtmlLoadExternal(htmlLoadExternal());
renderer.setIsPrinting(isPrinting());
renderer.setLevelQuote(levelQuote());
renderer.setShowEmoticons(showEmoticons());
renderer.setShowExpandQuotesMark(showExpandQuotesMark());
renderer.setShowOnlyOneMimePart(showOnlyOneMimePart);
renderer.setShowSignatureDetails(showSignatureDetails());
renderer.render(msgPart, htmlWriter());
}
......@@ -37,8 +37,6 @@ public:
EmptySource();
~EmptySource();
bool decryptMessage() const override;
bool htmlLoadExternal() const override;
bool showSignatureDetails() const override;
void setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes) override;
MimeTreeParser::Util::HtmlMode preferredMode() const override;
void setAllowDecryption(bool allowDecryption);
......@@ -51,10 +49,13 @@ public:
bool autoImportKeys() const override;
const MimeTreeParser::BodyPartFormatterFactory *bodyPartFormatterFactory() override;
void render(const MimeTreeParser::MessagePartPtr &msgPart, bool showOnlyOneMimePart) override;
bool isPrinting() const override;
/** Return true if external sources should be loaded in a html mail */
virtual bool htmlLoadExternal() const;
virtual bool showSignatureDetails() const;
virtual bool showEmoticons() const;
virtual bool showExpandQuotesMark() const;
virtual bool isPrinting() const;
virtual int levelQuote() const;
private:
EmptySourcePrivate *const d;
......
......@@ -30,14 +30,13 @@ class HtmlWriter;
class ViewerPrivate;
/** An ObjectTreeParser source working on a MailViewer object */
class MailViewerSource : public MessageViewer::EmptySource
class MailViewerSource : public MessageViewer::EmptySource
{
public:
explicit MailViewerSource(ViewerPrivate *viewer);
~MailViewerSource();
bool decryptMessage() const override;
bool htmlLoadExternal() const override;
bool showSignatureDetails() const override;
void setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes) override;
MimeTreeParser::Util::HtmlMode preferredMode() const override;
int levelQuote() const override;
......@@ -48,6 +47,7 @@ public:
CSSHelperBase *cssHelper() override;
bool autoImportKeys() const override;
bool showSignatureDetails() const override;
bool showEmoticons() const override;
bool showExpandQuotesMark() const override;
bool isPrinting() const override;
......
......@@ -43,21 +43,10 @@ class TestObjectTreeSource : public MimeTreeParser::Interface::ObjectTreeSource
public:
TestObjectTreeSource()
: mPreferredMode(Util::Html)
, mHtmlLoadExternal(false)
, mDecryptMessage(false)
{
}
bool htmlLoadExternal() const override
{
return mHtmlLoadExternal;
}
void setHtmlLoadExternal(bool loadExternal)
{
mHtmlLoadExternal = loadExternal;
}
bool autoImportKeys() const override
{
return true;
......@@ -78,16 +67,6 @@ public:
mDecryptMessage = allowDecryption;
}
void setShowSignatureDetails(bool showSignatureDetails)
{
mShowSignatureDetails = showSignatureDetails;
}
bool showSignatureDetails() const override
{
return mShowSignatureDetails;
}
void setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes) override
{
Q_UNUSED(mode);
......@@ -121,17 +100,10 @@ public:
Q_UNUSED(showOnlyOneMimePart);
}
bool isPrinting() const override
{
return false;
}
private:
BodyPartFormatterFactory mBodyPartFormatterFactory;
MimeTreeParser::Util::HtmlMode mPreferredMode;
bool mHtmlLoadExternal = false;
bool mDecryptMessage = false;
bool mShowSignatureDetails = false;
};
}
}
......
......@@ -59,12 +59,6 @@ public:
/** Return true if an encrypted mail should be decrypted */
virtual bool decryptMessage() const = 0;
/** Return true if external sources should be loaded in a html mail */
virtual bool htmlLoadExternal() const = 0;
/** Return true to include the signature details in the generated html */
virtual bool showSignatureDetails() const = 0;
/** The override codec that should be used for the mail */
virtual const QTextCodec *overrideCodec() = 0;
......@@ -77,8 +71,6 @@ public:
virtual void render(const MessagePartPtr &msgPart, bool showOnlyOneMimePart) = 0;
virtual bool isPrinting() const = 0;
private:
Q_DISABLE_COPY(ObjectTreeSource)
};
......
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