source: terepaima/terepaima-0.4.16/sources/model.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: 6.3 KB
Line 
1/*
2
3Copyright 2014 S. Razi Alavizadeh
4Copyright 2013-2014 Adam Reichold
5
6This file is part of qpdfview.
7
8qpdfview is free software: you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation, either version 2 of the License, or
11(at your option) any later version.
12
13qpdfview is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with qpdfview.  If not, see <http://www.gnu.org/licenses/>.
20
21*/
22
23#ifndef DOCUMENTMODEL_H
24#define DOCUMENTMODEL_H
25
26#include <QList>
27#include <QtPlugin>
28#include <QRect>
29#include <QStandardItemModel>
30#include <QString>
31#include <QWidget>
32
33class QColor;
34class QImage;
35class QPrinter;
36class QSizeF;
37
38#include "global.h"
39
40namespace qpdfview
41{
42
43namespace Model
44{
45    struct Link
46    {
47        QPainterPath boundary;
48
49        int page;
50        qreal left;
51        qreal top;
52
53        QString urlOrFileName;
54
55        Link() : boundary(), page(-1), left(qQNaN()), top(qQNaN()), urlOrFileName() {}
56
57        Link(const QPainterPath& boundary, int page, qreal left = qQNaN(), qreal top = qQNaN()) : boundary(boundary), page(page), left(left), top(top), urlOrFileName() {}
58        Link(const QRectF& boundingRect, int page, qreal left = qQNaN(), qreal top = qQNaN()) : boundary(), page(page), left(left), top(top), urlOrFileName() { boundary.addRect(boundingRect); }
59
60        Link(const QPainterPath& boundary, const QString& url) : boundary(boundary), page(-1), left(qQNaN()), top(qQNaN()), urlOrFileName(url) {}
61        Link(const QRectF& boundingRect, const QString& url) : boundary(), page(-1), left(qQNaN()), top(qQNaN()), urlOrFileName(url) { boundary.addRect(boundingRect); }
62
63        Link(const QPainterPath& boundary, const QString& fileName, int page) : boundary(boundary), page(page), left(qQNaN()), top(qQNaN()), urlOrFileName(fileName) {}
64        Link(const QRectF& boundingRect, const QString& fileName, int page) : boundary(), page(page), left(qQNaN()), top(qQNaN()), urlOrFileName(fileName) { boundary.addRect(boundingRect); }
65
66    };
67
68    class Annotation : public QObject
69    {
70        Q_OBJECT
71
72    public:
73        Annotation() : QObject() {}
74        virtual ~Annotation() {}
75
76        virtual QRectF boundary() const = 0;
77        virtual QString contents() const = 0;
78
79        virtual QWidget* createWidget() = 0;
80
81    signals:
82        void wasModified();
83
84    };
85
86    class FormField : public QObject
87    {
88        Q_OBJECT
89
90    public:
91        FormField() : QObject() {}
92        virtual ~FormField() {}
93
94        virtual QRectF boundary() const = 0;
95        virtual QString name() const = 0;
96
97        virtual QWidget* createWidget() = 0;
98
99    signals:
100        void wasModified();
101
102    };
103
104    class Page
105    {
106    public:
107        virtual ~Page() {}
108
109        virtual QSizeF size() const = 0;
110
111        virtual QImage render(qreal horizontalResolution = 72.0, qreal verticalResolution = 72.0, Rotation rotation = RotateBy0, const QRect& boundingRect = QRect()) const = 0;
112
113        virtual QString label() const { return QString(); }
114
115        virtual QList< Link* > links() const { return QList< Link* >(); }
116
117        virtual QString text(const QRectF& rect) const { Q_UNUSED(rect); return QString(); }
118        virtual QString cachedText(const QRectF& rect) const { return text(rect); }
119
120        virtual QList< QRectF > search(const QString& text, bool matchCase, bool wholeWords) const { Q_UNUSED(text); Q_UNUSED(matchCase); Q_UNUSED(wholeWords); return QList< QRectF >(); }
121
122        virtual QList< Annotation* > annotations() const { return QList< Annotation* >(); }
123
124        virtual bool canAddAndRemoveAnnotations() const { return false; }
125        virtual Annotation* addTextAnnotation(const QRectF& boundary, const QColor& color) { Q_UNUSED(boundary); Q_UNUSED(color); return 0; }
126        virtual Annotation* addHighlightAnnotation(const QRectF& boundary, const QColor& color) { Q_UNUSED(boundary); Q_UNUSED(color); return 0; }
127        virtual void removeAnnotation(Annotation* annotation) { Q_UNUSED(annotation); }
128
129        virtual QList< FormField* > formFields() const { return QList< FormField* >(); }
130
131    };
132
133    class Document
134    {
135    public:
136        virtual ~Document() {}
137
138        virtual int numberOfPages() const = 0;
139
140        virtual Page* page(int index) const = 0;
141
142        virtual bool isLocked() const { return false; }
143        virtual bool unlock(const QString& password) { Q_UNUSED(password); return false; }
144
145        virtual QStringList saveFilter() const { return QStringList(); }
146
147        virtual bool canSave() const { return false; }
148        virtual bool save(const QString& filePath, bool withChanges) const { Q_UNUSED(filePath); Q_UNUSED(withChanges); return false; }
149
150        virtual bool canBePrintedUsingCUPS() const { return false; }
151
152        virtual void setPaperColor(const QColor& paperColor) { Q_UNUSED(paperColor); }
153
154        enum
155        {
156            PageRole = Qt::UserRole + 1,
157            LeftRole,
158            TopRole,
159            ExpansionRole
160        };
161
162        virtual void loadOutline(QStandardItemModel* outlineModel) const { outlineModel->clear(); }
163        virtual void loadProperties(QStandardItemModel* propertiesModel) const { propertiesModel->clear(); propertiesModel->setColumnCount(2); }
164
165        virtual void loadFonts(QStandardItemModel* fontsModel) const { fontsModel->clear(); }
166
167        virtual bool wantsContinuousMode() const { return false; }
168        virtual bool wantsSinglePageMode() const { return false; }
169        virtual bool wantsTwoPagesMode() const { return false; }
170        virtual bool wantsTwoPagesWithCoverPageMode() const { return false; }
171        virtual bool wantsRightToLeftMode() const { return false; }
172
173    };
174}
175
176class SettingsWidget : public QWidget
177{
178    Q_OBJECT
179
180public:
181    explicit SettingsWidget(QWidget* parent = 0) : QWidget(parent) {}
182
183    virtual void accept() = 0;
184    virtual void reset() = 0;
185
186};
187
188class Plugin
189{
190public:
191    virtual ~Plugin() {}
192
193    virtual Model::Document* loadDocument(const QString& filePath) const = 0;
194
195    virtual SettingsWidget* createSettingsWidget(QWidget* parent = 0) const { Q_UNUSED(parent); return 0; }
196
197};
198
199} // qpdfview
200
201Q_DECLARE_INTERFACE(qpdfview::Plugin, "local.qpdfview.Plugin")
202
203#endif // DOCUMENTMODEL_H
Note: See TracBrowser for help on using the repository browser.