Commit e11bbac6 authored by hjk's avatar hjk

TextEditor: Add a convenience append method for quick fixes

Less noise on the user side.

Change-Id: Ia5b495a1f9d3ec43623056d793f6771b3b84fd6b
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 14022854
......@@ -114,7 +114,7 @@ public:
CppLocalRenaming m_localRenaming;
CppTools::SemanticInfo m_lastSemanticInfo;
QList<QuickFixOperation::Ptr> m_quickFixes;
QuickFixOperations m_quickFixes;
CppUseSelectionsUpdater m_useSelectionsUpdater;
......@@ -474,8 +474,7 @@ bool CppEditorWidget::event(QEvent *e)
void CppEditorWidget::performQuickFix(int index)
{
QuickFixOperation::Ptr op = d->m_quickFixes.at(index);
op->perform();
d->m_quickFixes.at(index)->perform();
}
void CppEditorWidget::processKeyNormally(QKeyEvent *e)
......
......@@ -1088,7 +1088,7 @@ void InsertVirtualMethods::match(const CppQuickFixInterface &interface, QuickFix
{
InsertVirtualMethodsOp *op = new InsertVirtualMethodsOp(interface, m_dialog);
if (op->isValid())
result.append(QuickFixOperation::Ptr(op));
result.append(op);
else
delete op;
}
......
......@@ -234,8 +234,7 @@ public:
void match(const CppQuickFixInterface &cppQuickFixInterface, QuickFixOperations &result)
{
result += CppQuickFixOperation::Ptr(
new AddIncludeForUndefinedIdentifierOp(cppQuickFixInterface, 0, m_include));
result.append(new AddIncludeForUndefinedIdentifierOp(cppQuickFixInterface, 0, m_include));
}
private:
......
This diff is collapsed.
......@@ -176,13 +176,13 @@ void ComponentFromObjectDef::match(const QmlJSQuickFixInterface &interface, Quic
return;
// check that the node is not the root node
if (i > 0 && !cast<UiProgram*>(path.at(i - 1))) {
result.append(QuickFixOperation::Ptr(new Operation(interface, objDef)));
result.append(new Operation(interface, objDef));
return;
}
} else if (UiObjectBinding *objBinding = cast<UiObjectBinding *>(node)) {
if (!interface->currentFile()->isCursorOn(objBinding->qualifiedTypeNameId))
return;
result.append(QuickFixOperation::Ptr(new Operation(interface, objBinding)));
result.append(new Operation(interface, objBinding));
return;
}
}
......
......@@ -665,8 +665,7 @@ void QmlJSEditorWidget::showContextPane()
void QmlJSEditorWidget::performQuickFix(int index)
{
QuickFixOperation::Ptr op = m_quickFixes.at(index);
op->perform();
m_quickFixes.at(index)->perform();
}
void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e)
......
......@@ -129,7 +129,7 @@ private:
QModelIndex m_outlineModelIndex;
QmlJS::ModelManagerInterface *m_modelManager;
QList<TextEditor::QuickFixOperation::Ptr> m_quickFixes;
TextEditor::QuickFixOperations m_quickFixes;
QmlJS::IContextPane *m_contextPane;
int m_oldCursorPosition;
......
......@@ -81,7 +81,7 @@ class SplitInitializerOp: public QmlJSQuickFixFactory
}
if (objectInitializer)
result.append(TextEditor::QuickFixOperation::Ptr(new Operation(interface, objectInitializer)));
result.append(new Operation(interface, objectInitializer));
}
class Operation: public QmlJSQuickFixOperation
......@@ -139,7 +139,7 @@ public:
foreach (const StaticAnalysis::Message &message, messages) {
if (interface->currentFile()->isCursorOn(message.location)) {
result.append(QuickFixOperation::Ptr(new Operation(interface, message)));
result.append(new Operation(interface, message));
return;
}
}
......
......@@ -189,13 +189,13 @@ void WrapInLoader::match(const QmlJSQuickFixInterface &interface, QuickFixOperat
return;
// check that the node is not the root node
if (i > 0 && !cast<UiProgram*>(path.at(i - 1))) {
result.append(QuickFixOperation::Ptr(new Operation<UiObjectDefinition>(interface, objDef)));
result.append(new Operation<UiObjectDefinition>(interface, objDef));
return;
}
} else if (UiObjectBinding *objBinding = cast<UiObjectBinding *>(node)) {
if (!interface->currentFile()->isCursorOn(objBinding->qualifiedTypeNameId))
return;
result.append(QuickFixOperation::Ptr(new Operation<UiObjectBinding>(interface, objBinding)));
result.append(new Operation<UiObjectBinding>(interface, objBinding));
return;
}
}
......
......@@ -90,7 +90,13 @@ private:
QString _description;
};
typedef QList<QuickFixOperation::Ptr> QuickFixOperations;
class TEXTEDITOR_EXPORT QuickFixOperations : public QList<QuickFixOperation::Ptr>
{
public:
using QList<QuickFixOperation::Ptr>::append;
void append(QuickFixOperation *op) { append(QuickFixOperation::Ptr(op)); }
};
typedef QSharedPointer<const AssistInterface> QuickFixInterface;
/*!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment