kbookmark.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00110
00111
00112
00113
00114
00118 QDomElement internalElement() const { return element; }
00119
00125 void updateAccessMetadata();
00126
00127
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
00165 QString metaDataItem( const QString &key ) const;
00166
00175 void setMetaDataItem( const QString &key, const QString &value, MetaDataOverwriteMode mode = OverwriteMetaData );
00176
00177 protected:
00178 QDomElement element;
00179
00180
00181
00182
00183
00184 private:
00185 bool hasMetaData() const;
00186 };
00187
00191 class KIO_EXPORT KBookmarkGroup : public KBookmark
00192 {
00193 public:
00200 KBookmarkGroup();
00201
00205 KBookmarkGroup( QDomElement elem );
00206
00211 QString groupAddress() const;
00212
00216 bool isOpen() const;
00217
00221 KBookmark first() const;
00226 KBookmark previous( const KBookmark & current ) const;
00231 KBookmark next( const KBookmark & current ) const;
00232
00239 KBookmarkGroup createNewFolder( KBookmarkManager* mgr, const QString & text = QString::null, bool emitSignal = true );
00243 KBookmark createNewSeparator();
00244
00254 KBookmark addBookmark( KBookmarkManager* mgr, const KBookmark &bm, bool emitSignal = true );
00255
00267 KBookmark addBookmark( KBookmarkManager* mgr, const QString & text, const KURL & url, const QString & icon = QString::null, bool emitSignal = true );
00268
00273 bool moveItem( const KBookmark & item, const KBookmark & after );
00274
00278 void deleteBookmark( KBookmark bk );
00279
00283 bool isToolbarGroup() const;
00287 QDomElement findToolbar() const;
00288
00293 QValueList<KURL> groupUrlList() const;
00294
00295 protected:
00296 QDomElement nextKnownTag( QDomElement start, bool goNext ) const;
00297
00298 private:
00299 mutable QString m_address;
00300
00301
00302
00303
00304 };
00305
00309 class KIO_EXPORT KBookmarkGroupTraverser {
00310 protected:
00311 virtual ~KBookmarkGroupTraverser() { ; }
00312 void traverse(const KBookmarkGroup &);
00313 virtual void visit(const KBookmark &) { ; }
00314 virtual void visitEnter(const KBookmarkGroup &) { ; }
00315 virtual void visitLeave(const KBookmarkGroup &) { ; }
00316 private:
00317 class KBookmarkGroupTraverserPrivate *d;
00318 };
00319
00320 #endif
This file is part of the documentation for kio Library Version 3.4.3.