PDF4QT/Pdf4QtViewer/pdfadvancedfindwidget.h

108 lines
3.3 KiB
C
Raw Normal View History

2021-04-30 20:12:10 +02:00
// Copyright (C) 2020-2021 Jakub Melka
2020-01-03 18:11:03 +01:00
//
2021-08-10 19:22:56 +02:00
// This file is part of PDF4QT.
2020-01-03 18:11:03 +01:00
//
2021-08-10 19:22:56 +02:00
// PDF4QT is free software: you can redistribute it and/or modify
2020-01-03 18:11:03 +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.
2020-01-03 18:11:03 +01:00
//
2021-08-10 19:22:56 +02:00
// PDF4QT is distributed in the hope that it will be useful,
2020-01-03 18:11:03 +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
2021-08-10 19:22:56 +02:00
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
2020-01-03 18:11:03 +01:00
#ifndef PDFADVANCEDFINDWIDGET_H
#define PDFADVANCEDFINDWIDGET_H
#include "pdfglobal.h"
#include "pdfdrawspacecontroller.h"
2020-01-04 17:58:55 +01:00
#include "pdftextlayout.h"
2020-01-03 18:11:03 +01:00
#include <QWidget>
namespace Ui
{
class PDFAdvancedFindWidget;
}
namespace pdf
{
class PDFDocument;
class PDFDrawWidgetProxy;
}
namespace pdfviewer
{
class PDFAdvancedFindWidget : public QWidget, public pdf::IDocumentDrawInterface
2020-01-03 18:11:03 +01:00
{
Q_OBJECT
private:
using BaseClass = QWidget;
2020-01-03 18:11:03 +01:00
public:
explicit PDFAdvancedFindWidget(pdf::PDFDrawWidgetProxy* proxy, QWidget* parent = nullptr);
virtual ~PDFAdvancedFindWidget() override;
virtual void drawPage(QPainter* painter,
pdf::PDFInteger pageIndex,
const pdf::PDFPrecompiledPage* compiledPage,
pdf::PDFTextLayoutGetter& layoutGetter,
const QMatrix& pagePointToDevicePointMatrix,
QList<pdf::PDFRenderError>& errors) const override;
void setDocument(const pdf::PDFModifiedDocument& document);
2020-01-03 18:11:03 +01:00
2020-12-30 18:26:45 +01:00
/// Returns selected text items in the table (selected means not all results,
/// but those, which are selected rows in the result table)
pdf::PDFTextSelection getSelectedText() const;
protected:
virtual void showEvent(QShowEvent* event) override;
virtual void hideEvent(QHideEvent* event) override;
2020-01-03 18:11:03 +01:00
private slots:
void on_searchButton_clicked();
void onSelectionChanged();
2020-01-05 18:13:43 +01:00
void onResultItemDoubleClicked(int row, int column);
2020-01-03 18:11:03 +01:00
void on_clearButton_clicked();
2020-01-03 18:11:03 +01:00
private:
void updateUI();
2020-01-04 17:58:55 +01:00
void updateResultsUI();
2020-01-03 18:11:03 +01:00
void performSearch();
pdf::PDFTextSelection getTextSelection() const { return m_textSelection.get(this, &PDFAdvancedFindWidget::getTextSelectionImpl); }
pdf::PDFTextSelection getTextSelectionImpl() const;
2020-01-03 18:11:03 +01:00
struct SearchParameters
{
QString phrase;
bool isCaseSensitive = false;
bool isWholeWordsOnly = false;
bool isRegularExpression = false;
bool isDotMatchingEverything = false;
bool isMultiline = false;
bool isSearchFinished = false;
2020-01-04 17:58:55 +01:00
bool isSoftHyphenRemoved = false;
2020-01-03 18:11:03 +01:00
};
Ui::PDFAdvancedFindWidget* ui;
pdf::PDFDrawWidgetProxy* m_proxy;
const pdf::PDFDocument* m_document;
SearchParameters m_parameters;
2020-01-04 17:58:55 +01:00
pdf::PDFFindResults m_findResults;
mutable pdf::PDFCachedItem<pdf::PDFTextSelection> m_textSelection;
2020-01-03 18:11:03 +01:00
};
} // namespace pdfviewer
#endif // PDFADVANCEDFINDWIDGET_H