// -*- indent-tabs-mode:nil -*- // vim: set ts=4 sts=4 sw=4 et: /* This file is part of the KDE project Copyright (C) 2003 Alexander Kellett This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) version 3. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see */ #include "exporters.h" #include #include #include #include HTMLExporter::HTMLExporter() : m_out(&m_string, QIODevice::WriteOnly) { } void HTMLExporter::write(const KBookmarkGroup &grp, const QString &filename, bool showAddress) { QFile file(filename); if (!file.open(QIODevice::WriteOnly)) { kError(7043) << "Can't write to file " << filename << endl; return; } QTextStream tstream(&file); tstream.setCodec("UTF-8"); tstream << toString(grp, showAddress); } QString HTMLExporter::toString(const KBookmarkGroup &grp, bool showAddress) { m_showAddress = showAddress; traverse(grp); return "\n" ""+i18n("My Bookmarks")+"\n" "" "\n" "\n" "
" + m_string + "
\n" "\n\n"; } void HTMLExporter::visit(const KBookmark &bk) { // kDebug() << "visit(" << bk.text() << ")"; if(bk.isSeparator()) { m_out << bk.fullText() << "
"<"<< endl; m_out << "
" << bk.url().url().toUtf8() << "
"; } else { m_out << ""; m_out << bk.fullText() << "
" << endl; } } } void HTMLExporter::visitEnter(const KBookmarkGroup &grp) { // kDebug() << "visitEnter(" << grp.text() << ")"; m_out << "" << grp.fullText() << "
" << endl; m_out << "
"<< endl; } void HTMLExporter::visitLeave(const KBookmarkGroup &) { // kDebug() << "visitLeave()"; m_out << "
" << endl; }