forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <texteditor/fontsettings.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
#include <utils/textutils.h>
|
||||
@@ -268,7 +269,15 @@ TextEditor::RefactorMarker createFixItAvailableMarker(QTextDocument *textDocumen
|
||||
TextEditor::RefactorMarker marker;
|
||||
marker.tooltip = tooltipForFixItAvailableMarker();
|
||||
marker.cursor = cursorAtLastPositionOfLine(textDocument, lineNumber);
|
||||
marker.data = QLatin1String(CppTools::Constants::CPP_CLANG_FIXIT_AVAILABLE_MARKER_ID);
|
||||
marker.callback = [marker](TextEditor::TextEditorWidget *editor) {
|
||||
int line, column;
|
||||
if (Utils::Text::convertPosition(marker.cursor.document(),
|
||||
marker.cursor.position(), &line, &column)) {
|
||||
editor->setTextCursor(marker.cursor);
|
||||
editor->invokeAssist(TextEditor::QuickFix);
|
||||
}
|
||||
};
|
||||
marker.type = CppTools::Constants::CPP_CLANG_FIXIT_AVAILABLE_MARKER_ID;
|
||||
|
||||
return marker;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user