Okular

observer.h
1/*
2 SPDX-FileCopyrightText: 2005 Enrico Ros <eros.kde@email.it>
3 SPDX-FileCopyrightText: 2005 Albert Astals Cid <aacid@kde.org>
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 <info@kdab.com>
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
18namespace Okular
19{
20class 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 */
28class OKULARCORE_EXPORT DocumentObserver
29{
30public:
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 */
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 };
52
53 /**
54 * ...
55 */
57 DocumentChanged = 1, ///< The document is a new document.
58 NewLayoutForPages = 2, ///< All the pages have
59 UrlChanged = 4 ///< The URL has changed @since 1.3
60 };
61
62 /**
63 * This method is called whenever the document is initialized or reconstructed.
64 *
65 * @param pages The vector of pages of the document.
66 * @param setupFlags the flags with the information about the setup
67 */
68 virtual void notifySetup(const QVector<Okular::Page *> &pages, int setupFlags);
69
70 /**
71 * This method is called whenever the viewport has been changed.
72 *
73 * @param smoothMove If true, the move shall be animated.
74 */
75 virtual void notifyViewportChanged(bool smoothMove);
76
77 /**
78 * This method is called whenever the content on @p page described by the
79 * passed @p flags has been changed.
80 */
81 virtual void notifyPageChanged(int page, int flags);
82
83 /**
84 * This method is called whenever the content described by the passed @p flags
85 * has been cleared.
86 */
87 virtual void notifyContentsCleared(int flags);
88
89 /**
90 * This method is called whenever the visible rects have been changed.
91 */
92 virtual void notifyVisibleRectsChanged();
93
94 /**
95 * This method is called whenever the zoom of the document has been changed.
96 */
97 virtual void notifyZoom(int factor);
98
99 /**
100 * Returns whether the observer agrees that all pixmaps for the given
101 * @p page can be unloaded to improve memory usage.
102 *
103 * Returns true per default.
104 */
105 virtual bool canUnloadPixmap(int page) const;
106
107 /**
108 * This method is called after the current page of the document has been entered.
109 *
110 * @param previous The number of the previous page (is @c -1 for the initial page change).
111 * @param current The number of the current page.
112 *
113 * @since 0.16 (KDE 4.10)
114 */
115 virtual void notifyCurrentPageChanged(int previous, int current);
116
117private:
118 class Private;
119 const Private *d;
120};
121
122}
123
124#endif
Base class for objects being notified when something changes.
Definition observer.h:29
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
Wrapper around the information needed to generate the selection area.
Definition misc.h:19
global.h
Definition action.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:48:49 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.