forked from qt-creator/qt-creator
CppEditor: Expand templates for Qt5 connect conversion
Fixes at least explicit data() calls for templated pointers: QPointer<QAction> action; connect(action.data(), SIGNAL(triggered()), this, SLOT(slot())); Change-Id: I7f76c1f556c0f271936728d611751424969916a7 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
ef894f21e2
commit
683540bee7
@@ -4537,6 +4537,12 @@ void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectWithinClass_data()
|
||||
QTest::newRow("three-args-connect")
|
||||
<< QByteArray("conne@ct(this, SIGNAL(sigFoo(int)), SLOT(setProp(int)));")
|
||||
<< QByteArray("connect(this, &TestClass::sigFoo, this, &TestClass::setProp);");
|
||||
|
||||
QTest::newRow("template-value")
|
||||
<< QByteArray("Pointer<TestClass> p;\n"
|
||||
"conne@ct(p.t, SIGNAL(sigFoo(int)), p.t, SLOT(setProp(int)));")
|
||||
<< QByteArray("Pointer<TestClass> p;\n"
|
||||
"connect(p.t, &TestClass::sigFoo, p.t, &TestClass::setProp);");
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectWithinClass()
|
||||
@@ -4545,6 +4551,11 @@ void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectWithinClass()
|
||||
QFETCH(QByteArray, expected);
|
||||
|
||||
QByteArray prefix =
|
||||
"template<class T>\n"
|
||||
"struct Pointer\n"
|
||||
"{\n"
|
||||
" T *t;\n"
|
||||
"};\n"
|
||||
"class QObject {};\n"
|
||||
"class TestClass : public QObject\n"
|
||||
"{\n"
|
||||
|
@@ -5592,6 +5592,7 @@ Class *senderOrReceiverClass(const CppQuickFixInterface &interface,
|
||||
objectPointerExpression = "this";
|
||||
|
||||
TypeOfExpression toe;
|
||||
toe.setExpandTemplates(true);
|
||||
toe.init(interface.semanticInfo().doc, interface.snapshot(), context.bindings());
|
||||
const QList<LookupItem> objectPointerExpressions = toe(objectPointerExpression,
|
||||
objectPointerScope, TypeOfExpression::Preprocess);
|
||||
|
Reference in New Issue
Block a user