1 | /* |
---|
2 | |
---|
3 | Copyright 2015 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 IMAGEMODEL_H |
---|
23 | #define IMAGEMODEL_H |
---|
24 | |
---|
25 | #include <QCoreApplication> |
---|
26 | |
---|
27 | #include "model.h" |
---|
28 | |
---|
29 | namespace qpdfview |
---|
30 | { |
---|
31 | |
---|
32 | class ImagePlugin; |
---|
33 | |
---|
34 | namespace Model |
---|
35 | { |
---|
36 | class ImagePage : public Page |
---|
37 | { |
---|
38 | friend class ImageDocument; |
---|
39 | |
---|
40 | public: |
---|
41 | QSizeF size() const; |
---|
42 | |
---|
43 | QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const; |
---|
44 | |
---|
45 | private: |
---|
46 | Q_DISABLE_COPY(ImagePage) |
---|
47 | |
---|
48 | ImagePage(QImage image); |
---|
49 | |
---|
50 | QImage m_image; |
---|
51 | |
---|
52 | }; |
---|
53 | |
---|
54 | class ImageDocument : public Document |
---|
55 | { |
---|
56 | Q_DECLARE_TR_FUNCTIONS(Model::ImageDocument) |
---|
57 | |
---|
58 | friend class qpdfview::ImagePlugin; |
---|
59 | |
---|
60 | public: |
---|
61 | int numberOfPages() const; |
---|
62 | |
---|
63 | Page* page(int index) const; |
---|
64 | |
---|
65 | QStringList saveFilter() const; |
---|
66 | |
---|
67 | bool canSave() const; |
---|
68 | bool save(const QString& filePath, bool withChanges) const; |
---|
69 | |
---|
70 | void loadProperties(QStandardItemModel* propertiesModel) const; |
---|
71 | |
---|
72 | private: |
---|
73 | Q_DISABLE_COPY(ImageDocument) |
---|
74 | |
---|
75 | ImageDocument(QImage image); |
---|
76 | |
---|
77 | QImage m_image; |
---|
78 | |
---|
79 | }; |
---|
80 | } |
---|
81 | |
---|
82 | class ImagePlugin : public QObject, Plugin |
---|
83 | { |
---|
84 | Q_OBJECT |
---|
85 | Q_INTERFACES(qpdfview::Plugin) |
---|
86 | |
---|
87 | #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) |
---|
88 | |
---|
89 | Q_PLUGIN_METADATA(IID "local.qpdfview.Plugin") |
---|
90 | |
---|
91 | #endif // QT_VERSION |
---|
92 | |
---|
93 | public: |
---|
94 | ImagePlugin(QObject* parent = 0); |
---|
95 | |
---|
96 | Model::Document* loadDocument(const QString& filePath) const; |
---|
97 | |
---|
98 | private: |
---|
99 | Q_DISABLE_COPY(ImagePlugin) |
---|
100 | |
---|
101 | }; |
---|
102 | |
---|
103 | } // qpdfview |
---|
104 | |
---|
105 | #endif // IMAGEMODEL_H |
---|