kio Library API Documentation

kbookmark.h

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., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 #ifndef __kbookmark_h 00021 #define __kbookmark_h 00022 00023 #include <qstring.h> 00024 #include <qvaluelist.h> 00025 #include <kurl.h> 00026 #include <qdom.h> 00027 00028 class KBookmarkManager; 00029 class KBookmarkGroup; 00030 00031 class KBookmark 00032 { 00033 friend class KBookmarkGroup; 00034 public: 00035 KBookmark( ) {} 00036 KBookmark( QDomElement elem ) : element(elem) {} 00037 00038 static KBookmark standaloneBookmark( const QString & text, const KURL & url, const QString & icon = QString::null ); 00039 00043 bool isGroup() const; 00044 00048 bool isSeparator() const; 00049 00055 bool isNull() const {return element.isNull();} 00056 00063 bool hasParent() const; 00064 00070 QString text() const; 00075 QString fullText() const; 00079 KURL url() const; 00084 QString icon() const; 00085 00089 KBookmarkGroup parentGroup() const; 00090 00095 KBookmarkGroup toGroup() const; 00096 00103 QString address() const; 00104 00105 // Hard to decide. Good design would imply that each bookmark 00106 // knows about its manager, so that there can be several managers. 00107 // But if we say there is only one manager (i.e. set of bookmarks) 00108 // per application, then KBookmarkManager::self() is much easier. 00109 //KBookmarkManager * manager() const { return m_manager; } 00110 00114 QDomElement internalElement() const { return element; } 00115 00121 void updateAccessMetadata(); 00122 00123 // Utility functions (internal) 00124 00128 static QString parentAddress( const QString & address ) 00129 { return address.left( address.findRev('/') ); } 00130 00134 static uint positionInParent( const QString & address ) 00135 { return address.mid( address.findRev('/') + 1 ).toInt(); } 00136 00141 static QString previousAddress( const QString & address ) 00142 { 00143 uint pp = positionInParent(address); 00144 return pp>0 ? parentAddress(address) + '/' + QString::number(pp-1) : QString::null; 00145 } 00146 00151 static QString nextAddress( const QString & address ) 00152 { return parentAddress(address) + '/' + QString::number(positionInParent(address)+1); } 00153 00154 protected: 00155 QDomElement element; 00156 // Note: you can't add new member variables here. 00157 // The KBookmarks are created on the fly, as wrappers 00158 // around internal QDomElements. Any additional information 00159 // has to be implemented as an attribute of the QDomElement. 00160 }; 00161 00165 class KBookmarkGroup : public KBookmark 00166 { 00167 public: 00174 KBookmarkGroup(); 00175 00179 KBookmarkGroup( QDomElement elem ); 00180 00185 QString groupAddress() const; 00186 00190 bool isOpen() const; 00191 00195 KBookmark first() const; 00200 KBookmark previous( const KBookmark & current ) const; 00205 KBookmark next( const KBookmark & current ) const; 00206 00212 KBookmarkGroup createNewFolder( KBookmarkManager* mgr, const QString & text = QString::null, bool emitSignal = true ); 00216 KBookmark createNewSeparator(); 00223 KBookmark addBookmark( KBookmarkManager* mgr, const QString & text, const KURL & url, const QString & icon = QString::null, bool emitSignal = true ); 00224 00229 bool moveItem( const KBookmark & item, const KBookmark & after ); 00230 00234 void deleteBookmark( KBookmark bk ); 00235 00239 bool isToolbarGroup() const; 00243 QDomElement findToolbar() const; 00244 00249 QValueList<KURL> groupUrlList() const; 00250 00251 protected: 00252 QDomElement nextKnownTag( QDomElement start, bool goNext ) const; 00253 00254 private: 00255 mutable QString m_address; 00256 // Note: you can't add other member variables here, except for caching info. 00257 // The KBookmarks are created on the fly, as wrappers 00258 // around internal QDomElements. Any additional information 00259 // has to be implemented as an attribute of the QDomElement. 00260 }; 00261 00265 class KBookmarkGroupTraverser { 00266 protected: 00267 virtual ~KBookmarkGroupTraverser() { ; } 00268 void traverse(const KBookmarkGroup &); 00269 virtual void visit(const KBookmark &) { ; } 00270 virtual void visitEnter(const KBookmarkGroup &) { ; } 00271 virtual void visitLeave(const KBookmarkGroup &) { ; } 00272 private: 00273 class KBookmarkGroupTraverserPrivate *d; 00274 }; 00275 00276 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 10 18:55:25 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003