MCPcopy Create free account
hub / github.com/TeXworks/texworks / goToPDFDestination

Method goToPDFDestination

modules/QtPDF/src/PDFDocumentView.cpp:563–603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561}
562
563void 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
605void PDFDocumentView::zoomBy(const qreal zoomFactor, const QGraphicsView::ViewportAnchor anchor /* = QGraphicsView::AnchorViewCenter */)
606{

Callers 1

maybeOpenPdfMethod · 0.80

Calls 14

isNullMethod · 0.80
isExplicitMethod · 0.80
pageAtMethod · 0.80
boundingRectMethod · 0.80
viewportMethod · 0.80
setTypeMethod · 0.80
isValidMethod · 0.45
documentMethod · 0.45
resolveDestinationMethod · 0.45
rectMethod · 0.45
mapToPageMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected