File indexing completed on 2024-04-28 04:32:44
0001 /* 0002 SPDX-FileCopyrightText: 2005 Enrico Ros <eros.kde@email.it> 0003 SPDX-FileCopyrightText: 2005 Albert Astals Cid <aacid@kde.org> 0004 0005 Work sponsored by the LiMux project of the city of Munich: 0006 SPDX-FileCopyrightText: 2017 Klarälvdalens Datakonsult AB a KDAB Group company <info@kdab.com> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #ifndef _OKULAR_DOCUMENTOBSERVER_H_ 0012 #define _OKULAR_DOCUMENTOBSERVER_H_ 0013 0014 #include <QVector> 0015 0016 #include "okularcore_export.h" 0017 0018 namespace Okular 0019 { 0020 class Page; 0021 0022 /** 0023 * @short Base class for objects being notified when something changes. 0024 * 0025 * Inherit this class and call Document->addObserver( yourClass ) to get 0026 * notified of asynchronous events (new pixmap generated, or changed, etc..). 0027 */ 0028 class OKULARCORE_EXPORT DocumentObserver 0029 { 0030 public: 0031 DocumentObserver(); 0032 /** 0033 * Destroys the document observer. 0034 */ 0035 virtual ~DocumentObserver(); 0036 0037 DocumentObserver(const DocumentObserver &) = delete; 0038 DocumentObserver &operator=(const DocumentObserver &) = delete; 0039 0040 /** 0041 * Flags that can be sent from the document to all observers to 0042 * inform them about the type of object that has been changed. 0043 */ 0044 enum ChangedFlags { 0045 Pixmap = 1, ///< Pixmaps has been changed 0046 Bookmark = 2, ///< Bookmarks has been changed 0047 Highlights = 4, ///< Highlighting information has been changed 0048 TextSelection = 8, ///< Text selection has been changed 0049 Annotations = 16, ///< Annotations have been changed 0050 BoundingBox = 32, ///< Bounding boxes have been changed 0051 }; 0052 0053 /** 0054 * ... 0055 */ 0056 enum SetupFlags { 0057 DocumentChanged = 1, ///< The document is a new document. 0058 NewLayoutForPages = 2, ///< All the pages have 0059 UrlChanged = 4 ///< The URL has changed @since 1.3 0060 }; 0061 0062 /** 0063 * This method is called whenever the document is initialized or reconstructed. 0064 * 0065 * @param pages The vector of pages of the document. 0066 * @param setupFlags the flags with the information about the setup 0067 */ 0068 virtual void notifySetup(const QVector<Okular::Page *> &pages, int setupFlags); 0069 0070 /** 0071 * This method is called whenever the viewport has been changed. 0072 * 0073 * @param smoothMove If true, the move shall be animated. 0074 */ 0075 virtual void notifyViewportChanged(bool smoothMove); 0076 0077 /** 0078 * This method is called whenever the content on @p page described by the 0079 * passed @p flags has been changed. 0080 */ 0081 virtual void notifyPageChanged(int page, int flags); 0082 0083 /** 0084 * This method is called whenever the content described by the passed @p flags 0085 * has been cleared. 0086 */ 0087 virtual void notifyContentsCleared(int flags); 0088 0089 /** 0090 * This method is called whenever the visible rects have been changed. 0091 */ 0092 virtual void notifyVisibleRectsChanged(); 0093 0094 /** 0095 * This method is called whenever the zoom of the document has been changed. 0096 */ 0097 virtual void notifyZoom(int factor); 0098 0099 /** 0100 * Returns whether the observer agrees that all pixmaps for the given 0101 * @p page can be unloaded to improve memory usage. 0102 * 0103 * Returns true per default. 0104 */ 0105 virtual bool canUnloadPixmap(int page) const; 0106 0107 /** 0108 * This method is called after the current page of the document has been entered. 0109 * 0110 * @param previous The number of the previous page (is @c -1 for the initial page change). 0111 * @param current The number of the current page. 0112 * 0113 * @since 0.16 (KDE 4.10) 0114 */ 0115 virtual void notifyCurrentPageChanged(int previous, int current); 0116 0117 private: 0118 class Private; 0119 const Private *d; 0120 }; 0121 0122 } 0123 0124 #endif