summaryrefslogtreecommitdiffstats
path: root/src/pdf
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-03-15 22:39:24 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2022-03-24 12:38:55 +0100
commitcb775365eb505d99d592bbfd443fc765fd3a93f3 (patch)
treeb1ce5ad36943b9e17cd0cae753406bad9baed738 /src/pdf
parent6a9b4e8072f3a2c0d6685100e0c7afb906b2535a (diff)
Combine QPdfDestination and QPdfSearchResult into QPdfLink
Inheritance was a decent way to model this, conceptually. A hyperlink is modeled like the HTML kind: a region covering the source material that the user will click on, and a destination where we will jump when they click it; whereas a search result has the same information plus the text before and after the search text, so that we can show some context in a ListView with search results. By going this way, we need to document which fields we use which way under which conditions. But, we have a rule that value types cannot use inheritance, just in case the user would ever try to use them polymorphically (in spite of the other rule that we never pass value types by pointer, and thus there is no actual polymorphism), or just in case the destructor of the base class would not be called when a subclass value goes out of scope. Anyway, perhaps an upside is that this resembles a link in Xanadu, or in a fully-normalized database schema: an object that fully describes both ends of a connection, and thus is able to traverse either direction, in theory. (Although we don't really use it that way. The link-following behavior in a PDF viewer tends to be one-way, as in a web browser.) When using QAbstractItemModel (as in QPdfSearchModel and QPdfLinkModel), the cells in the "database" are accessed separately via the data() function, so there is no need for a transport object to hold a whole "row". That's OK for item views; but we need this link object for the purpose of less-clumsy C++ API, as a return value from a few functions. For example when implementing a viewer in QML, we use Repeater to instantiate Items for each hyperlink (decorations and a TapHandler), and Repeater uses the QAIM interface. But when implementing a widget-based viewer, it's better to call a hit-testing function like QPdfLinkModel::linkAt(pos) to find out whether a link exists at a particular mouse location; and that function can return a QPdfLink. In this case, the link will not contain contextBefore and contextAfter, because the viewer doesn't need them, and it's difficult to find this text in the PDF model. But QPdfSearchModel::resultsOnPage() and reultAtIndex() return link objects that do contain the context strings. We don't expect users to have made much use of these classes in C++ so far, because we prioritized QML API (which this change does not affect), and did not yet document how to use QPdfSearchModel and QPdfLinkModel in widget-based viewers. Fixes: QTBUG-98886 Change-Id: Ie68f9b893a342d145abac0b143e9254827c70bd7 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/pdf')
-rw-r--r--src/pdf/CMakeLists.txt3
-rw-r--r--src/pdf/doc/images/wrapping-search-result.pngbin0 -> 39106 bytes
-rw-r--r--src/pdf/qpdfdestination.cpp133
-rw-r--r--src/pdf/qpdflink.cpp186
-rw-r--r--src/pdf/qpdflink.h (renamed from src/pdf/qpdfdestination.h)51
-rw-r--r--src/pdf/qpdflink_p.h (renamed from src/pdf/qpdfdestination_p.h)27
-rw-r--r--src/pdf/qpdfsearchmodel.cpp14
-rw-r--r--src/pdf/qpdfsearchmodel.h6
-rw-r--r--src/pdf/qpdfsearchmodel_p.h3
-rw-r--r--src/pdf/qpdfsearchresult.cpp90
-rw-r--r--src/pdf/qpdfsearchresult.h80
-rw-r--r--src/pdf/qpdfsearchresult_p.h77
12 files changed, 248 insertions, 422 deletions
diff --git a/src/pdf/CMakeLists.txt b/src/pdf/CMakeLists.txt
index 841eea446..fc06b92e9 100644
--- a/src/pdf/CMakeLists.txt
+++ b/src/pdf/CMakeLists.txt
@@ -15,15 +15,14 @@ set(buildDir "${CMAKE_CURRENT_BINARY_DIR}")
qt_internal_add_module(Pdf
SOURCES
qpdfbookmarkmodel.cpp qpdfbookmarkmodel.h
- qpdfdestination.cpp qpdfdestination.h qpdfdestination_p.h
qpdfdocument.cpp qpdfdocument.h qpdfdocument_p.h
qpdfdocumentrenderoptions.h
qpdffile.cpp qpdffile_p.h
+ qpdflink.cpp qpdflink.h qpdflink_p.h
qpdflinkmodel.cpp qpdflinkmodel_p.h qpdflinkmodel_p_p.h
qpdfpagenavigation.cpp qpdfpagenavigation.h
qpdfpagerenderer.cpp qpdfpagerenderer.h
qpdfsearchmodel.cpp qpdfsearchmodel.h qpdfsearchmodel_p.h
- qpdfsearchresult.cpp qpdfsearchresult.h qpdfsearchresult_p.h
qpdfselection.cpp qpdfselection.h qpdfselection_p.h
qtpdfglobal.h
qpdfnamespace.h
diff --git a/src/pdf/doc/images/wrapping-search-result.png b/src/pdf/doc/images/wrapping-search-result.png
new file mode 100644
index 000000000..108ec0444
--- /dev/null
+++ b/src/pdf/doc/images/wrapping-search-result.png
Binary files differ
diff --git a/src/pdf/qpdfdestination.cpp b/src/pdf/qpdfdestination.cpp
deleted file mode 100644
index 33ec391da..000000000
--- a/src/pdf/qpdfdestination.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPDF module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpdfdestination.h"
-#include "qpdfdestination_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QPdfDestination
- \since 5.15
- \inmodule QtPdf
-
- \brief The QPdfDestination class defines a location on a page in a PDF
- document, and a suggested zoom level at which it is intended to be viewed.
-*/
-
-/*!
- Constructs an invalid Destination.
-
- \sa valid
-*/
-QPdfDestination::QPdfDestination()
- : d(new QPdfDestinationPrivate())
-{
-}
-
-QPdfDestination::QPdfDestination(int page, QPointF location, qreal zoom)
- : d(new QPdfDestinationPrivate(page, location, zoom))
-{
-}
-
-QPdfDestination::QPdfDestination(QPdfDestinationPrivate *d)
- : d(d)
-{
-}
-
-QPdfDestination::~QPdfDestination() = default;
-QPdfDestination::QPdfDestination(const QPdfDestination &other) = default;
-QPdfDestination::QPdfDestination(QPdfDestination &&other) noexcept = default;
-QPdfDestination &QPdfDestination::operator=(const QPdfDestination &other) = default;
-
-/*!
- \property QPdfDestination::valid
-
- This property holds whether the destination is valid.
-*/
-bool QPdfDestination::isValid() const
-{
- return d->page >= 0;
-}
-
-/*!
- \property QPdfDestination::page
-
- This property holds the page number.
-*/
-int QPdfDestination::page() const
-{
- return d->page;
-}
-
-/*!
- \property QPdfDestination::location
-
- This property holds the location on the page, in units of points.
-*/
-QPointF QPdfDestination::location() const
-{
- return d->location;
-}
-
-/*!
- \property QPdfDestination::zoom
-
- This property holds the suggested magnification level, where 1.0 means default scale
- (1 pixel = 1 point).
-*/
-qreal QPdfDestination::zoom() const
-{
- return d->zoom;
-}
-
-QDebug operator<<(QDebug dbg, const QPdfDestination& dest)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace();
- dbg << "QPdfDestination(page=" << dest.page()
- << " location=" << dest.location()
- << " zoom=" << dest.zoom();
- dbg << ')';
- return dbg;
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qpdfdestination.cpp"
diff --git a/src/pdf/qpdflink.cpp b/src/pdf/qpdflink.cpp
new file mode 100644
index 000000000..091a29729
--- /dev/null
+++ b/src/pdf/qpdflink.cpp
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtPDF module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qpdflink.h"
+#include "qpdflink_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QPdfLink
+ \since 6.4
+ \inmodule QtPdf
+
+ \brief The QPdfLink class defines a link between a region on a page
+ (such as a hyperlink or a search result) and a destination
+ (page, location on the page, and zoom level at which to view it).
+*/
+
+/*!
+ Constructs an invalid Destination.
+
+ \sa valid
+*/
+QPdfLink::QPdfLink() :
+ QPdfLink(new QPdfLinkPrivate()) { }
+
+QPdfLink::QPdfLink(int page, QPointF location, qreal zoom)
+ : QPdfLink(new QPdfLinkPrivate(page, location, zoom))
+{
+}
+
+QPdfLink::QPdfLink(int page, QList<QRectF> rects,
+ QString contextBefore, QString contextAfter)
+ : QPdfLink(new QPdfLinkPrivate(page, std::move(rects),
+ std::move(contextBefore),
+ std::move(contextAfter)))
+{
+}
+
+QPdfLink::QPdfLink(QPdfLinkPrivate *d) : d(d) {}
+
+QPdfLink::~QPdfLink() = default;
+QPdfLink::QPdfLink(const QPdfLink &other) noexcept = default;
+QPdfLink::QPdfLink(QPdfLink &&other) noexcept = default;
+QPdfLink &QPdfLink::operator=(const QPdfLink &other) = default;
+
+/*!
+ \property QPdfLink::valid
+
+ This property holds whether the link is valid.
+*/
+bool QPdfLink::isValid() const
+{
+ return d->page >= 0;
+}
+
+/*!
+ \property QPdfLink::page
+
+ This property holds the page number.
+ If the link is a search result, it is the page number on which the result is found;
+ if the link is a hyperlink, it is the destination page number.
+*/
+int QPdfLink::page() const
+{
+ return d->page;
+}
+
+/*!
+ \property QPdfLink::location
+
+ This property holds the location on the \l page, in units of points.
+ If the link is a search result, it is the location where the result is found;
+ if the link is a hyperlink, it is the destination location.
+*/
+QPointF QPdfLink::location() const
+{
+ return d->location;
+}
+
+/*!
+ \property QPdfLink::zoom
+
+ This property holds the suggested magnification level, where 1.0 means default scale
+ (1 pixel = 1 point). If the link is a search result, this value is not used.
+*/
+qreal QPdfLink::zoom() const
+{
+ return d->zoom;
+}
+
+/*!
+ \property QPdfLink::contextBefore
+
+ This property holds adjacent text found on the page before the search string.
+ If the link is a hyperlink, this string is empty.
+
+ \sa QPdfSearchModel::resultsOnPage(), QPdfSearchModel::resultAtIndex()
+*/
+QString QPdfLink::contextBefore() const
+{
+ return d->contextBefore;
+}
+
+/*!
+ \property QPdfLink::contextAfter
+
+ This property holds adjacent text found on the page after the search string.
+ If the link is a hyperlink, this string is empty.
+
+ \sa QPdfSearchModel::resultsOnPage(), QPdfSearchModel::resultAtIndex()
+*/
+QString QPdfLink::contextAfter() const
+{
+ return d->contextAfter;
+}
+
+/*!
+ \property QPdfLink::rectangles
+
+ This property holds the region (set of rectangles) occupied by the link or
+ search result on the page where it was found. If the text wraps around to
+ multiple lines on the page, there may be multiple rectangles:
+
+ \image wrapping-search-result.png
+
+ \sa QPdfSearchModel::resultsOnPage(), QPdfSearchModel::resultAtIndex()
+*/
+QList<QRectF> QPdfLink::rectangles() const
+{
+ return d->rects;
+}
+
+QDebug operator<<(QDebug dbg, const QPdfLink &link)
+{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace();
+ dbg << "QPdfLink(page=" << link.page()
+ << " location=" << link.location()
+ << " zoom=" << link.zoom()
+ << " contextBefore=" << link.contextBefore()
+ << " contextAfter=" << link.contextAfter()
+ << " rects=" << link.rectangles();
+ dbg << ')';
+ return dbg;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qpdflink.cpp"
diff --git a/src/pdf/qpdfdestination.h b/src/pdf/qpdflink.h
index e445f0e5a..81053b42a 100644
--- a/src/pdf/qpdfdestination.h
+++ b/src/pdf/qpdflink.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -37,56 +37,67 @@
**
****************************************************************************/
-#ifndef QPDFDESTINATION_H
-#define QPDFDESTINATION_H
+#ifndef QPDFLINK_H
+#define QPDFLINK_H
#include <QtPdf/qtpdfglobal.h>
#include <QtCore/qdebug.h>
+#include <QtCore/qlist.h>
#include <QtCore/qobject.h>
#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
#include <QtCore/qshareddata.h>
QT_BEGIN_NAMESPACE
-class QPdfDestinationPrivate;
+class QPdfLinkPrivate;
-class QPdfDestination
+class QPdfLink
{
Q_GADGET_EXPORT(Q_PDF_EXPORT)
Q_PROPERTY(bool valid READ isValid)
Q_PROPERTY(int page READ page)
Q_PROPERTY(QPointF location READ location)
Q_PROPERTY(qreal zoom READ zoom)
+ Q_PROPERTY(QString contextBefore READ contextBefore)
+ Q_PROPERTY(QString contextAfter READ contextAfter)
+ Q_PROPERTY(QList<QRectF> rectangles READ rectangles)
public:
- Q_PDF_EXPORT ~QPdfDestination();
- Q_PDF_EXPORT QPdfDestination(const QPdfDestination &other);
- Q_PDF_EXPORT QPdfDestination &operator=(const QPdfDestination &other);
+ Q_PDF_EXPORT QPdfLink();
+ Q_PDF_EXPORT ~QPdfLink();
+ Q_PDF_EXPORT QPdfLink &operator=(const QPdfLink &other);
- Q_PDF_EXPORT QPdfDestination(QPdfDestination &&other) noexcept;
- QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QPdfDestination)
+ Q_PDF_EXPORT QPdfLink(const QPdfLink &other) noexcept;
+ Q_PDF_EXPORT QPdfLink(QPdfLink &&other) noexcept;
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QPdfLink)
- void swap(QPdfDestination &other) noexcept { d.swap(other.d); }
+ void swap(QPdfLink &other) noexcept { d.swap(other.d); }
Q_PDF_EXPORT bool isValid() const;
Q_PDF_EXPORT int page() const;
Q_PDF_EXPORT QPointF location() const;
Q_PDF_EXPORT qreal zoom() const;
+ Q_PDF_EXPORT QString contextBefore() const;
+ Q_PDF_EXPORT QString contextAfter() const;
+ Q_PDF_EXPORT QList<QRectF> rectangles() const;
-protected:
- QPdfDestination();
- QPdfDestination(int page, QPointF location, qreal zoom);
- QPdfDestination(QPdfDestinationPrivate *d);
+private: // methods
+ QPdfLink(int page, QPointF location, qreal zoom);
+ QPdfLink(int page, QList<QRectF> rects, QString contextBefore, QString contextAfter);
+ QPdfLink(QPdfLinkPrivate *d);
friend class QPdfDocument;
+ friend class QPdfSearchModelPrivate;
friend class QQuickPdfNavigationStack;
-protected:
- QExplicitlySharedDataPointer<QPdfDestinationPrivate> d;
+private: // storage
+ QExplicitlySharedDataPointer<QPdfLinkPrivate> d;
+
};
-Q_DECLARE_SHARED(QPdfDestination)
+Q_DECLARE_SHARED(QPdfLink)
-Q_PDF_EXPORT QDebug operator<<(QDebug, const QPdfDestination &);
+Q_PDF_EXPORT QDebug operator<<(QDebug, const QPdfLink &);
QT_END_NAMESPACE
-#endif // QPDFDESTINATION_H
+#endif // QPDFLINK_H
diff --git a/src/pdf/qpdfdestination_p.h b/src/pdf/qpdflink_p.h
index f1e639125..7cda6edfc 100644
--- a/src/pdf/qpdfdestination_p.h
+++ b/src/pdf/qpdflink_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtPDF module of the Qt Toolkit.
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QPDFDESTINATION_P_H
-#define QPDFDESTINATION_P_H
+#ifndef QPDFLINK_P_H
+#define QPDFLINK_P_H
//
// W A R N I N G
@@ -51,26 +51,37 @@
// We mean it.
//
-#include "qpdfdestination.h"
+#include "qpdflink.h"
#include <QPointF>
+#include <QRectF>
QT_BEGIN_NAMESPACE
-class QPdfDestinationPrivate : public QSharedData
+class QPdfLinkPrivate : public QSharedData
{
public:
- QPdfDestinationPrivate() = default;
- QPdfDestinationPrivate(int page, QPointF location, qreal zoom)
+ QPdfLinkPrivate() = default;
+ QPdfLinkPrivate(int page, QPointF location, qreal zoom)
: page(page),
location(location),
zoom(zoom) { }
+ QPdfLinkPrivate(int page, QList<QRectF> rects, QString contextBefore, QString contextAfter)
+ : page(page),
+ location(rects.first().topLeft()),
+ zoom(0),
+ contextBefore{std::move(contextBefore)},
+ contextAfter{std::move(contextAfter)},
+ rects{std::move(rects)} {}
int page = -1;
QPointF location;
qreal zoom = 1;
+ QString contextBefore;
+ QString contextAfter;
+ QList<QRectF> rects;
};
QT_END_NAMESPACE
-#endif // QPDFDESTINATION_P_H
+#endif // QPDFLINK_P_H
diff --git a/src/pdf/qpdfsearchmodel.cpp b/src/pdf/qpdfsearchmodel.cpp
index e515cabfd..03e729b4c 100644
--- a/src/pdf/qpdfsearchmodel.cpp
+++ b/src/pdf/qpdfsearchmodel.cpp
@@ -37,11 +37,11 @@
**
****************************************************************************/
-#include "qpdfdestination.h"
#include "qpdfdocument_p.h"
+#include "qpdflink.h"
+#include "qpdflink_p.h"
#include "qpdfsearchmodel.h"
#include "qpdfsearchmodel_p.h"
-#include "qpdfsearchresult_p.h"
#include "third_party/pdfium/public/fpdf_doc.h"
#include "third_party/pdfium/public/fpdf_text.h"
@@ -139,7 +139,7 @@ void QPdfSearchModel::setSearchString(const QString &searchString)
endResetModel();
}
-QList<QPdfSearchResult> QPdfSearchModel::resultsOnPage(int page) const
+QList<QPdfLink> QPdfSearchModel::resultsOnPage(int page) const
{
Q_D(const QPdfSearchModel);
const_cast<QPdfSearchModelPrivate *>(d)->doSearch(page);
@@ -148,12 +148,12 @@ QList<QPdfSearchResult> QPdfSearchModel::resultsOnPage(int page) const
return d->searchResults[page];
}
-QPdfSearchResult QPdfSearchModel::resultAtIndex(int index) const
+QPdfLink QPdfSearchModel::resultAtIndex(int index) const
{
Q_D(const QPdfSearchModel);
const auto pi = const_cast<QPdfSearchModelPrivate*>(d)->pageAndIndexForResult(index);
if (pi.page < 0)
- return QPdfSearchResult();
+ return {};
return d->searchResults[pi.page][pi.index];
}
@@ -230,7 +230,7 @@ bool QPdfSearchModelPrivate::doSearch(int page)
return false;
}
FPDF_SCHHANDLE sh = FPDFText_FindStart(textPage, searchString.utf16(), 0, 0);
- QList<QPdfSearchResult> newSearchResults;
+ QList<QPdfLink> newSearchResults;
while (FPDFText_FindNext(sh)) {
int idx = FPDFText_GetSchResultIndex(sh);
int count = FPDFText_GetSchCount(sh);
@@ -276,7 +276,7 @@ bool QPdfSearchModelPrivate::doSearch(int page)
}
}
if (!rects.isEmpty())
- newSearchResults << QPdfSearchResult(page, rects, contextBefore, contextAfter);
+ newSearchResults << QPdfLink(page, rects, contextBefore, contextAfter);
}
FPDFText_FindClose(sh);
FPDFText_ClosePage(textPage);
diff --git a/src/pdf/qpdfsearchmodel.h b/src/pdf/qpdfsearchmodel.h
index f440953d9..97678b8c5 100644
--- a/src/pdf/qpdfsearchmodel.h
+++ b/src/pdf/qpdfsearchmodel.h
@@ -44,7 +44,7 @@
#include <QtCore/qabstractitemmodel.h>
#include <QtPdf/qpdfdocument.h>
-#include <QtPdf/qpdfsearchresult.h>
+#include <QtPdf/qpdflink.h>
QT_BEGIN_NAMESPACE
@@ -70,8 +70,8 @@ public:
explicit QPdfSearchModel(QObject *parent);
~QPdfSearchModel() override;
- QList<QPdfSearchResult> resultsOnPage(int page) const;
- QPdfSearchResult resultAtIndex(int index) const;
+ QList<QPdfLink> resultsOnPage(int page) const;
+ QPdfLink resultAtIndex(int index) const;
QPdfDocument *document() const;
QString searchString() const;
diff --git a/src/pdf/qpdfsearchmodel_p.h b/src/pdf/qpdfsearchmodel_p.h
index 3b89f5f35..2fca249a0 100644
--- a/src/pdf/qpdfsearchmodel_p.h
+++ b/src/pdf/qpdfsearchmodel_p.h
@@ -52,7 +52,6 @@
//
#include "qpdfsearchmodel.h"
-#include "qpdfsearchresult_p.h"
#include <private/qabstractitemmodel_p.h>
#include "third_party/pdfium/public/fpdfview.h"
@@ -78,7 +77,7 @@ public:
QPdfDocument *document = nullptr;
QString searchString;
QList<bool> pagesSearched;
- QList<QList<QPdfSearchResult>> searchResults;
+ QList<QList<QPdfLink>> searchResults;
int rowCountSoFar = 0;
int updateTimerId = -1;
int nextPageToUpdate = 0;
diff --git a/src/pdf/qpdfsearchresult.cpp b/src/pdf/qpdfsearchresult.cpp
deleted file mode 100644
index 7c096868a..000000000
--- a/src/pdf/qpdfsearchresult.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPDF module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpdfsearchresult.h"
-#include "qpdfsearchresult_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QPdfSearchResult::QPdfSearchResult() :
- QPdfSearchResult(new QPdfSearchResultPrivate()) { }
-
-QPdfSearchResult::QPdfSearchResult(int page, QList<QRectF> rects,
- QString contextBefore, QString contextAfter)
- : QPdfSearchResult(new QPdfSearchResultPrivate(page, std::move(rects),
- std::move(contextBefore),
- std::move(contextAfter)))
-{
-}
-
-QPdfSearchResult::QPdfSearchResult(QPdfSearchResultPrivate *d) :
- QPdfDestination(static_cast<QPdfDestinationPrivate *>(d)) { }
-
-QPdfSearchResult::~QPdfSearchResult() = default;
-
-QString QPdfSearchResult::contextBefore() const
-{
- return static_cast<QPdfSearchResultPrivate *>(d.data())->contextBefore;
-}
-
-QString QPdfSearchResult::contextAfter() const
-{
- return static_cast<QPdfSearchResultPrivate *>(d.data())->contextAfter;
-}
-
-QList<QRectF> QPdfSearchResult::rectangles() const
-{
- return static_cast<QPdfSearchResultPrivate *>(d.data())->rects;
-}
-
-QDebug operator<<(QDebug dbg, const QPdfSearchResult &searchResult)
-{
- QDebugStateSaver saver(dbg);
- dbg.nospace();
- dbg << "QPdfSearchResult(page=" << searchResult.page()
- << " contextBefore=" << searchResult.contextBefore()
- << " contextAfter=" << searchResult.contextAfter()
- << " rects=" << searchResult.rectangles();
- dbg << ')';
- return dbg;
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qpdfsearchresult.cpp"
diff --git a/src/pdf/qpdfsearchresult.h b/src/pdf/qpdfsearchresult.h
deleted file mode 100644
index f191b0082..000000000
--- a/src/pdf/qpdfsearchresult.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPDF module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPDFSEARCHRESULT_H
-#define QPDFSEARCHRESULT_H
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qrect.h>
-#include <QtPdf/qpdfdestination.h>
-
-QT_BEGIN_NAMESPACE
-
-class QPdfSearchResultPrivate;
-
-class QPdfSearchResult : public QPdfDestination
-{
- Q_GADGET_EXPORT(Q_PDF_EXPORT)
- Q_PROPERTY(QString contextBefore READ contextBefore)
- Q_PROPERTY(QString contextAfter READ contextAfter)
- Q_PROPERTY(QList<QRectF> rectangles READ rectangles)
-
-public:
- Q_PDF_EXPORT QPdfSearchResult();
- Q_PDF_EXPORT ~QPdfSearchResult();
-
- Q_PDF_EXPORT QString contextBefore() const;
- Q_PDF_EXPORT QString contextAfter() const;
- Q_PDF_EXPORT QList<QRectF> rectangles() const;
-
-private:
- QPdfSearchResult(int page, QList<QRectF> rects, QString contextBefore, QString contextAfter);
- QPdfSearchResult(QPdfSearchResultPrivate *d);
- friend class QPdfDocument;
- friend class QPdfSearchModelPrivate;
- friend class QQuickPdfNavigationStack;
-};
-Q_DECLARE_SHARED(QPdfSearchResult)
-
-Q_PDF_EXPORT QDebug operator<<(QDebug, const QPdfSearchResult &);
-
-QT_END_NAMESPACE
-
-#endif // QPDFSEARCHRESULT_H
diff --git a/src/pdf/qpdfsearchresult_p.h b/src/pdf/qpdfsearchresult_p.h
deleted file mode 100644
index 2ad25aa6a..000000000
--- a/src/pdf/qpdfsearchresult_p.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtPDF module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPDFSEARCHRESULT_P_H
-#define QPDFSEARCHRESULT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qpdfsearchresult.h"
-
-#include "qpdfdestination_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QPdfSearchResultPrivate : public QPdfDestinationPrivate
-{
-public:
- QPdfSearchResultPrivate() = default;
- QPdfSearchResultPrivate(int page, QList<QRectF> rects, QString contextBefore, QString contextAfter) :
- QPdfDestinationPrivate(page, rects.first().topLeft(), 0),
- contextBefore{std::move(contextBefore)},
- contextAfter{std::move(contextAfter)},
- rects{std::move(rects)} {}
-
- QString contextBefore;
- QString contextAfter;
- QList<QRectF> rects;
-};
-
-QT_END_NAMESPACE
-
-#endif // QPDFSEARCHRESULT_P_H