kio
kbookmarkdombuilder.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <kbookmarkmanager.h>
00022 #include <kdebug.h>
00023
00024 #include "kbookmarkdombuilder.h"
00025
00026 KBookmarkDomBuilder::KBookmarkDomBuilder(
00027 const KBookmarkGroup &bkGroup, KBookmarkManager *manager
00028 ) {
00029 m_manager = manager;
00030 m_stack.push(bkGroup);
00031 }
00032
00033 KBookmarkDomBuilder::~KBookmarkDomBuilder() {
00034 m_list.clear();
00035 m_stack.clear();
00036 }
00037
00038 void KBookmarkDomBuilder::connectImporter(const QObject *importer) {
00039 connect(importer, SIGNAL( newBookmark(const QString &, const QCString &, const QString &) ),
00040 SLOT( newBookmark(const QString &, const QCString &, const QString &) ));
00041 connect(importer, SIGNAL( newFolder(const QString &, bool, const QString &) ),
00042 SLOT( newFolder(const QString &, bool, const QString &) ));
00043 connect(importer, SIGNAL( newSeparator() ),
00044 SLOT( newSeparator() ) );
00045 connect(importer, SIGNAL( endFolder() ),
00046 SLOT( endFolder() ) );
00047 }
00048
00049 void KBookmarkDomBuilder::newBookmark(
00050 const QString &text, const QCString &url, const QString &additionalInfo
00051 ) {
00052 KBookmark bk = m_stack.top().addBookmark(
00053 m_manager, text,
00054 KURL( QString::fromUtf8(url), 106 ),
00055 QString::null, false);
00056
00057 bk.internalElement().setAttribute("netscapeinfo", additionalInfo);
00058 }
00059
00060 void KBookmarkDomBuilder::newFolder(
00061 const QString & text, bool open, const QString & additionalInfo
00062 ) {
00063
00064 KBookmarkGroup gp = m_stack.top().createNewFolder(m_manager, text, false);
00065 m_list.append(gp);
00066 m_stack.push(m_list.last());
00067
00068 QDomElement element = m_list.last().internalElement();
00069 element.setAttribute("netscapeinfo", additionalInfo);
00070 element.setAttribute("folded", (open?"no":"yes"));
00071 }
00072
00073 void KBookmarkDomBuilder::newSeparator() {
00074 m_stack.top().createNewSeparator();
00075 }
00076
00077 void KBookmarkDomBuilder::endFolder() {
00078 m_stack.pop();
00079 }
00080
00081 #include "kbookmarkdombuilder.moc"