kviewshell
documentPageCache.h
Go to the documentation of this file.00001 // -*- C++ -*- 00002 // 00003 // Class: documentPageCache 00004 // 00005 // Cache that holds a number of pages in a document. 00006 // Part of KDVI- A previewer for TeX DVI files. 00007 // 00008 // (C) 2004 Stefan Kebekus. Distributed under the GPL. 00009 00010 #ifndef _documentpagecache_h_ 00011 #define _documentpagecache_h_ 00012 00013 #include "renderedDocumentPagePixmap.h" 00014 #include "pageNumber.h" 00015 #include "pageSize.h" 00016 #include "selection.h" 00017 00018 #include <qcache.h> 00019 #include <qguardedptr.h> 00020 #include <qobject.h> 00021 00022 class DocumentRenderer; 00023 class QPixmap; 00024 class RenderedDocumentPage; 00025 00026 00027 class DocumentPageCache: public QObject 00028 { 00029 Q_OBJECT 00030 00031 public: 00032 DocumentPageCache(); 00033 virtual ~DocumentPageCache(); 00034 00040 void setRenderer(DocumentRenderer *_renderer); 00041 00042 void setResolution(double res); 00043 double getResolution() const {return resolutionInDPI;} 00044 00045 const TextSelection& selectedText() const { return userSelection; } 00046 00047 void deselectText(); 00048 void selectText(const TextSelection& selection); 00049 00053 SimplePageSize sizeOfPage(const PageNumber& page = 1) const; 00054 00059 QSize sizeOfPageInPixel(const PageNumber& page) const; 00060 00064 RenderedDocumentPagePixmap* getPage(const PageNumber& pageNr); 00065 00067 bool isPageCached(const PageNumber& pageNumber, const QSize& size); 00068 00071 bool isPageCached(const PageNumber& pageNumber); 00072 00076 QPixmap createThumbnail(const PageNumber& pageNr, int width); 00077 00078 signals: 00082 void paperSizeChanged(); 00083 00087 void textSelected(bool); 00088 00089 public slots: 00091 void clear(); 00092 00094 void setUserPreferredSize(const SimplePageSize& t); 00095 void setUseDocumentSpecifiedSize(bool); 00096 00097 protected: 00102 virtual RenderedDocumentPagePixmap* createDocumentPagePixmap() const; 00103 00105 QString createKey(const PageNumber& pageNumber, const QSize& size); 00106 00109 QString createKey(const PageNumber& pageNumber); 00110 00111 QGuardedPtr<DocumentRenderer> renderer; 00112 00113 private: 00116 Q_UINT32 maxMemory; 00117 00126 double resolutionInDPI; 00127 00128 SimplePageSize userPreferredSize; 00129 bool useDocumentSpecifiedSize; 00130 00131 TextSelection userSelection; 00132 00133 00135 QCache<RenderedDocumentPagePixmap> LRUCache; 00136 00139 RenderedDocumentPagePixmap thumbnailPage; 00140 }; 00141 00142 00143 #endif