compile
[kdegraphics.git] / okular / core / bookmarkmanager.h
bloba520ad359a151c162ca3255d0f6eaeb1ddbd56e5
1 /***************************************************************************
2 * Copyright (C) 2006 by Pino Toscano <pino@kde.org> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef _OKULAR_BOOKMARK_MANAGER_H_
11 #define _OKULAR_BOOKMARK_MANAGER_H_
13 #include <kbookmark.h>
15 #include "okular_export.h"
17 class QAction;
18 class KUrl;
20 namespace Okular {
22 class Document;
23 class DocumentPrivate;
24 class DocumentViewport;
26 /**
27 * @brief Bookmarks manager utility.
29 * This class is responsible for loading and saving the bookmarks using the
30 * proper format, and for working with them (eg querying, adding, removing).
32 class OKULAR_EXPORT BookmarkManager : public QObject
34 Q_OBJECT
36 public:
37 virtual ~BookmarkManager();
39 /**
40 * Returns the list of documents with bookmarks.
42 KUrl::List files() const;
43 /**
44 * Returns the list of bookmarks for the specified @p url.
46 KBookmark::List bookmarks( const KUrl& url ) const;
48 /**
49 * Forces to save the list of bookmarks.
51 void save() const;
53 /**
54 * Adds a bookmark for the given @p page.
56 void addBookmark( int page );
58 /**
59 * Adds a new bookmark for the @p referurl at the specified viewport @p vp,
60 * with an optional @p title.
62 * If no @p title is specified, then \em #n will be used.
64 bool addBookmark( const KUrl& referurl, const Okular::DocumentViewport& vp, const QString& title = QString() );
66 /**
67 * Remove a bookmark for the given @p page.
69 void removeBookmark( int page );
71 /**
72 * Removes the bookmark @p bm for the @p referurl specified.
74 int removeBookmark( const KUrl& referurl, const KBookmark& bm );
76 /**
77 * Returns whether the given @p page is bookmarked.
79 bool isBookmarked( int page ) const;
81 /**
82 * Returns a list of actions for the bookmarks of the specified @p url.
84 * @note the actions will have no parents, so you have to delete them
85 * yourself
87 QList< QAction* > actionsForUrl( const KUrl& url ) const;
89 Q_SIGNALS:
90 /**
91 * The bookmark manager is requesting to open the specified @p url.
93 void openUrl( const KUrl& url );
95 /**
96 * This signal is emitted whenever bookmarks have been saved.
98 void saved();
101 * The bookmarks for specified @p url were changed.
103 * @since 0.7 (KDE 4.1)
105 void bookmarksChanged( const KUrl& url );
107 private:
108 class Private;
109 Private * const d;
110 friend class Private;
112 // private interface used by the Document
113 friend class Document;
114 friend class DocumentPrivate;
116 BookmarkManager( DocumentPrivate * document );
118 void setUrl( const KUrl& url );
119 bool setPageBookmark( int page );
120 bool removePageBookmark( int page );
122 Q_DISABLE_COPY( BookmarkManager )
127 #endif