forked from qt-creator/qt-creator
Autotest: Use new construction pattern for project panel factory
Change-Id: I09abb1d5dbb07a700053077b03e65a3dce4b3f1f Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -45,7 +45,6 @@
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectexplorericons.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
@@ -138,14 +137,7 @@ AutotestPluginPrivate::AutotestPluginPrivate()
|
||||
|
||||
m_resultsPane = TestResultsPane::instance();
|
||||
|
||||
auto panelFactory = new ProjectExplorer::ProjectPanelFactory();
|
||||
panelFactory->setPriority(666);
|
||||
// panelFactory->setIcon(); // TODO ?
|
||||
panelFactory->setDisplayName(Tr::tr("Testing"));
|
||||
panelFactory->setCreateWidgetFunction([](ProjectExplorer::Project *project) {
|
||||
return new ProjectTestSettingsWidget(project);
|
||||
});
|
||||
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
|
||||
setupAutotestProjectPanel();
|
||||
|
||||
TestFrameworkManager::activateFrameworksAndToolsFromSettings();
|
||||
m_testTreeModel.synchronizeTestFrameworks();
|
||||
|
||||
@@ -9,25 +9,45 @@
|
||||
#include "testprojectsettings.h"
|
||||
#include "testtreemodel.h"
|
||||
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <projectexplorer/projectsettingswidget.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QTimer>
|
||||
#include <QTreeWidget>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace Autotest::Internal {
|
||||
|
||||
enum ItemDataRole {
|
||||
BaseIdRole = Qt::UserRole + 1,
|
||||
BaseTypeRole
|
||||
};
|
||||
|
||||
ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *project,
|
||||
QWidget *parent)
|
||||
: ProjectExplorer::ProjectSettingsWidget(parent)
|
||||
, m_projectSettings(AutotestPlugin::projectSettings(project))
|
||||
class ProjectTestSettingsWidget : public ProjectSettingsWidget
|
||||
{
|
||||
public:
|
||||
explicit ProjectTestSettingsWidget(Project *project);
|
||||
|
||||
private:
|
||||
void populateFrameworks(const QHash<Autotest::ITestFramework *, bool> &frameworks,
|
||||
const QHash<Autotest::ITestTool *, bool> &testTools);
|
||||
void onActiveFrameworkChanged(QTreeWidgetItem *item, int column);
|
||||
TestProjectSettings *m_projectSettings;
|
||||
QComboBox *m_useGlobalSettings = nullptr;
|
||||
QTreeWidget *m_activeFrameworks = nullptr;
|
||||
QComboBox *m_runAfterBuild = nullptr;
|
||||
QTimer m_syncTimer;
|
||||
int m_syncType = 0;
|
||||
};
|
||||
|
||||
ProjectTestSettingsWidget::ProjectTestSettingsWidget(Project *project)
|
||||
: m_projectSettings(AutotestPlugin::projectSettings(project))
|
||||
{
|
||||
setGlobalSettingsId(Constants::AUTOTEST_SETTINGS_ID);
|
||||
|
||||
@@ -131,5 +151,24 @@ void ProjectTestSettingsWidget::onActiveFrameworkChanged(QTreeWidgetItem *item,
|
||||
m_syncType |= type;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
class AutotestProjectPanelFactory final : public ProjectPanelFactory
|
||||
{
|
||||
public:
|
||||
AutotestProjectPanelFactory()
|
||||
{
|
||||
setPriority(666);
|
||||
// setIcon(); // TODO ?
|
||||
setDisplayName(Tr::tr("Testing"));
|
||||
setCreateWidgetFunction([](Project *project) {
|
||||
return new ProjectTestSettingsWidget(project);
|
||||
});
|
||||
ProjectPanelFactory::registerFactory(this);
|
||||
}
|
||||
};
|
||||
|
||||
void setupAutotestProjectPanel()
|
||||
{
|
||||
static AutotestProjectPanelFactory theAutotestProjectPanelFactory;
|
||||
}
|
||||
|
||||
} // Autotest::Internal
|
||||
|
||||
@@ -3,46 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/projectsettingswidget.h>
|
||||
namespace Autotest::Internal {
|
||||
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
void setupAutotestProjectPanel();
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ProjectExplorer { class Project; }
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
class ITestFramework;
|
||||
class ITestTool;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class TestProjectSettings;
|
||||
|
||||
class ProjectTestSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProjectTestSettingsWidget(ProjectExplorer::Project *project,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
void populateFrameworks(const QHash<Autotest::ITestFramework *, bool> &frameworks,
|
||||
const QHash<Autotest::ITestTool *, bool> &testTools);
|
||||
void onActiveFrameworkChanged(QTreeWidgetItem *item, int column);
|
||||
TestProjectSettings *m_projectSettings;
|
||||
QComboBox *m_useGlobalSettings = nullptr;
|
||||
QTreeWidget *m_activeFrameworks = nullptr;
|
||||
QComboBox *m_runAfterBuild = nullptr;
|
||||
QTimer m_syncTimer;
|
||||
int m_syncType = 0;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
} // Autotest::Internal
|
||||
|
||||
Reference in New Issue
Block a user