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-2005 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 <kio/kio_export.h> 00024 00025 #include <QtCore/QString> 00026 #include <QtCore/QList> 00027 #include <QtCore/QMetaType> 00028 #include <QtXml/QDomElement> 00029 #include <kurl.h> 00030 00031 class KBookmarkManager; 00032 class KBookmarkGroup; 00033 00034 class KIO_EXPORT KBookmark 00035 { 00036 friend class KBookmarkGroup; 00037 public: 00038 enum MetaDataOverwriteMode { 00039 OverwriteMetaData, DontOverwriteMetaData 00040 }; 00041 00048 class KIO_EXPORT List : public QList<KBookmark> 00049 { 00050 public: 00051 List(); 00052 00058 void populateMimeData( QMimeData* mimeData ) const; 00059 00063 static bool canDecode( const QMimeData *mimeData ); 00064 00068 static QStringList mimeDataTypes(); 00069 00079 #ifndef KDE_NO_DEPRECATED 00080 static KDE_DEPRECATED KBookmark::List fromMimeData( const QMimeData *mimeData ); 00081 #endif 00082 00093 static KBookmark::List fromMimeData( const QMimeData *mimeData, QDomDocument& parentDocument ); 00094 }; 00095 00096 00102 KBookmark( ); 00103 00109 explicit KBookmark( const QDomElement &elem ); 00110 00114 static KBookmark standaloneBookmark( const QString & text, const KUrl & url, const QString & icon = QString() ); 00115 00119 bool isGroup() const; 00120 00124 bool isSeparator() const; 00125 00131 bool isNull() const; 00132 00138 bool hasParent() const; 00139 00145 QString text() const; 00150 QString fullText() const; 00156 void setFullText(const QString &fullText); 00160 KUrl url() const; 00166 void setUrl(const KUrl &url); 00167 00172 QString icon() const; 00173 00179 void setIcon(const QString &icon); 00180 00185 QString description() const; 00186 00193 void setDescription(const QString &description); 00194 00199 QString mimeType() const; 00200 00207 void setMimeType(const QString &mimeType); 00208 00214 bool showInToolbar() const; 00215 00219 void setShowInToolbar(bool show); 00220 00221 00225 KBookmarkGroup parentGroup() const; 00226 00231 KBookmarkGroup toGroup() const; 00232 00240 QString address() const; 00241 00245 int positionInParent() const; 00246 00247 // Hard to decide. Good design would imply that each bookmark 00248 // knows about its manager, so that there can be several managers. 00249 // But if we say there is only one manager (i.e. set of bookmarks) 00250 // per application, then KBookmarkManager::self() is much easier. 00251 //KBookmarkManager * manager() const { return m_manager; } 00252 00256 QDomElement internalElement() const; 00257 00262 void updateAccessMetadata(); 00263 00264 // Utility functions (internal) 00265 00269 static QString parentAddress( const QString & address ); 00270 00274 static uint positionInParent( const QString & address ); 00275 00280 static QString previousAddress( const QString & address ); 00281 00286 static QString nextAddress( const QString & address ); 00287 00292 static QString commonParent( const QString &A, const QString &B ); 00293 00298 QDomNode metaData(const QString &owner, bool create) const; 00299 00306 QString metaDataItem( const QString &key ) const; 00307 00315 void setMetaDataItem( const QString &key, const QString &value, MetaDataOverwriteMode mode = OverwriteMetaData ); 00316 00324 void populateMimeData( QMimeData* mimeData ) const; 00325 00329 bool operator==(const KBookmark& rhs) const; 00330 00331 protected: 00332 QDomElement element; 00333 // Note: you can't add new member variables here. 00334 // The KBookmarks are created on the fly, as wrappers 00335 // around internal QDomElements. Any additional information 00336 // has to be implemented as an attribute of the QDomElement. 00337 00338 }; 00339 00340 #ifdef MAKE_KIO_LIB 00341 KDE_DUMMY_QHASH_FUNCTION(KBookmark) 00342 #endif 00343 00347 class KIO_EXPORT KBookmarkGroup : public KBookmark 00348 { 00349 public: 00356 KBookmarkGroup(); 00357 00361 KBookmarkGroup( const QDomElement &elem ); 00362 00366 bool isOpen() const; 00367 00371 KBookmark first() const; 00376 KBookmark previous( const KBookmark & current ) const; 00381 KBookmark next( const KBookmark & current ) const; 00382 00386 int indexOf(const KBookmark& child) const; 00387 00393 KBookmarkGroup createNewFolder( const QString & text ); 00398 KBookmark createNewSeparator(); 00399 00405 KBookmark addBookmark( const KBookmark &bm ); 00406 00415 KBookmark addBookmark( const QString & text, const KUrl & url, const QString & icon = QString() ); 00416 00422 bool moveBookmark( const KBookmark & bookmark, const KBookmark & after); 00423 00424 #ifndef KDE_NO_DEPRECATED 00425 KDE_DEPRECATED bool moveItem( const KBookmark & item, const KBookmark & after ); 00426 #endif 00427 00432 void deleteBookmark( const KBookmark &bk ); 00433 00437 bool isToolbarGroup() const; 00441 QDomElement findToolbar() const; 00442 00446 QList<KUrl> groupUrlList() const; 00447 00448 protected: 00449 QDomElement nextKnownTag( const QDomElement &start, bool goNext ) const; 00450 00451 private: 00452 00453 // Note: you can't add other member variables here, except for caching info. 00454 // The KBookmarks are created on the fly, as wrappers 00455 // around internal QDomElements. Any additional information 00456 // has to be implemented as an attribute of the QDomElement. 00457 }; 00458 00459 class KIO_EXPORT KBookmarkGroupTraverser { 00460 protected: 00461 virtual ~KBookmarkGroupTraverser(); 00462 void traverse(const KBookmarkGroup &); 00463 virtual void visit(const KBookmark &); 00464 virtual void visitEnter(const KBookmarkGroup &); 00465 virtual void visitLeave(const KBookmarkGroup &); 00466 }; 00467 00468 #define KIO_KBOOKMARK_METATYPE_DEFINED 1 00469 Q_DECLARE_METATYPE( KBookmark ) 00470 00471 #endif
KDE 4.6 API Reference