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

Method maybeOpenPdf

src/PDFDocumentWindow.cpp:1125–1149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1123}
1124
1125void PDFDocumentWindow::maybeOpenPdf(const QString & filename, const QtPDF::PDFDestination & destination, const bool newWindow)
1126{
1127 Q_UNUSED(newWindow)
1128 // Unlike in maybeOpenUrl, this function only works on local PDF files which
1129 // we assume are safe.
1130 // TODO: We currently ignore the value of newWindow and always open a new
1131 // window. This avoids the need to update/invalidate all pointers to this
1132 // PDFDocument (e.g., in the TeXDocument associated with it) to notify the
1133 // other parts of the code that a completely new and unrelated document is
1134 // loaded here now.
1135 // NB: TWApp::openFile() requires an absolute filename. Therefore, we have
1136 // to make it absolute (using the current file's folder as base) if it isn't
1137 // already
1138 PDFDocumentWindow * pdf = qobject_cast<PDFDocumentWindow*>(TWApp::instance()->openFile([this] (const QString & filename) {
1139 const QFileInfo fi(filename);
1140 if (fi.isAbsolute()) {
1141 return filename;
1142 }
1143 return QFileInfo(this->fileName()).dir().filePath(filename);
1144 }(filename)
1145 ));
1146 if (!pdf || !pdf->widget())
1147 return;
1148 pdf->widget()->goToPDFDestination(destination, false);
1149}
1150
1151
1152void PDFDocumentWindow::print()

Callers

nothing calls this directly

Calls 4

fileNameMethod · 0.95
openFileMethod · 0.80
widgetMethod · 0.80
goToPDFDestinationMethod · 0.80

Tested by

no test coverage detected