| 690 | } |
| 691 | |
| 692 | void PDFDocumentView::zoomFitContentWidth() |
| 693 | { |
| 694 | if (!_pdf_scene) |
| 695 | return; |
| 696 | |
| 697 | PDFPageGraphicsItem *currentPage = dynamic_cast<PDFPageGraphicsItem*>(_pdf_scene->pageAt(_currentPage)); |
| 698 | if (!currentPage) |
| 699 | return; |
| 700 | |
| 701 | QSharedPointer<Backend::Page> page = currentPage->page().toStrongRef(); |
| 702 | if (!page) |
| 703 | return; |
| 704 | |
| 705 | QRectF rect(page->getContentBoundingBox()); |
| 706 | rect = currentPage->mapRectToScene(QRectF(currentPage->mapFromPage(rect.topLeft()), currentPage->mapFromPage(rect.bottomRight()))); |
| 707 | |
| 708 | // Store current y position so we can center on it later. |
| 709 | qreal ypos = mapToScene(viewport()->rect()).boundingRect().center().y(); |
| 710 | |
| 711 | // Squash the rect to minimal height so its width will be limitting the zoom |
| 712 | // factor |
| 713 | rect.setTop(ypos - 1e-5); |
| 714 | rect.setBottom(ypos + 1e-5); |
| 715 | |
| 716 | zoomToRect(rect); |
| 717 | } |
| 718 | |
| 719 | |
| 720 | void PDFDocumentView::zoom100() |
no test coverage detected