kbookmarkmanager.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., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 #ifndef __kbookmarkmanager_h
00021 #define __kbookmarkmanager_h
00022 
00023 #include <qstring.h>
00024 #include <qstringlist.h>
00025 #include <qobject.h>
00026 #include <qdom.h>
00027 #include <dcopobject.h>
00028 #include "kbookmark.h"
00029 #include "kbookmarknotifier.h"
00030 
00053 class KIO_EXPORT KBookmarkManager : public QObject, public DCOPObject
00054 {
00055     Q_OBJECT
00056     K_DCOP
00057 protected:
00072     KBookmarkManager( const QString & bookmarksFile, bool bImportDesktopFiles = true );
00073 
00077     KBookmarkManager();
00078 
00079 public:
00083     ~KBookmarkManager();
00084 
00089     void setUpdate( bool update );
00090 
00098     bool save( bool toolbarCache = true ) const;
00099 
00106     bool saveAs( const QString & filename, bool toolbarCache = true ) const;
00107 
00115     bool updateAccessMetadata( const QString &url, bool emitSignal = true );
00116 
00117     /*
00118      * NB. currently *unimplemented*
00119      *
00120      * Update favicon url for a given url.
00121      * @param url the viewed url
00122      * @param faviconurl the favicion url
00123      * @emitSignal iff true emit KBookmarkNotifier signal
00124      * @since 3.3
00125      */
00126     void updateFavicon( const QString &url, const QString &faviconurl, bool emitSignal = true );
00127 
00134     QString path() { return m_bookmarksFile; }
00135 
00142     KBookmarkGroup root() const;
00143 
00150     KBookmarkGroup toolbar();
00151 
00158     KBookmark findByAddress( const QString & address, bool tolerate = false );
00159 
00164     void emitChanged( KBookmarkGroup & group );
00165 
00166     void emitConfigChanged();
00167 
00173     bool showNSBookmarks() const;
00174 
00179     void setShowNSBookmarks( bool show );
00180 
00191     void setEditorOptions( const QString& caption, bool browser );
00192 
00209     static KBookmarkManager* managerForFile( const QString& bookmarksFile,
00210                                    bool bImportDesktopFiles = true );
00211 
00212 
00213     static KBookmarkManager* createTempManager();
00214 
00219     static KBookmarkManager* userBookmarksManager();
00220 
00224     const QDomDocument & internalDocument() const;
00225 
00231     KBookmarkNotifier& notifier() { return m_notifier; }
00232 
00236     KBookmarkGroup addBookmarkDialog( const QString & _url, const QString & _title,
00237                                       const QString & _parentBookmarkAddress = QString::null );
00238 
00239 public slots:
00240     void slotEditBookmarks();
00241     void slotEditBookmarksAtAddress( const QString& address );
00242 
00243 public:
00244 k_dcop:
00249     ASYNC notifyCompleteChange( QString caller );
00250 
00257     ASYNC notifyChanged( QString groupAddress );
00258 
00259     ASYNC notifyConfigChanged();
00260 
00261 signals:
00267     void changed( const QString & groupAddress, const QString & caller );
00268 
00269 protected:
00270     // consts added to avoid a copy-and-paste of internalDocument
00271     void parse() const;
00272     void importDesktopFiles();
00273     static void convertToXBEL( QDomElement & group );
00274     static void convertAttribute( QDomElement elem, const QString & oldName, const QString & newName );
00275 
00276 private:
00277     KBookmarkNotifier m_notifier;
00278     QString m_bookmarksFile;
00279     mutable QDomDocument m_doc;
00280     mutable QDomDocument m_toolbarDoc;
00281     mutable bool m_docIsLoaded;
00282     bool m_update;
00283     static QPtrList<KBookmarkManager>* s_pSelf;
00284     bool m_showNSBookmarks;
00285 
00286 private:
00287     class KBookmarkManagerPrivate* dptr() const;
00288 };
00289 
00311 class KIO_EXPORT KBookmarkOwner
00312 {
00313 public:
00318   virtual void openBookmarkURL(const QString& _url);
00319 
00328   virtual QString currentTitle() const { return QString::null; }
00329 
00338   virtual QString currentURL() const { return QString::null; }
00339 
00340 protected:
00341   virtual void virtual_hook( int id, void* data );
00342 };
00343 
00347 class KIO_EXPORT KExtendedBookmarkOwner : public QObject, virtual public KBookmarkOwner
00348 {
00349     Q_OBJECT
00350 public:
00351     typedef QValueList<QPair<QString,QString> > QStringPairList;
00352 public slots:
00353     void fillBookmarksList( KExtendedBookmarkOwner::QStringPairList & list ) { emit signalFillBookmarksList( list ); };
00354 signals:
00355     void signalFillBookmarksList( KExtendedBookmarkOwner::QStringPairList & list );
00356 private:
00357     class KExtendedBookmarkOwnerPrivate;
00358     KExtendedBookmarkOwnerPrivate *d;
00359 };
00360 
00361 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys