MCPcopy Create free account
hub / github.com/KDE/kdevelop / open

Method open

plugins/patchreview/patchreviewtoolview.cpp:359–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357}
358
359void PatchReviewToolView::open( const QUrl& url, bool activate ) const
360{
361 qCDebug(PLUGIN_PATCHREVIEW) << "activating url" << url;
362 // If the document is already open in this area, just re-activate it
363 if(KDevelop::IDocument* doc = ICore::self()->documentController()->documentForUrl(url)) {
364 const auto views = ICore::self()->uiController()->activeArea()->views();
365 for (Sublime::View* view : views) {
366 if(view->document() == dynamic_cast<Sublime::Document*>(doc))
367 {
368 if (activate) {
369 // use openDocument() for the activation so that the document is added to File/Open Recent.
370 ICore::self()->documentController()->openDocument(doc->url(), KTextEditor::Range::invalid());
371 }
372 return;
373 }
374 }
375 }
376
377 QStandardItem* item = m_fileModel->itemForUrl( url );
378
379 IDocument* buddyDoc = nullptr;
380
381 if (m_plugin->patch() && item) {
382 for (int preRow = item->row() - 1; preRow >= 0; --preRow) {
383 QStandardItem* preItem = m_fileModel->item(preRow);
384 if (!m_fileModel->isCheckable() || preItem->checkState() == Qt::Checked) {
385 // found valid predecessor, take it as buddy
386 buddyDoc = ICore::self()->documentController()->documentForUrl(preItem->index().data(VcsFileChangesModel::UrlRole).toUrl());
387 if (buddyDoc) {
388 break;
389 }
390 }
391 }
392 if (!buddyDoc) {
393 buddyDoc = ICore::self()->documentController()->documentForUrl(m_plugin->patch()->file());
394 }
395 }
396
397 // we simplify and assume that documents to be opened without activating them also need not be
398 // added to the Files/Open Recent menu.
399 IDocument* newDoc = ICore::self()->documentController()->openDocument(url, KTextEditor::Range::invalid(),
400 activate ? IDocumentController::DefaultMode : IDocumentController::DoNotActivate|IDocumentController::DoNotAddToRecentOpen,
401 QString(), buddyDoc);
402
403 KTextEditor::View* view = nullptr;
404 if(newDoc)
405 view = newDoc->activeTextView();
406
407 if(view && view->cursorPosition().line() == 0)
408 m_plugin->seekHunk( true, url );
409}
410
411void PatchReviewToolView::fileItemChanged( QStandardItem* item )
412{

Callers 15

ChecksDBMethod · 0.45
addFilesMethod · 0.45
commitFilesMethod · 0.45
testAnnotationMethod · 0.45
generateMakefileMethod · 0.45
StashPatchSourceMethod · 0.45
updatePatchFileMethod · 0.45

Calls 15

documentForUrlMethod · 0.80
documentControllerMethod · 0.80
activeAreaMethod · 0.80
uiControllerMethod · 0.80
patchMethod · 0.80
isCheckableMethod · 0.80
checkStateMethod · 0.80
seekHunkMethod · 0.80
invalidFunction · 0.50
QStringClass · 0.50
viewsMethod · 0.45
documentMethod · 0.45

Tested by 15

addFilesMethod · 0.36
commitFilesMethod · 0.36
testAnnotationMethod · 0.36
writeFileFunction · 0.36
commitFilesMethod · 0.36
testStashMethod · 0.36
importJSONFileMethod · 0.36
createFileFunction · 0.36
createFileMethod · 0.36