File indexing completed on 2024-04-28 05:38:14

0001 /***************************************************************************
0002  *  Copyright (C) 2018 by Renaud Guezennec                                 *
0003  *   https://rolisteam.org/contact                                      *
0004  *                                                                         *
0005  *   rolisteam is free software; you can redistribute it and/or modify     *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 
0021 #ifndef PDFVIEWER_H
0022 #define PDFVIEWER_H
0023 
0024 #include <QAction>
0025 #include <QFile>
0026 #include <QLabel>
0027 #include <QMenu>
0028 #include <QPointer>
0029 #include <QString>
0030 #include <QWidget>
0031 #include <memory>
0032 
0033 #include "customs/workspace.h"
0034 #include "preferences/preferencesmanager.h"
0035 
0036 #include "rwidgets/mediacontainers/mediacontainer.h"
0037 Q_DECLARE_LOGGING_CATEGORY(MediaContainerPDF)
0038 class NetworkLink;
0039 class NetworkMessageWriter;
0040 class QPdfWidget;
0041 class Overlay;
0042 class PdfController;
0043 class QPdfDocument;
0044 class QPdfView;
0045 namespace Ui
0046 {
0047 class PdfViewer;
0048 }
0049 /**
0050  * @brief The Image class displays image to the screen. It also manages image from Internet and the zooming.
0051  */
0052 class PdfViewer : public MediaContainer
0053 {
0054     Q_OBJECT
0055 public:
0056     enum ZoomLevelValue
0057     {
0058         FitWidth,
0059         FitInView,
0060         TwentyFiveZoom,
0061         FiftyZoom,
0062         SeventyFiveZoom,
0063         OneHundredZoom,
0064         OneHundredFitfyZoom,
0065         TwoHundredZoom
0066     };
0067     Q_ENUM(ZoomLevelValue)
0068     PdfViewer(PdfController* ctrl, QWidget* parent= nullptr);
0069     /**
0070      * @brief ~PdfViewer destructor.
0071      */
0072     virtual ~PdfViewer();
0073 
0074     void savePdfToFile(QFile& file);
0075     void savePdfToFile(QDataStream& out);
0076     void setParent(Workspace* parent);
0077     void contextMenuEvent(QContextMenuEvent* event) override;
0078 
0079 protected:
0080     void makeConnections();
0081     bool eventFilter(QObject* obj, QEvent* event) override;
0082 
0083 protected slots:
0084     void extractImage();
0085     void extractText();
0086     void extractMap();
0087     void showOverLay();
0088     void sharePdfTo();
0089     void updateTitle();
0090     void bookmarkSelected(const QModelIndex& index);
0091 
0092 private:
0093     Ui::PdfViewer* m_ui= nullptr;
0094     std::unique_ptr<QPdfDocument> m_document;
0095     QPointer<PdfController> m_pdfCtrl;
0096     std::unique_ptr<Overlay> m_overlay;
0097 };
0098 
0099 #endif