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 <[email protected]>
6 
7  SPDX-License-Identifier: GPL-2.0-or-later
8 */
9 
10 #include "filehtmlwriter.h"
11 #include "messageviewer_debug.h"
12 
13 using namespace MessageViewer;
14 
15 FileHtmlWriter::FileHtmlWriter(const QString &filename)
16  : mFile(filename.isEmpty() ? QStringLiteral("filehtmlwriter.out") : filename)
17 {
18 }
19 
20 FileHtmlWriter::~FileHtmlWriter()
21 {
22  if (mFile.isOpen()) {
23  qCWarning(MESSAGEVIEWER_LOG) << "FileHtmlWriter: file still open!";
24  HtmlWriter::end();
25  mFile.close();
26  }
27 }
28 
29 void FileHtmlWriter::begin()
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  }
38  HtmlWriter::begin();
39 }
40 
41 void FileHtmlWriter::end()
42 {
43  HtmlWriter::end();
44  mFile.close();
45 }
46 
47 void FileHtmlWriter::reset()
48 {
49  HtmlWriter::reset();
50  if (mFile.isOpen()) {
51  mFile.close();
52  }
53 }
54 
55 QIODevice *FileHtmlWriter::device() const
56 {
57  return const_cast<QFile *>(&mFile);
58 }
59 
60 void FileHtmlWriter::embedPart(const QByteArray &contentId, const QString &url)
61 {
62  *stream() << "<!-- embedPart(contentID=" << contentId << ", url=" << url << ") -->" << Qt::endl;
63 }
64 
65 void FileHtmlWriter::setExtraHead(const QString &)
66 {
67 }
68 
69 void FileHtmlWriter::setStyleBody(const QString &)
70 {
71 }
QTextStream & endl(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Dec 2 2021 23:06:08 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.