| 667 | } |
| 668 | |
| 669 | void PDFDocumentWindow::syncFromSource(const QString& sourceFile, int lineNo, int col, bool activatePreview) |
| 670 | { |
| 671 | if (!_synchronizer) |
| 672 | return; |
| 673 | |
| 674 | Tw::Settings settings; |
| 675 | TWSynchronizer::Resolution res{TWSynchronizer::kDefault_Resolution_ToPDF}; |
| 676 | switch (settings.value(QString::fromLatin1("syncResolutionToPDF"), TWSynchronizer::kDefault_Resolution_ToPDF).toInt()) { |
| 677 | case 0: |
| 678 | res = TWSynchronizer::CharacterResolution; |
| 679 | break; |
| 680 | case 1: |
| 681 | res = TWSynchronizer::WordResolution; |
| 682 | break; |
| 683 | case 2: |
| 684 | res = TWSynchronizer::LineResolution; |
| 685 | break; |
| 686 | } |
| 687 | |
| 688 | TWSynchronizer::TeXSyncPoint src; |
| 689 | src.filename = sourceFile; |
| 690 | src.line = lineNo; |
| 691 | src.col = col; |
| 692 | |
| 693 | // Get target point |
| 694 | TWSynchronizer::PDFSyncPoint dest = _synchronizer->syncFromTeX(src, res); |
| 695 | |
| 696 | // Check target point |
| 697 | if (dest.page < 1 || QFileInfo(curFile) != QFileInfo(dest.filename)) |
| 698 | return; |
| 699 | |
| 700 | // Display the result |
| 701 | pdfWidget->goToPage(dest.page - 1); |
| 702 | QPainterPath path; |
| 703 | path.setFillRule(Qt::WindingFill); |
| 704 | foreach(QRectF r, dest.rects) |
| 705 | path.addRect(r); |
| 706 | |
| 707 | clearSyncHighlight(); |
| 708 | _syncHighlight = pdfWidget->addHighlightPath(dest.page - 1, path, QColor(255, 255, 0, 63)); |
| 709 | |
| 710 | // Ensure that the synhronization point is displayed (in the center) |
| 711 | pdfWidget->centerOn(_syncHighlight->mapToScene(_syncHighlight->boundingRect().center())); |
| 712 | |
| 713 | // Start the highlight removal timer (if applicable) |
| 714 | if (kPDFHighlightDuration > 0) |
| 715 | _syncHighlightRemover.start(kPDFHighlightDuration); |
| 716 | |
| 717 | // Update the view (and possibly bring it to the front) |
| 718 | pdfWidget->update(); |
| 719 | if (activatePreview) |
| 720 | selectWindow(); |
| 721 | } |
| 722 | |
| 723 | void PDFDocumentWindow::invalidateSyncHighlight() |
| 724 | { |
nothing calls this directly
no test coverage detected