diff --git a/CMakeLists.txt b/CMakeLists.txt index dc9a9540b..e9dc22275 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ set(okularcore_SRCS core/document.cpp core/generator.cpp core/link.cpp + core/observer.cpp core/page.cpp core/pagetransition.cpp core/rotationjob.cpp diff --git a/core/observer.cpp b/core/observer.cpp new file mode 100644 index 000000000..6a4a95e53 --- /dev/null +++ b/core/observer.cpp @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2005 by Enrico Ros * + * Copyright (C) 2005 by Albert Astals Cid * + * * + * 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. * + ***************************************************************************/ + +#include "observer.h" + +using namespace Okular; + +DocumentObserver::~DocumentObserver() +{ +} + +void DocumentObserver::notifySetup( const QVector< Okular::Page * >&, bool ) +{ +} + +void DocumentObserver::notifyViewportChanged( bool ) +{ +} + +void DocumentObserver::notifyPageChanged( int, int ) +{ +} + +void DocumentObserver::notifyContentsCleared( int ) +{ +} + +void DocumentObserver::notifyVisibleRectsChanged() +{ +} + +bool DocumentObserver::canUnloadPixmap( int ) const +{ + return true; +} diff --git a/core/observer.h b/core/observer.h index 857c92722..db0faa0de 100644 --- a/core/observer.h +++ b/core/observer.h @@ -52,7 +52,7 @@ class DocumentObserver /** * Destroys the document observer. */ - virtual ~DocumentObserver() {}; + virtual ~DocumentObserver(); /** * Must return an unique ID for each observer (used for notifications). @@ -83,14 +83,49 @@ class DocumentObserver VisibleAreas = 16 ///< The visible are changed }; - virtual void notifySetup( const QVector< Okular::Page * > &/*pages*/, bool /*documentChanged*/ ) {}; - virtual void notifyViewportChanged( bool /*smoothMove*/ ) {}; - virtual void notifyPageChanged( int /*pageNumber*/, int /*changedFlags*/ ) {}; - virtual void notifyContentsCleared( int /*changedFlags*/ ) {}; - virtual void notifyVisibleRectsChanged() {}; + /** + * This method is called whenever the document is initialized or reconstructed. + * + * @param pages The vector of pages of the document. + * @param documentChanged If true, the document is reconstructed. + */ + virtual void notifySetup( const QVector< Okular::Page * > &pages, bool documentChanged ); + + /** + * This method is called whenever the viewport has been changed. + * + * @param smoothMove If true, the move shall be animated. + */ + virtual void notifyViewportChanged( bool smoothMove ); + + /** + * This method is called whenever the content on @p page described by the + * passed @p flags has been changed. + */ + virtual void notifyPageChanged( int page, int flags ); + + /** + * This method is called whenever the content described by the passed @p flags + * has been cleared. + */ + virtual void notifyContentsCleared( int flags ); + + /** + * This method is called whenever the visible rects have been changed. + */ + virtual void notifyVisibleRectsChanged(); + + /** + * Returns whether the observer agrees that all pixmaps for the given + * @p page can be unloaded to improve memory usage. + * + * Returns true per default. + */ + virtual bool canUnloadPixmap( int page ) const; - // queries to observers - virtual bool canUnloadPixmap( int /*pageNum*/ ) const { return true; } + private: + class Private; + Private* d; }; }