kio Library API Documentation

KBookmarkManager Class Reference

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

#include <kbookmarkmanager.h>

Inheritance diagram for KBookmarkManager:

Inheritance graph
[legend]
Collaboration diagram for KBookmarkManager:

Collaboration graph
[legend]
List of all members.

Public Slots

void slotEditBookmarks ()
void slotEditBookmarksAtAddress (const QString &address)

Signals

void changed (const QString &groupAddress, const QString &caller)

DCOP Member Functions

ASYNC notifyCompleteChange (QString caller)
ASYNC notifyChanged (QString groupAddress)
ASYNC notifyConfigChanged ()

Public Member Functions

 ~KBookmarkManager ()
void setUpdate (bool update)
bool save (bool toolbarCache=true) const
bool saveAs (const QString &filename, bool toolbarCache=true) const
bool updateAccessMetadata (const QString &url, bool emitSignal=true)
void updateFavicon (const QString &url, const QString &faviconurl, bool emitSignal=true)
QString path ()
KBookmarkGroup root () const
KBookmarkGroup toolbar ()
KBookmark findByAddress (const QString &address, bool tolerate=false)
void emitChanged (KBookmarkGroup &group)
void emitConfigChanged ()
bool showNSBookmarks () const
void setShowNSBookmarks (bool show)
void setEditorOptions (const QString &caption, bool browser)
const QDomDocumentinternalDocument () const
KBookmarkNotifiernotifier ()
KBookmarkGroup addBookmarkDialog (const QString &_url, const QString &_title, const QString &_parentBookmarkAddress=QString::null)

Static Public Member Functions

static KBookmarkManagermanagerForFile (const QString &bookmarksFile, bool bImportDesktopFiles=true)
static KBookmarkManagercreateTempManager ()
static KBookmarkManageruserBookmarksManager ()

Protected Member Functions

 KBookmarkManager (const QString &bookmarksFile, bool bImportDesktopFiles=true)
 KBookmarkManager ()
void parse () const
void importDesktopFiles ()

Static Protected Member Functions

static void convertToXBEL (QDomElement &group)
static 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 :

 <xbel>
   <bookmark href="http://developer.kde.org"><title>Developer Web Site</title></bookmark>
   <folder folded="no">
     <title>Title of this folder</title>
     <bookmark icon="kde" href="http://www.kde.org"><title>KDE Web Site</title></bookmark>
     <folder toolbar="yes">
       <title>My own bookmarks</title>
       <bookmark href="http://www.koffice.org"><title>KOffice Web Site</title></bookmark>
       <separator/>
       <bookmark href="http://www.kdevelop.org"><title>KDevelop Web Site</title></bookmark>
     </folder>
   </folder>
 </xbel>

Definition at line 53 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 128 of file kbookmarkmanager.cc.

References DCOPObject::connectDCOPSignal(), QDomDocument::createElement(), QDomDocument::createProcessingInstruction(), and DCOPObject::objId().

KBookmarkManager::KBookmarkManager  )  [protected]
 

Since:
3.2

Definition at line 153 of file kbookmarkmanager.cc.

References DCOPObject::connectDCOPSignal(), QDomDocument::createElement(), QDomDocument::createProcessingInstruction(), and DCOPObject::objId().

Referenced by managerForFile().

KBookmarkManager::~KBookmarkManager  ) 
 

Destructor.

Definition at line 174 of file kbookmarkmanager.cc.

References QPtrList::removeRef().


Member Function Documentation

void KBookmarkManager::setUpdate bool  update  ) 
 

Set the update flag.

Defaults to true. TODO - check

Parameters:
update if true then KBookmarkManager will listen to DCOP update requests.

Definition at line 180 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 319 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 324 of file kbookmarkmanager.cc.

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

Referenced by save().

bool KBookmarkManager::updateAccessMetadata const QString url,
bool  emitSignal = true
 

Update access time stamps for a given url.

Parameters:
url the viewed url
emitSignal iff true emit KBookmarkNotifier signal
Since:
3.2
Returns:
true if any metadata was modified (bookmarks file is not saved automatically)

Definition at line 646 of file kbookmarkmanager.cc.

References QValueList::begin(), QValueList::count(), QValueList::end(), notifier(), path(), and KBookmarkNotifier::updatedAccessMetadata().

QString KBookmarkManager::path  )  [inline]
 

This will return the path that this manager is using to read the bookmarks.

Definition at line 132 of file kbookmarkmanager.h.

Referenced by KBookmarkMenu::fillBookmarkMenu(), and updateAccessMetadata().

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 377 of file kbookmarkmanager.cc.

Referenced by findByAddress(), saveAs(), KBookmarkMenu::showDynamicBookmarks(), 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 382 of file kbookmarkmanager.cc.

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

Referenced by KBookmarkBar::parentAddress().

KBookmark KBookmarkManager::findByAddress const QString address,
bool  tolerate = false
 

Returns:
the bookmark designated by address
Parameters:
address the address belonging to the bookmark you're looking for
tolerate when true tries to find the most tolerable bookmark position
See also:
KBookmark::address

Definition at line 423 of file kbookmarkmanager.cc.

References endl(), KBookmarkGroup::first(), kdWarning(), KBookmarkGroup::next(), root(), QStringList::split(), and QString::toUInt().

Referenced by addBookmarkDialog(), and KBookmarkMenu::fillBookmarkMenu().

bool KBookmarkManager::showNSBookmarks  )  const
 

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

Definition at line 593 of file kbookmarkmanager.cc.

References KBookmarkMenu::showDynamicBookmarks().

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 598 of file kbookmarkmanager.cc.

References KBookmarkMenu::setDynamicBookmarks(), KBookmarkMenu::DynMenuInfo::show, KBookmarkMenu::showDynamicBookmarks(), and userBookmarksManager().

void KBookmarkManager::setEditorOptions const QString caption,
bool  browser
 

Set options with which slotEditBookmarks called keditbookmarks this can be used to change the appearance of the keditbookmarks in order to provide a slightly differing outer shell depending on the bookmarks file / app which calls it.

Parameters:
caption the --caption string, for instance "Konsole"
browser iff false display no browser specific menu items in keditbookmarks :: --nobrowser
Since:
3.2

Definition at line 609 of file kbookmarkmanager.cc.

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 98 of file kbookmarkmanager.cc.

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

Referenced by userBookmarksManager().

KBookmarkManager * KBookmarkManager::userBookmarksManager  )  [static]
 

Returns a pointer to the users main bookmark collection.

Since:
3.2

Definition at line 692 of file kbookmarkmanager.cc.

References locateLocal(), and managerForFile().

Referenced by setShowNSBookmarks(), and KBookmarkMenu::showDynamicBookmarks().

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 228 of file kbookmarkmanager.h.

Referenced by updateAccessMetadata().

KBookmarkGroup KBookmarkManager::addBookmarkDialog const QString _url,
const QString _title,
const QString _parentBookmarkAddress = QString::null
 

Since:
3.2

Definition at line 494 of file kbookmarkmanager.cc.

References KBookmarkGroup::addBookmark(), KMessageBox::error(), findByAddress(), QString::isEmpty(), and QString::isNull().

void KBookmarkManager::notifyCompleteChange QString  caller  ) 
 

Reparse the whole bookmarks file and notify about the change (Called by the bookmark editor).

Definition at line 554 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 578 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:
KDE Logo
This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:17 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003