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 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<QString, ChoicePair> m_runconfigCache;
@@ -117,6 +116,8 @@ AutotestPlugin::AutotestPlugin()
qRegisterMetaType<TestCodeLocationAndType>();
// warm up meta type system to be able to read Qt::CheckState with persistent settings
qRegisterMetaType<Qt::CheckState>();
setupTestNavigationWidgetFactory();
}
AutotestPlugin::~AutotestPlugin()

View File

@@ -19,6 +19,7 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/find/itemviewfind.h>
#include <coreplugin/inavigationwidgetfactory.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/project.h>
@@ -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<QToolButton *> createToolButtons();
void updateExpandedStateCache();
@@ -364,17 +365,26 @@ void TestNavigationWidget::reapplyCachedExpandedState()
// TestNavigationWidgetFactory
TestNavigationWidgetFactory::TestNavigationWidgetFactory()
class TestNavigationWidgetFactory final : public INavigationWidgetFactory
{
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()
{
static TestNavigationWidgetFactory theTestNavigationWidgetFactory;
}
} // Autotest::Internal

View File

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