KBookmarks

kbookmarkimporter.cpp
1 // -*- c-basic-offset:4; indent-tabs-mode:nil -*-
2 /* This file is part of the KDE libraries
3  Copyright (C) 2003 Alexander Kellett <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #include "kbookmarkimporter.h"
21 
22 #include "kbookmarks_debug.h"
23 #include <kcharsets.h>
24 #include <qtextcodec.h>
25 
26 #include <qplatformdefs.h>
27 #include <stddef.h>
28 #include <assert.h>
29 
30 
31 #include "kbookmarkmanager.h"
32 
33 #include "kbookmarkimporter_ns.h"
34 #include "kbookmarkimporter_opera.h"
35 #include "kbookmarkimporter_ie.h"
36 
37 void KXBELBookmarkImporterImpl::parse()
38 {
39  // qCDebug(KBOOKMARKS_LOG) << "KXBELBookmarkImporterImpl::parse()";
41  KBookmarkGroup root = manager->root();
42  traverse(root);
43  // FIXME delete it!
44  // delete manager;
45 }
46 
47 void KXBELBookmarkImporterImpl::visit(const KBookmark &bk)
48 {
49  // qCDebug(KBOOKMARKS_LOG) << "KXBELBookmarkImporterImpl::visit";
50  if (bk.isSeparator()) {
51  emit newSeparator();
52  } else {
53  emit newBookmark(bk.fullText(), bk.url().toString(), QLatin1String(""));
54  }
55 }
56 
57 void KXBELBookmarkImporterImpl::visitEnter(const KBookmarkGroup &grp)
58 {
59  // qCDebug(KBOOKMARKS_LOG) << "KXBELBookmarkImporterImpl::visitEnter";
60  emit newFolder(grp.fullText(), false, QLatin1String(""));
61 }
62 
63 void KXBELBookmarkImporterImpl::visitLeave(const KBookmarkGroup &)
64 {
65  // qCDebug(KBOOKMARKS_LOG) << "KXBELBookmarkImporterImpl::visitLeave";
66  emit endFolder();
67 }
68 
69 void KBookmarkImporterBase::setupSignalForwards(QObject *src, QObject *dst)
70 {
72  dst, SIGNAL(newBookmark(QString,QString,QString)));
73  connect(src, SIGNAL(newFolder(QString,bool,QString)),
74  dst, SIGNAL(newFolder(QString,bool,QString)));
75  connect(src, SIGNAL(newSeparator()),
76  dst, SIGNAL(newSeparator()));
77  connect(src, SIGNAL(endFolder()),
78  dst, SIGNAL(endFolder()));
79 }
80 
81 KBookmarkImporterBase *KBookmarkImporterBase::factory(const QString &type)
82 {
83  if (type == QLatin1String("netscape")) {
84  return new KNSBookmarkImporterImpl;
85  } else if (type == QLatin1String("mozilla")) {
87  } else if (type == QLatin1String("xbel")) {
88  return new KXBELBookmarkImporterImpl;
89  } else if (type == QLatin1String("ie")) {
90  return new KIEBookmarkImporterImpl;
91  } else if (type == QLatin1String("opera")) {
92  return new KOperaBookmarkImporterImpl;
93  } else {
94  return nullptr;
95  }
96 }
97 
98 #include "moc_kbookmarkimporter.cpp"
A class for importing NS bookmarks utf8 defaults to off.
A class for importing Mozilla bookmarks utf8 defaults to on.
void endFolder()
Tell the outside world that we&#39;re going down one menu.
This class implements the reading/writing of bookmarks in XML.
A class for importing IE bookmarks.
static KBookmarkManager * managerForFile(const QString &bookmarksFile, const QString &dbusObjectName)
This static function will return an instance of the KBookmarkManager, responsible for the given bookm...
void newBookmark(const QString &text, const QString &url, const QString &additionalInfo)
Notify about a new bookmark Use "html" for the icon.
A group of bookmarks.
Definition: kbookmark.h:327
KBookmarkGroup root() const
This will return the root bookmark.
void newSeparator()
Notify about a new separator.
A class for importing NS bookmarks KEditBookmarks uses it to insert bookmarks into its DOM tree...
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
A class for importing Opera bookmarks.
A class for importing XBEL files.
void newFolder(const QString &text, bool open, const QString &additionalInfo)
Notify about a new folder Use "bookmark_folder" for the icon.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jul 1 2020 22:38:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.