Debian Codegraph @

src/file/ApvlvQtPdf.h

raw
1 /*
2 * This file is part of the apvlv package
3 * Copyright (C) <2010> <Alf>
4 *
5 * Contact: Alf <[email protected]>
6 *
7 * This program 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 * This program 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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22 /* @CPPFILE ApvlvPdf.h
23 *
24 * Author: Alf <[email protected]>
25 */
26
27 #ifndef _APVLV_QTPDF_H_
28 #define _APVLV_QTPDF_H_
29
30 #include <QPdfBookmarkModel>
31 #include <QPdfSearchModel>
32
33 #include "ApvlvFile.h"
34 #include "ApvlvFileWidget.h"
35
36 namespace apvlv
37 {
38
39 class PDFWidget : public FileWidget
40 {
41 public:
42 PDFWidget ()
43 {
44 mHalScrollBar = mPdfView.horizontalScrollBar ();
45 mValScrollBar = mPdfView.verticalScrollBar ();
46 }
47
48 [[nodiscard]] QWidget *
49 widget () override
50 {
51 return &mPdfView;
52 }
53
54 void setFile (File *file) override;
55
56 void showPage (int pn, double s) override;
57 void showPage (int pn, const std::string &anchor) override;
58
59 void setSearchSelect (int select) override;
60
61 void setZoomrate (double zm) override;
62
63 private:
64 QPdfView mPdfView{};
65 };
66
67 class ApvlvPDF : public File
68 {
69 FILE_TYPE_DECLARATION (ApvlvPDF);
70
71 public:
72 bool load (const std::string &filename) override;
73
74 ~ApvlvPDF () override = default;
75
76 [[nodiscard]] DISPLAY_TYPE
77 getDisplayType () const override
78 {
79 return DISPLAY_TYPE::IMAGE;
80 }
81
82 PDFWidget *getWidget () override;
83
84 SizeF pageSizeF (int page, int rot) override;
85
86 int sum () override;
87
88 bool pageIsOnlyImage (int pn) override;
89
90 bool pageRenderToImage (int pn, double zm, int rot, QImage *img) override;
91
92 bool pageText (int, const Rectangle &rect, std::string &text) override;
93
94 std::unique_ptr<WordListRectangle> pageSearch (int pn,
95 const char *s) override;
96
97 private:
98 void pageRenderComments(int pn, QImage *img, const std::vector<Comment> &comments);
99 bool generateIndex ();
100 void getIndexIter (FileIndex &file_index,
101 const QPdfBookmarkModel *bookmark_model,
102 const QModelIndex &parent);
103
104 std::unique_ptr<QPdfDocument> mDoc;
105 std::unique_ptr<QPdfSearchModel> mSearchModel;
106
107 QWidget *mView;
108
109 friend class PDFWidget;
110 };
111 }
112 #endif
113
114 /* Local Variables: */
115 /* mode: c++ */
116 /* End: */