• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KIO

  • kio
  • bookmarks
kbookmarkdombuilder.cc
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 2000 David Faure <faure@kde.org>
3 Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
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 as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "kbookmarkdombuilder.h"
22
23#include <kbookmarkmanager.h>
24#include <kdebug.h>
25
26KBookmarkDomBuilder::KBookmarkDomBuilder(
27 const KBookmarkGroup &bkGroup, KBookmarkManager *manager
28) {
29 m_manager = manager;
30 m_stack.push(bkGroup);
31}
32
33KBookmarkDomBuilder::~KBookmarkDomBuilder() {
34 m_list.clear();
35 m_stack.clear();
36}
37
38void KBookmarkDomBuilder::connectImporter(const QObject *importer) {
39 connect(importer, SIGNAL( newBookmark(const QString &, const QString &, const QString &) ),
40 SLOT( newBookmark(const QString &, const QString &, const QString &) ));
41 connect(importer, SIGNAL( newFolder(const QString &, bool, const QString &) ),
42 SLOT( newFolder(const QString &, bool, const QString &) ));
43 connect(importer, SIGNAL( newSeparator() ),
44 SLOT( newSeparator() ) );
45 connect(importer, SIGNAL( endFolder() ),
46 SLOT( endFolder() ) );
47}
48
49void KBookmarkDomBuilder::newBookmark(
50 const QString &text, const QString &url, const QString &additionalInfo
51) {
52 if (!m_stack.isEmpty()) {
53 KBookmark bk = m_stack.top().addBookmark(
54 text,
55 KUrl( url ), // utf8
56 QString());
57 // store additional info
58 bk.internalElement().setAttribute("netscapeinfo", additionalInfo);
59 }
60 else
61 kWarning() << "m_stack is empty. This should not happen when importing a valid bookmarks file!";
62}
63
64void KBookmarkDomBuilder::newFolder(
65 const QString & text, bool open, const QString & additionalInfo
66) {
67 if (!m_stack.isEmpty()) {
68 // we use a qvaluelist so that we keep pointers to valid objects in the stack
69 KBookmarkGroup gp = m_stack.top().createNewFolder(text);
70 m_list.append(gp);
71 m_stack.push(m_list.last());
72 // store additional info
73 QDomElement element = m_list.last().internalElement();
74 element.setAttribute("netscapeinfo", additionalInfo);
75 element.setAttribute("folded", (open?"no":"yes"));
76 }
77 else
78 kWarning() << "m_stack is empty. This should not happen when importing a valid bookmarks file!";
79}
80
81void KBookmarkDomBuilder::newSeparator() {
82 if (!m_stack.isEmpty())
83 m_stack.top().createNewSeparator();
84 else
85 kWarning() << "m_stack is empty. This should not happen when importing a valid bookmarks file!";
86}
87
88void KBookmarkDomBuilder::endFolder() {
89 if (!m_stack.isEmpty())
90 m_stack.pop();
91 else
92 kWarning() << "m_stack is empty. This should not happen when importing a valid bookmarks file!";
93}
94
95#include "kbookmarkdombuilder.moc"
KBookmarkDomBuilder::newSeparator
void newSeparator()
Definition: kbookmarkdombuilder.cc:81
KBookmarkDomBuilder::newBookmark
void newBookmark(const QString &text, const QString &url, const QString &additionalInfo)
Definition: kbookmarkdombuilder.cc:49
KBookmarkDomBuilder::connectImporter
void connectImporter(const QObject *)
Definition: kbookmarkdombuilder.cc:38
KBookmarkDomBuilder::endFolder
void endFolder()
Definition: kbookmarkdombuilder.cc:88
KBookmarkDomBuilder::~KBookmarkDomBuilder
virtual ~KBookmarkDomBuilder()
Definition: kbookmarkdombuilder.cc:33
KBookmarkDomBuilder::newFolder
void newFolder(const QString &text, bool open, const QString &additionalInfo)
Definition: kbookmarkdombuilder.cc:64
KBookmarkDomBuilder::KBookmarkDomBuilder
KBookmarkDomBuilder(const KBookmarkGroup &group, KBookmarkManager *)
Definition: kbookmarkdombuilder.cc:26
KBookmarkGroup
A group of bookmarks.
Definition: kbookmark.h:348
KBookmarkManager
This class implements the reading/writing of bookmarks in XML.
Definition: kbookmarkmanager.h:66
KBookmark
Definition: kbookmark.h:35
KBookmark::internalElement
QDomElement internalElement() const
Definition: kbookmark.cc:496
KUrl
QObject
kWarning
#define kWarning
kbookmarkdombuilder.h
kbookmarkmanager.h
kdebug.h
open
int open(const QString &pathname, int flags, mode_t mode)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal