static void addDeclaration(const Snapshot &snapshot, const QString &fileName, const Class *cl, const QString &functionName) { const QString declaration = "void " + functionName + ";\n"; CppTools::CppRefactoringChanges refactoring(snapshot); CppTools::InsertionPointLocator find(refactoring); const CppTools::InsertionLocation loc = find.methodDeclarationInClass( fileName, cl, CppTools::InsertionPointLocator::PrivateSlot); // //! \todo change this to use the Refactoring changes. // if (BaseTextEditor *editor = editorAt(fileName, loc.line(), loc.column() - 1)) { QTextCursor tc = editor->textCursor(); int pos = tc.position(); tc.beginEditBlock(); tc.insertText(loc.prefix() + declaration + loc.suffix()); tc.setPosition(pos, QTextCursor::KeepAnchor); editor->textDocument()->autoIndent(tc); tc.endEditBlock(); } }
static void addDeclaration(const Snapshot &snapshot, const QString &fileName, const Class *cl, const QString &functionName) { QString declaration = QLatin1String("void "); declaration += functionName; declaration += QLatin1String(";\n"); CppTools::CppRefactoringChanges refactoring(snapshot); CppTools::InsertionPointLocator find(&refactoring); const CppTools::InsertionLocation loc = find.methodDeclarationInClass( fileName, cl, CppTools::InsertionPointLocator::PrivateSlot); // //! \todo change this to use the Refactoring changes. // if (ITextEditor *editable = editableAt(fileName, loc.line(), loc.column() - 1)) { BaseTextEditorWidget *editor = qobject_cast<BaseTextEditorWidget *>(editable->widget()); if (editor) { QTextCursor tc = editor->textCursor(); int pos = tc.position(); tc.beginEditBlock(); tc.insertText(loc.prefix() + declaration + loc.suffix()); tc.setPosition(pos, QTextCursor::KeepAnchor); editor->indentInsertedText(tc); tc.endEditBlock(); } } }