summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-02-26 11:09:09 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-02-26 15:40:40 +0100
commit7e75e9b80249f553fcfbdb2716c93707b40f8c48 (patch)
tree15b24447d5d0e9df91b6feb186cad3d99473f6a2
parent82674435efc1f2fa025d84a5feac1f1416ad7ef1 (diff)
PdfMultiPageView: update search highlights when results change
In the single-page view, we bind to the PdfSearchModel.currentPageBoundingPolygons property, which is convenient because it has a changed signal, so it stays updated in all cases: when the user changes the search string, when a different document is loaded, or when changing the current page. In the multi-page view, we need to invoke a function to get the search results on each page, because results are different on each page, and we often need to show multiple pages at the same time. The challenge then is how to ensure that it gets re-evaluated often enough. It requires connecting to more than one signal; but there isn't any way to "kick" a binding when some signal occurs, so the solution isn't very declarative, unfortunately. Change-Id: I72e7dad01b8cb6c43abcccf4fa46e443409b39e0 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r--src/pdf/quick/qml/PdfMultiPageView.qml14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/pdf/quick/qml/PdfMultiPageView.qml b/src/pdf/quick/qml/PdfMultiPageView.qml
index d50763a64..5efad39f0 100644
--- a/src/pdf/quick/qml/PdfMultiPageView.qml
+++ b/src/pdf/quick/qml/PdfMultiPageView.qml
@@ -183,21 +183,33 @@ Item {
image.sourceSize.width = paper.pagePointSize.width * renderScale
image.sourceSize.height = 0
paper.scale = 1
+ searchHighlights.update()
}
}
Shape {
anchors.fill: parent
opacity: 0.25
visible: image.status === Image.Ready
+ onVisibleChanged: searchHighlights.update()
ShapePath {
strokeWidth: 1
strokeColor: "cyan"
fillColor: "steelblue"
scale: Qt.size(paper.pageScale, paper.pageScale)
PathMultiline {
- paths: searchModel.boundingPolygonsOnPage(index)
+ id: searchHighlights
+ function update() {
+ // paths could be a binding, but we need to be able to "kick" it sometimes
+ paths = searchModel.boundingPolygonsOnPage(index)
+ }
}
}
+ Connections {
+ target: searchModel
+ // whenever the highlights on the _current_ page change, they actually need to change on _all_ pages
+ // (usually because the search string has changed)
+ function onCurrentPageBoundingPolygonsChanged() { searchHighlights.update() }
+ }
ShapePath {
fillColor: "orange"
scale: Qt.size(paper.pageScale, paper.pageScale)