kbookmark.h
// -*- c-basic-offset: 4; indent-tabs-mode:nil -*-
// vim: set ts=4 sts=4 sw=4 et:
/* This file is part of the KDE libraries
Copyright (C) 2000 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __kbookmark_h
#define __kbookmark_h
#include <qstring.h>
#include <qvaluelist.h>
#include <qdom.h>
#include <kurl.h>
class KBookmarkManager;
class KBookmarkGroup;
class KIO_EXPORT KBookmark
{
friend class KBookmarkGroup;
public:
enum MetaDataOverwriteMode {
OverwriteMetaData, DontOverwriteMetaData
};
KBookmark( ) {}
KBookmark( QDomElement elem ) : element(elem) {}
static KBookmark standaloneBookmark( const QString & text, const KURL & url, const QString & icon = QString::null );
bool isGroup() const;
bool isSeparator() const;
bool isNull() const {return element.isNull();}
bool hasParent() const;
QString text() const;
QString fullText() const;
KURL url() const;
QString icon() const;
KBookmarkGroup parentGroup() const;
KBookmarkGroup toGroup() const;
QString address() const;
// Hard to decide. Good design would imply that each bookmark
// knows about its manager, so that there can be several managers.
// But if we say there is only one manager (i.e. set of bookmarks)
// per application, then KBookmarkManager::self() is much easier.
//KBookmarkManager * manager() const { return m_manager; }
QDomElement internalElement() const { return element; }
void updateAccessMetadata();
// Utility functions (internal)
static QString parentAddress( const QString & address )
{ return address.left( address.findRev('/') ); }
static uint positionInParent( const QString & address )
{ return address.mid( address.findRev('/') + 1 ).toInt(); }
static QString previousAddress( const QString & address )
{
uint pp = positionInParent(address);
return pp>0 ? parentAddress(address) + '/' + QString::number(pp-1) : QString::null;
}
static QString nextAddress( const QString & address )
{ return parentAddress(address) + '/' + QString::number(positionInParent(address)+1); }
static QString commonParent(QString A, QString B);
QString metaDataItem( const QString &key ) const;
void setMetaDataItem( const QString &key, const QString &value, MetaDataOverwriteMode mode = OverwriteMetaData );
protected:
QDomElement element;
// Note: you can't add new member variables here.
// The KBookmarks are created on the fly, as wrappers
// around internal QDomElements. Any additional information
// has to be implemented as an attribute of the QDomElement.
private:
bool hasMetaData() const;
static QString left(const QString & str, uint len);
};
class KIO_EXPORT KBookmarkGroup : public KBookmark
{
public:
KBookmarkGroup();
KBookmarkGroup( QDomElement elem );
QString groupAddress() const;
bool isOpen() const;
KBookmark first() const;
KBookmark previous( const KBookmark & current ) const;
KBookmark next( const KBookmark & current ) const;
KBookmarkGroup createNewFolder( KBookmarkManager* mgr, const QString & text = QString::null, bool emitSignal = true );
KBookmark createNewSeparator();
KBookmark addBookmark( KBookmarkManager* mgr, const KBookmark &bm, bool emitSignal = true );
KBookmark addBookmark( KBookmarkManager* mgr, const QString & text, const KURL & url, const QString & icon = QString::null, bool emitSignal = true );
bool moveItem( const KBookmark & item, const KBookmark & after );
void deleteBookmark( KBookmark bk );
bool isToolbarGroup() const;
QDomElement findToolbar() const;
QValueList<KURL> groupUrlList() const;
protected:
QDomElement nextKnownTag( QDomElement start, bool goNext ) const;
private:
mutable QString m_address;
// Note: you can't add other member variables here, except for caching info.
// The KBookmarks are created on the fly, as wrappers
// around internal QDomElements. Any additional information
// has to be implemented as an attribute of the QDomElement.
};
class KIO_EXPORT KBookmarkGroupTraverser {
protected:
virtual ~KBookmarkGroupTraverser() { ; }
void traverse(const KBookmarkGroup &);
virtual void visit(const KBookmark &) { ; }
virtual void visitEnter(const KBookmarkGroup &) { ; }
virtual void visitLeave(const KBookmarkGroup &) { ; }
private:
class KBookmarkGroupTraverserPrivate *d;
};
#endif
KBookmarkManager
This class implements the reading/writing of bookmarks in XML.
Definition: kbookmarkmanager.h:53
KBookmarkGroup
A group of bookmarks.
Definition: kbookmark.h:199
KBookmarkGroupTraverser
Definition: kbookmark.h:318

KDE Home | KDE Accessibility Home | Description of Access Keys