| 561 | } |
| 562 | |
| 563 | void PDFDocumentView::goToPDFDestination(const PDFDestination & dest, bool saveOldViewRect /* = true */) |
| 564 | { |
| 565 | if (!dest.isValid()) |
| 566 | return; |
| 567 | |
| 568 | Q_ASSERT(_pdf_scene != nullptr); |
| 569 | Q_ASSERT(!_pdf_scene->document().isNull()); |
| 570 | QSharedPointer<Backend::Document> doc(_pdf_scene->document().toStrongRef()); |
| 571 | if (!doc) |
| 572 | return; |
| 573 | |
| 574 | PDFDestination finalDest; |
| 575 | if (!dest.isExplicit()) { |
| 576 | finalDest = doc->resolveDestination(dest); |
| 577 | if (!finalDest.isValid()) |
| 578 | return; |
| 579 | } |
| 580 | else |
| 581 | finalDest = dest; |
| 582 | |
| 583 | Q_ASSERT(PDFDocumentScene::isPageItem(_pdf_scene->pageAt(_currentPage))); |
| 584 | PDFPageGraphicsItem * pageItem = dynamic_cast<PDFPageGraphicsItem*>(_pdf_scene->pageAt(_currentPage)); |
| 585 | Q_ASSERT(pageItem != nullptr); |
| 586 | |
| 587 | // Get the current (=old) viewport in the current (=old) page's |
| 588 | // coordinate system |
| 589 | QRectF oldViewport = pageItem->mapRectFromScene(mapToScene(viewport()->rect()).boundingRect()); |
| 590 | oldViewport = QRectF(pageItem->mapToPage(oldViewport.topLeft()), \ |
| 591 | pageItem->mapToPage(oldViewport.bottomRight())); |
| 592 | // Calculate the new viewport (in page coordinates) |
| 593 | QRectF view(finalDest.viewport(doc.data(), oldViewport, _zoomLevel)); |
| 594 | |
| 595 | if (saveOldViewRect) { |
| 596 | PDFDestination origin(_currentPage); |
| 597 | origin.setType(PDFDestination::Destination_FitR); |
| 598 | origin.setRect(oldViewport); |
| 599 | _oldViewRects.push(origin); |
| 600 | } |
| 601 | |
| 602 | goToPage(dynamic_cast<PDFPageGraphicsItem*>(_pdf_scene->pageAt(finalDest.page())), view, true); |
| 603 | } |
| 604 | |
| 605 | void PDFDocumentView::zoomBy(const qreal zoomFactor, const QGraphicsView::ViewportAnchor anchor /* = QGraphicsView::AnchorViewCenter */) |
| 606 | { |
no test coverage detected