1 /***************************************************************************
2 * Copyright (C) 2006 by Pino Toscano <pino@kde.org> *
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"
23 class DocumentPrivate
;
24 class DocumentViewport
;
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
37 virtual ~BookmarkManager();
40 * Returns the list of documents with bookmarks.
42 KUrl::List
files() const;
44 * Returns the list of bookmarks for the specified @p url.
46 KBookmark::List
bookmarks( const KUrl
& url
) const;
49 * Forces to save the list of bookmarks.
54 * Adds a bookmark for the given @p page.
56 void addBookmark( int page
);
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() );
67 * Remove a bookmark for the given @p page.
69 void removeBookmark( int page
);
72 * Removes the bookmark @p bm for the @p referurl specified.
74 int removeBookmark( const KUrl
& referurl
, const KBookmark
& bm
);
77 * Returns whether the given @p page is bookmarked.
79 bool isBookmarked( int page
) const;
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
87 QList
< QAction
* > actionsForUrl( const KUrl
& url
) const;
91 * The bookmark manager is requesting to open the specified @p url.
93 void openUrl( const KUrl
& url
);
96 * This signal is emitted whenever bookmarks have been saved.
101 * The bookmarks for specified @p url were changed.
103 * @since 0.7 (KDE 4.1)
105 void bookmarksChanged( const KUrl
& url
);
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
)