kio
kbookmark.h
Go to the documentation of this file.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
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
00187
00188
00189
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
00310
00311
00312
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