2006-12-27 16:04:49 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2006 by Pino Toscano <pino@kde.org> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _OKULAR_BOOKMARK_MANAGER_H_
|
|
|
|
#define _OKULAR_BOOKMARK_MANAGER_H_
|
|
|
|
|
|
|
|
#include <kbookmark.h>
|
|
|
|
|
2014-10-27 21:35:06 +00:00
|
|
|
#include "okularcore_export.h"
|
2015-03-02 12:07:33 +00:00
|
|
|
#include <QObject>
|
2015-01-29 19:55:57 +00:00
|
|
|
#include <QUrl>
|
2006-12-27 16:04:49 +00:00
|
|
|
|
2007-01-13 17:28:54 +00:00
|
|
|
class QAction;
|
2006-12-27 16:04:49 +00:00
|
|
|
|
|
|
|
namespace Okular {
|
|
|
|
|
|
|
|
class Document;
|
2007-10-28 18:31:33 +00:00
|
|
|
class DocumentPrivate;
|
2006-12-27 16:04:49 +00:00
|
|
|
class DocumentViewport;
|
|
|
|
|
2007-01-20 14:51:43 +00:00
|
|
|
/**
|
|
|
|
* @brief Bookmarks manager utility.
|
|
|
|
*
|
|
|
|
* This class is responsible for loading and saving the bookmarks using the
|
|
|
|
* proper format, and for working with them (eg querying, adding, removing).
|
|
|
|
*/
|
2014-10-27 21:35:06 +00:00
|
|
|
class OKULARCORE_EXPORT BookmarkManager : public QObject
|
2006-12-27 16:04:49 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~BookmarkManager();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of documents with bookmarks.
|
|
|
|
*/
|
2014-08-13 11:07:44 +00:00
|
|
|
QList<QUrl> files() const;
|
2011-10-25 20:21:22 +00:00
|
|
|
|
2006-12-27 16:04:49 +00:00
|
|
|
/**
|
|
|
|
* Returns the list of bookmarks for the specified @p url.
|
|
|
|
*/
|
2015-01-29 19:55:57 +00:00
|
|
|
KBookmark::List bookmarks( const QUrl& url ) const;
|
2006-12-27 16:04:49 +00:00
|
|
|
|
2011-10-25 20:21:22 +00:00
|
|
|
/**
|
|
|
|
* Returns the list of bookmarks for document
|
|
|
|
* @since 0.14 (KDE 4.8)
|
|
|
|
*/
|
|
|
|
KBookmark::List bookmarks() const;
|
2012-03-26 18:01:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of bookmarks for the given page of the document
|
|
|
|
* @since 0.15 (KDE 4.9)
|
|
|
|
*/
|
|
|
|
KBookmark::List bookmarks( int page ) const;
|
|
|
|
|
2011-10-25 20:21:22 +00:00
|
|
|
/**
|
|
|
|
* Returns the bookmark for the given page of the document
|
|
|
|
* @since 0.14 (KDE 4.8)
|
|
|
|
*/
|
|
|
|
KBookmark bookmark( int page ) const;
|
2012-03-26 18:01:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the bookmark for the given @p viewport of the document
|
|
|
|
* @since 0.15 (KDE 4.9)
|
|
|
|
*/
|
|
|
|
KBookmark bookmark( const DocumentViewport &viewport ) const;
|
|
|
|
|
2006-12-27 16:04:49 +00:00
|
|
|
/**
|
|
|
|
* Forces to save the list of bookmarks.
|
|
|
|
*/
|
|
|
|
void save() const;
|
|
|
|
|
2007-10-28 18:31:33 +00:00
|
|
|
/**
|
|
|
|
* Adds a bookmark for the given @p page.
|
|
|
|
*/
|
|
|
|
void addBookmark( int page );
|
|
|
|
|
2012-03-26 18:01:01 +00:00
|
|
|
/**
|
|
|
|
* Adds a bookmark for the given viewport @p vp
|
|
|
|
* @since 0.15 (KDE 4.9)
|
|
|
|
*/
|
|
|
|
void addBookmark( const DocumentViewport &vp );
|
|
|
|
|
2006-12-27 16:04:49 +00:00
|
|
|
/**
|
|
|
|
* Adds a new bookmark for the @p referurl at the specified viewport @p vp,
|
|
|
|
* with an optional @p title.
|
|
|
|
*
|
2018-10-18 19:04:49 +00:00
|
|
|
* If no @p title is specified, then \em \#n will be used.
|
2006-12-27 16:04:49 +00:00
|
|
|
*/
|
2015-01-29 19:55:57 +00:00
|
|
|
bool addBookmark( const QUrl& referurl, const Okular::DocumentViewport& vp, const QString& title = QString() );
|
2006-12-27 16:04:49 +00:00
|
|
|
|
2007-10-28 18:31:33 +00:00
|
|
|
/**
|
|
|
|
* Remove a bookmark for the given @p page.
|
|
|
|
*/
|
|
|
|
void removeBookmark( int page );
|
|
|
|
|
2012-03-26 18:01:01 +00:00
|
|
|
/**
|
|
|
|
* Remove a bookmark for the given viewport @p vp
|
|
|
|
* @since 0.15 (KDE 4.9)
|
|
|
|
*/
|
|
|
|
void removeBookmark( const DocumentViewport &vp );
|
|
|
|
|
2006-12-27 16:04:49 +00:00
|
|
|
/**
|
|
|
|
* Removes the bookmark @p bm for the @p referurl specified.
|
|
|
|
*/
|
2015-01-29 19:55:57 +00:00
|
|
|
int removeBookmark( const QUrl& referurl, const KBookmark& bm );
|
2006-12-27 16:04:49 +00:00
|
|
|
|
2010-01-09 13:13:43 +00:00
|
|
|
/**
|
|
|
|
* Removes the bookmarks in @p list for the @p referurl specified.
|
|
|
|
*
|
|
|
|
* @note it will remove only the bookmarks which belong to @p referurl
|
|
|
|
*
|
|
|
|
* @since 0.11 (KDE 4.5)
|
|
|
|
*/
|
2015-01-29 19:55:57 +00:00
|
|
|
void removeBookmarks( const QUrl& referurl, const KBookmark::List& list );
|
2010-01-09 13:13:43 +00:00
|
|
|
|
2011-10-25 20:21:22 +00:00
|
|
|
/**
|
|
|
|
* Returns the bookmark given bookmark of the document
|
|
|
|
* @since 0.14 (KDE 4.8)
|
|
|
|
*/
|
|
|
|
void renameBookmark( KBookmark* bm, const QString& newName );
|
|
|
|
|
2012-03-08 22:26:44 +00:00
|
|
|
/**
|
|
|
|
* Renames the top-level bookmark for the @p referurl specified with
|
|
|
|
* the @p newName specified.
|
|
|
|
* @since 0.15 (KDE 4.9)
|
|
|
|
*/
|
2015-01-29 19:55:57 +00:00
|
|
|
void renameBookmark( const QUrl& referurl, const QString& newName );
|
2012-03-08 22:26:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns title for the @p referurl
|
|
|
|
* @since 0.15 (KDE 4.9)
|
|
|
|
*/
|
2015-01-29 19:55:57 +00:00
|
|
|
QString titleForUrl( const QUrl& referurl ) const;
|
2012-03-08 22:26:44 +00:00
|
|
|
|
2007-10-28 18:31:33 +00:00
|
|
|
/**
|
|
|
|
* Returns whether the given @p page is bookmarked.
|
|
|
|
*/
|
|
|
|
bool isBookmarked( int page ) const;
|
|
|
|
|
2012-03-26 18:01:01 +00:00
|
|
|
/**
|
2013-06-24 10:46:16 +00:00
|
|
|
* Return whether the given @p viewport is bookmarked.
|
2012-03-26 18:01:01 +00:00
|
|
|
* @since 0.15 (KDE 4.9)
|
|
|
|
*/
|
|
|
|
bool isBookmarked( const DocumentViewport &viewport ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a @p viewport, returns the next bookmark
|
|
|
|
* @since 0.15 (KDE 4.9)
|
|
|
|
*/
|
|
|
|
KBookmark nextBookmark( const DocumentViewport &viewport ) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Given a @p viewport, returns the previous bookmark
|
|
|
|
* @since 0.15 (KDE 4.9)
|
|
|
|
*/
|
|
|
|
KBookmark previousBookmark( const DocumentViewport &viewport ) const;
|
|
|
|
|
2007-01-13 17:28:54 +00:00
|
|
|
/**
|
|
|
|
* Returns a list of actions for the bookmarks of the specified @p url.
|
|
|
|
*
|
|
|
|
* @note the actions will have no parents, so you have to delete them
|
|
|
|
* yourself
|
|
|
|
*/
|
2015-01-29 19:55:57 +00:00
|
|
|
QList< QAction* > actionsForUrl( const QUrl& url ) const;
|
2007-01-13 17:28:54 +00:00
|
|
|
|
2006-12-27 16:04:49 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* The bookmark manager is requesting to open the specified @p url.
|
|
|
|
*/
|
2015-01-29 19:55:57 +00:00
|
|
|
void openUrl( const QUrl& url );
|
2006-12-27 16:04:49 +00:00
|
|
|
|
2008-02-05 17:36:04 +00:00
|
|
|
/**
|
|
|
|
* This signal is emitted whenever bookmarks have been saved.
|
|
|
|
*/
|
|
|
|
void saved();
|
|
|
|
|
2008-04-04 09:50:41 +00:00
|
|
|
/**
|
|
|
|
* The bookmarks for specified @p url were changed.
|
|
|
|
*
|
|
|
|
* @since 0.7 (KDE 4.1)
|
|
|
|
*/
|
2015-01-29 19:55:57 +00:00
|
|
|
void bookmarksChanged( const QUrl& url );
|
2008-04-04 09:50:41 +00:00
|
|
|
|
2006-12-27 16:04:49 +00:00
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private * const d;
|
2007-01-13 15:26:05 +00:00
|
|
|
friend class Private;
|
2006-12-27 16:04:49 +00:00
|
|
|
|
|
|
|
// private interface used by the Document
|
|
|
|
friend class Document;
|
2007-10-28 18:31:33 +00:00
|
|
|
friend class DocumentPrivate;
|
2007-01-05 12:44:35 +00:00
|
|
|
|
2007-10-28 18:31:33 +00:00
|
|
|
BookmarkManager( DocumentPrivate * document );
|
2007-01-05 12:44:35 +00:00
|
|
|
|
2015-01-29 19:55:57 +00:00
|
|
|
void setUrl( const QUrl& url );
|
2006-12-27 16:04:49 +00:00
|
|
|
bool setPageBookmark( int page );
|
2007-01-13 14:45:51 +00:00
|
|
|
bool removePageBookmark( int page );
|
2006-12-27 16:04:49 +00:00
|
|
|
|
|
|
|
Q_DISABLE_COPY( BookmarkManager )
|
2009-12-26 16:57:09 +00:00
|
|
|
|
|
|
|
Q_PRIVATE_SLOT( d, void _o_changed( const QString &, const QString & ) )
|
2006-12-27 16:04:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|