forked from qt-creator/qt-creator
CppEditor: Allow connect quickfix to operate on disconnect, too
Change-Id: I94794214d969aeda6b3ce21fdca9e0bd23dea800 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
@@ -3865,11 +3865,15 @@ void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectWithinClass_data()
|
|||||||
QTest::addColumn<QByteArray>("original");
|
QTest::addColumn<QByteArray>("original");
|
||||||
QTest::addColumn<QByteArray>("expected");
|
QTest::addColumn<QByteArray>("expected");
|
||||||
|
|
||||||
QTest::newRow("case1")
|
QTest::newRow("four-args-connect")
|
||||||
<< QByteArray("conne@ct(this, SIGNAL(sigFoo(int)), this, SLOT(setProp(int)));")
|
<< QByteArray("conne@ct(this, SIGNAL(sigFoo(int)), this, SLOT(setProp(int)));")
|
||||||
<< QByteArray("connect(this, &TestClass::sigFoo, this, &TestClass::setProp);");
|
<< 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("conne@ct(this, SIGNAL(sigFoo(int)), SLOT(setProp(int)));")
|
||||||
<< QByteArray("connect(this, &TestClass::sigFoo, this, &TestClass::setProp);");
|
<< QByteArray("connect(this, &TestClass::sigFoo, this, &TestClass::setProp);");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5412,7 +5412,7 @@ bool findConnectReplacement(const CppQuickFixInterface &interface,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onConnectCall(AST *ast, const ExpressionListAST **arguments)
|
bool onConnectOrDisconnectCall(AST *ast, const ExpressionListAST **arguments)
|
||||||
{
|
{
|
||||||
if (!ast)
|
if (!ast)
|
||||||
return false;
|
return false;
|
||||||
@@ -5437,7 +5437,7 @@ bool onConnectCall(AST *ast, const ExpressionListAST **arguments)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QByteArray name(id->chars(), id->size());
|
const QByteArray name(id->chars(), id->size());
|
||||||
if (name != "connect")
|
if (name != "connect" && name != "disconnect")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (arguments)
|
if (arguments)
|
||||||
@@ -5493,7 +5493,7 @@ void ConvertQt4Connect::match(const CppQuickFixInterface &interface, QuickFixOpe
|
|||||||
|
|
||||||
for (int i = path.size(); --i >= 0; ) {
|
for (int i = path.size(); --i >= 0; ) {
|
||||||
const ExpressionListAST *arguments;
|
const ExpressionListAST *arguments;
|
||||||
if (!onConnectCall(path.at(i), &arguments))
|
if (!onConnectOrDisconnectCall(path.at(i), &arguments))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const ExpressionAST *arg1, *arg3;
|
const ExpressionAST *arg1, *arg3;
|
||||||
|
|||||||
Reference in New Issue
Block a user