Okular

observer.h
1 /*
2  SPDX-FileCopyrightText: 2005 Enrico Ros <[email protected]>
3  SPDX-FileCopyrightText: 2005 Albert Astals Cid <[email protected]>
4 
5  Work sponsored by the LiMux project of the city of Munich:
6  SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB a KDAB Group company <[email protected]>
7 
8  SPDX-License-Identifier: GPL-2.0-or-later
9 */
10 
11 #ifndef _OKULAR_DOCUMENTOBSERVER_H_
12 #define _OKULAR_DOCUMENTOBSERVER_H_
13 
14 #include <QVector>
15 
16 #include "okularcore_export.h"
17 
18 namespace Okular
19 {
20 class Page;
21 
22 /**
23  * @short Base class for objects being notified when something changes.
24  *
25  * Inherit this class and call Document->addObserver( yourClass ) to get
26  * notified of asynchronous events (new pixmap generated, or changed, etc..).
27  */
28 class OKULARCORE_EXPORT DocumentObserver
29 {
30 public:
32  /**
33  * Destroys the document observer.
34  */
35  virtual ~DocumentObserver();
36 
37  DocumentObserver(const DocumentObserver &) = delete;
38  DocumentObserver &operator=(const DocumentObserver &) = delete;
39 
40  /**
41  * Flags that can be sent from the document to all observers to
42  * inform them about the type of object that has been changed.
43  */
44  enum ChangedFlags {
45  Pixmap = 1, ///< Pixmaps has been changed
46  Bookmark = 2, ///< Bookmarks has been changed
47  Highlights = 4, ///< Highlighting information has been changed
48  TextSelection = 8, ///< Text selection has been changed
49  Annotations = 16, ///< Annotations have been changed
50  BoundingBox = 32, ///< Bounding boxes have been changed
51  NeedSaveAs = 64 ///< Set when "Save" is needed or annotation/form changes will be lost @since 0.15 (KDE 4.9) @deprecated
52  };
53 
54  /**
55  * ...
56  */
57  enum SetupFlags {
58  DocumentChanged = 1, ///< The document is a new document.
59  NewLayoutForPages = 2, ///< All the pages have
60  UrlChanged = 4 ///< The URL has changed @since 1.3
61  };
62 
63  /**
64  * This method is called whenever the document is initialized or reconstructed.
65  *
66  * @param pages The vector of pages of the document.
67  * @param setupFlags the flags with the information about the setup
68  */
69  virtual void notifySetup(const QVector<Okular::Page *> &pages, int setupFlags);
70 
71  /**
72  * This method is called whenever the viewport has been changed.
73  *
74  * @param smoothMove If true, the move shall be animated.
75  */
76  virtual void notifyViewportChanged(bool smoothMove);
77 
78  /**
79  * This method is called whenever the content on @p page described by the
80  * passed @p flags has been changed.
81  */
82  virtual void notifyPageChanged(int page, int flags);
83 
84  /**
85  * This method is called whenever the content described by the passed @p flags
86  * has been cleared.
87  */
88  virtual void notifyContentsCleared(int flags);
89 
90  /**
91  * This method is called whenever the visible rects have been changed.
92  */
93  virtual void notifyVisibleRectsChanged();
94 
95  /**
96  * This method is called whenever the zoom of the document has been changed.
97  */
98  virtual void notifyZoom(int factor);
99 
100  /**
101  * Returns whether the observer agrees that all pixmaps for the given
102  * @p page can be unloaded to improve memory usage.
103  *
104  * Returns true per default.
105  */
106  virtual bool canUnloadPixmap(int page) const;
107 
108  /**
109  * This method is called after the current page of the document has been entered.
110  *
111  * @param previous The number of the previous page (is @c -1 for the initial page change).
112  * @param current The number of the current page.
113  *
114  * @since 0.16 (KDE 4.10)
115  */
116  virtual void notifyCurrentPageChanged(int previous, int current);
117 
118 private:
119  class Private;
120  const Private *d;
121 };
122 
123 }
124 
125 #endif
global.h
Definition: action.h:16
ChangedFlags
Flags that can be sent from the document to all observers to inform them about the type of object tha...
Definition: observer.h:44
Base class for objects being notified when something changes.
Definition: observer.h:28
Wrapper around the information needed to generate the selection area There are two assumptions inside...
Definition: misc.h:33
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Jan 25 2022 22:32:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.