mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Redact text search result
This commit is contained in:
@ -66,6 +66,30 @@ void PDFAdvancedFindWidget::setDocument(const pdf::PDFModifiedDocument& document
|
||||
}
|
||||
}
|
||||
|
||||
pdf::PDFTextSelection PDFAdvancedFindWidget::getSelectedText() const
|
||||
{
|
||||
pdf::PDFTextSelection result;
|
||||
|
||||
std::vector<size_t> selectedRowIndices;
|
||||
QModelIndexList selectedRows = ui->resultsTableWidget->selectionModel()->selectedRows();
|
||||
std::transform(selectedRows.cbegin(), selectedRows.cend(), std::back_inserter(selectedRowIndices), [] (const QModelIndex& index) { return index.row(); });
|
||||
std::sort(selectedRowIndices.begin(), selectedRowIndices.end());
|
||||
|
||||
for (size_t i = 0; i < m_findResults.size(); ++i)
|
||||
{
|
||||
const pdf::PDFFindResult& findResult = m_findResults[i];
|
||||
|
||||
QColor color(Qt::yellow);
|
||||
if (std::binary_search(selectedRowIndices.cbegin(), selectedRowIndices.cend(), i))
|
||||
{
|
||||
result.addItems(findResult.textSelectionItems, color);
|
||||
}
|
||||
}
|
||||
result.build();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void PDFAdvancedFindWidget::on_searchButton_clicked()
|
||||
{
|
||||
m_parameters.phrase = ui->searchPhraseEdit->text();
|
||||
|
@ -58,6 +58,10 @@ public:
|
||||
|
||||
void setDocument(const pdf::PDFModifiedDocument& document);
|
||||
|
||||
/// 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;
|
||||
|
@ -1052,6 +1052,11 @@ QString PDFProgramController::getOriginalFileName() const
|
||||
return m_fileInfo.originalFileName;
|
||||
}
|
||||
|
||||
pdf::PDFTextSelection PDFProgramController::getSelectedText() const
|
||||
{
|
||||
return m_mainWindowInterface->getSelectedText();
|
||||
}
|
||||
|
||||
void PDFProgramController::onActionRotateRightTriggered()
|
||||
{
|
||||
m_pdfWidget->getDrawWidgetProxy()->performOperation(pdf::PDFDrawWidgetProxy::RotateRight);
|
||||
|
@ -63,6 +63,7 @@ public:
|
||||
virtual void setStatusBarMessage(QString message, int time) = 0;
|
||||
virtual void setDocument(const pdf::PDFModifiedDocument& document) = 0;
|
||||
virtual void adjustToolbar(QToolBar* toolbar) = 0;
|
||||
virtual pdf::PDFTextSelection getSelectedText() const = 0;
|
||||
};
|
||||
|
||||
class Pdf4QtVIEWERLIBSHARED_EXPORT PDFActionManager : public QObject
|
||||
@ -280,6 +281,7 @@ public:
|
||||
bool canClose() const;
|
||||
|
||||
virtual QString getOriginalFileName() const override;
|
||||
virtual pdf::PDFTextSelection getSelectedText() const override;
|
||||
|
||||
signals:
|
||||
void queryPasswordRequest(QString* password, bool* ok);
|
||||
|
@ -468,6 +468,16 @@ void PDFViewerMainWindow::adjustToolbar(QToolBar* toolbar)
|
||||
toolbar->setIconSize(iconSize);
|
||||
}
|
||||
|
||||
pdf::PDFTextSelection PDFViewerMainWindow::getSelectedText() const
|
||||
{
|
||||
if (!m_advancedFindWidget)
|
||||
{
|
||||
return pdf::PDFTextSelection();
|
||||
}
|
||||
|
||||
return m_advancedFindWidget->getSelectedText();
|
||||
}
|
||||
|
||||
void PDFViewerMainWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
if (!m_programController->canClose())
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
virtual void setStatusBarMessage(QString message, int time) override;
|
||||
virtual void setDocument(const pdf::PDFModifiedDocument& document) override;
|
||||
virtual void adjustToolbar(QToolBar* toolbar) override;
|
||||
virtual pdf::PDFTextSelection getSelectedText() const override;
|
||||
|
||||
protected:
|
||||
virtual void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
|
@ -385,6 +385,11 @@ void PDFViewerMainWindowLite::adjustToolbar(QToolBar* toolbar)
|
||||
toolbar->setIconSize(iconSize);
|
||||
}
|
||||
|
||||
pdf::PDFTextSelection PDFViewerMainWindowLite::getSelectedText() const
|
||||
{
|
||||
return pdf::PDFTextSelection();
|
||||
}
|
||||
|
||||
void PDFViewerMainWindowLite::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
if (!m_programController->canClose())
|
||||
|
@ -84,6 +84,7 @@ public:
|
||||
virtual void setStatusBarMessage(QString message, int time) override;
|
||||
virtual void setDocument(const pdf::PDFModifiedDocument& document) override;
|
||||
virtual void adjustToolbar(QToolBar* toolbar) override;
|
||||
virtual pdf::PDFTextSelection getSelectedText() const override;
|
||||
|
||||
protected:
|
||||
virtual void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
|
Reference in New Issue
Block a user