summaryrefslogtreecommitdiff
path: root/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2019-01-24 06:39:20 +0100
committerDavid Schulz <david.schulz@qt.io>2019-01-25 06:13:11 +0000
commit7b7a2ad63083717ce92cfc6d2d871034d6dc43c3 (patch)
treef974dd852987a2a9e489f424b84b167331729391 /src/plugins/cppeditor/cppfunctiondecldeflink.cpp
parenta420374976a691fee6483c9419e78250a3a30b28 (diff)
downloadqt-creator-7b7a2ad63083717ce92cfc6d2d871034d6dc43c3.tar.gz
TextEditor: Use callback in refactoring markers
Allows to trigger actions without adding specific handling into the editor. Change-Id: Ia63d65d3feca37bcefca1b6322ade039027a92d8 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/cppeditor/cppfunctiondecldeflink.cpp')
-rw-r--r--src/plugins/cppeditor/cppfunctiondecldeflink.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
index 86bdf2a0cf..a1af83596f 100644
--- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
+++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp
@@ -32,6 +32,7 @@
#include <coreplugin/actionmanager/command.h>
#include <cpptools/cppcodestylesettings.h>
#include <cpptools/cpplocalsymbols.h>
+#include <cpptools/cpptoolsconstants.h>
#include <cpptools/symbolfinder.h>
#include <texteditor/refactoroverlay.h>
#include <texteditor/texteditorconstants.h>
@@ -300,21 +301,12 @@ void FunctionDeclDefLink::apply(CppEditorWidget *editor, bool jumpToMatch)
}
}
-static QList<RefactorMarker> removeDeclDefLinkMarkers(const QList<RefactorMarker> &markers)
-{
- QList<RefactorMarker> result;
- foreach (const RefactorMarker &marker, markers) {
- if (!marker.data.canConvert<FunctionDeclDefLink::Marker>())
- result += marker;
- }
- return result;
-}
-
void FunctionDeclDefLink::hideMarker(CppEditorWidget *editor)
{
if (!hasMarker)
return;
- editor->setRefactorMarkers(removeDeclDefLinkMarkers(editor->refactorMarkers()));
+ editor->setRefactorMarkers(RefactorMarker::filterOutType(
+ editor->refactorMarkers(), CppTools::Constants::CPP_FUNCTION_DECL_DEF_LINK_MARKER_ID));
hasMarker = false;
}
@@ -323,7 +315,8 @@ void FunctionDeclDefLink::showMarker(CppEditorWidget *editor)
if (hasMarker)
return;
- QList<RefactorMarker> markers = removeDeclDefLinkMarkers(editor->refactorMarkers());
+ QList<RefactorMarker> markers = RefactorMarker::filterOutType(
+ editor->refactorMarkers(), CppTools::Constants::CPP_FUNCTION_DECL_DEF_LINK_MARKER_ID);
RefactorMarker marker;
// show the marker at the end of the linked area, with a special case
@@ -348,7 +341,11 @@ void FunctionDeclDefLink::showMarker(CppEditorWidget *editor)
message = ProxyAction::stringWithAppendedShortcut(message, quickfixCommand->keySequence());
marker.tooltip = message;
- marker.data = QVariant::fromValue(Marker());
+ marker.type = CppTools::Constants::CPP_FUNCTION_DECL_DEF_LINK_MARKER_ID;
+ marker.callback = [](TextEditor::TextEditorWidget *widget) {
+ if (auto cppEditor = qobject_cast<CppEditorWidget *>(widget))
+ cppEditor->applyDeclDefLinkChanges(true);
+ };
markers += marker;
editor->setRefactorMarkers(markers);