CppEditor: Default to .cpp for QuickFix creation of 1-line setter/getter

Until Qt Creator 4.14, the QuickFix for setter/getter creation for
simple members added the implementation in the .cpp file.

The new QuickFix settings in Qt Creator 4.15 in theory keep the default
like before, but the threshold of 2 lines is usually not reached, which
causes the getter/setter implementations to now land in the header file.

This change sets the default threshold to 1 to restore the previous
default behavior.

Fixes: QTCREATORBUG-25331
Change-Id: I570deaa8b81686dc31254e8261b59ddcf8731f91
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Alessandro Portale
2021-02-11 11:57:57 +01:00
parent 6829d92d38
commit 395e7cbfb9
2 changed files with 30 additions and 22 deletions

View File

@@ -3532,10 +3532,7 @@ void CppEditorPlugin::test_quickfix_InsertQtPropertyMembers_data()
" Q_PROPERTY(int it READ getIt WRITE setIt RESET resetIt NOTIFY itChanged)\n"
"\n"
"public:\n"
" int getIt() const\n"
" {\n"
" return m_it;\n"
" }\n"
" int getIt() const;\n"
"\n"
"public slots:\n"
" void setIt(int it)\n"
@@ -3555,7 +3552,12 @@ void CppEditorPlugin::test_quickfix_InsertQtPropertyMembers_data()
"\n"
"private:\n"
" int m_it;\n"
"};\n");
"};\n"
"\n"
"int XmarksTheSpot::getIt() const\n"
"{\n"
" return m_it;\n"
"}\n");
QTest::newRow("InsertQtPropertyMembersResetWithoutSet")
<< _("struct XmarksTheSpot {\n"
@@ -3565,10 +3567,7 @@ void CppEditorPlugin::test_quickfix_InsertQtPropertyMembers_data()
" Q_PROPERTY(int it READ getIt RESET resetIt NOTIFY itChanged)\n"
"\n"
"public:\n"
" int getIt() const\n"
" {\n"
" return m_it;\n"
" }\n"
" int getIt() const;\n"
"\n"
"public slots:\n"
" void resetIt()\n"
@@ -3586,7 +3585,12 @@ void CppEditorPlugin::test_quickfix_InsertQtPropertyMembers_data()
"\n"
"private:\n"
" int m_it;\n"
"};\n");
"};\n"
"\n"
"int XmarksTheSpot::getIt() const\n"
"{\n"
" return m_it;\n"
"}\n");
QTest::newRow("InsertQtPropertyMembersResetWithoutSetAndNotify")
<< _("struct XmarksTheSpot {\n"
@@ -3596,10 +3600,7 @@ void CppEditorPlugin::test_quickfix_InsertQtPropertyMembers_data()
" Q_PROPERTY(int it READ getIt RESET resetIt)\n"
"\n"
"public:\n"
" int getIt() const\n"
" {\n"
" return m_it;\n"
" }\n"
" int getIt() const;\n"
"\n"
"public slots:\n"
" void resetIt()\n"
@@ -3611,7 +3612,12 @@ void CppEditorPlugin::test_quickfix_InsertQtPropertyMembers_data()
"\n"
"private:\n"
" int m_it;\n"
"};\n");
"};\n"
"\n"
"int XmarksTheSpot::getIt() const\n"
"{\n"
" return m_it;\n"
"}\n");
QTest::newRow("InsertQtPropertyMembersPrivateBeforePublic")
<< _("class XmarksTheSpot {\n"
@@ -3627,10 +3633,7 @@ void CppEditorPlugin::test_quickfix_InsertQtPropertyMembers_data()
"\n"
"public:\n"
" void find();\n"
" int getIt() const\n"
" {\n"
" return m_it;\n"
" }\n"
" int getIt() const;\n"
"public slots:\n"
" void setIt(int it)\n"
" {\n"
@@ -3641,7 +3644,12 @@ void CppEditorPlugin::test_quickfix_InsertQtPropertyMembers_data()
" }\n"
"signals:\n"
" void itChanged(int);\n"
"};\n");
"};\n"
"\n"
"int XmarksTheSpot::getIt() const\n"
"{\n"
" return m_it;\n"
"}\n");
}
void CppEditorPlugin::test_quickfix_InsertQtPropertyMembers()