• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • htmlwriter
filehtmlwriter.cpp
Go to the documentation of this file.
1 /* -*- c++ -*-
2  filehtmlwriter.cpp
3 
4  This file is part of KMail, the KDE mail client.
5  Copyright (c) 2003 Marc Mutz <mutz@kde.org>
6 
7  KMail is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License, version 2, as
9  published by the Free Software Foundation.
10 
11  KMail is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 
20  In addition, as a special exception, the copyright holders give
21  permission to link the code of this program with any edition of
22  the Qt library by Trolltech AS, Norway (or with modified versions
23  of Qt that use the same license as Qt), and distribute linked
24  combinations including the two. You must obey the GNU General
25  Public License in all respects for all of the code used other than
26  Qt. If you modify this file, you may extend this exception to
27  your version of the file, but you are not obligated to do so. If
28  you do not wish to do so, delete this exception statement from
29  your version.
30 */
31 
32 
33 
34 #include "filehtmlwriter.h"
35 
36 #include <kdebug.h>
37 
38 #include <QTextStream>
39 
40 
41 namespace MessageViewer {
42 
43  FileHtmlWriter::FileHtmlWriter( const QString & filename )
44  : HtmlWriter(),
45  mFile( filename.isEmpty() ? QLatin1String( "filehtmlwriter.out" ) : filename )
46  {
47  mStream.setCodec( "UTF-8" );
48  }
49 
50  FileHtmlWriter::~FileHtmlWriter() {
51  if ( mFile.isOpen() ) {
52  kWarning() << "FileHtmlWriter: file still open!";
53  mStream.setDevice(0);
54  mFile.close();
55  }
56  }
57 
58  void FileHtmlWriter::begin( const QString & css ) {
59  openOrWarn();
60  if ( !css.isEmpty() )
61  write( QLatin1String("<!-- CSS Definitions \n") + css + QLatin1String("-->\n") );
62  }
63 
64  void FileHtmlWriter::end() {
65  flush();
66  mStream.setDevice(0);
67  mFile.close();
68  }
69 
70  void FileHtmlWriter::reset() {
71  if ( mFile.isOpen() ) {
72  mStream.setDevice( 0 );
73  mFile.close();
74  }
75  }
76 
77  void FileHtmlWriter::write( const QString & str ) {
78  mStream << str.toUtf8();
79  flush();
80  }
81 
82  void FileHtmlWriter::queue( const QString & str ) {
83  write( str );
84  }
85 
86  void FileHtmlWriter::flush() {
87  mStream.flush();
88  mFile.flush();
89  }
90 
91  void FileHtmlWriter::openOrWarn() {
92  if ( mFile.isOpen() ) {
93  kWarning() << "FileHtmlWriter: file still open!";
94  mStream.setDevice( 0 );
95  mFile.close();
96  }
97  if ( !mFile.open( QIODevice::WriteOnly ) )
98  kWarning() << "FileHtmlWriter: Cannot open file" << mFile.fileName();
99  else
100  mStream.setDevice( &mFile );
101  }
102 
103  void FileHtmlWriter::embedPart( const QByteArray & contentId, const QString & url ) {
104  mStream << "<!-- embedPart(contentID=" << contentId << ", url=" << url << ") -->" << endl;
105  flush();
106  }
107  void FileHtmlWriter::extraHead( const QString& ) {
108 
109  }
110 
111 } //
MessageViewer::FileHtmlWriter::FileHtmlWriter
FileHtmlWriter(const QString &filename)
Definition: filehtmlwriter.cpp:43
MessageViewer::FileHtmlWriter::embedPart
void embedPart(const QByteArray &contentId, const QString &url)
Embed a part with Content-ID contentId, using url url.
Definition: filehtmlwriter.cpp:103
filehtmlwriter.h
MessageViewer::FileHtmlWriter::write
void write(const QString &str)
Write out a chunk of text.
Definition: filehtmlwriter.cpp:77
MessageViewer::FileHtmlWriter::~FileHtmlWriter
virtual ~FileHtmlWriter()
Definition: filehtmlwriter.cpp:50
MessageViewer::FileHtmlWriter::flush
void flush()
(Start) flushing internal buffers, if any.
Definition: filehtmlwriter.cpp:86
MessageViewer::FileHtmlWriter::reset
void reset()
Stop all possibly pending processing in order to be able to call begin() again.
Definition: filehtmlwriter.cpp:70
MessageViewer::FileHtmlWriter::end
void end()
Signal the end of stuff to write.
Definition: filehtmlwriter.cpp:64
MessageViewer::FileHtmlWriter::begin
void begin(const QString &cssDefs)
Signal the begin of stuff to write, and give the CSS definitions.
Definition: filehtmlwriter.cpp:58
MessageViewer::HtmlWriter
An interface to HTML sinks.
Definition: htmlwriter.h:98
MessageViewer::FileHtmlWriter::queue
void queue(const QString &str)
Definition: filehtmlwriter.cpp:82
MessageViewer::FileHtmlWriter::extraHead
void extraHead(const QString &str)
Definition: filehtmlwriter.cpp:107
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal