AutoTest: Use new setup pattern for TestNavigationWidgetFactory

Change-Id: I2d2c6f2a3dc8b416dae2e041f358a3f412216d4d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2024-01-09 16:01:16 +01:00
parent 78a708f0fe
commit 00815e006d
3 changed files with 25 additions and 23 deletions

View File

@@ -76,14 +76,13 @@ using namespace Utils;
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
class AutotestPluginPrivate : public QObject class AutotestPluginPrivate final : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
AutotestPluginPrivate(); AutotestPluginPrivate();
~AutotestPluginPrivate() override; ~AutotestPluginPrivate() final;
TestNavigationWidgetFactory m_navigationWidgetFactory;
TestResultsPane *m_resultsPane = nullptr; TestResultsPane *m_resultsPane = nullptr;
QMap<QString, ChoicePair> m_runconfigCache; QMap<QString, ChoicePair> m_runconfigCache;
@@ -117,6 +116,8 @@ AutotestPlugin::AutotestPlugin()
qRegisterMetaType<TestCodeLocationAndType>(); qRegisterMetaType<TestCodeLocationAndType>();
// warm up meta type system to be able to read Qt::CheckState with persistent settings // warm up meta type system to be able to read Qt::CheckState with persistent settings
qRegisterMetaType<Qt::CheckState>(); qRegisterMetaType<Qt::CheckState>();
setupTestNavigationWidgetFactory();
} }
AutotestPlugin::~AutotestPlugin() AutotestPlugin::~AutotestPlugin()

View File

@@ -19,6 +19,7 @@
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/find/itemviewfind.h> #include <coreplugin/find/itemviewfind.h>
#include <coreplugin/inavigationwidgetfactory.h>
#include <projectexplorer/buildmanager.h> #include <projectexplorer/buildmanager.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -42,12 +43,12 @@ using namespace Utils;
namespace Autotest::Internal { namespace Autotest::Internal {
class TestNavigationWidget : public QWidget class TestNavigationWidget final : public QWidget
{ {
public: public:
TestNavigationWidget(); TestNavigationWidget();
void contextMenuEvent(QContextMenuEvent *event) override; void contextMenuEvent(QContextMenuEvent *event) final;
QList<QToolButton *> createToolButtons(); QList<QToolButton *> createToolButtons();
void updateExpandedStateCache(); void updateExpandedStateCache();
@@ -364,17 +365,26 @@ void TestNavigationWidget::reapplyCachedExpandedState()
// TestNavigationWidgetFactory // TestNavigationWidgetFactory
TestNavigationWidgetFactory::TestNavigationWidgetFactory() class TestNavigationWidgetFactory final : public INavigationWidgetFactory
{ {
setDisplayName(Tr::tr("Tests")); public:
setId(Autotest::Constants::AUTOTEST_ID); TestNavigationWidgetFactory()
setPriority(666); {
} 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; static TestNavigationWidgetFactory theTestNavigationWidgetFactory;
return {treeViewWidget, treeViewWidget->createToolButtons()};
} }
} // Autotest::Internal } // Autotest::Internal

View File

@@ -3,17 +3,8 @@
#pragma once #pragma once
#include <coreplugin/inavigationwidgetfactory.h>
namespace Autotest::Internal { namespace Autotest::Internal {
class TestNavigationWidgetFactory : public Core::INavigationWidgetFactory void setupTestNavigationWidgetFactory();
{
public:
TestNavigationWidgetFactory();
private:
Core::NavigationView createWidget() override;
};
} // Autotest::Internal } // Autotest::Internal