CppEditor: Introduce central function for registering quickfixes

... and use it to register the InsertVirtualMethods quickfix.
The resulting registration pattern encourages the presence of tests and
easily allows minimal visibility of the classes involved.

Change-Id: I85fba0b983b51d84b6fae1f6fe51b63eed0ee336
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2024-05-14 11:06:46 +02:00
parent ce16d58214
commit 6a3f66af85
6 changed files with 59 additions and 22 deletions

View File

@@ -116,6 +116,11 @@ public:
QSortFilterProxyModel *classFunctionFilterModel;
};
void registerInsertVirtualMethodsQuickfix()
{
CppQuickFixFactory::registerFactory<InsertVirtualMethods>();
}
} // namespace Internal
} // namespace CppEditor
@@ -1269,6 +1274,17 @@ public:
void saveSettings() override { }
};
class InsertVirtualMethodsTest : public QObject
{
Q_OBJECT
private slots:
void test_data();
void test();
void testImplementationFile();
void testBaseClassInNamespace();
};
void InsertVirtualMethodsTest::test_data()
{
QTest::addColumn<InsertVirtualMethodsDialog::ImplementationMode>("implementationMode");
@@ -1969,6 +1985,11 @@ InsertVirtualMethods *InsertVirtualMethods::createTestFactory()
InsertVirtualMethodsDialog::ModeOutsideClass, true, false));
}
QObject *InsertVirtualMethods::createTest()
{
return new Tests::InsertVirtualMethodsTest;
}
#endif // WITH_TESTS
} // namespace Internal