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/projectexplorer.h>
|
||||||
#include <projectexplorer/projectexplorericons.h>
|
#include <projectexplorer/projectexplorericons.h>
|
||||||
#include <projectexplorer/projectmanager.h>
|
#include <projectexplorer/projectmanager.h>
|
||||||
#include <projectexplorer/projectpanelfactory.h>
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
@@ -138,14 +137,7 @@ AutotestPluginPrivate::AutotestPluginPrivate()
|
|||||||
|
|
||||||
m_resultsPane = TestResultsPane::instance();
|
m_resultsPane = TestResultsPane::instance();
|
||||||
|
|
||||||
auto panelFactory = new ProjectExplorer::ProjectPanelFactory();
|
setupAutotestProjectPanel();
|
||||||
panelFactory->setPriority(666);
|
|
||||||
// panelFactory->setIcon(); // TODO ?
|
|
||||||
panelFactory->setDisplayName(Tr::tr("Testing"));
|
|
||||||
panelFactory->setCreateWidgetFunction([](ProjectExplorer::Project *project) {
|
|
||||||
return new ProjectTestSettingsWidget(project);
|
|
||||||
});
|
|
||||||
ProjectExplorer::ProjectPanelFactory::registerFactory(panelFactory);
|
|
||||||
|
|
||||||
TestFrameworkManager::activateFrameworksAndToolsFromSettings();
|
TestFrameworkManager::activateFrameworksAndToolsFromSettings();
|
||||||
m_testTreeModel.synchronizeTestFrameworks();
|
m_testTreeModel.synchronizeTestFrameworks();
|
||||||
|
|||||||
@@ -9,25 +9,45 @@
|
|||||||
#include "testprojectsettings.h"
|
#include "testprojectsettings.h"
|
||||||
#include "testtreemodel.h"
|
#include "testtreemodel.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/projectpanelfactory.h>
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QTimer>
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
|
|
||||||
namespace Autotest {
|
using namespace ProjectExplorer;
|
||||||
namespace Internal {
|
|
||||||
|
namespace Autotest::Internal {
|
||||||
|
|
||||||
enum ItemDataRole {
|
enum ItemDataRole {
|
||||||
BaseIdRole = Qt::UserRole + 1,
|
BaseIdRole = Qt::UserRole + 1,
|
||||||
BaseTypeRole
|
BaseTypeRole
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectTestSettingsWidget::ProjectTestSettingsWidget(ProjectExplorer::Project *project,
|
class ProjectTestSettingsWidget : public ProjectSettingsWidget
|
||||||
QWidget *parent)
|
{
|
||||||
: ProjectExplorer::ProjectSettingsWidget(parent)
|
public:
|
||||||
, m_projectSettings(AutotestPlugin::projectSettings(project))
|
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);
|
setGlobalSettingsId(Constants::AUTOTEST_SETTINGS_ID);
|
||||||
|
|
||||||
@@ -131,5 +151,24 @@ void ProjectTestSettingsWidget::onActiveFrameworkChanged(QTreeWidgetItem *item,
|
|||||||
m_syncType |= type;
|
m_syncType |= type;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
class AutotestProjectPanelFactory final : public ProjectPanelFactory
|
||||||
} // namespace Autotest
|
{
|
||||||
|
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
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/projectsettingswidget.h>
|
namespace Autotest::Internal {
|
||||||
|
|
||||||
#include <QTimer>
|
void setupAutotestProjectPanel();
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
} // Autotest::Internal
|
||||||
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user