File indexing completed on 2024-09-01 13:20:28
0001 // -*- c-basic-offset:4; indent-tabs-mode:nil -*- 0002 /* 0003 This file is part of the KDE libraries 0004 SPDX-FileCopyrightText: 2003 Alexander Kellett <lypanov@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-only 0007 */ 0008 0009 #include "kbookmarkimporter.h" 0010 0011 #include "kbookmarkimporter_ie.h" 0012 #include "kbookmarkimporter_ns.h" 0013 #include "kbookmarkimporter_opera.h" 0014 #include "kbookmarkmanager.h" 0015 #include "kbookmarks_debug.h" 0016 0017 #include <assert.h> 0018 #include <stddef.h> 0019 0020 void KXBELBookmarkImporterImpl::parse() 0021 { 0022 // qCDebug(KBOOKMARKS_LOG) << "KXBELBookmarkImporterImpl::parse()"; 0023 KBookmarkManager *manager = KBookmarkManager::managerForFile(m_fileName, QString()); 0024 KBookmarkGroup root = manager->root(); 0025 traverse(root); 0026 // FIXME delete it! 0027 // delete manager; 0028 } 0029 0030 void KXBELBookmarkImporterImpl::visit(const KBookmark &bk) 0031 { 0032 // qCDebug(KBOOKMARKS_LOG) << "KXBELBookmarkImporterImpl::visit"; 0033 if (bk.isSeparator()) { 0034 Q_EMIT newSeparator(); 0035 } else { 0036 Q_EMIT newBookmark(bk.fullText(), bk.url().toString(), QLatin1String("")); 0037 } 0038 } 0039 0040 void KXBELBookmarkImporterImpl::visitEnter(const KBookmarkGroup &grp) 0041 { 0042 // qCDebug(KBOOKMARKS_LOG) << "KXBELBookmarkImporterImpl::visitEnter"; 0043 Q_EMIT newFolder(grp.fullText(), false, QLatin1String("")); 0044 } 0045 0046 void KXBELBookmarkImporterImpl::visitLeave(const KBookmarkGroup &) 0047 { 0048 // qCDebug(KBOOKMARKS_LOG) << "KXBELBookmarkImporterImpl::visitLeave"; 0049 Q_EMIT endFolder(); 0050 } 0051 0052 void KBookmarkImporterBase::setupSignalForwards(QObject *src, QObject *dst) 0053 { 0054 // clang-format off 0055 connect(src, SIGNAL(newBookmark(QString,QString,QString)), dst, SIGNAL(newBookmark(QString,QString,QString))); 0056 connect(src, SIGNAL(newFolder(QString,bool,QString)), dst, SIGNAL(newFolder(QString,bool,QString))); 0057 // clang-format on 0058 connect(src, SIGNAL(newSeparator()), dst, SIGNAL(newSeparator())); 0059 connect(src, SIGNAL(endFolder()), dst, SIGNAL(endFolder())); 0060 } 0061 0062 KBookmarkImporterBase *KBookmarkImporterBase::factory(const QString &type) 0063 { 0064 if (type == QLatin1String("netscape")) { 0065 return new KNSBookmarkImporterImpl; 0066 } else if (type == QLatin1String("mozilla")) { 0067 return new KMozillaBookmarkImporterImpl; 0068 } else if (type == QLatin1String("xbel")) { 0069 return new KXBELBookmarkImporterImpl; 0070 } else if (type == QLatin1String("ie")) { 0071 return new KIEBookmarkImporterImpl; 0072 } else if (type == QLatin1String("opera")) { 0073 return new KOperaBookmarkImporterImpl; 0074 } else { 0075 return nullptr; 0076 } 0077 } 0078 0079 #include "moc_kbookmarkimporter.cpp"