PDF4QT/Pdf4QtViewer/pdfsidebarwidget.h

139 lines
4.2 KiB
C
Raw Normal View History

2021-04-30 20:12:10 +02:00
// Copyright (C) 2019-2021 Jakub Melka
2019-11-28 18:20:32 +01:00
//
2020-12-20 19:03:58 +01:00
// This file is part of Pdf4Qt.
2019-11-28 18:20:32 +01:00
//
2020-12-20 19:03:58 +01:00
// Pdf4Qt is free software: you can redistribute it and/or modify
2019-11-28 18:20:32 +01:00
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
2021-04-30 20:12:10 +02:00
// with the written consent of the copyright owner, any later version.
2019-11-28 18:20:32 +01:00
//
2020-12-20 19:03:58 +01:00
// Pdf4Qt is distributed in the hope that it will be useful,
2019-11-28 18:20:32 +01:00
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
2020-12-20 19:03:58 +01:00
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
2019-11-28 18:20:32 +01:00
#ifndef PDFSIDEBARWIDGET_H
#define PDFSIDEBARWIDGET_H
2019-12-08 19:20:36 +01:00
#include "pdfglobal.h"
2019-11-28 18:20:32 +01:00
#include <QWidget>
class QPushButton;
class QWidget;
namespace Ui
{
class PDFSidebarWidget;
}
namespace pdf
{
2019-11-29 19:10:29 +01:00
class PDFAction;
2019-11-28 18:20:32 +01:00
class PDFDocument;
2020-06-27 17:28:03 +02:00
class PDFCertificateInfo;
2019-12-07 17:59:03 +01:00
class PDFDrawWidgetProxy;
2020-06-27 17:28:03 +02:00
class PDFCertificateStore;
class PDFModifiedDocument;
2019-12-07 17:59:03 +01:00
class PDFThumbnailsItemModel;
2020-06-20 18:20:57 +02:00
class PDFOutlineTreeItemModel;
2019-11-28 18:20:32 +01:00
class PDFOptionalContentActivity;
2020-06-20 18:20:57 +02:00
class PDFAttachmentsTreeItemModel;
class PDFSignatureVerificationResult;
2019-11-28 18:20:32 +01:00
class PDFOptionalContentTreeItemModel;
}
namespace pdfviewer
{
2020-02-18 20:21:18 +01:00
class PDFTextToSpeech;
2020-06-27 17:28:03 +02:00
class PDFViewerSettings;
2019-11-28 18:20:32 +01:00
class PDFSidebarWidget : public QWidget
{
Q_OBJECT
public:
2020-06-27 17:28:03 +02:00
explicit PDFSidebarWidget(pdf::PDFDrawWidgetProxy* proxy,
PDFTextToSpeech* textToSpeech,
pdf::PDFCertificateStore* certificateStore,
PDFViewerSettings* settings,
QWidget* parent);
2019-11-28 18:20:32 +01:00
virtual ~PDFSidebarWidget() override;
virtual void paintEvent(QPaintEvent* event) override;
2019-11-28 18:20:32 +01:00
enum Page
{
Invalid,
_BEGIN,
2019-12-01 18:10:11 +01:00
Bookmarks = _BEGIN,
2019-11-28 18:20:32 +01:00
Thumbnails,
2019-12-01 18:10:11 +01:00
OptionalContent,
Attachments,
2020-02-18 20:21:18 +01:00
Speech,
2020-06-20 18:20:57 +02:00
Signatures,
2019-11-28 18:20:32 +01:00
_END
};
2020-06-20 18:20:57 +02:00
void setDocument(const pdf::PDFModifiedDocument& document, const std::vector<pdf::PDFSignatureVerificationResult>& signatures);
2019-11-28 18:20:32 +01:00
/// Returns true, if all items in sidebar are empty
bool isEmpty() const;
/// Returns true, if page is empty
bool isEmpty(Page page) const;
/// Selects current page
void selectPage(Page page);
/// Returns list of valid pages (nonempty pages)
std::vector<Page> getValidPages() const;
2019-12-08 19:20:36 +01:00
/// Sets current pages (for example, selects the correct thumbnail)
void setCurrentPages(const std::vector<pdf::PDFInteger>& currentPages);
2019-11-29 19:10:29 +01:00
signals:
void actionTriggered(const pdf::PDFAction* action);
2019-11-28 18:20:32 +01:00
private:
void updateGUI(Page preferredPage);
void updateButtons();
2020-06-20 18:20:57 +02:00
void updateSignatures(const std::vector<pdf::PDFSignatureVerificationResult>& signatures);
2019-11-28 18:20:32 +01:00
2019-12-07 17:59:03 +01:00
void onPageButtonClicked();
2019-11-29 19:10:29 +01:00
void onOutlineItemClicked(const QModelIndex& index);
2019-12-07 17:59:03 +01:00
void onThumbnailsSizeChanged(int size);
2019-12-03 19:24:43 +01:00
void onAttachmentCustomContextMenuRequested(const QPoint& pos);
2019-12-08 19:20:36 +01:00
void onThumbnailClicked(const QModelIndex& index);
2020-06-27 17:28:03 +02:00
void onSignatureCustomContextMenuRequested(const QPoint &pos);
2019-11-29 19:10:29 +01:00
2019-11-28 18:20:32 +01:00
struct PageInfo
{
QPushButton* button = nullptr;
QWidget* page = nullptr;
};
Ui::PDFSidebarWidget* ui;
2019-12-08 19:20:36 +01:00
pdf::PDFDrawWidgetProxy* m_proxy;
2020-02-18 20:21:18 +01:00
PDFTextToSpeech* m_textToSpeech;
2020-06-27 17:28:03 +02:00
pdf::PDFCertificateStore* m_certificateStore;
PDFViewerSettings* m_settings;
2019-11-28 18:20:32 +01:00
pdf::PDFOutlineTreeItemModel* m_outlineTreeModel;
2019-12-07 17:59:03 +01:00
pdf::PDFThumbnailsItemModel* m_thumbnailsModel;
2019-11-28 18:20:32 +01:00
pdf::PDFOptionalContentTreeItemModel* m_optionalContentTreeModel;
const pdf::PDFDocument* m_document;
pdf::PDFOptionalContentActivity* m_optionalContentActivity;
2019-12-01 18:10:11 +01:00
pdf::PDFAttachmentsTreeItemModel* m_attachmentsTreeModel;
2019-11-28 18:20:32 +01:00
std::map<Page, PageInfo> m_pageInfo;
2020-06-20 18:20:57 +02:00
std::vector<pdf::PDFSignatureVerificationResult> m_signatures;
2020-06-27 17:28:03 +02:00
std::vector<pdf::PDFCertificateInfo> m_certificateInfos;
2019-11-28 18:20:32 +01:00
};
} // namespace pdfviewer
#endif // PDFSIDEBARWIDGET_H