• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kio

kbookmark.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4; indent-tabs-mode:nil -*-
00002 // vim: set ts=4 sts=4 sw=4 et:
00003 /* This file is part of the KDE libraries
00004    Copyright (C) 2000 David Faure <faure@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 #ifndef __kbookmark_h
00021 #define __kbookmark_h
00022 
00023 #include <qstring.h>
00024 #include <qvaluelist.h>
00025 #include <qdom.h>
00026 #include <kurl.h>
00027 
00028 class KBookmarkManager;
00029 class KBookmarkGroup;
00030 
00031 class KIO_EXPORT KBookmark
00032 {
00033     friend class KBookmarkGroup;
00034 public:
00035     enum MetaDataOverwriteMode {
00036         OverwriteMetaData, DontOverwriteMetaData
00037     };
00038 
00039     KBookmark( ) {}
00040     KBookmark( QDomElement elem ) : element(elem) {}
00041 
00042     static KBookmark standaloneBookmark( const QString & text, const KURL & url, const QString & icon = QString::null );
00043 
00047     bool isGroup() const;
00048 
00052     bool isSeparator() const;
00053 
00059     bool isNull() const {return element.isNull();}
00060 
00067     bool hasParent() const;
00068 
00074     QString text() const;
00079     QString fullText() const;
00083     KURL url() const;
00088     QString icon() const;
00089 
00093     KBookmarkGroup parentGroup() const;
00094 
00099     KBookmarkGroup toGroup() const;
00100 
00107     QString address() const;
00108 
00109     // Hard to decide. Good design would imply that each bookmark
00110     // knows about its manager, so that there can be several managers.
00111     // But if we say there is only one manager (i.e. set of bookmarks)
00112     // per application, then KBookmarkManager::self() is much easier.
00113     //KBookmarkManager * manager() const { return m_manager; }
00114 
00118     QDomElement internalElement() const { return element; }
00119 
00125     void updateAccessMetadata();
00126 
00127     // Utility functions (internal)
00128 
00132     static QString parentAddress( const QString & address )
00133     { return address.left( address.findRev('/') ); }
00134 
00138     static uint positionInParent( const QString & address )
00139     { return address.mid( address.findRev('/') + 1 ).toInt(); }
00140 
00145     static QString previousAddress( const QString & address )
00146     {
00147         uint pp = positionInParent(address);
00148         return pp>0 ? parentAddress(address) + '/' + QString::number(pp-1) : QString::null;
00149     }
00150 
00155     static QString nextAddress( const QString & address )
00156     { return parentAddress(address) + '/' + QString::number(positionInParent(address)+1); }
00157 
00163      static QString commonParent(QString A, QString B);
00164 
00172     QString metaDataItem( const QString &key ) const;
00173 
00182     void setMetaDataItem( const QString &key, const QString &value, MetaDataOverwriteMode mode = OverwriteMetaData );
00183 
00184 protected:
00185     QDomElement element;
00186     // Note: you can't add new member variables here.
00187     // The KBookmarks are created on the fly, as wrappers
00188     // around internal QDomElements. Any additional information
00189     // has to be implemented as an attribute of the QDomElement.
00190 
00191 private:
00192     bool hasMetaData() const;
00193     static QString left(const QString & str, uint len);
00194 };
00195 
00199 class KIO_EXPORT KBookmarkGroup : public KBookmark
00200 {
00201 public:
00208     KBookmarkGroup();
00209 
00213     KBookmarkGroup( QDomElement elem );
00214 
00219     QString groupAddress() const;
00220 
00224     bool isOpen() const;
00225 
00229     KBookmark first() const;
00234     KBookmark previous( const KBookmark & current ) const;
00239     KBookmark next( const KBookmark & current ) const;
00240 
00247     KBookmarkGroup createNewFolder( KBookmarkManager* mgr, const QString & text = QString::null, bool emitSignal = true );
00252     KBookmark createNewSeparator();
00253 
00262     KBookmark addBookmark( KBookmarkManager* mgr, const KBookmark &bm, bool emitSignal = true );
00263 
00274     KBookmark addBookmark( KBookmarkManager* mgr, const QString & text, const KURL & url, const QString & icon = QString::null, bool emitSignal = true );
00275 
00281     bool moveItem( const KBookmark & item, const KBookmark & after );
00282 
00287     void deleteBookmark( KBookmark bk );
00288 
00292     bool isToolbarGroup() const;
00296     QDomElement findToolbar() const;
00297 
00302     QValueList<KURL> groupUrlList() const;
00303 
00304 protected:
00305     QDomElement nextKnownTag( QDomElement start, bool goNext ) const;
00306 
00307 private:
00308     mutable QString m_address;
00309     // Note: you can't add other member variables here, except for caching info.
00310     // The KBookmarks are created on the fly, as wrappers
00311     // around internal QDomElements. Any additional information
00312     // has to be implemented as an attribute of the QDomElement.
00313 };
00314 
00318 class KIO_EXPORT KBookmarkGroupTraverser {
00319 protected:
00320     virtual ~KBookmarkGroupTraverser() { ; }
00321     void traverse(const KBookmarkGroup &);
00322     virtual void visit(const KBookmark &) { ; }
00323     virtual void visitEnter(const KBookmarkGroup &) { ; }
00324     virtual void visitLeave(const KBookmarkGroup &) { ; }
00325 private:
00326     class KBookmarkGroupTraverserPrivate *d;
00327 };
00328 
00329 #endif

kio

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal