Commit 8872ef1b authored by hjk's avatar hjk

CppEditor: Allow connect quickfix to operate on disconnect, too

Change-Id: I94794214d969aeda6b3ce21fdca9e0bd23dea800
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 20f48628
......@@ -3865,11 +3865,15 @@ void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectWithinClass_data()
QTest::addColumn<QByteArray>("original");
QTest::addColumn<QByteArray>("expected");
QTest::newRow("case1")
QTest::newRow("four-args-connect")
<< QByteArray("conne@ct(this, SIGNAL(sigFoo(int)), this, SLOT(setProp(int)));")
<< QByteArray("connect(this, &TestClass::sigFoo, this, &TestClass::setProp);");
QTest::newRow("case2")
QTest::newRow("four-args-disconnect")
<< QByteArray("disconne@ct(this, SIGNAL(sigFoo(int)), this, SLOT(setProp(int)));")
<< QByteArray("disconnect(this, &TestClass::sigFoo, this, &TestClass::setProp);");
QTest::newRow("three-args-connect")
<< QByteArray("conne@ct(this, SIGNAL(sigFoo(int)), SLOT(setProp(int)));")
<< QByteArray("connect(this, &TestClass::sigFoo, this, &TestClass::setProp);");
}
......
......@@ -5412,7 +5412,7 @@ bool findConnectReplacement(const CppQuickFixInterface &interface,
return true;
}
bool onConnectCall(AST *ast, const ExpressionListAST **arguments)
bool onConnectOrDisconnectCall(AST *ast, const ExpressionListAST **arguments)
{
if (!ast)
return false;
......@@ -5437,7 +5437,7 @@ bool onConnectCall(AST *ast, const ExpressionListAST **arguments)
return false;
const QByteArray name(id->chars(), id->size());
if (name != "connect")
if (name != "connect" && name != "disconnect")
return false;
if (arguments)
......@@ -5493,7 +5493,7 @@ void ConvertQt4Connect::match(const CppQuickFixInterface &interface, QuickFixOpe
for (int i = path.size(); --i >= 0; ) {
const ExpressionListAST *arguments;
if (!onConnectCall(path.at(i), &arguments))
if (!onConnectOrDisconnectCall(path.at(i), &arguments))
continue;
const ExpressionAST *arg1, *arg3;
......
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