From 00815e006d04a85afd84bfd45cbefe080053990c Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 9 Jan 2024 16:01:16 +0100 Subject: [PATCH] AutoTest: Use new setup pattern for TestNavigationWidgetFactory Change-Id: I2d2c6f2a3dc8b416dae2e041f358a3f412216d4d Reviewed-by: Christian Stenger Reviewed-by: --- src/plugins/autotest/autotestplugin.cpp | 7 +++-- src/plugins/autotest/testnavigationwidget.cpp | 30 ++++++++++++------- src/plugins/autotest/testnavigationwidget.h | 11 +------ 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 35503f73a77..c577ab08398 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -76,14 +76,13 @@ using namespace Utils; namespace Autotest { namespace Internal { -class AutotestPluginPrivate : public QObject +class AutotestPluginPrivate final : public QObject { Q_OBJECT public: AutotestPluginPrivate(); - ~AutotestPluginPrivate() override; + ~AutotestPluginPrivate() final; - TestNavigationWidgetFactory m_navigationWidgetFactory; TestResultsPane *m_resultsPane = nullptr; QMap m_runconfigCache; @@ -117,6 +116,8 @@ AutotestPlugin::AutotestPlugin() qRegisterMetaType(); // warm up meta type system to be able to read Qt::CheckState with persistent settings qRegisterMetaType(); + + setupTestNavigationWidgetFactory(); } AutotestPlugin::~AutotestPlugin() diff --git a/src/plugins/autotest/testnavigationwidget.cpp b/src/plugins/autotest/testnavigationwidget.cpp index 1908af8203b..435b510f85c 100644 --- a/src/plugins/autotest/testnavigationwidget.cpp +++ b/src/plugins/autotest/testnavigationwidget.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -42,12 +43,12 @@ using namespace Utils; namespace Autotest::Internal { -class TestNavigationWidget : public QWidget +class TestNavigationWidget final : public QWidget { public: TestNavigationWidget(); - void contextMenuEvent(QContextMenuEvent *event) override; + void contextMenuEvent(QContextMenuEvent *event) final; QList createToolButtons(); void updateExpandedStateCache(); @@ -364,17 +365,26 @@ void TestNavigationWidget::reapplyCachedExpandedState() // TestNavigationWidgetFactory -TestNavigationWidgetFactory::TestNavigationWidgetFactory() +class TestNavigationWidgetFactory final : public INavigationWidgetFactory { - setDisplayName(Tr::tr("Tests")); - setId(Autotest::Constants::AUTOTEST_ID); - setPriority(666); -} +public: + TestNavigationWidgetFactory() + { + setDisplayName(Tr::tr("Tests")); + setId(Autotest::Constants::AUTOTEST_ID); + setPriority(666); + } -NavigationView TestNavigationWidgetFactory::createWidget() + NavigationView createWidget() final + { + TestNavigationWidget *treeViewWidget = new TestNavigationWidget; + return {treeViewWidget, treeViewWidget->createToolButtons()}; + } +}; + +void setupTestNavigationWidgetFactory() { - TestNavigationWidget *treeViewWidget = new TestNavigationWidget; - return {treeViewWidget, treeViewWidget->createToolButtons()}; + static TestNavigationWidgetFactory theTestNavigationWidgetFactory; } } // Autotest::Internal diff --git a/src/plugins/autotest/testnavigationwidget.h b/src/plugins/autotest/testnavigationwidget.h index 3b598a670fc..f2cb273918b 100644 --- a/src/plugins/autotest/testnavigationwidget.h +++ b/src/plugins/autotest/testnavigationwidget.h @@ -3,17 +3,8 @@ #pragma once -#include - namespace Autotest::Internal { -class TestNavigationWidgetFactory : public Core::INavigationWidgetFactory -{ -public: - TestNavigationWidgetFactory(); - -private: - Core::NavigationView createWidget() override; -}; +void setupTestNavigationWidgetFactory(); } // Autotest::Internal