| 420 | } |
| 421 | |
| 422 | KTextEditor::Document *Application::findUrl(const QUrl &url) const |
| 423 | { |
| 424 | if (url.isEmpty()) { |
| 425 | // Return the first found document with an empty URL. |
| 426 | // Perform a linear search across all open documents. Cannot just look a document |
| 427 | // up by an empty URL, because each IDocument has a unique nonempty URL. |
| 428 | const auto documents = Core::self()->documentControllerInternal()->openDocuments(); |
| 429 | const auto it = std::find_if(documents.cbegin(), documents.cend(), [](const IDocument* document) { |
| 430 | return DocumentController::isEmptyDocumentUrl(document->url()); |
| 431 | }); |
| 432 | return it == documents.cend() ? nullptr : (*it)->textDocument(); |
| 433 | } |
| 434 | |
| 435 | const auto resolvedUrl = resolvedToLocalFile(url); |
| 436 | if (!canPointToFile(resolvedUrl)) { |
| 437 | return nullptr; // a document cannot have a non-file URL |
| 438 | } |
| 439 | |
| 440 | // ensure that a local-file URL has canonical path so that DocumentController::documentForUrl() finds the document |
| 441 | const auto* const doc = |
| 442 | Core::self()->documentControllerInternal()->documentForUrl(urlWithCanonicalizedPathIfLocalFile(resolvedUrl)); |
| 443 | return doc ? doc->textDocument() : nullptr; |
| 444 | } |
| 445 | |
| 446 | bool Application::quit() const |
| 447 | { |
nothing calls this directly
no test coverage detected