~adamreichold/qpdfview/trunk

1927.1.1 by Adam Reichold
Add simple image plug-in using Qt's built-in image I/O routines.
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
2041.2.12 by Adam Reichold
Fix usage of QList in the bookmark and search models and various small performance issues reported by the clazy tool using the checks of "level0,level1,level2,no-missing-qobject-macro,no-qstring-allocations,no-copyable-polymorphic,no-ctor-missing-parent-argument,no-reserve-candidates".
43
        QImage render(qreal horizontalResolution, qreal verticalResolution, Rotation rotation, QRect boundingRect) const;
1927.1.1 by Adam Reichold
Add simple image plug-in using Qt's built-in image I/O routines.
44
45
    private:
46
        Q_DISABLE_COPY(ImagePage)
47
2041.2.12 by Adam Reichold
Fix usage of QList in the bookmark and search models and various small performance issues reported by the clazy tool using the checks of "level0,level1,level2,no-missing-qobject-macro,no-qstring-allocations,no-copyable-polymorphic,no-ctor-missing-parent-argument,no-reserve-candidates".
48
        ImagePage(const QImage& image);
1927.1.1 by Adam Reichold
Add simple image plug-in using Qt's built-in image I/O routines.
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
1927.1.5 by Adam Reichold
Add support to save images using Qt's built-in formats.
65
        QStringList saveFilter() const;
66
67
        bool canSave() const;
68
        bool save(const QString& filePath, bool withChanges) const;
69
2040 by Adam Reichold
Improve naming consistency in the model accessor methods.
70
        Properties properties() const;
1927.1.4 by Adam Reichold
Fix image resolution computation and load some image meta-data.
71
1927.1.1 by Adam Reichold
Add simple image plug-in using Qt's built-in image I/O routines.
72
    private:
73
        Q_DISABLE_COPY(ImageDocument)
74
2041.2.12 by Adam Reichold
Fix usage of QList in the bookmark and search models and various small performance issues reported by the clazy tool using the checks of "level0,level1,level2,no-missing-qobject-macro,no-qstring-allocations,no-copyable-polymorphic,no-ctor-missing-parent-argument,no-reserve-candidates".
75
        ImageDocument(const QImage& image);
1927.1.1 by Adam Reichold
Add simple image plug-in using Qt's built-in image I/O routines.
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