1
// -*- mode:cperl; cperl-indent-level:4; cperl-continued-statement-offset:4; indent-tabs-mode:nil -*-
2
// vim: set ts=4 sts=4 sw=4 et:
3
/* This file is part of the KDE project
4
Copyright (C) 2003 Alexander Kellett <lypanov@kde.org>
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of the GNU General Public
8
License version 2 as published by the Free Software Foundation.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; see the file COPYING. If not, write to
17
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
Boston, MA 02111-1307, USA.
21
#include "exporters.h"
25
#include <kapplication.h>
29
HTMLExporter::HTMLExporter()
30
: m_out(&m_string, IO_WriteOnly) {
34
void HTMLExporter::write(const KBookmarkGroup &grp, const QString &filename) {
36
if (!file.open(IO_WriteOnly)) {
37
kdError(7043) << "Can't write to file " << filename << endl;
40
QTextStream tstream(&file);
41
tstream.setEncoding(QTextStream::UnicodeUTF8);
42
tstream << toString(grp);
45
QString HTMLExporter::toString(const KBookmarkGroup &grp)
48
return "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
49
"<HTML><HEAD><TITLE>My Bookmarks</TITLE>\n"
50
"<META http-equiv=\"Content-Type\" content=\"text/html; charset=utf8\" />"
57
void HTMLExporter::visit(const KBookmark &bk) {
58
// kdDebug() << "visit(" << bk.text() << ")" << endl;
59
m_out << "<A href=\"" << bk.url().url().utf8() << "\">";
60
m_out << bk.fullText() << "</A><BR>" << endl;
63
void HTMLExporter::visitEnter(const KBookmarkGroup &grp) {
64
// kdDebug() << "visitEnter(" << grp.text() << ")" << endl;
65
m_out << "<H3>" << grp.fullText() << "</H3>" << endl;
66
m_out << "<P style=\"margin-left: "
67
<< (m_level * 3) << "em\">" << endl;
71
void HTMLExporter::visitLeave(const KBookmarkGroup &) {
72
// kdDebug() << "visitLeave()" << endl;
73
m_out << "</P>" << endl;
76
m_out << "<P style=\"left-margin: "
77
<< (m_level * 3) << "em\">" << endl;