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

Method annotation

kdevplatform/vcs/vcspluginhelper.cpp:372–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372void VcsPluginHelper::annotation()
373{
374 Q_D(VcsPluginHelper);
375
376 SINGLEURL_SETUP_VARS
377 KDevelop::IDocument* doc = ICore::self()->documentController()->documentForUrl(url);
378
379 if (!doc)
380 doc = ICore::self()->documentController()->openDocument(url);
381
382 KTextEditor::View* view = doc ? doc->activeTextView() : nullptr;
383 if (view && view->isAnnotationBorderVisible()) {
384 view->setAnnotationBorderVisible(false);
385 return;
386 }
387
388 if (doc && doc->textDocument() && iface) {
389 KDevelop::VcsJob* job = iface->annotate(url);
390 if( !job )
391 {
392 qCWarning(VCS) << "Couldn't create annotate job for:" << url << "with iface:" << iface << dynamic_cast<KDevelop::IPlugin*>( iface );
393 return;
394 }
395
396 QColor foreground(Qt::black);
397 QColor background(Qt::white);
398 if (view) {
399 const auto style = view->defaultStyleAttribute(KSyntaxHighlighting::Theme::TextStyle::Normal);
400 foreground = style->foreground().color();
401 if (style->hasProperty(QTextFormat::BackgroundBrush)) {
402 background = style->background().color();
403 }
404
405 // TODO: only create model if there is none yet (e.g. from another view)
406 auto* model = new KDevelop::VcsAnnotationModel(job, url, doc->textDocument(),
407 foreground, background);
408 doc->textDocument()->setAnnotationModel(model);
409
410 // TODO: only create delegate if there is none yet
411 auto delegate = new VcsAnnotationItemDelegate(view, model, view);
412 view->setAnnotationItemDelegate(delegate);
413 view->setAnnotationUniformItemSizes(true);
414 view->setAnnotationBorderVisible(true);
415 connect(view, &KTextEditor::View::annotationContextMenuAboutToShow, this,
416 &VcsPluginHelper::annotationContextMenuAboutToShow);
417 connect(view, &KTextEditor::View::annotationBorderVisibilityChanged, this,
418 &VcsPluginHelper::handleAnnotationBorderVisibilityChanged);
419 } else {
420 KMessageBox::error(nullptr, i18n("Cannot display annotations, missing interface KTextEditor::AnnotationInterface for the editor."));
421 delete job;
422 }
423 } else {
424 KMessageBox::error(nullptr, i18n("Cannot execute annotate action because the "
425 "document was not found, or was not a text document:\n%1", url.toDisplayString(QUrl::PreferLocalFile)));
426 }
427}
428
429void VcsPluginHelper::annotationContextMenuAboutToShow( KTextEditor::View* view, QMenu* menu, int line )

Callers 1

Calls 7

documentForUrlMethod · 0.80
documentControllerMethod · 0.80
hasPropertyMethod · 0.80
openDocumentMethod · 0.45
activeTextViewMethod · 0.45
textDocumentMethod · 0.45
annotateMethod · 0.45

Tested by

no test coverage detected