Messagelib

htmlwriter.cpp
1/*
2 SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "htmlwriter.h"
8
9#include <QTextStream>
10
11using namespace MessageViewer;
12
13HtmlWriter::HtmlWriter() = default;
14HtmlWriter::~HtmlWriter() = default;
15
17{
18 if (!m_stream) {
19 m_stream = std::make_unique<QTextStream>();
20 }
21 m_stream->setDevice(device());
22}
23
24void HtmlWriter::write(const QString &html)
25{
26 Q_ASSERT(m_stream);
27 if (!m_stream) {
28 return;
29 }
30 *stream() << html;
31}
32
34{
35 if (!m_stream) {
36 return;
37 }
38 m_stream->flush();
39 m_stream->setDevice(nullptr);
40}
41
43{
44 if (!m_stream) {
45 return;
46 }
47 m_stream->setDevice(nullptr);
48}
49
51{
52 return m_stream.get();
53}
virtual void end()
Signal the end of stuff to write.
virtual void begin()
Signal the begin of stuff to write.
QTextStream * stream() const
Returns a QTextStream on device().
virtual void reset()
Stop all possibly pending processing in order to be able to call begin() again.
void write(const QString &html)
Write out a chunk of text.
virtual QIODevice * device() const =0
Returns the QIODevice backing this HtmlWriter instance.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:07:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.