source: terepaima/terepaima-0.4.16/sources/tileitem.h

desarrollostretch
Last change on this file was 1f4adec, checked in by aosorio <aosorio@…>, 8 years ago

Agregado proyecto base, esto luego del dh_make -f

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2
3Copyright 2014 Adam Reichold
4
5This file is part of qpdfview.
6
7qpdfview is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 of the License, or
10(at your option) any later version.
11
12qpdfview is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with qpdfview.  If not, see <http://www.gnu.org/licenses/>.
19
20*/
21
22#ifndef TILEITEM_H
23#define TILEITEM_H
24
25#include <QCache>
26#include <QObject>
27#include <QPixmap>
28
29#include "global.h"
30
31namespace qpdfview
32{
33
34class Settings;
35class RenderParam;
36class RenderTask;
37class PageItem;
38
39class TileItem : public QObject
40{
41    Q_OBJECT
42
43public:
44    TileItem(PageItem* page);
45    ~TileItem();
46
47    const QRect& rect() const { return m_rect; }
48    void setRect(const QRect& rect) { m_rect = rect; }
49
50    const QRectF& cropRect() const { return m_cropRect; }
51    void resetCropRect() { m_cropRect = QRectF(); }
52    void setCropRect(const QRectF& cropRect);
53
54    void dropPixmap() { m_pixmap = QPixmap(); }
55    void dropObsoletePixmap() { m_obsoletePixmap = QPixmap(); }
56
57    static void dropCachedPixmaps(PageItem* page);
58
59    bool paint(QPainter* painter, const QPointF& topLeft);
60
61public slots:
62    void refresh(bool keepObsoletePixmaps = false);
63
64    int startRender(bool prefetch = false);
65    void cancelRender();
66
67    void deleteAfterRender();
68
69protected slots:
70    void on_renderTask_finished();
71    void on_renderTask_imageReady(const RenderParam& renderParam,
72                                  const QRect& rect, bool prefetch,
73                                  const QImage& image, const QRectF& cropRect);
74
75private:
76    Q_DISABLE_COPY(TileItem)
77
78    static Settings* s_settings;
79
80    typedef QPair< PageItem*, QByteArray > CacheKey;
81    typedef QPair< QPixmap, QRectF > CacheObject;
82
83    static QCache< CacheKey, CacheObject > s_cache;
84
85    CacheKey cacheKey() const;
86
87    PageItem* m_page;
88
89    QRect m_rect;
90    QRectF m_cropRect;
91
92    bool m_pixmapError;
93    QPixmap m_pixmap;
94    QPixmap m_obsoletePixmap;
95
96    QPixmap takePixmap();
97
98    bool m_deleteAfterRender;
99    RenderTask* m_renderTask;
100
101};
102
103} // qpdfview
104
105#endif // PAGEITEM_H
Note: See TracBrowser for help on using the repository browser.