1 /***************************************************************************
2 * Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> *
3 * Copyright (C) 2005 by Albert Astals Cid <tsdgeos@terra.es> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
11 #ifndef _OKULAR_DOCUMENTOBSERVER_H_
12 #define _OKULAR_DOCUMENTOBSERVER_H_
14 #include <QtCore/QVector>
16 #include <okular/core/okular_export.h>
20 /** IDs for observers. Globally defined here. **/
21 #define PRESENTATION_ID 1
24 #define THUMBNAILS_ID 4
28 #define PROGRESSWIDGET_ID 8
29 #define PAGESIZELABEL_ID 9
30 #define BOOKMARKLIST_ID 10
31 #define ANNOTATIONMODEL_ID 11
33 // the biggest id, useful for ignoring wrong id request
34 #define MAX_OBSERVER_ID 12
36 /** PRIORITIES for requests. Globally defined here. **/
37 #define PAGEVIEW_PRIO 1
38 #define PAGEVIEW_PRELOAD_PRIO 4
39 #define THUMBNAILS_PRIO 2
40 #define THUMBNAILS_PRELOAD_PRIO 5
41 #define PRESENTATION_PRIO 0
42 #define PRESENTATION_PRELOAD_PRIO 3
47 * @short Base class for objects being notified when something changes.
49 * Inherit this class and call Document->addObserver( yourClass ) to get
50 * notified of asynchronous events (new pixmap generated, or changed, etc..).
52 class OKULAR_EXPORT DocumentObserver
57 * Destroys the document observer.
59 virtual ~DocumentObserver();
62 * Must return an unique ID for each observer (used for notifications).
64 virtual uint
observerId() const = 0;
67 * Flags that can be sent from the document to all observers to
68 * inform them about the type of object that has been changed.
71 Pixmap
= 1, ///< Pixmaps has been changed
72 Bookmark
= 2, ///< Bookmarks has been changed
73 Highlights
= 4, ///< Highlighting information has been changed
74 TextSelection
= 8, ///< Text selection has been changed
75 Annotations
= 16, ///< Annotations has been changed
76 BoundingBox
= 32 ///< Bounding boxes have been changed
83 DocumentChanged
= 1, ///< The document is a new document.
84 NewLayoutForPages
= 2 ///< All the pages have
88 * This method is called whenever the document is initialized or reconstructed.
90 * @param pages The vector of pages of the document.
91 * @param setupFlags the flags with the information about the setup
93 virtual void notifySetup( const QVector
< Okular::Page
* > &pages
, int setupFlags
);
96 * This method is called whenever the viewport has been changed.
98 * @param smoothMove If true, the move shall be animated.
100 virtual void notifyViewportChanged( bool smoothMove
);
103 * This method is called whenever the content on @p page described by the
104 * passed @p flags has been changed.
106 virtual void notifyPageChanged( int page
, int flags
);
109 * This method is called whenever the content described by the passed @p flags
112 virtual void notifyContentsCleared( int flags
);
115 * This method is called whenever the visible rects have been changed.
117 virtual void notifyVisibleRectsChanged();
120 * This method is called whenever the zoom of the document has been changed.
122 virtual void notifyZoom( int factor
);
125 * Returns whether the observer agrees that all pixmaps for the given
126 * @p page can be unloaded to improve memory usage.
128 * Returns true per default.
130 virtual bool canUnloadPixmap( int page
) const;