~ubuntu-branches/ubuntu/vivid/qpdfview/vivid

« back to all changes in this revision

Viewing changes to sources/tileitem.h

  • Committer: Package Import Robot
  • Author(s): Benjamin Eltzner
  • Date: 2014-10-22 21:49:15 UTC
  • mfrom: (1.2.15)
  • Revision ID: package-import@ubuntu.com-20141022214915-agqeoe318lzs2s4d
Tags: 0.4.12-1
* New upstream release.
* Fixed option to zoom to selection and implemented tiled rendering
  (Closes: #739554)
* Enable support for qt5 and poppler-qt5.
* Explicit dependence on hicolor-icon-theme.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
Copyright 2014 Adam Reichold
 
4
 
 
5
This file is part of qpdfview.
 
6
 
 
7
qpdfview is free software: you can redistribute it and/or modify
 
8
it under the terms of the GNU General Public License as published by
 
9
the Free Software Foundation, either version 2 of the License, or
 
10
(at your option) any later version.
 
11
 
 
12
qpdfview is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
GNU General Public License for more details.
 
16
 
 
17
You should have received a copy of the GNU General Public License
 
18
along 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
 
 
31
namespace qpdfview
 
32
{
 
33
 
 
34
class Settings;
 
35
class RenderTask;
 
36
class PageItem;
 
37
 
 
38
class TileItem : public QObject
 
39
{
 
40
    Q_OBJECT
 
41
 
 
42
public:
 
43
    TileItem(QObject* parent = 0);
 
44
    ~TileItem();
 
45
 
 
46
    inline const QRect& rect() const { return m_rect; }
 
47
    inline void setRect(const QRect& rect) { m_rect = rect; }
 
48
 
 
49
    inline const QRectF& cropRect() const { return m_cropRect; }
 
50
    void setCropRect(const QRectF& cropRect);
 
51
 
 
52
    inline void dropPixmap() { m_pixmap = QPixmap(); }
 
53
    inline void dropObsoletePixmap() { m_obsoletePixmap = QPixmap(); }
 
54
 
 
55
    static void dropCachedPixmaps(PageItem* page);
 
56
 
 
57
    void paint(QPainter* painter, const QPointF& topLeft);
 
58
 
 
59
public slots:
 
60
    void refresh(bool keepObsoletePixmaps = false);
 
61
 
 
62
    int startRender(bool prefetch = false);
 
63
    void cancelRender();
 
64
 
 
65
    void deleteAfterRender();
 
66
 
 
67
protected slots:
 
68
    void on_renderTask_finished();
 
69
    void on_renderTask_imageReady(const RenderParam& renderParam,
 
70
                                  const QRect& rect, bool prefetch,
 
71
                                  QImage image, QRectF cropRect);
 
72
 
 
73
private:
 
74
    Q_DISABLE_COPY(TileItem)
 
75
 
 
76
    static Settings* s_settings;
 
77
 
 
78
    typedef QPair< PageItem*, QByteArray > CacheKey;
 
79
    typedef QPair< QPixmap, QRectF > CacheObject;
 
80
 
 
81
    static QCache< CacheKey, CacheObject > s_cache;
 
82
 
 
83
    PageItem* parentPage() const;
 
84
    CacheKey cacheKey() const;
 
85
 
 
86
    QRect m_rect;
 
87
    QRectF m_cropRect;
 
88
 
 
89
    bool m_pixmapError;
 
90
    QPixmap m_pixmap;
 
91
    QPixmap m_obsoletePixmap;
 
92
 
 
93
    QPixmap takePixmap();
 
94
 
 
95
    RenderTask* m_renderTask;
 
96
 
 
97
};
 
98
 
 
99
} // qpdfview
 
100
 
 
101
#endif // PAGEITEM_H