diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-02-10 10:49:33 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2020-02-17 17:50:01 +0100 |
commit | 0b6a4d94945a975390b2574e6aff2568ebb7f061 (patch) | |
tree | 480d54e4146ee0d23dd3f2ce69877408162bb512 /src/pdf/quick/qquickpdfsearchmodel_p.h | |
parent | e5a33355798d3277c631b0024f389cdca2f2c683 (diff) |
PdfSearchModel: be QALM and find search results on all pages
It's a QAbstractListModel, so now PdfMultiPageView has a ListView in a
left-side Drawer showing all results found so far.
- In PdfMultiPageView, multiple pages exist at once, so it makes sense
to use the same searchmodel for all.
- It's faster and saves memory.
- Search results on each page can be cached.
- It's possible to show search results in a ListView or QListView.
Change-Id: I66fba6975954a09a4d23262be87ff8cc25ee7478
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/pdf/quick/qquickpdfsearchmodel_p.h')
-rw-r--r-- | src/pdf/quick/qquickpdfsearchmodel_p.h | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/pdf/quick/qquickpdfsearchmodel_p.h b/src/pdf/quick/qquickpdfsearchmodel_p.h index 82a6289d0..3e05f80e3 100644 --- a/src/pdf/quick/qquickpdfsearchmodel_p.h +++ b/src/pdf/quick/qquickpdfsearchmodel_p.h @@ -51,7 +51,7 @@ #include "qquickpdfdocument_p.h" #include "../api/qpdfsearchmodel.h" -#include <QVariant> +#include <QtCore/qvariant.h> #include <QtQml/qqml.h> QT_BEGIN_NAMESPACE @@ -60,9 +60,10 @@ class QQuickPdfSearchModel : public QPdfSearchModel { Q_OBJECT Q_PROPERTY(QQuickPdfDocument *document READ document WRITE setDocument NOTIFY documentChanged) - Q_PROPERTY(int page READ page WRITE setPage NOTIFY pageChanged) - Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged) - Q_PROPERTY(QVector<QPolygonF> matchGeometry READ matchGeometry NOTIFY matchGeometryChanged) + Q_PROPERTY(int currentPage READ currentPage WRITE setCurrentPage NOTIFY currentPageChanged) + Q_PROPERTY(int currentResult READ currentResult WRITE setCurrentResult NOTIFY currentResultChanged) + Q_PROPERTY(QVector<QPolygonF> currentPageBoundingPolygons READ currentPageBoundingPolygons NOTIFY currentPageBoundingPolygonsChanged) + Q_PROPERTY(QVector<QPolygonF> currentResultBoundingPolygons READ currentResultBoundingPolygons NOTIFY currentResultBoundingPolygonsChanged) public: explicit QQuickPdfSearchModel(QObject *parent = nullptr); @@ -70,28 +71,33 @@ public: QQuickPdfDocument *document() const; void setDocument(QQuickPdfDocument * document); - int page() const; - void setPage(int page); + Q_INVOKABLE QVector<QPolygonF> boundingPolygonsOnPage(int page); - QString searchString() const; - void setSearchString(QString searchString); + int currentPage() const { return m_currentPage; } + void setCurrentPage(int currentPage); - QVector<QPolygonF> matchGeometry() const; + int currentResult() const { return m_currentResult; } + void setCurrentResult(int currentResult); + + QVector<QPolygonF> currentPageBoundingPolygons() const; + QVector<QPolygonF> currentResultBoundingPolygons() const; signals: void documentChanged(); - void pageChanged(); - void searchStringChanged(); - void matchGeometryChanged(); + void currentPageChanged(); + void currentResultChanged(); + void currentPageBoundingPolygonsChanged(); + void currentResultBoundingPolygonsChanged(); private: void updateResults(); + void onResultsChanged(); private: QQuickPdfDocument *m_quickDocument = nullptr; - QString m_searchString; - QVector<QPolygonF> m_matchGeometry; - int m_page; + int m_currentPage = 0; + int m_currentResult = 0; + bool m_suspendSignals = false; Q_DISABLE_COPY(QQuickPdfSearchModel) }; |