[1f4adec] | 1 | /* |
---|
| 2 | |
---|
| 3 | Copyright 2012-2013 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 PRESENTATIONVIEW_H |
---|
| 23 | #define PRESENTATIONVIEW_H |
---|
| 24 | |
---|
| 25 | #include <QGraphicsView> |
---|
| 26 | |
---|
| 27 | #include "renderparam.h" |
---|
| 28 | |
---|
| 29 | namespace qpdfview |
---|
| 30 | { |
---|
| 31 | |
---|
| 32 | namespace Model |
---|
| 33 | { |
---|
| 34 | class Page; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | class Settings; |
---|
| 38 | class PageItem; |
---|
| 39 | |
---|
| 40 | class PresentationView : public QGraphicsView |
---|
| 41 | { |
---|
| 42 | Q_OBJECT |
---|
| 43 | |
---|
| 44 | public: |
---|
| 45 | PresentationView(const QVector< Model::Page* >& pages, QWidget* parent = 0); |
---|
| 46 | ~PresentationView(); |
---|
| 47 | |
---|
| 48 | int numberOfPages() const { return m_pages.count(); } |
---|
| 49 | int currentPage() const { return m_currentPage; } |
---|
| 50 | |
---|
| 51 | ScaleMode scaleMode() const { return m_scaleMode; } |
---|
| 52 | void setScaleMode(ScaleMode scaleMode); |
---|
| 53 | |
---|
| 54 | qreal scaleFactor() const { return m_scaleFactor; } |
---|
| 55 | void setScaleFactor(qreal scaleFactor); |
---|
| 56 | |
---|
| 57 | Rotation rotation() const { return m_rotation; } |
---|
| 58 | void setRotation(Rotation rotation); |
---|
| 59 | |
---|
| 60 | qpdfview::RenderFlags renderFlags() const { return m_renderFlags; } |
---|
| 61 | void setRenderFlags(qpdfview::RenderFlags renderFlags); |
---|
| 62 | |
---|
| 63 | signals: |
---|
| 64 | void currentPageChanged(int currentPage, bool trackChange = false); |
---|
| 65 | |
---|
| 66 | void scaleModeChanged(ScaleMode scaleMode); |
---|
| 67 | void scaleFactorChanged(qreal scaleFactor); |
---|
| 68 | void rotationChanged(Rotation rotation); |
---|
| 69 | |
---|
| 70 | void renderFlagsChanged(qpdfview::RenderFlags renderFlags); |
---|
| 71 | |
---|
| 72 | public slots: |
---|
| 73 | void show(); |
---|
| 74 | |
---|
| 75 | void previousPage(); |
---|
| 76 | void nextPage(); |
---|
| 77 | void firstPage(); |
---|
| 78 | void lastPage(); |
---|
| 79 | |
---|
| 80 | void jumpToPage(int page, bool trackChange = true); |
---|
| 81 | |
---|
| 82 | void jumpBackward(); |
---|
| 83 | void jumpForward(); |
---|
| 84 | |
---|
| 85 | void zoomIn(); |
---|
| 86 | void zoomOut(); |
---|
| 87 | void originalSize(); |
---|
| 88 | |
---|
| 89 | void rotateLeft(); |
---|
| 90 | void rotateRight(); |
---|
| 91 | |
---|
| 92 | protected slots: |
---|
| 93 | void on_prefetch_timeout(); |
---|
| 94 | |
---|
| 95 | void on_pages_cropRectChanged(); |
---|
| 96 | |
---|
| 97 | void on_pages_linkClicked(bool newTab, int page, qreal left, qreal top); |
---|
| 98 | |
---|
| 99 | protected: |
---|
| 100 | void resizeEvent(QResizeEvent* event); |
---|
| 101 | |
---|
| 102 | void keyPressEvent(QKeyEvent* event); |
---|
| 103 | void wheelEvent(QWheelEvent* event); |
---|
| 104 | |
---|
| 105 | private: |
---|
| 106 | Q_DISABLE_COPY(PresentationView) |
---|
| 107 | |
---|
| 108 | static Settings* s_settings; |
---|
| 109 | |
---|
| 110 | QTimer* m_prefetchTimer; |
---|
| 111 | |
---|
| 112 | QVector< Model::Page* > m_pages; |
---|
| 113 | |
---|
| 114 | int m_currentPage; |
---|
| 115 | |
---|
| 116 | QList< int > m_past; |
---|
| 117 | QList< int > m_future; |
---|
| 118 | |
---|
| 119 | ScaleMode m_scaleMode; |
---|
| 120 | qreal m_scaleFactor; |
---|
| 121 | Rotation m_rotation; |
---|
| 122 | |
---|
| 123 | qpdfview::RenderFlags m_renderFlags; |
---|
| 124 | |
---|
| 125 | QVector< PageItem* > m_pageItems; |
---|
| 126 | |
---|
| 127 | void preparePages(); |
---|
| 128 | void prepareBackground(); |
---|
| 129 | |
---|
| 130 | void prepareScene(); |
---|
| 131 | void prepareView(); |
---|
| 132 | |
---|
| 133 | }; |
---|
| 134 | |
---|
| 135 | } // qpdfview |
---|
| 136 | |
---|
| 137 | #endif // PRESENTATIONVIEW_H |
---|