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