| 430 | } |
| 431 | |
| 432 | void PatchReviewPlugin::updateReview() |
| 433 | { |
| 434 | if( !m_patch ) |
| 435 | return; |
| 436 | |
| 437 | m_updateKompareTimer->stop(); |
| 438 | |
| 439 | switchToEmptyReviewArea(); |
| 440 | |
| 441 | KDevelop::IDocumentController *docController = ICore::self()->documentController(); |
| 442 | // don't add documents opened automatically to the Files/Open Recent list |
| 443 | IDocument* futureActiveDoc = docController->openDocument( m_patch->file(), KTextEditor::Range::invalid(), |
| 444 | IDocumentController::DoNotAddToRecentOpen ); |
| 445 | |
| 446 | updateKompareModel(); |
| 447 | |
| 448 | if ( !m_modelList || !futureActiveDoc || !futureActiveDoc->textDocument() ) { |
| 449 | // might happen if e.g. openDocument dialog was cancelled by user |
| 450 | // or under the theoretic possibility of a non-text document getting opened |
| 451 | return; |
| 452 | } |
| 453 | |
| 454 | futureActiveDoc->textDocument()->setReadWrite( false ); |
| 455 | futureActiveDoc->setPrettyName(i18nc("@title complete patch", "Overview")); |
| 456 | futureActiveDoc->textDocument()->setModifiedOnDiskWarning(false); |
| 457 | |
| 458 | docController->activateDocument( futureActiveDoc ); |
| 459 | |
| 460 | auto* toolView = qobject_cast<PatchReviewToolView*>(ICore::self()->uiController()->findToolView(i18nc("@title:window", "Patch Review"), m_factory)); |
| 461 | Q_ASSERT( toolView ); |
| 462 | |
| 463 | //Open all relates files |
| 464 | for( int a = 0; a < m_modelList->modelCount() && a < maximumFilesToOpenDirectly; ++a ) { |
| 465 | QUrl absoluteUrl = urlForFileModel( m_modelList->modelAt( a ) ); |
| 466 | if (absoluteUrl.isRelative()) { |
| 467 | const QString messageText = i18n("The base directory of the patch must be an absolute directory."); |
| 468 | auto* message = new Sublime::Message(messageText, Sublime::Message::Error); |
| 469 | ICore::self()->uiController()->postMessage(message); |
| 470 | break; |
| 471 | } |
| 472 | |
| 473 | if( QFileInfo::exists( absoluteUrl.toLocalFile() ) && absoluteUrl.toLocalFile() != QLatin1String("/dev/null") ) |
| 474 | { |
| 475 | toolView->open( absoluteUrl, false ); |
| 476 | }else{ |
| 477 | // Maybe the file was deleted |
| 478 | qCDebug(PLUGIN_PATCHREVIEW) << "could not open" << absoluteUrl << "because it doesn't exist"; |
| 479 | } |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | void PatchReviewPlugin::setPatch( IPatchSource* patch ) { |
| 484 | if ( patch == m_patch ) { |
nothing calls this directly
no test coverage detected