| 662 | |
| 663 | |
| 664 | void PDFDocumentView::zoomFitWidth() |
| 665 | { |
| 666 | if (!_pdf_scene) |
| 667 | return; |
| 668 | |
| 669 | QGraphicsItem *currentPage = _pdf_scene->pageAt(_currentPage); |
| 670 | if (!currentPage) |
| 671 | return; |
| 672 | |
| 673 | QRectF rect(currentPage->sceneBoundingRect()); |
| 674 | |
| 675 | // Add a margin of half the inter-page spacing around the page rect so |
| 676 | // scrolling by one such rect will take us to exactly the same area on the |
| 677 | // next page |
| 678 | qreal dx = _pdf_scene->pageLayout().xSpacing(); |
| 679 | rect.adjust(-dx / 2, 0, dx / 2, 0); |
| 680 | |
| 681 | // Store current y position so we can center on it later. |
| 682 | qreal ypos = mapToScene(viewport()->rect()).boundingRect().center().y(); |
| 683 | |
| 684 | // Squash the rect to minimal height so its width will be limitting the zoom |
| 685 | // factor |
| 686 | rect.setTop(ypos - 1e-5); |
| 687 | rect.setBottom(ypos + 1e-5); |
| 688 | |
| 689 | zoomToRect(rect); |
| 690 | } |
| 691 | |
| 692 | void PDFDocumentView::zoomFitContentWidth() |
| 693 | { |
no test coverage detected