1 | /* |
---|
2 | |
---|
3 | Copyright 2013 Alexander Volkov |
---|
4 | Copyright 2013 Adam Reichold |
---|
5 | |
---|
6 | This file is part of qpdfview. |
---|
7 | |
---|
8 | qpdfview is free software: you can redistribute it and/or modify |
---|
9 | it under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation, either version 2 of the License, or |
---|
11 | (at your option) any later version. |
---|
12 | |
---|
13 | qpdfview is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with qpdfview. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef PSMODEL_H |
---|
24 | #define PSMODEL_H |
---|
25 | |
---|
26 | #include <QCoreApplication> |
---|
27 | #include <QMutex> |
---|
28 | |
---|
29 | class QFormLayout; |
---|
30 | class QSettings; |
---|
31 | class QSpinBox; |
---|
32 | |
---|
33 | struct SpectrePage; |
---|
34 | struct SpectreDocument; |
---|
35 | struct SpectreRenderContext; |
---|
36 | |
---|
37 | #include "model.h" |
---|
38 | |
---|
39 | namespace qpdfview |
---|
40 | { |
---|
41 | |
---|
42 | class PsPlugin; |
---|
43 | |
---|
44 | namespace Model |
---|
45 | { |
---|
46 | class PsPage : public Page |
---|
47 | { |
---|
48 | friend class PsDocument; |
---|
49 | |
---|
50 | public: |
---|
51 | ~PsPage(); |
---|
52 | |
---|
53 | QSizeF size() const; |
---|
54 | |
---|
55 | QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, const QRect& boundingRect) const; |
---|
56 | |
---|
57 | private: |
---|
58 | Q_DISABLE_COPY(PsPage) |
---|
59 | |
---|
60 | PsPage(QMutex* mutex, SpectrePage* page, SpectreRenderContext* renderContext); |
---|
61 | |
---|
62 | mutable QMutex* m_mutex; |
---|
63 | SpectrePage* m_page; |
---|
64 | SpectreRenderContext* m_renderContext; |
---|
65 | |
---|
66 | }; |
---|
67 | |
---|
68 | class PsDocument : public Document |
---|
69 | { |
---|
70 | Q_DECLARE_TR_FUNCTIONS(Model::PsDocument) |
---|
71 | |
---|
72 | friend class qpdfview::PsPlugin; |
---|
73 | |
---|
74 | public: |
---|
75 | ~PsDocument(); |
---|
76 | |
---|
77 | int numberOfPages() const; |
---|
78 | |
---|
79 | Page* page(int index) const; |
---|
80 | |
---|
81 | QStringList saveFilter() const; |
---|
82 | |
---|
83 | bool canSave() const; |
---|
84 | bool save(const QString& filePath, bool withChanges) const; |
---|
85 | |
---|
86 | bool canBePrintedUsingCUPS() const; |
---|
87 | |
---|
88 | void loadProperties(QStandardItemModel* propertiesModel) const; |
---|
89 | |
---|
90 | private: |
---|
91 | Q_DISABLE_COPY(PsDocument) |
---|
92 | |
---|
93 | PsDocument(SpectreDocument* document, SpectreRenderContext* renderContext); |
---|
94 | |
---|
95 | mutable QMutex m_mutex; |
---|
96 | SpectreDocument* m_document; |
---|
97 | SpectreRenderContext* m_renderContext; |
---|
98 | |
---|
99 | }; |
---|
100 | } |
---|
101 | |
---|
102 | class PsSettingsWidget : public SettingsWidget |
---|
103 | { |
---|
104 | Q_OBJECT |
---|
105 | |
---|
106 | public: |
---|
107 | PsSettingsWidget(QSettings* settings, QWidget* parent = 0); |
---|
108 | |
---|
109 | void accept(); |
---|
110 | void reset(); |
---|
111 | |
---|
112 | private: |
---|
113 | Q_DISABLE_COPY(PsSettingsWidget) |
---|
114 | |
---|
115 | QSettings* m_settings; |
---|
116 | |
---|
117 | QFormLayout* m_layout; |
---|
118 | |
---|
119 | QSpinBox* m_graphicsAntialiasBitsSpinBox; |
---|
120 | QSpinBox* m_textAntialiasBitsSpinBox; |
---|
121 | |
---|
122 | }; |
---|
123 | |
---|
124 | class PsPlugin : public QObject, Plugin |
---|
125 | { |
---|
126 | Q_OBJECT |
---|
127 | Q_INTERFACES(qpdfview::Plugin) |
---|
128 | |
---|
129 | #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) |
---|
130 | |
---|
131 | Q_PLUGIN_METADATA(IID "local.qpdfview.Plugin") |
---|
132 | |
---|
133 | #endif // QT_VERSION |
---|
134 | |
---|
135 | public: |
---|
136 | PsPlugin(QObject* parent = 0); |
---|
137 | |
---|
138 | Model::Document* loadDocument(const QString& filePath) const; |
---|
139 | |
---|
140 | SettingsWidget* createSettingsWidget(QWidget* parent) const; |
---|
141 | |
---|
142 | private: |
---|
143 | Q_DISABLE_COPY(PsPlugin) |
---|
144 | |
---|
145 | QSettings* m_settings; |
---|
146 | |
---|
147 | }; |
---|
148 | |
---|
149 | } // qpdfview |
---|
150 | |
---|
151 | #endif // PSMODEL_H |
---|