kbookmark.h Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kbookmark.h

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2000 David Faure <faure@kde.org>
    00003
    00004    This library is free software; you can redistribute it and/or
    00005    modify it under the terms of the GNU Library General Public
    00006    License version 2 as published by the Free Software Foundation.
    00007
    00008    This library is distributed in the hope that it will be useful,
    00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00011    Library General Public License for more details.
    00012
    00013    You should have received a copy of the GNU Library General Public License
    00014    along with this library; see the file COPYING.LIB.  If not, write to
    00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00016    Boston, MA 02111-1307, USA.
    00017 */
    00018 #ifndef __kbookmark_h
    00019 #define __kbookmark_h
    00020
    00021 #include <qstring.h>
    00022 #include <kurl.h>
    00023 #include <qdom.h>
    00024
    00025 class KBookmarkManager;
    00026 class KBookmarkGroup;
    00027
    00028 class KBookmark
    00029 {
    00030     friend class KBookmarkGroup;
    00031 public:
    00032     KBookmark( ) {}
    00033     KBookmark( QDomElement elem ) : element(elem) {}
    00034
    00035     static KBookmark standaloneBookmark( const QString & text, const KURL & url, const QString & icon = QString::null );
    00036
    00040     bool isGroup() const;
    00041
    00045     bool isSeparator() const;
    00046
    00052     bool isNull() const {return element.isNull();}
    00053
    00059     QString text() const;
    00064     QString fullText() const;
    00068     KURL url() const;
    00073     QString icon() const;
    00074
    00078     KBookmarkGroup parentGroup() const;
    00079
    00084     KBookmarkGroup toGroup() const;
    00085
    00092     QString address() const;
    00093
    00094     // Hard to decide. Good design would imply that each bookmark
    00095     // knows about its manager, so that there can be several managers.
    00096     // But if we say there is only one manager (i.e. set of bookmarks)
    00097     // per application, then KBookmarkManager::self() is much easier.
    00098     //KBookmarkManager * manager() const { return m_manager; }
    00099
    00103     QDomElement internalElement() const { return element; }
    00104
    00105     // Utility functions (internal)
    00106
    00110     static QString parentAddress( const QString & address )
    00111     { return address.left( address.findRev('/') ); }
    00112
    00116     static uint positionInParent( const QString & address )
    00117     { return address.mid( address.findRev('/') + 1 ).toInt(); }
    00118
    00123     static QString previousAddress( const QString & address )
    00124     {
    00125         uint pp = positionInParent(address);
    00126         return pp>0 ? parentAddress(address) + '/' + QString::number(pp-1) : QString::null;
    00127     }
    00128
    00133     static QString nextAddress( const QString & address )
    00134     { return parentAddress(address) + '/' + QString::number(positionInParent(address)+1); }
    00135
    00136 protected:
    00137     QDomElement element;
    00138     // Note: you can't add new member variables here.
    00139     // The KBookmarks are created on the fly, as wrappers
    00140     // around internal QDomElements. Any additional information
    00141     // has to be implemented as an attribute of the QDomElement.
    00142 };
    00143
    00147 class KBookmarkGroup : public KBookmark
    00148 {
    00149 public:
    00156     KBookmarkGroup();
    00157
    00161     KBookmarkGroup( QDomElement elem );
    00162
    00167     QString groupAddress() const;
    00168
    00172     bool isOpen() const;
    00173
    00177     KBookmark first() const;
    00182     KBookmark previous( const KBookmark & current ) const;
    00187     KBookmark next( const KBookmark & current ) const;
    00188
    00193     KBookmarkGroup createNewFolder( KBookmarkManager* mgr, const QString & text = QString::null, bool emitSignal = true );
    00197     KBookmark createNewSeparator();
    00203     KBookmark addBookmark( KBookmarkManager* mgr, const QString & text, const KURL & url, const QString & icon = QString::null, bool emitSignal = true );
    00204
    00209     bool moveItem( const KBookmark & item, const KBookmark & after );
    00210
    00214     void deleteBookmark( KBookmark bk );
    00215
    00219     bool isToolbarGroup() const;
    00223     QDomElement findToolbar() const;
    00224
    00225 protected:
    00226     QDomElement nextKnownTag( QDomElement start, bool goNext ) const;
    00227
    00228 private:
    00229     mutable QString m_address;
    00230     // Note: you can't add other member variables here, except for caching info.
    00231     // The KBookmarks are created on the fly, as wrappers
    00232     // around internal QDomElements. Any additional information
    00233     // has to be implemented as an attribute of the QDomElement.
    00234 };
    00235
    00236 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:13:10 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001