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

KIO

  • sources
  • kde-4.12
  • kdelibs
  • 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 
26 KBookmarkDomBuilder::KBookmarkDomBuilder(
27  const KBookmarkGroup &bkGroup, KBookmarkManager *manager
28 ) {
29  m_manager = manager;
30  m_stack.push(bkGroup);
31 }
32 
33 KBookmarkDomBuilder::~KBookmarkDomBuilder() {
34  m_list.clear();
35  m_stack.clear();
36 }
37 
38 void 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 
49 void 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 
64 void 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 
81 void 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 
88 void 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"
kbookmarkmanager.h
KBookmarkDomBuilder::newSeparator
void newSeparator()
Definition: kbookmarkdombuilder.cc:81
kdebug.h
KBookmark::internalElement
QDomElement internalElement() const
Definition: kbookmark.cc:496
KBookmarkManager
This class implements the reading/writing of bookmarks in XML.
Definition: kbookmarkmanager.h:65
QString
QObject
KBookmark
Definition: kbookmark.h:34
KUrl
KBookmarkDomBuilder::connectImporter
void connectImporter(const QObject *)
Definition: kbookmarkdombuilder.cc:38
KBookmarkDomBuilder::~KBookmarkDomBuilder
virtual ~KBookmarkDomBuilder()
Definition: kbookmarkdombuilder.cc:33
KBookmarkDomBuilder::endFolder
void endFolder()
Definition: kbookmarkdombuilder.cc:88
KIO::open
FileJob * open(const KUrl &url, QIODevice::OpenMode mode)
Open ( random access I/O )
Definition: filejob.cpp:211
KBookmarkGroup
A group of bookmarks.
Definition: kbookmark.h:347
KBookmarkDomBuilder::newBookmark
void newBookmark(const QString &text, const QString &url, const QString &additionalInfo)
Definition: kbookmarkdombuilder.cc:49
kbookmarkdombuilder.h
kWarning
static QDebug kWarning(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KBookmarkDomBuilder::KBookmarkDomBuilder
KBookmarkDomBuilder(const KBookmarkGroup &group, KBookmarkManager *)
Definition: kbookmarkdombuilder.cc:26
KBookmarkDomBuilder::newFolder
void newFolder(const QString &text, bool open, const QString &additionalInfo)
Definition: kbookmarkdombuilder.cc:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:02 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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