File indexing completed on 2024-12-01 12:30:22
0001 // -*- c-basic-offset:4; indent-tabs-mode:nil -*- 0002 /* 0003 This file is part of the KDE libraries 0004 SPDX-FileCopyrightText: 2000 David Faure <faure@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-only 0007 */ 0008 0009 #ifndef __kbookmarkimporter_h 0010 #define __kbookmarkimporter_h 0011 0012 #include <QObject> 0013 0014 #include "kbookmark.h" 0015 0016 /** 0017 * A class for importing NS bookmarks 0018 * KEditBookmarks uses it to insert bookmarks into its DOM tree, 0019 * and KActionMenu uses it to create actions directly. 0020 */ 0021 class KBOOKMARKS_EXPORT KBookmarkImporterBase : public QObject 0022 { 0023 Q_OBJECT 0024 public: 0025 KBookmarkImporterBase() 0026 { 0027 } 0028 ~KBookmarkImporterBase() override 0029 { 0030 } 0031 0032 void setFilename(const QString &filename) 0033 { 0034 m_fileName = filename; 0035 } 0036 0037 virtual void parse() = 0; 0038 virtual QString findDefaultLocation(bool forSaving = false) const = 0; 0039 0040 // TODO - make this static? 0041 void setupSignalForwards(QObject *src, QObject *dst); 0042 static KBookmarkImporterBase *factory(const QString &type); 0043 0044 Q_SIGNALS: 0045 /** 0046 * Notify about a new bookmark 0047 * Use "html" for the icon 0048 */ 0049 void newBookmark(const QString &text, const QString &url, const QString &additionalInfo); 0050 0051 /** 0052 * Notify about a new folder 0053 * Use "bookmark_folder" for the icon 0054 */ 0055 void newFolder(const QString &text, bool open, const QString &additionalInfo); 0056 0057 /** 0058 * Notify about a new separator 0059 */ 0060 void newSeparator(); 0061 0062 /** 0063 * Tell the outside world that we're going down 0064 * one menu 0065 */ 0066 void endFolder(); 0067 0068 protected: 0069 QString m_fileName; 0070 0071 private: 0072 class KBookmarkImporterBasePrivate *d; 0073 }; 0074 0075 /** 0076 * A class for importing XBEL files 0077 */ 0078 class KBOOKMARKS_EXPORT KXBELBookmarkImporterImpl : public KBookmarkImporterBase, protected KBookmarkGroupTraverser 0079 { 0080 Q_OBJECT 0081 public: 0082 KXBELBookmarkImporterImpl() 0083 { 0084 } 0085 void parse() override; 0086 QString findDefaultLocation(bool = false) const override 0087 { 0088 return QString(); 0089 } 0090 0091 protected: 0092 void visit(const KBookmark &) override; 0093 void visitEnter(const KBookmarkGroup &) override; 0094 void visitLeave(const KBookmarkGroup &) override; 0095 0096 private: 0097 class KXBELBookmarkImporterImplPrivate *d; 0098 }; 0099 0100 #endif