summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2022-06-02 21:51:21 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2022-06-04 20:55:31 +0200
commit33f6047ef17421fd07d0350fedcfbd049e31fe28 (patch)
tree0e64e05110dd5536bf07c4ed5cdaf72633d831ed /examples
parentfa260888d9c9a59acd6e35aa472ca53990ce6635 (diff)
Use QPdfLink in PageNavigator jump() / jumped(); QML views
One reason for this is to use the new tableView.positionViewAtCell(.., TableView.Contain, offset, rect) to do less scrolling when iterating search results. Now in that case, the QPdfLink object contains correct rectangles, so that we can scale the first one and pass it directly to positionViewAtCell(). When clicking a hyperlink, the destination is a point rather than a rectangle; but positionViewAtCell with a subRect works better than calling it with just an offset, so we construct a small rectangle for that purpose. It's important that the QPdfLink object emitted in the jumped() signal must not contain any rectangles in this case, so that we can distinguish a hyperlink destination from a search-result destination. The QPdfLink object from PdfLinkModel has its own rectangle, but that's the place where the user clicks. When clicked, the view calls pageNavigator.jump(page, location, zoom), rather than the jump(QPdfLink) overload, so that rectangle is not passed along. In an onJumped() handler, we expect the rectangles to be the destination, if present; otherwise we fall back to using the location property, which is always the destination, never the source. In both cases, we need to grow the destination rectangle by jumpLocationMargin, because the offset argument to positionViewAtCell() is an offset, not a margin. But since the rectangle needs to be scaled from points to pixels anyway (according to the current renderScale), it's not much more trouble to add the margin. It looks better to avoid having a search result and its highlight rectangle banging up against the corner of the viewport: the margin lets the user see a bit of context on the page, and the highlight looks more distinct by being spaced out away from the edge. And since the margin gets added to the rectangle's edges, it makes more sense to use the (qreal) point type rather than vector2d. To make it possible to emit a QPdfLink object and access its properties in QML, it's now registered as a QML type. Fixes: QTBUG-102740 Change-Id: I74ccd11a106c5e49a0ce94eef9cf2d50992923b4 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'examples')
0 files changed, 0 insertions, 0 deletions