Messagelib

objecttreeemptysource.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net
3 SPDX-FileCopyrightText: 2009 Andras Mantia <andras@kdab.net>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#include "objecttreeemptysource.h"
9#include "viewer/attachmentstrategy.h"
10#include "viewer/csshelperbase.h"
11#include "viewer/viewer_p.h"
12
13#include <MimeTreeParser/BodyPartFormatter>
14#include <MimeTreeParser/BodyPartFormatterFactory>
15
16#include "messagepartthemes/default/defaultrenderer.h"
17
18#include "messageviewer_debug.h"
19
20using namespace MessageViewer;
21
22namespace MessageViewer
23{
24class EmptySourcePrivate
25{
26public:
27 EmptySourcePrivate() = default;
28
29 bool mAllowDecryption = false;
30};
31}
32
33EmptySource::EmptySource()
34 : d(new MessageViewer::EmptySourcePrivate)
35{
36}
37
38EmptySource::~EmptySource() = default;
39
41{
42 return d->mAllowDecryption;
43}
44
46{
47 return false;
48}
49
51{
52 Q_UNUSED(mode)
53 Q_UNUSED(availableModes)
54}
55
60
61void EmptySource::setAllowDecryption(bool allowDecryption)
62{
63 d->mAllowDecryption = allowDecryption;
64}
65
67{
68 return {};
69}
70
71QString EmptySource::createMessageHeader(KMime::Message *message)
72{
73 Q_UNUSED(message)
74 return {}; // do nothing
75}
76
77const AttachmentStrategy *EmptySource::attachmentStrategy() const
78{
79 return AttachmentStrategy::smart();
80}
81
82HtmlWriter *EmptySource::htmlWriter() const
83{
84 return nullptr;
85}
86
87CSSHelperBase *EmptySource::cssHelper() const
88{
89 return nullptr;
90}
91
93{
94 return true;
95}
96
97const MimeTreeParser::BodyPartFormatterFactory *EmptySource::bodyPartFormatterFactory()
98{
99 return MimeTreeParser::BodyPartFormatterFactory::instance();
100}
101
102void EmptySource::render(const MimeTreeParser::MessagePartPtr &msgPart, bool showOnlyOneMimePart)
103{
104 if (!htmlWriter()) {
105 qCWarning(MESSAGEVIEWER_LOG) << "no htmlWriter - skipping rendering.";
106 return;
107 }
108
109 auto renderer = DefaultRenderer(cssHelper());
110 renderer.setAttachmentStrategy(attachmentStrategy());
111 renderer.setCreateMessageHeader(std::bind(&EmptySource::createMessageHeader, this, std::placeholders::_1));
112 renderer.setHtmlLoadExternal(htmlLoadExternal());
113 renderer.setIsPrinting(isPrinting());
114 renderer.setLevelQuote(levelQuote());
115 renderer.setShowEmoticons(showEmoticons());
116 renderer.setShowExpandQuotesMark(showExpandQuotesMark());
117 renderer.setShowOnlyOneMimePart(showOnlyOneMimePart);
118 renderer.setShowSignatureDetails(showSignatureDetails());
119 renderer.setShowEncryptionDetails(showEncryptionDetails());
120
121 renderer.render(msgPart, htmlWriter());
122}
123
124bool EmptySource::isPrinting() const
125{
126 return false;
127}
128
129bool EmptySource::showEmoticons() const
130{
131 return false;
132}
133
134bool EmptySource::showExpandQuotesMark() const
135{
136 return false;
137}
138
139bool EmptySource::showSignatureDetails() const
140{
141 return false;
142}
143
144bool EmptySource::showEncryptionDetails() const
145{
146 return false;
147}
148
149int EmptySource::levelQuote() const
150{
151 return 1;
152}
The AttachmentStrategy class.
The CSSHelperBase class.
MimeTreeParser::Util::HtmlMode preferredMode() const override
Return the mode that is the preferred to display.
bool autoImportKeys() const override
should keys be imported automatically
virtual bool htmlLoadExternal() const
Return true if external sources should be loaded in a html mail.
QByteArray overrideCodecName() const override
The override codec that should be used for the mail.
void setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList< MimeTreeParser::Util::HtmlMode > &availableModes) override
Sets the type of mail that is currently displayed.
bool decryptMessage() const override
Return true if an encrypted mail should be decrypted.
An interface for HTML sinks.
Definition htmlwriter.h:29
The place to obtain BodyPartFormatter candidates for a given mime type.
HtmlMode
Describes the type of the displayed message.
@ Html
A HTML message, non-multipart.
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Apr 25 2025 11:46:37 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.