From 683540bee70187d830f0c2873d5cd9ebf5be2bc5 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 5 Mar 2015 22:17:56 +0200 Subject: [PATCH] CppEditor: Expand templates for Qt5 connect conversion Fixes at least explicit data() calls for templated pointers: QPointer action; connect(action.data(), SIGNAL(triggered()), this, SLOT(slot())); Change-Id: I7f76c1f556c0f271936728d611751424969916a7 Reviewed-by: Nikolai Kosjar --- src/plugins/cppeditor/cppquickfix_test.cpp | 11 +++++++++++ src/plugins/cppeditor/cppquickfixes.cpp | 1 + 2 files changed, 12 insertions(+) diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index c964e438b2d..c2fd582d4d8 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -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 p;\n" + "conne@ct(p.t, SIGNAL(sigFoo(int)), p.t, SLOT(setProp(int)));") + << QByteArray("Pointer 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\n" + "struct Pointer\n" + "{\n" + " T *t;\n" + "};\n" "class QObject {};\n" "class TestClass : public QObject\n" "{\n" diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index d28b33be426..3c252082d18 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -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 objectPointerExpressions = toe(objectPointerExpression, objectPointerScope, TypeOfExpression::Preprocess);