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

move DefaultRenderPrivate into own file

parent cf0d5e9e
......@@ -19,6 +19,8 @@
#include "defaultrenderer.h"
#include "defaultrenderer_p.h"
#include "messageviewer_debug.h"
#include "converthtmltoplaintext.h"
......@@ -386,25 +388,23 @@ public:
MimeTreeParser::HtmlWriter *mBaseWriter;
};
class MimeTreeParser::DefaultRendererPrivate
{
public:
DefaultRendererPrivate(const Interface::MessagePart::Ptr &msgPart, CSSHelperBase *cssHelper)
DefaultRendererPrivate::DefaultRendererPrivate(const Interface::MessagePart::Ptr &msgPart, CSSHelperBase *cssHelper)
: mMsgPart(msgPart)
, mOldWriter(msgPart->htmlWriter())
, mCSSHelper(cssHelper)
{
mHtml = renderFactory(mMsgPart, QSharedPointer<CacheHtmlWriter>());
}
~DefaultRendererPrivate()
DefaultRendererPrivate::~DefaultRendererPrivate()
{
}
inline QString alignText()
inline QString DefaultRendererPrivate::alignText()
{
return QApplication::isRightToLeft() ? QStringLiteral("rtl") : QStringLiteral("ltr");
}
CSSHelperBase *cssHelper() const
CSSHelperBase *DefaultRendererPrivate::cssHelper() const
{
auto mp = mMsgPart.dynamicCast<MessagePart>();
if (mp) {
......@@ -413,7 +413,7 @@ public:
return nullptr;
}
Interface::ObjectTreeSource *source() const
Interface::ObjectTreeSource *DefaultRendererPrivate::source() const
{
auto mp = mMsgPart.dynamicCast<MessagePart>();
if (mp) {
......@@ -422,7 +422,7 @@ public:
return nullptr;
}
void renderSubParts(const MessagePart::Ptr &msgPart, const QSharedPointer<CacheHtmlWriter> &htmlWriter)
void DefaultRendererPrivate::renderSubParts(const MessagePart::Ptr &msgPart, const QSharedPointer<CacheHtmlWriter> &htmlWriter)
{
foreach (const auto &_m, msgPart->subParts()) {
const auto m = _m.dynamicCast<MessagePart>();
......@@ -438,7 +438,7 @@ public:
}
}
QString render(const MessagePartList::Ptr &mp)
QString DefaultRendererPrivate::render(const MessagePartList::Ptr &mp)
{
auto htmlWriter = QSharedPointer<CacheHtmlWriter>(new CacheHtmlWriter(mOldWriter));
{
......@@ -461,7 +461,7 @@ public:
return htmlWriter->html;
}
QString render(const MimeMessagePart::Ptr &mp)
QString DefaultRendererPrivate::render(const MimeMessagePart::Ptr &mp)
{
auto htmlWriter = QSharedPointer<CacheHtmlWriter>(new CacheHtmlWriter(mOldWriter));
{
......@@ -481,7 +481,7 @@ public:
return htmlWriter->html;
}
QString render(const EncapsulatedRfc822MessagePart::Ptr &mp)
QString DefaultRendererPrivate::render(const EncapsulatedRfc822MessagePart::Ptr &mp)
{
if (!mp->hasSubParts()) {
return QString();
......@@ -513,7 +513,7 @@ public:
return htmlWriter->html;
}
QString render(const AttachmentMessagePart::Ptr &mp)
QString DefaultRendererPrivate::render(const AttachmentMessagePart::Ptr &mp)
{
KMime::Content *node = mp->mNode;
NodeHelper *nodeHelper = mp->mOtp->nodeHelper();
......@@ -585,7 +585,7 @@ public:
}
}
QString render(const TextMessagePart::Ptr &mp)
QString DefaultRendererPrivate::render(const TextMessagePart::Ptr &mp)
{
KMime::Content *node = mp->mNode;
NodeHelper *nodeHelper = mp->mOtp->nodeHelper();
......@@ -818,7 +818,7 @@ public:
return htmlStr;
}
QString render(const MessagePart::Ptr mp)
QString DefaultRendererPrivate::render(const MessagePart::Ptr mp)
{
auto htmlWriter = QSharedPointer<CacheHtmlWriter>(new CacheHtmlWriter(mOldWriter));
{
......@@ -832,7 +832,7 @@ public:
return htmlWriter->html;
}
QString render(const HtmlMessagePart::Ptr &mp)
QString DefaultRendererPrivate::render(const HtmlMessagePart::Ptr &mp)
{
Grantlee::Template t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral(":/htmlmessagepart.html"));
Grantlee::Context c = MessageViewer::MessagePartRendererManager::self()->createContext();
......@@ -882,7 +882,7 @@ public:
}
QString renderEncrypted(const EncryptedMessagePart::Ptr &mp)
QString DefaultRendererPrivate::renderEncrypted(const EncryptedMessagePart::Ptr &mp)
{
KMime::Content *node = mp->mNode;
const auto metaData = mp->mMetaData;
......@@ -925,7 +925,7 @@ public:
return html;
}
QString renderSigned(const SignedMessagePart::Ptr &mp)
QString DefaultRendererPrivate::renderSigned(const SignedMessagePart::Ptr &mp)
{
KMime::Content *node = mp->mNode;
const auto metaData = mp->mMetaData;
......@@ -1155,7 +1155,7 @@ public:
return html;
}
QString render(const SignedMessagePart::Ptr &mp)
QString DefaultRendererPrivate::render(const SignedMessagePart::Ptr &mp)
{
auto htmlWriter = QSharedPointer<CacheHtmlWriter>(new CacheHtmlWriter(mOldWriter));
const auto metaData = mp->mMetaData;
......@@ -1183,7 +1183,7 @@ public:
return htmlWriter->html;
}
QString render(const EncryptedMessagePart::Ptr &mp)
QString DefaultRendererPrivate::render(const EncryptedMessagePart::Ptr &mp)
{
auto htmlWriter = QSharedPointer<CacheHtmlWriter>(new CacheHtmlWriter(mOldWriter));
const auto metaData = mp->mMetaData;
......@@ -1214,7 +1214,7 @@ public:
return htmlWriter->html;
}
QString render(const AlternativeMessagePart::Ptr &mp)
QString DefaultRendererPrivate::render(const AlternativeMessagePart::Ptr &mp)
{
auto htmlWriter = QSharedPointer<CacheHtmlWriter>(new CacheHtmlWriter(mOldWriter));
{
......@@ -1242,7 +1242,7 @@ public:
return htmlWriter->html;
}
QString render(const CertMessagePart::Ptr &mp)
QString DefaultRendererPrivate::render(const CertMessagePart::Ptr &mp)
{
const GpgME::ImportResult &importResult(mp->mImportResult);
Grantlee::Template t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral(":/certmessagepart.html"));
......@@ -1280,7 +1280,7 @@ public:
return htmlWriter->html;
}
QString renderFactory(const Interface::MessagePart::Ptr &msgPart, const QSharedPointer<CacheHtmlWriter> &htmlWriter)
QString DefaultRendererPrivate::renderFactory(const Interface::MessagePart::Ptr &msgPart, const QSharedPointer<CacheHtmlWriter> &htmlWriter)
{
const QString className = QString::fromUtf8(msgPart->metaObject()->className());
......@@ -1357,14 +1357,6 @@ public:
return QString();
}
QString mHtml;
Interface::MessagePart::Ptr mMsgPart;
private:
HtmlWriter *mOldWriter;
CSSHelperBase *mCSSHelper;
};
DefaultRenderer::DefaultRenderer(const MimeTreeParser::Interface::MessagePart::Ptr &msgPart, CSSHelperBase *cssHelper)
: d(new MimeTreeParser::DefaultRendererPrivate(msgPart, cssHelper))
{
......
......@@ -38,7 +38,6 @@ namespace MessageViewer
{
class CSSHelperBase;
class DefaultRendererPrivate;
class DefaultRenderer : public MimeTreeParser::Interface::MessagePartRenderer
{
......
/*
Copyright (c) 2016 Sandro Knauß <sknauss@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef __MESSAGEVIEWER_DEFAULTRENDERER_P_H__
#define __MESSAGEVIEWER_DEFAULTRENDERER_P_H__
#include "defaultrenderer.h"
#include <MimeTreeParser/MessagePart>
using namespace MimeTreeParser;
using namespace MessageViewer;
class CacheHtmlWriter;
class PartRendered;
namespace MessageViewer
{
class CSSHelperBase;
}
namespace MimeTreeParser
{
class DefaultRendererPrivate
{
public:
DefaultRendererPrivate(const Interface::MessagePart::Ptr &msgPart, CSSHelperBase *cssHelper);
~DefaultRendererPrivate();
inline QString alignText();
CSSHelperBase *cssHelper() const;
Interface::ObjectTreeSource *source() const;
void renderSubParts(const MessagePart::Ptr &msgPart, const QSharedPointer<CacheHtmlWriter> &htmlWriter);
QString render(const MessagePartList::Ptr &mp);
QString render(const MimeMessagePart::Ptr &mp);
QString render(const EncapsulatedRfc822MessagePart::Ptr &mp);
QString render(const AttachmentMessagePart::Ptr &mp);
QString render(const TextMessagePart::Ptr &mp);
QString render(const MessagePart::Ptr mp);
QString render(const HtmlMessagePart::Ptr &mp);
QString renderEncrypted(const EncryptedMessagePart::Ptr &mp);
QString renderSigned(const SignedMessagePart::Ptr &mp);
QString render(const SignedMessagePart::Ptr &mp);
QString render(const EncryptedMessagePart::Ptr &mp);
QString render(const AlternativeMessagePart::Ptr &mp);
QString render(const CertMessagePart::Ptr &mp);
QSharedPointer<PartRendered> renderWithFactory(QString className, const Interface::MessagePart::Ptr &msgPart);
QString renderFactory(const Interface::MessagePart::Ptr &msgPart, const QSharedPointer<CacheHtmlWriter> &htmlWriter);
QString mHtml;
Interface::MessagePart::Ptr mMsgPart;
HtmlWriter *mOldWriter;
CSSHelperBase *mCSSHelper;
const MessageViewer::MessagePartRendererFactoryBase *mRendererFactory;
};
}
#endif
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