diff --git a/vcs/vcspluginhelper.h b/vcs/vcspluginhelper.h --- a/vcs/vcspluginhelper.h +++ b/vcs/vcspluginhelper.h @@ -28,6 +28,13 @@ class Document; } +// KTextEditor::AnnotationViewInterface has a bad signature in the +// annotationBorderVisibilityChanged signal, using type "View" instead +// of "KTextEditor::View". +// To enable a string based signal-slot connection, as needed due to +// annotationBorderVisibilityChanged being an "interface" signal, +// with the slot VcsPluginHelper::removeAnnotationModel, +// make View known here using KTextEditor::View; namespace KDevelop @@ -79,6 +86,8 @@ private Q_SLOTS: void delayedModificationWarningOn(); + // namespace-less type "View" needed here, see comment above on "using KTextEditor::View;" + void handleAnnotationBorderVisibilityChanged(View* view, bool visible); private: void diffForRev(const QUrl& url); diff --git a/vcs/vcspluginhelper.cpp b/vcs/vcspluginhelper.cpp --- a/vcs/vcspluginhelper.cpp +++ b/vcs/vcspluginhelper.cpp @@ -386,14 +386,17 @@ } if (annotateiface && viewiface) { + // TODO: only create model if there is none yet (e.g. from another view) KDevelop::VcsAnnotationModel* model = new KDevelop::VcsAnnotationModel(job, url, doc->textDocument(), foreground, background); annotateiface->setAnnotationModel(model); viewiface->setAnnotationBorderVisible(true); // can't use new signal slot syntax here, AnnotationInterface is not a QObject connect(doc->activeTextView(), SIGNAL(annotationContextMenuAboutToShow(KTextEditor::View*,QMenu*,int)), this, SLOT(annotationContextMenuAboutToShow(KTextEditor::View*,QMenu*,int))); + connect(doc->activeTextView(), SIGNAL(annotationBorderVisibilityChanged(View*,bool)), + this, SLOT(handleAnnotationBorderVisibilityChanged(View*,bool))); } else { KMessageBox::error(nullptr, i18n("Cannot display annotations, missing interface KTextEditor::AnnotationInterface for the editor.")); delete job; @@ -435,6 +438,21 @@ }); } +void VcsPluginHelper::handleAnnotationBorderVisibilityChanged(View* view, bool visible) +{ + if (visible) { + return; + } + + disconnect(view, SIGNAL(annotationContextMenuAboutToShow(KTextEditor::View*,QMenu*,int)), + this, SLOT(annotationContextMenuAboutToShow(KTextEditor::View*,QMenu*,int))); + + disconnect(view, SIGNAL(annotationBorderVisibilityChanged(View*,bool)), + this, SLOT(handleAnnotationBorderVisibilityChanged(View*,bool))); + + // TODO: remove the model if last user of it +} + void VcsPluginHelper::update() { EXECUTE_VCS_METHOD(update);