File indexing completed on 2025-03-09 04:54:35
0001 /* 0002 SPDX-FileCopyrightText: 2017 Sandro Knauß <sknauss@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "messageviewer_export.h" 0010 0011 #include <MimeTreeParser/MessagePart> 0012 0013 #include <map> 0014 #include <memory> 0015 0016 #include <QSharedPointer> 0017 0018 namespace MessageViewer 0019 { 0020 class CSSHelperBase; 0021 class HtmlWriter; 0022 /** 0023 * @brief The RenderContext class 0024 */ 0025 class MESSAGEVIEWER_EXPORT RenderContext 0026 { 0027 public: 0028 virtual ~RenderContext(); 0029 0030 virtual CSSHelperBase *cssHelper() const = 0; 0031 template<typename T> 0032 inline bool renderWithFactory(const MimeTreeParser::MessagePart::Ptr &msgPart, HtmlWriter *writer) 0033 { 0034 return renderWithFactory(&T::staticMetaObject, msgPart, writer); 0035 } 0036 0037 inline bool renderWithFactory(const MimeTreeParser::MessagePart::Ptr &msgPart, HtmlWriter *writer) 0038 { 0039 return renderWithFactory(msgPart->metaObject(), msgPart, writer); 0040 } 0041 0042 virtual void renderSubParts(const MimeTreeParser::MessagePart::Ptr &msgPart, HtmlWriter *htmlWriter) = 0; 0043 0044 [[nodiscard]] virtual bool isHiddenHint(const MimeTreeParser::MessagePart::Ptr &msgPart) = 0; 0045 [[nodiscard]] virtual MimeTreeParser::IconType displayHint(const MimeTreeParser::MessagePart::Ptr &msgPart) = 0; 0046 [[nodiscard]] virtual bool showEmoticons() const = 0; 0047 [[nodiscard]] virtual bool isPrinting() const = 0; 0048 [[nodiscard]] virtual bool htmlLoadExternal() const = 0; 0049 [[nodiscard]] virtual bool showExpandQuotesMark() const = 0; 0050 [[nodiscard]] virtual bool showOnlyOneMimePart() const = 0; 0051 [[nodiscard]] virtual bool showSignatureDetails() const = 0; 0052 [[nodiscard]] virtual bool showEncryptionDetails() const = 0; 0053 [[nodiscard]] virtual int levelQuote() const = 0; 0054 0055 protected: 0056 [[nodiscard]] virtual bool renderWithFactory(const QMetaObject *mo, const MimeTreeParser::MessagePart::Ptr &msgPart, HtmlWriter *writer) = 0; 0057 }; 0058 /** 0059 * @brief The MessagePartRendererBase class 0060 */ 0061 class MESSAGEVIEWER_EXPORT MessagePartRendererBase 0062 { 0063 public: 0064 MessagePartRendererBase(); 0065 virtual ~MessagePartRendererBase(); 0066 [[nodiscard]] virtual bool render(const MimeTreeParser::MessagePart::Ptr &, HtmlWriter *htmlWriter, RenderContext *context) const = 0; 0067 }; 0068 }