# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KBookmarkManager Class Reference

This class implements the reading/writing of bookmarks in XML. More...

`#include <kbookmarkmanager.h>`

Inheritance diagram for KBookmarkManager:

[legend]
Collaboration diagram for KBookmarkManager:

[legend]
List of all members.

## Public Slots

void | slotEditBookmarks ()

## Signals

void | changed (const QString &groupAddress, const QString &caller)
| Signals that the group with the address `groupAddress` (e.g.

## DCOP Member Functions

ASYNC | notifyCompleteChange (QString caller)
| Reparse the whole bookmarks file and notify about the change (Called by the bookmark editor).
ASYNC | notifyChanged (QString groupAddress)
| Emit the changed signal for the group whose address is given.

## Public Member Functions

void | setUpdate (bool update)
| Set the update flag.
bool | save (bool toolbarCache=true) const
| Save the bookmarks to the default konqueror XML file on disk.
bool | saveAs (const QString &filename, bool toolbarCache=true) const
| Save the bookmarks to the given XML file on disk.
QString | path ()
| This will return the path that this manager is using to read the bookmarks.
KBookmarkGroup | root () const
| This will return the root bookmark.
KBookmarkGroup | toolbar ()
| This returns the root of the toolbar menu.
KBookmark | findByAddress (const QString &address, bool tolerate=false)
void | emitChanged (KBookmarkGroup &group)
bool | showNSBookmarks () const
void | setShowNSBookmarks (bool show)
| Shows an extra menu for NS bookmarks.
const QDomDocument & | internalDocument () const
KBookmarkNotifier & | notifier ()
| Access to bookmark notifier, for emitting signals.

## Static Public Member Functions

KBookmarkManager * | managerForFile (const QString &bookmarksFile, bool bImportDesktopFiles=true)
| This static function will return an instance of the KBookmarkManager, responsible for the given `bookmarksFile`.

## Protected Member Functions

| KBookmarkManager (const QString &bookmarksFile, bool bImportDesktopFiles=true)
| Creates a bookmark manager with a path to the bookmarks.
void | parse () const
void | importDesktopFiles ()

## Static Protected Member Functions

void | convertToXBEL (QDomElement &group)
void | convertAttribute (QDomElement elem, const QString &oldName, const QString &newName)

## Detailed Description

This class implements the reading/writing of bookmarks in XML.

The bookmarks file is read and written using the XBEL standard (http://pyxml.sourceforge.net/topics/xbel/)

A sample file looks like this : Developer Web Site Title of this folder KDE Web Site My own bookmarks KOffice Web Site <separator/> KDevelop Web Site

Definition at line 48 of file kbookmarkmanager.h.

## Constructor & Destructor Documentation

KBookmarkManager::KBookmarkManager | ( | const QString & | bookmarksFile,
|  | bool | bImportDesktopFiles = true
| ) | `[protected]`

Creates a bookmark manager with a path to the bookmarks.

By default, it will use the KDE standard dirs to find and create the correct location. If you are using your own app-specific bookmarks directory, you must instantiate this class with your own path before KBookmarkManager::managerForFile() is ever called.

Parameters:

  bookmarksFile | full path to the bookmarks file, Use ~/.kde/share/apps/konqueror/bookmarks.xml for the konqueror bookmarks
  bImportDesktopFiles | if true, and if the bookmarksFile doesn't already exist, import bookmarks from desktop files

Definition at line 56 of file kbookmarkmanager.cc.

References QDomDocument::createElement(), QFile::exists(), and QString::isEmpty().

Referenced by managerForFile().

## Member Function Documentation

void KBookmarkManager::setUpdate | ( | bool | update | ) |

Set the update flag.

Parameters:

  update | iff true will KBookmarkManager listen to DCOP update requests.

Definition at line 84 of file kbookmarkmanager.cc.

bool KBookmarkManager::save | ( | bool | toolbarCache = true | ) | const

Save the bookmarks to the default konqueror XML file on disk.

Parameters:

  toolbarCache | iff true save a cache of the toolbar folder, too

Returns:
  true if saving was successful

Definition at line 208 of file kbookmarkmanager.cc.

References saveAs().

bool KBookmarkManager::saveAs | ( | const QString & | filename,
|  | bool | toolbarCache = true
| ) | const

Save the bookmarks to the given XML file on disk.

Parameters:

  filename | full path to the desired bookmarks file location
  toolbarCache | iff true save a cache of the toolbar folder, too

Returns:
  true if saving was successful

Definition at line 213 of file kbookmarkmanager.cc.

References KSaveFile::close(), KMessageBox::error(), KSaveFile::file(), KBookmarkGroup::findToolbar(), QString::fromLatin1(), KBookmarkGroup::isToolbarGroup(), QCString::length(), QFile::remove(), root(), KSaveFile::status(), QDomDocument::toCString(), and QString::utf8().

Referenced by save().

QString KBookmarkManager::path | ( |  | ) | `[inline]`

| This will return the path that this manager is using to read the bookmarks. Definition at line 100 of file kbookmarkmanager.h. Referenced by KBookmarkGroup::addBookmark(), and KBookmarkGroup::createNewFolder().

KBookmarkGroup KBookmarkManager::root | ( |  | ) | const

This will return the root bookmark.

It is used to iterate through the bookmarks manually. It is mostly used internally.

Returns:
  the root (top-level) bookmark

Definition at line 255 of file kbookmarkmanager.cc.

Referenced by findByAddress(), saveAs(), setShowNSBookmarks(), showNSBookmarks(), and toolbar().

KBookmarkGroup KBookmarkManager::toolbar | ( |  | ) |

This returns the root of the toolbar menu.

In the XML, this is the group with the attribute TOOLBAR=1

Returns:
  the toolbar group

Definition at line 260 of file kbookmarkmanager.cc.

References QFile::exists(), KBookmarkGroup::findToolbar(), QString::fromLatin1(), QFileInfo::lastModified(), QFile::open(), root(), and QDomDocument::setContent().

Referenced by KBookmarkBar::KBookmarkBar().

KBookmark KBookmarkManager::findByAddress | ( | const QString & | address,
|  | bool | tolerate = false
| ) |

Returns:
  the bookmark designated by `address`

Parameters:

  tolerate | when true tries to find the most tolerable bookmark position

See also:
  KBookmark::address

Definition at line 301 of file kbookmarkmanager.cc.

References KBookmarkGroup::first(), KBookmarkGroup::next(), KIO::number(), root(), QStringList::split(), and QString::toUInt().

Referenced by KBookmarkMenu::fillBookmarkMenu().

bool KBookmarkManager::showNSBookmarks | ( |  | ) | const

Returns:
  true if the NS bookmarks should be dynamically shown in the toplevel kactionmenu

Definition at line 386 of file kbookmarkmanager.cc.

References root().

Referenced by KBookmarkMenu::fillBookmarkMenu().

void KBookmarkManager::setShowNSBookmarks | ( | bool | show | ) |

| Shows an extra menu for NS bookmarks. Set this to false, if you don't want this. Definition at line 392 of file kbookmarkmanager.cc. References root().

KBookmarkManager * KBookmarkManager::managerForFile | ( | const QString & | bookmarksFile,
|  | bool | bImportDesktopFiles = true
| ) | `[static]`

This static function will return an instance of the KBookmarkManager, responsible for the given `bookmarksFile`.

If you do not instantiate this class either natively or in a derived class, then it will return an object with the default behaviors. If you wish to use different behaviors, you must derive your own class and instantiate it before this method is ever called.

Parameters:

  bookmarksFile | full path to the bookmarks file, Use ~/.kde/share/apps/konqueror/bookmarks.xml for the konqueror bookmarks
  bImportDesktopFiles | if true, and if the bookmarksFile doesn't already exist, import bookmarks from desktop files

Returns:
  a pointer to an instance of the KBookmarkManager.

Definition at line 40 of file kbookmarkmanager.cc.

References QPtrList< KBookmarkManager >::append(), QPtrListIterator::current(), KBookmarkManager(), and QPtrList< KBookmarkManager >::setAutoDelete().

KBookmarkNotifier& KBookmarkManager::notifier | ( |  | ) | `[inline]`

| Access to bookmark notifier, for emitting signals. We need this object to exist in one instance only, so we could connectDCOP to it by name. Definition at line 169 of file kbookmarkmanager.h. Referenced by KBookmarkGroup::addBookmark(), and KBookmarkGroup::createNewFolder().

void KBookmarkManager::notifyCompleteChange | ( | QString | caller | ) |

| Reparse the whole bookmarks file and notify about the change (Called by the bookmark editor). Definition at line 355 of file kbookmarkmanager.cc.

void KBookmarkManager::notifyChanged | ( | QString | groupAddress | ) |

Emit the changed signal for the group whose address is given.

See also:
  KBookmark::address() Called by the instance of konqueror that saved the file after a small change (new bookmark or new folder).

Definition at line 372 of file kbookmarkmanager.cc.

void KBookmarkManager::changed | ( | const QString & | groupAddress,
|  | const QString & | caller
| ) | `[signal]`

| Signals that the group with the address `groupAddress` (e.g. "/4/5") has been modified by the caller `caller`.

The documentation for this class was generated from the following files:

- kbookmarkmanager.h
- kbookmarkmanager.cc

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:15:28 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001