Messagelib

filehtmlwriter.cpp
1/* -*- c++ -*-
2 filehtmlwriter.cpp
3
4 This file is part of KMail, the KDE mail client.
5 SPDX-FileCopyrightText: 2003 Marc Mutz <mutz@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9
10#include "filehtmlwriter.h"
11#include "messageviewer_debug.h"
12
13using namespace MessageViewer;
14
15FileHtmlWriter::FileHtmlWriter(const QString &filename)
16 : mFile(filename.isEmpty() ? QStringLiteral("filehtmlwriter.out") : filename)
17{
18}
19
20FileHtmlWriter::~FileHtmlWriter()
21{
22 if (mFile.isOpen()) {
23 qCWarning(MESSAGEVIEWER_LOG) << "FileHtmlWriter: file still open!";
25 mFile.close();
26 }
27}
28
30{
31 if (mFile.isOpen()) {
32 qCWarning(MESSAGEVIEWER_LOG) << "FileHtmlWriter: file still open!";
33 mFile.close();
34 }
35 if (!mFile.open(QIODevice::WriteOnly)) {
36 qCWarning(MESSAGEVIEWER_LOG) << "FileHtmlWriter: Cannot open file" << mFile.fileName();
37 }
39}
40
42{
44 mFile.close();
45}
46
48{
50 if (mFile.isOpen()) {
51 mFile.close();
52 }
53}
54
56{
57 return const_cast<QFile *>(&mFile);
58}
59
60void FileHtmlWriter::embedPart(const QByteArray &contentId, const QString &url)
61{
62 *stream() << "<!-- embedPart(contentID=" << contentId << ", url=" << url << ") -->" << Qt::endl;
63}
64
65void FileHtmlWriter::setExtraHead(const QString &)
66{
67}
68
69void FileHtmlWriter::setStyleBody(const QString &)
70{
71}
void end() override
Signal the end of stuff to write.
void reset() override
Stop all possibly pending processing in order to be able to call begin() again.
void begin() override
Signal the begin of stuff to write.
QIODevice * device() const override
Returns the QIODevice backing this HtmlWriter instance.
void embedPart(const QByteArray &contentId, const QString &url) override
Embed a part with Content-ID contentId, using url url.
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.
virtual QString fileName() const const override
bool open(FILE *fh, OpenMode mode, FileHandleFlags handleFlags)
virtual void close() override
bool isOpen() const const
QTextStream & endl(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.