bare-metal: Refactor the plugin code a bit more

* An include files and forward declarations are sorted in an
  alphabetical order.
* Used the 'final' keywords for the methods and classes which
  not should be overridden.
* Used the 'auto' and 'explicit' keywords more.
* A class members are initialized in an initializier list.

Change-Id: Ia74783e47aff92467d696d471760b5a97bca3d7a
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Denis Shienkov
2019-05-08 13:49:19 +03:00
parent d0839bc1de
commit dfb0f391dd
46 changed files with 468 additions and 343 deletions

View File

@@ -24,11 +24,10 @@
****************************************************************************/ ****************************************************************************/
#include "baremetalcustomrunconfiguration.h" #include "baremetalcustomrunconfiguration.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include <projectexplorer/target.h>
#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtoutputformatter.h> #include <qtsupport/qtoutputformatter.h>
@@ -38,10 +37,12 @@ using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// BareMetalCustomRunConfiguration
BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(Target *target, Core::Id id) BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(Target *target, Core::Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto exeAspect = addAspect<ExecutableAspect>(); const auto exeAspect = addAspect<ExecutableAspect>();
exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable"); exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable");
exeAspect->setPlaceHolderText(tr("Unknown")); exeAspect->setPlaceHolderText(tr("Unknown"));
exeAspect->setDisplayStyle(BaseStringAspect::PathChooserDisplay); exeAspect->setDisplayStyle(BaseStringAspect::PathChooserDisplay);

View File

@@ -30,23 +30,29 @@
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class BareMetalCustomRunConfiguration : public ProjectExplorer::RunConfiguration // BareMetalCustomRunConfiguration
class BareMetalCustomRunConfiguration final
: public ProjectExplorer::RunConfiguration
{ {
Q_OBJECT Q_OBJECT
public: public:
BareMetalCustomRunConfiguration(ProjectExplorer::Target *target, Core::Id id); explicit BareMetalCustomRunConfiguration(ProjectExplorer::Target *target, Core::Id id);
public: public:
static const char *Id; static const char *Id;
bool isConfigured() const override; bool isConfigured() const final;
ConfigurationState ensureConfigured(QString *errorMessage) override; ConfigurationState ensureConfigured(QString *errorMessage) final;
}; };
class BareMetalCustomRunConfigurationFactory : public ProjectExplorer::FixedRunConfigurationFactory // BareMetalCustomRunConfigurationFactory
class BareMetalCustomRunConfigurationFactory final
: public ProjectExplorer::FixedRunConfigurationFactory
{ {
public: public:
BareMetalCustomRunConfigurationFactory(); explicit BareMetalCustomRunConfigurationFactory();
}; };
} // namespace Internal } // namespace Internal

View File

@@ -30,8 +30,8 @@
#include "gdbserverprovider.h" #include "gdbserverprovider.h"
#include "gdbserverprovidermanager.h" #include "gdbserverprovidermanager.h"
#include <debugger/debuggerruncontrol.h>
#include <debugger/debuggerkitinformation.h> #include <debugger/debuggerkitinformation.h>
#include <debugger/debuggerruncontrol.h>
#include <projectexplorer/buildconfiguration.h> #include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildsteplist.h>
@@ -52,10 +52,12 @@ using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// BareMetalDebugSupport
BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl) BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
: Debugger::DebuggerRunTool(runControl) : Debugger::DebuggerRunTool(runControl)
{ {
auto dev = qSharedPointerCast<const BareMetalDevice>(device()); const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
if (!dev) { if (!dev) {
reportFailure(tr("Cannot debug: Kit has no device.")); reportFailure(tr("Cannot debug: Kit has no device."));
return; return;

View File

@@ -30,15 +30,17 @@
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class BareMetalDebugSupport : public Debugger::DebuggerRunTool // BareMetalDebugSupport
class BareMetalDebugSupport final : public Debugger::DebuggerRunTool
{ {
Q_OBJECT Q_OBJECT
public: public:
BareMetalDebugSupport(ProjectExplorer::RunControl *runControl); explicit BareMetalDebugSupport(ProjectExplorer::RunControl *runControl);
private: private:
void start() override; void start() final;
ProjectExplorer::SimpleTargetRunner *m_gdbServer = nullptr; ProjectExplorer::SimpleTargetRunner *m_gdbServer = nullptr;
}; };

View File

@@ -24,12 +24,13 @@
** **
****************************************************************************/ ****************************************************************************/
#include "baremetaldevice.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "baremetaldevice.h"
#include "baremetaldeviceconfigurationwidget.h" #include "baremetaldeviceconfigurationwidget.h"
#include "baremetaldeviceconfigurationwizard.h" #include "baremetaldeviceconfigurationwizard.h"
#include "defaultgdbserverprovider.h" #include "defaultgdbserverprovider.h"
#include "gdbserverprovidermanager.h" #include "gdbserverprovidermanager.h"
#include "gdbserverproviderprocess.h" #include "gdbserverproviderprocess.h"
@@ -47,6 +48,8 @@ namespace Internal {
const char gdbServerProviderIdKeyC[] = "GdbServerProviderId"; const char gdbServerProviderIdKeyC[] = "GdbServerProviderId";
// BareMetalDevice
BareMetalDevice::~BareMetalDevice() BareMetalDevice::~BareMetalDevice()
{ {
if (GdbServerProvider *provider = GdbServerProviderManager::findProvider(m_gdbServerProviderId)) if (GdbServerProvider *provider = GdbServerProviderManager::findProvider(m_gdbServerProviderId))
@@ -163,8 +166,7 @@ BareMetalDevice::BareMetalDevice(const BareMetalDevice &other)
setGdbServerProviderId(other.gdbServerProviderId()); setGdbServerProviderId(other.gdbServerProviderId());
} }
// BareMetalDeviceFactory
// Factory
BareMetalDeviceFactory::BareMetalDeviceFactory() BareMetalDeviceFactory::BareMetalDeviceFactory()
: IDeviceFactory(Constants::BareMetalOsType) : IDeviceFactory(Constants::BareMetalOsType)

View File

@@ -34,50 +34,54 @@ namespace Internal {
class GdbServerProvider; class GdbServerProvider;
class BareMetalDevice : public ProjectExplorer::IDevice // BareMetalDevice
class BareMetalDevice final : public ProjectExplorer::IDevice
{ {
public: public:
using Ptr = QSharedPointer<BareMetalDevice>; using Ptr = QSharedPointer<BareMetalDevice>;
using ConstPtr = QSharedPointer<const BareMetalDevice>; using ConstPtr = QSharedPointer<const BareMetalDevice>;
static Ptr create() { return Ptr(new BareMetalDevice); } static Ptr create() { return Ptr(new BareMetalDevice); }
~BareMetalDevice() override; ~BareMetalDevice() final;
QString displayType() const override; QString displayType() const final;
ProjectExplorer::IDeviceWidget *createWidget() override; ProjectExplorer::IDeviceWidget *createWidget() final;
Utils::OsType osType() const override; Utils::OsType osType() const final;
ProjectExplorer::IDevice::Ptr clone() const override; ProjectExplorer::IDevice::Ptr clone() const final;
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override; ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const final;
bool canCreateProcess() const override { return true; } bool canCreateProcess() const final { return true; }
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const override; ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const final;
QString gdbServerProviderId() const; QString gdbServerProviderId() const;
void setGdbServerProviderId(const QString &id); void setGdbServerProviderId(const QString &id);
void unregisterProvider(GdbServerProvider *provider); void unregisterProvider(GdbServerProvider *provider);
void providerUpdated(GdbServerProvider *provider); void providerUpdated(GdbServerProvider *provider);
void fromMap(const QVariantMap &map) override; void fromMap(const QVariantMap &map) final;
QVariantMap toMap() const override; QVariantMap toMap() const final;
private: private:
BareMetalDevice() = default; explicit BareMetalDevice() = default;
BareMetalDevice(const BareMetalDevice &other); explicit BareMetalDevice(const BareMetalDevice &other);
void setChannelByServerProvider(GdbServerProvider *provider); void setChannelByServerProvider(GdbServerProvider *provider);
BareMetalDevice &operator=(const BareMetalDevice &); BareMetalDevice &operator=(const BareMetalDevice &);
QString m_gdbServerProviderId; QString m_gdbServerProviderId;
}; };
class BareMetalDeviceFactory : public ProjectExplorer::IDeviceFactory // BareMetalDeviceFactory
class BareMetalDeviceFactory final : public ProjectExplorer::IDeviceFactory
{ {
Q_OBJECT Q_OBJECT
public: public:
BareMetalDeviceFactory(); explicit BareMetalDeviceFactory();
ProjectExplorer::IDevice::Ptr create() const override; ProjectExplorer::IDevice::Ptr create() const final;
}; };
} //namespace Internal } //namespace Internal

View File

@@ -24,11 +24,11 @@
** **
****************************************************************************/ ****************************************************************************/
#include "baremetaldeviceconfigurationwidget.h"
#include "baremetaldevice.h" #include "baremetaldevice.h"
#include "baremetaldeviceconfigurationwidget.h"
#include "gdbserverproviderchooser.h"
#include "gdbserverprovider.h" #include "gdbserverprovider.h"
#include "gdbserverproviderchooser.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -37,6 +37,8 @@
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// BareMetalDeviceConfigurationWidget
BareMetalDeviceConfigurationWidget::BareMetalDeviceConfigurationWidget( BareMetalDeviceConfigurationWidget::BareMetalDeviceConfigurationWidget(
const ProjectExplorer::IDevice::Ptr &deviceConfig, QWidget *parent) const ProjectExplorer::IDevice::Ptr &deviceConfig, QWidget *parent)
: IDeviceWidget(deviceConfig, parent) : IDeviceWidget(deviceConfig, parent)
@@ -44,7 +46,7 @@ BareMetalDeviceConfigurationWidget::BareMetalDeviceConfigurationWidget(
const auto dev = qSharedPointerCast<const BareMetalDevice>(device()); const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
QTC_ASSERT(dev, return); QTC_ASSERT(dev, return);
auto formLayout = new QFormLayout(this); const auto formLayout = new QFormLayout(this);
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
m_gdbServerProviderChooser = new GdbServerProviderChooser(true, this); m_gdbServerProviderChooser = new GdbServerProviderChooser(true, this);
@@ -58,7 +60,7 @@ BareMetalDeviceConfigurationWidget::BareMetalDeviceConfigurationWidget(
void BareMetalDeviceConfigurationWidget::gdbServerProviderChanged() void BareMetalDeviceConfigurationWidget::gdbServerProviderChanged()
{ {
auto dev = qSharedPointerCast<BareMetalDevice>(device()); const auto dev = qSharedPointerCast<BareMetalDevice>(device());
QTC_ASSERT(dev, return); QTC_ASSERT(dev, return);
dev->setGdbServerProviderId(m_gdbServerProviderChooser->currentProviderId()); dev->setGdbServerProviderId(m_gdbServerProviderChooser->currentProviderId());
} }

View File

@@ -33,7 +33,9 @@ namespace Internal {
class GdbServerProviderChooser; class GdbServerProviderChooser;
class BareMetalDeviceConfigurationWidget // BareMetalDeviceConfigurationWidget
class BareMetalDeviceConfigurationWidget final
: public ProjectExplorer::IDeviceWidget : public ProjectExplorer::IDeviceWidget
{ {
Q_OBJECT Q_OBJECT
@@ -44,9 +46,9 @@ public:
private: private:
void gdbServerProviderChanged(); void gdbServerProviderChanged();
void updateDeviceFromUi() override; void updateDeviceFromUi() final;
GdbServerProviderChooser *m_gdbServerProviderChooser; GdbServerProviderChooser *m_gdbServerProviderChooser = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -24,16 +24,18 @@
** **
****************************************************************************/ ****************************************************************************/
#include "baremetalconstants.h"
#include "baremetaldevice.h"
#include "baremetaldeviceconfigurationwizard.h" #include "baremetaldeviceconfigurationwizard.h"
#include "baremetaldeviceconfigurationwizardpages.h" #include "baremetaldeviceconfigurationwizardpages.h"
#include "baremetaldevice.h"
#include "baremetalconstants.h"
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
enum PageId { SetupPageId }; enum PageId { SetupPageId };
// BareMetalDeviceConfigurationWizard
BareMetalDeviceConfigurationWizard::BareMetalDeviceConfigurationWizard(QWidget *parent) : BareMetalDeviceConfigurationWizard::BareMetalDeviceConfigurationWizard(QWidget *parent) :
Utils::Wizard(parent), Utils::Wizard(parent),
m_setupPage(new BareMetalDeviceConfigurationWizardSetupPage(this)) m_setupPage(new BareMetalDeviceConfigurationWizardSetupPage(this))
@@ -45,7 +47,7 @@ BareMetalDeviceConfigurationWizard::BareMetalDeviceConfigurationWizard(QWidget *
ProjectExplorer::IDevice::Ptr BareMetalDeviceConfigurationWizard::device() const ProjectExplorer::IDevice::Ptr BareMetalDeviceConfigurationWizard::device() const
{ {
auto dev = BareMetalDevice::create(); const auto dev = BareMetalDevice::create();
dev->setupId(ProjectExplorer::IDevice::ManuallyAdded, Core::Id()); dev->setupId(ProjectExplorer::IDevice::ManuallyAdded, Core::Id());
dev->setDisplayName(m_setupPage->configurationName()); dev->setDisplayName(m_setupPage->configurationName());
dev->setType(Constants::BareMetalOsType); dev->setType(Constants::BareMetalOsType);

View File

@@ -33,17 +33,19 @@ namespace Internal {
class BareMetalDeviceConfigurationWizardSetupPage; class BareMetalDeviceConfigurationWizardSetupPage;
class BareMetalDeviceConfigurationWizard : public Utils::Wizard // BareMetalDeviceConfigurationWizard
class BareMetalDeviceConfigurationWizard final : public Utils::Wizard
{ {
Q_OBJECT Q_OBJECT
public: public:
BareMetalDeviceConfigurationWizard(QWidget *parent = nullptr); explicit BareMetalDeviceConfigurationWizard(QWidget *parent = nullptr);
ProjectExplorer::IDevice::Ptr device() const; ProjectExplorer::IDevice::Ptr device() const;
private: private:
BareMetalDeviceConfigurationWizardSetupPage *m_setupPage; BareMetalDeviceConfigurationWizardSetupPage *m_setupPage = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -24,8 +24,8 @@
** **
****************************************************************************/ ****************************************************************************/
#include "baremetaldeviceconfigurationwizardpages.h"
#include "baremetaldevice.h" #include "baremetaldevice.h"
#include "baremetaldeviceconfigurationwizardpages.h"
#include "gdbserverproviderchooser.h" #include "gdbserverproviderchooser.h"
@@ -38,13 +38,15 @@
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// BareMetalDeviceConfigurationWizardSetupPage
BareMetalDeviceConfigurationWizardSetupPage::BareMetalDeviceConfigurationWizardSetupPage( BareMetalDeviceConfigurationWizardSetupPage::BareMetalDeviceConfigurationWizardSetupPage(
QWidget *parent) QWidget *parent)
: QWizardPage(parent) : QWizardPage(parent)
{ {
setTitle(tr("Set up GDB Server or Hardware Debugger")); setTitle(tr("Set up GDB Server or Hardware Debugger"));
auto formLayout = new QFormLayout(this); const auto formLayout = new QFormLayout(this);
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
m_nameLineEdit = new QLineEdit(this); m_nameLineEdit = new QLineEdit(this);
formLayout->addRow(tr("Name:"), m_nameLineEdit); formLayout->addRow(tr("Name:"), m_nameLineEdit);

View File

@@ -37,23 +37,25 @@ namespace Internal {
class GdbServerProviderChooser; class GdbServerProviderChooser;
class BareMetalDeviceConfigurationWizardSetupPage : public QWizardPage // BareMetalDeviceConfigurationWizardSetupPage
class BareMetalDeviceConfigurationWizardSetupPage final : public QWizardPage
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BareMetalDeviceConfigurationWizardSetupPage(QWidget *parent = nullptr); explicit BareMetalDeviceConfigurationWizardSetupPage(QWidget *parent = nullptr);
void initializePage() override; void initializePage() final;
bool isComplete() const override; bool isComplete() const final;
QString configurationName() const; QString configurationName() const;
QString gdbServerProviderId() const; QString gdbServerProviderId() const;
virtual QString defaultConfigurationName() const; virtual QString defaultConfigurationName() const;
private: private:
QLineEdit *m_nameLineEdit; QLineEdit *m_nameLineEdit = nullptr;
GdbServerProviderChooser *m_gdbServerProviderChooser; GdbServerProviderChooser *m_gdbServerProviderChooser = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -34,10 +34,12 @@ namespace Internal {
const char GdbCommandsKey[] = "BareMetal.GdbCommandsStep.Commands"; const char GdbCommandsKey[] = "BareMetal.GdbCommandsStep.Commands";
// BareMetalGdbCommandsDeployStepWidget
BareMetalGdbCommandsDeployStepWidget::BareMetalGdbCommandsDeployStepWidget(BareMetalGdbCommandsDeployStep &step) BareMetalGdbCommandsDeployStepWidget::BareMetalGdbCommandsDeployStepWidget(BareMetalGdbCommandsDeployStep &step)
: BuildStepConfigWidget(&step), m_step(step) : BuildStepConfigWidget(&step), m_step(step)
{ {
auto fl = new QFormLayout(this); const auto fl = new QFormLayout(this);
fl->setMargin(0); fl->setMargin(0);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(fl); setLayout(fl);
@@ -62,6 +64,8 @@ QString BareMetalGdbCommandsDeployStepWidget::summaryText() const
return displayName(); return displayName();
} }
// BareMetalGdbCommandsDeployStep
BareMetalGdbCommandsDeployStep::BareMetalGdbCommandsDeployStep(BuildStepList *bsl) BareMetalGdbCommandsDeployStep::BareMetalGdbCommandsDeployStep(BuildStepList *bsl)
: BuildStep(bsl, stepId()) : BuildStep(bsl, stepId())
{ {

View File

@@ -27,23 +27,25 @@
#include <projectexplorer/buildstep.h> #include <projectexplorer/buildstep.h>
#include <QVariantMap>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QVariantMap>
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class BareMetalGdbCommandsDeployStep : public ProjectExplorer::BuildStep // BareMetalGdbCommandsDeployStep
class BareMetalGdbCommandsDeployStep final : public ProjectExplorer::BuildStep
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BareMetalGdbCommandsDeployStep(ProjectExplorer::BuildStepList *bsl); explicit BareMetalGdbCommandsDeployStep(ProjectExplorer::BuildStepList *bsl);
bool fromMap(const QVariantMap &map) override; bool fromMap(const QVariantMap &map) final;
QVariantMap toMap() const override; QVariantMap toMap() const final;
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; ProjectExplorer::BuildStepConfigWidget *createConfigWidget() final;
static Core::Id stepId(); static Core::Id stepId();
static QString displayName(); static QString displayName();
@@ -52,13 +54,16 @@ public:
QString gdbCommands() const; QString gdbCommands() const;
private: private:
bool init() override; bool init() final;
void doRun() override; void doRun() final;
QString m_gdbCommands; QString m_gdbCommands;
}; };
class BareMetalGdbCommandsDeployStepWidget: public ProjectExplorer::BuildStepConfigWidget // BareMetalGdbCommandsDeployStepWidget
class BareMetalGdbCommandsDeployStepWidget final
: public ProjectExplorer::BuildStepConfigWidget
{ {
Q_OBJECT Q_OBJECT
@@ -71,7 +76,7 @@ private:
QString summaryText() const; QString summaryText() const;
BareMetalGdbCommandsDeployStep &m_step; BareMetalGdbCommandsDeployStep &m_step;
QPlainTextEdit *m_commands; QPlainTextEdit *m_commands = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -24,32 +24,34 @@
** **
****************************************************************************/ ****************************************************************************/
#include "baremetalplugin.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "baremetalcustomrunconfiguration.h" #include "baremetalcustomrunconfiguration.h"
#include "baremetaldevice.h"
#include "baremetaldebugsupport.h" #include "baremetaldebugsupport.h"
#include "baremetaldevice.h"
#include "baremetalplugin.h"
#include "baremetalrunconfiguration.h" #include "baremetalrunconfiguration.h"
#include "gdbserverproviderssettingspage.h"
#include "gdbserverprovidermanager.h" #include "gdbserverprovidermanager.h"
#include "gdbserverproviderssettingspage.h"
#include "iarewtoolchain.h" #include "iarewtoolchain.h"
#include "keiltoolchain.h" #include "keiltoolchain.h"
#include "sdcctoolchain.h" #include "sdcctoolchain.h"
#include <coreplugin/icore.h> #include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/icontext.h>
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h> #include <coreplugin/actionmanager/command.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// BareMetalPluginPrivate
class BareMetalPluginPrivate class BareMetalPluginPrivate
{ {
public: public:
@@ -63,6 +65,8 @@ public:
GdbServerProviderManager gdbServerProviderManager; GdbServerProviderManager gdbServerProviderManager;
}; };
// BareMetalPlugin
BareMetalPlugin::~BareMetalPlugin() BareMetalPlugin::~BareMetalPlugin()
{ {
delete d; delete d;

View File

@@ -31,7 +31,9 @@
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class BareMetalPlugin : public ExtensionSystem::IPlugin // BareMetalPlugin
class BareMetalPlugin final : public ExtensionSystem::IPlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "BareMetal.json") Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "BareMetal.json")
@@ -41,7 +43,7 @@ class BareMetalPlugin : public ExtensionSystem::IPlugin
bool initialize(const QStringList &arguments, QString *errorString) final; bool initialize(const QStringList &arguments, QString *errorString) final;
void extensionsInitialized() final; void extensionsInitialized() final;
class BareMetalPluginPrivate *d; class BareMetalPluginPrivate *d = nullptr;
#ifdef WITH_TESTS #ifdef WITH_TESTS
private slots: private slots:

View File

@@ -23,9 +23,8 @@
** **
****************************************************************************/ ****************************************************************************/
#include "baremetalrunconfiguration.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "baremetalrunconfiguration.h"
#include <projectexplorer/buildtargetinfo.h> #include <projectexplorer/buildtargetinfo.h>
#include <projectexplorer/project.h> #include <projectexplorer/project.h>
@@ -43,7 +42,7 @@ namespace Internal {
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *target, Core::Id id) BareMetalRunConfiguration::BareMetalRunConfiguration(Target *target, Core::Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto exeAspect = addAspect<ExecutableAspect>(); const auto exeAspect = addAspect<ExecutableAspect>();
exeAspect->setDisplayStyle(BaseStringAspect::LabelDisplay); exeAspect->setDisplayStyle(BaseStringAspect::LabelDisplay);
exeAspect->setPlaceHolderText(tr("Unknown")); exeAspect->setPlaceHolderText(tr("Unknown"));

View File

@@ -30,12 +30,14 @@
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class BareMetalRunConfiguration : public ProjectExplorer::RunConfiguration // BareMetalRunConfiguration
class BareMetalRunConfiguration final : public ProjectExplorer::RunConfiguration
{ {
Q_OBJECT Q_OBJECT
public: public:
BareMetalRunConfiguration(ProjectExplorer::Target *target, Core::Id id); explicit BareMetalRunConfiguration(ProjectExplorer::Target *target, Core::Id id);
static const char *IdPrefix; static const char *IdPrefix;
@@ -43,10 +45,13 @@ private:
void updateTargetInformation(); void updateTargetInformation();
}; };
class BareMetalRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory // BareMetalRunConfigurationFactory
class BareMetalRunConfigurationFactory final
: public ProjectExplorer::RunConfigurationFactory
{ {
public: public:
BareMetalRunConfigurationFactory(); explicit BareMetalRunConfigurationFactory();
}; };
} // namespace Internal } // namespace Internal

View File

@@ -23,8 +23,8 @@
** **
****************************************************************************/ ****************************************************************************/
#include "defaultgdbserverprovider.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "defaultgdbserverprovider.h"
#include "gdbserverprovidermanager.h" #include "gdbserverprovidermanager.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -40,10 +40,10 @@ namespace Internal {
static const char hostKeyC[] = "BareMetal.DefaultGdbServerProvider.Host"; static const char hostKeyC[] = "BareMetal.DefaultGdbServerProvider.Host";
static const char portKeyC[] = "BareMetal.DefaultGdbServerProvider.Port"; static const char portKeyC[] = "BareMetal.DefaultGdbServerProvider.Port";
// DefaultGdbServerProvider
DefaultGdbServerProvider::DefaultGdbServerProvider() DefaultGdbServerProvider::DefaultGdbServerProvider()
: GdbServerProvider(QLatin1String(Constants::DEFAULT_PROVIDER_ID)) : GdbServerProvider(QLatin1String(Constants::DEFAULT_PROVIDER_ID))
, m_host(QLatin1String("localhost"))
, m_port(3333)
{ {
} }
@@ -132,6 +132,8 @@ GdbServerProviderConfigWidget *DefaultGdbServerProvider::configurationWidget()
return new DefaultGdbServerProviderConfigWidget(this); return new DefaultGdbServerProviderConfigWidget(this);
} }
// DefaultGdbServerProviderFactory
DefaultGdbServerProviderFactory::DefaultGdbServerProviderFactory() DefaultGdbServerProviderFactory::DefaultGdbServerProviderFactory()
{ {
setId(QLatin1String(Constants::DEFAULT_PROVIDER_ID)); setId(QLatin1String(Constants::DEFAULT_PROVIDER_ID));
@@ -152,7 +154,7 @@ bool DefaultGdbServerProviderFactory::canRestore(const QVariantMap &data) const
GdbServerProvider *DefaultGdbServerProviderFactory::restore(const QVariantMap &data) GdbServerProvider *DefaultGdbServerProviderFactory::restore(const QVariantMap &data)
{ {
auto p = new DefaultGdbServerProvider; const auto p = new DefaultGdbServerProvider;
auto updated = data; auto updated = data;
if (p->fromMap(updated)) if (p->fromMap(updated))
return p; return p;
@@ -160,6 +162,8 @@ GdbServerProvider *DefaultGdbServerProviderFactory::restore(const QVariantMap &d
return nullptr; return nullptr;
} }
// GdbServerProviderConfigWidget
DefaultGdbServerProviderConfigWidget::DefaultGdbServerProviderConfigWidget( DefaultGdbServerProviderConfigWidget::DefaultGdbServerProviderConfigWidget(
DefaultGdbServerProvider *provider) DefaultGdbServerProvider *provider)
: GdbServerProviderConfigWidget(provider) : GdbServerProviderConfigWidget(provider)
@@ -179,7 +183,7 @@ DefaultGdbServerProviderConfigWidget::DefaultGdbServerProviderConfigWidget(
addErrorLabel(); addErrorLabel();
setFromProvider(); setFromProvider();
auto chooser = new Core::VariableChooser(this); const auto chooser = new Core::VariableChooser(this);
chooser->addSupportedWidget(m_initCommandsTextEdit); chooser->addSupportedWidget(m_initCommandsTextEdit);
chooser->addSupportedWidget(m_resetCommandsTextEdit); chooser->addSupportedWidget(m_resetCommandsTextEdit);

View File

@@ -33,7 +33,9 @@ namespace Internal {
class DefaultGdbServerProviderConfigWidget; class DefaultGdbServerProviderConfigWidget;
class DefaultGdbServerProviderFactory; class DefaultGdbServerProviderFactory;
class DefaultGdbServerProvider : public GdbServerProvider // DefaultGdbServerProvider
class DefaultGdbServerProvider final : public GdbServerProvider
{ {
public: public:
QString typeDisplayName() const final; QString typeDisplayName() const final;
@@ -60,15 +62,17 @@ private:
explicit DefaultGdbServerProvider(); explicit DefaultGdbServerProvider();
explicit DefaultGdbServerProvider(const DefaultGdbServerProvider &); explicit DefaultGdbServerProvider(const DefaultGdbServerProvider &);
QString m_host; QString m_host = QLatin1String("localhost");
quint16 m_port; quint16 m_port = 3333;
friend class DefaultGdbServerProviderConfigWidget; friend class DefaultGdbServerProviderConfigWidget;
friend class DefaultGdbServerProviderFactory; friend class DefaultGdbServerProviderFactory;
friend class BareMetalDevice; friend class BareMetalDevice;
}; };
class DefaultGdbServerProviderFactory : public GdbServerProviderFactory // DefaultGdbServerProviderFactory
class DefaultGdbServerProviderFactory final : public GdbServerProviderFactory
{ {
Q_OBJECT Q_OBJECT
@@ -81,7 +85,9 @@ public:
GdbServerProvider *restore(const QVariantMap &data) final; GdbServerProvider *restore(const QVariantMap &data) final;
}; };
class DefaultGdbServerProviderConfigWidget : public GdbServerProviderConfigWidget // DefaultGdbServerProviderConfigWidget
class DefaultGdbServerProviderConfigWidget final : public GdbServerProviderConfigWidget
{ {
Q_OBJECT Q_OBJECT
@@ -94,9 +100,9 @@ private:
void setFromProvider(); void setFromProvider();
HostWidget *m_hostWidget; HostWidget *m_hostWidget = nullptr;
QPlainTextEdit *m_initCommandsTextEdit; QPlainTextEdit *m_initCommandsTextEdit = nullptr;
QPlainTextEdit *m_resetCommandsTextEdit; QPlainTextEdit *m_resetCommandsTextEdit = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -23,22 +23,21 @@
** **
****************************************************************************/ ****************************************************************************/
#include "baremetaldevice.h"
#include "gdbserverprovider.h" #include "gdbserverprovider.h"
#include "gdbserverprovidermanager.h" #include "gdbserverprovidermanager.h"
#include "baremetaldevice.h"
#include <utils/qtcassert.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/qtcassert.h>
#include <QCoreApplication>
#include <QUuid>
#include <QFormLayout>
#include <QLineEdit>
#include <QLabel>
#include <QComboBox> #include <QComboBox>
#include <QSpinBox> #include <QCoreApplication>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QSpinBox>
#include <QUuid>
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
@@ -56,9 +55,10 @@ static QString createId(const QString &id)
return newId; return newId;
} }
// GdbServerProvider
GdbServerProvider::GdbServerProvider(const QString &id) GdbServerProvider::GdbServerProvider(const QString &id)
: m_id(createId(id)) : m_id(createId(id))
, m_startupMode(NoStartup)
{ {
} }
@@ -204,6 +204,8 @@ bool GdbServerProvider::fromMap(const QVariantMap &data)
return true; return true;
} }
// GdbServerProviderFactory
QString GdbServerProviderFactory::id() const QString GdbServerProviderFactory::id() const
{ {
return m_id; return m_id;
@@ -234,6 +236,8 @@ void GdbServerProviderFactory::idToMap(QVariantMap &data, const QString &id)
data.insert(QLatin1String(idKeyC), id); data.insert(QLatin1String(idKeyC), id);
} }
// GdbServerProviderConfigWidget
GdbServerProviderConfigWidget::GdbServerProviderConfigWidget( GdbServerProviderConfigWidget::GdbServerProviderConfigWidget(
GdbServerProvider *provider) GdbServerProvider *provider)
: m_provider(provider) : m_provider(provider)
@@ -373,6 +377,8 @@ QString GdbServerProviderConfigWidget::defaultResetCommandsTooltip()
"The MCU should be halted after these commands."); "The MCU should be halted after these commands.");
} }
// HostWidget
HostWidget::HostWidget(QWidget *parent) HostWidget::HostWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
@@ -383,7 +389,7 @@ HostWidget::HostWidget(QWidget *parent)
m_portSpinBox->setRange(0, 65535); m_portSpinBox->setRange(0, 65535);
m_portSpinBox->setToolTip(tr("Enter TCP/IP port which will be listened by " m_portSpinBox->setToolTip(tr("Enter TCP/IP port which will be listened by "
"the GDB server provider.")); "the GDB server provider."));
auto layout = new QHBoxLayout(this); const auto layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_hostLineEdit); layout->addWidget(m_hostLineEdit);
layout->addWidget(m_portSpinBox); layout->addWidget(m_portSpinBox);

View File

@@ -33,12 +33,12 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QFormLayout;
class QLineEdit;
class QLabel;
class QComboBox; class QComboBox;
class QSpinBox; class QFormLayout;
class QLabel;
class QLineEdit;
class QPlainTextEdit; class QPlainTextEdit;
class QSpinBox;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace BareMetal { namespace BareMetal {
@@ -48,6 +48,8 @@ class BareMetalDevice;
class GdbServerProviderConfigWidget; class GdbServerProviderConfigWidget;
class GdbServerProviderManager; class GdbServerProviderManager;
// GdbServerProvider
class GdbServerProvider class GdbServerProvider
{ {
public: public:
@@ -104,7 +106,7 @@ protected:
private: private:
QString m_id; QString m_id;
mutable QString m_displayName; mutable QString m_displayName;
StartupMode m_startupMode; StartupMode m_startupMode = NoStartup;
QString m_initCommands; QString m_initCommands;
QString m_resetCommands; QString m_resetCommands;
QSet<BareMetalDevice *> m_devices; QSet<BareMetalDevice *> m_devices;
@@ -112,6 +114,8 @@ private:
friend class GdbServerProviderConfigWidget; friend class GdbServerProviderConfigWidget;
}; };
// GdbServerProviderFactory
class GdbServerProviderFactory : public QObject class GdbServerProviderFactory : public QObject
{ {
Q_OBJECT Q_OBJECT
@@ -137,6 +141,8 @@ private:
QString m_id; QString m_id;
}; };
// GdbServerProviderConfigWidget
class GdbServerProviderConfigWidget : public QWidget class GdbServerProviderConfigWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
@@ -166,18 +172,20 @@ protected:
static QString defaultInitCommandsTooltip(); static QString defaultInitCommandsTooltip();
static QString defaultResetCommandsTooltip(); static QString defaultResetCommandsTooltip();
QFormLayout *m_mainLayout; QFormLayout *m_mainLayout = nullptr;
QLineEdit *m_nameLineEdit; QLineEdit *m_nameLineEdit = nullptr;
QComboBox *m_startupModeComboBox; QComboBox *m_startupModeComboBox = nullptr;
private: private:
void setFromProvider(); void setFromProvider();
GdbServerProvider *m_provider; GdbServerProvider *m_provider = nullptr;
QLabel *m_errorLabel = nullptr; QLabel *m_errorLabel = nullptr;
}; };
class HostWidget : public QWidget // HostWidget
class HostWidget final : public QWidget
{ {
Q_OBJECT Q_OBJECT
@@ -193,8 +201,8 @@ signals:
void dataChanged(); void dataChanged();
private: private:
QLineEdit *m_hostLineEdit; QLineEdit *m_hostLineEdit = nullptr;
QSpinBox *m_portSpinBox; QSpinBox *m_portSpinBox = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -23,12 +23,12 @@
** **
****************************************************************************/ ****************************************************************************/
#include "gdbserverproviderchooser.h"
#include "gdbserverprovidermanager.h"
#include "gdbserverprovider.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "gdbserverprovider.h"
#include "gdbserverproviderchooser.h"
#include "gdbserverprovidermanager.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <QComboBox> #include <QComboBox>
@@ -39,6 +39,8 @@
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// GdbServerProviderChooser
GdbServerProviderChooser::GdbServerProviderChooser( GdbServerProviderChooser::GdbServerProviderChooser(
bool useManageButton, QWidget *parent) bool useManageButton, QWidget *parent)
: QWidget(parent) : QWidget(parent)
@@ -49,7 +51,7 @@ GdbServerProviderChooser::GdbServerProviderChooser(
m_manageButton->setEnabled(useManageButton); m_manageButton->setEnabled(useManageButton);
m_manageButton->setVisible(useManageButton); m_manageButton->setVisible(useManageButton);
auto layout = new QHBoxLayout(this); const auto layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(m_chooser); layout->addWidget(m_chooser);
layout->addWidget(m_manageButton); layout->addWidget(m_manageButton);

View File

@@ -39,7 +39,9 @@ namespace Internal {
class GdbServerProvider; class GdbServerProvider;
class GdbServerProviderChooser : public QWidget // GdbServerProviderChooser
class GdbServerProviderChooser final : public QWidget
{ {
Q_OBJECT Q_OBJECT
@@ -60,8 +62,8 @@ private:
bool providerMatches(const GdbServerProvider *) const; bool providerMatches(const GdbServerProvider *) const;
QString providerText(const GdbServerProvider *) const; QString providerText(const GdbServerProvider *) const;
QComboBox *m_chooser; QComboBox *m_chooser = nullptr;
QPushButton *m_manageButton; QPushButton *m_manageButton = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -23,11 +23,11 @@
** **
****************************************************************************/ ****************************************************************************/
#include "gdbserverprovidermanager.h"
#include "gdbserverprovider.h" #include "gdbserverprovider.h"
#include "gdbserverprovidermanager.h"
#include "openocdgdbserverprovider.h"
#include "defaultgdbserverprovider.h" #include "defaultgdbserverprovider.h"
#include "openocdgdbserverprovider.h"
#include "stlinkutilgdbserverprovider.h" #include "stlinkutilgdbserverprovider.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
@@ -35,8 +35,8 @@
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <utils/persistentsettings.h> #include <utils/persistentsettings.h>
#include <utils/qtcassert.h>
#include <QDir> #include <QDir>
@@ -50,6 +50,8 @@ const char fileNameKeyC[] = "/gdbserverproviders.xml";
static GdbServerProviderManager *m_instance = nullptr; static GdbServerProviderManager *m_instance = nullptr;
// GdbServerProviderManager
GdbServerProviderManager::GdbServerProviderManager() GdbServerProviderManager::GdbServerProviderManager()
: m_configFile(Utils::FileName::fromString(Core::ICore::userResourcePath() + fileNameKeyC)) : m_configFile(Utils::FileName::fromString(Core::ICore::userResourcePath() + fileNameKeyC))
, m_factories({new DefaultGdbServerProviderFactory, , m_factories({new DefaultGdbServerProviderFactory,

View File

@@ -25,8 +25,8 @@
#pragma once #pragma once
#include <QObject>
#include <QList> #include <QList>
#include <QObject>
#include <utils/fileutils.h> #include <utils/fileutils.h>
@@ -40,13 +40,15 @@ class BareMetalPluginPrivate;
class GdbServerProvider; class GdbServerProvider;
class GdbServerProviderFactory; class GdbServerProviderFactory;
class GdbServerProviderManager : public QObject // GdbServerProviderManager
class GdbServerProviderManager final : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static GdbServerProviderManager *instance(); static GdbServerProviderManager *instance();
~GdbServerProviderManager() override; ~GdbServerProviderManager() final;
static QList<GdbServerProvider *> providers(); static QList<GdbServerProvider *> providers();
static QList<GdbServerProviderFactory *> factories(); static QList<GdbServerProviderFactory *> factories();
@@ -69,7 +71,7 @@ private:
void restoreProviders(); void restoreProviders();
static void notifyAboutUpdate(GdbServerProvider *); static void notifyAboutUpdate(GdbServerProvider *);
Utils::PersistentSettingsWriter *m_writer; Utils::PersistentSettingsWriter *m_writer = nullptr;
QList<GdbServerProvider *> m_providers; QList<GdbServerProvider *> m_providers;
const Utils::FileName m_configFile; const Utils::FileName m_configFile;
const QList<GdbServerProviderFactory *> m_factories; const QList<GdbServerProviderFactory *> m_factories;

View File

@@ -29,14 +29,16 @@
#include <projectexplorer/runcontrol.h> #include <projectexplorer/runcontrol.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <utils/qtcprocess.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// GdbServerProviderProcess
GdbServerProviderProcess::GdbServerProviderProcess( GdbServerProviderProcess::GdbServerProviderProcess(
const QSharedPointer<const ProjectExplorer::IDevice> &device, const QSharedPointer<const ProjectExplorer::IDevice> &device,
QObject *parent) QObject *parent)

View File

@@ -32,7 +32,9 @@ namespace Utils { class QtcProcess; }
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class GdbServerProviderProcess : public ProjectExplorer::DeviceProcess // GdbServerProviderProcess
class GdbServerProviderProcess final : public ProjectExplorer::DeviceProcess
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -40,23 +42,23 @@ public:
const QSharedPointer<const ProjectExplorer::IDevice> &device, const QSharedPointer<const ProjectExplorer::IDevice> &device,
QObject *parent = nullptr); QObject *parent = nullptr);
void start(const ProjectExplorer::Runnable &runnable) override; void start(const ProjectExplorer::Runnable &runnable) final;
void interrupt() override; void interrupt() final;
void terminate() override; void terminate() final;
void kill() override; void kill() final;
QProcess::ProcessState state() const override; QProcess::ProcessState state() const final;
QProcess::ExitStatus exitStatus() const override; QProcess::ExitStatus exitStatus() const final;
int exitCode() const override; int exitCode() const final;
QString errorString() const override; QString errorString() const final;
QByteArray readAllStandardOutput() override; QByteArray readAllStandardOutput() final;
QByteArray readAllStandardError() override; QByteArray readAllStandardError() final;
qint64 write(const QByteArray &data) override; qint64 write(const QByteArray &data) final;
private: private:
Utils::QtcProcess *m_process; Utils::QtcProcess *m_process = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -23,21 +23,23 @@
** **
****************************************************************************/ ****************************************************************************/
#include "gdbserverproviderssettingspage.h"
#include "gdbserverprovider.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "gdbserverprovider.h"
#include "gdbserverprovidermanager.h" #include "gdbserverprovidermanager.h"
#include "gdbserverproviderssettingspage.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <utils/algorithm.h>
#include <utils/detailswidget.h> #include <utils/detailswidget.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/algorithm.h>
#include <QApplication>
#include <QAction> #include <QAction>
#include <QApplication>
#include <QGroupBox>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QHeaderView> #include <QHeaderView>
#include <QItemSelectionModel> #include <QItemSelectionModel>
@@ -48,22 +50,23 @@
#include <QTextStream> #include <QTextStream>
#include <QTreeView> #include <QTreeView>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QGroupBox>
using namespace Utils; using namespace Utils;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class GdbServerProviderNode : public TreeItem // GdbServerProviderNode
class GdbServerProviderNode final : public TreeItem
{ {
public: public:
GdbServerProviderNode(GdbServerProvider *provider, bool changed = false) explicit GdbServerProviderNode(GdbServerProvider *provider, bool changed = false)
: provider(provider), changed(changed) : provider(provider), changed(changed)
{ {
} }
QVariant data(int column, int role) const override QVariant data(int column, int role) const final
{ {
if (role == Qt::FontRole) { if (role == Qt::FontRole) {
QFont f = QApplication::font(); QFont f = QApplication::font();
@@ -77,7 +80,7 @@ public:
} }
// FIXME: Need to handle ToolTipRole role? // FIXME: Need to handle ToolTipRole role?
return QVariant(); return {};
} }
GdbServerProvider *provider = nullptr; GdbServerProvider *provider = nullptr;
@@ -85,6 +88,8 @@ public:
bool changed = false; bool changed = false;
}; };
// GdbServerProviderModel
GdbServerProviderModel::GdbServerProviderModel() GdbServerProviderModel::GdbServerProviderModel()
{ {
setHeader({tr("Name"), tr("Type")}); setHeader({tr("Name"), tr("Type")});
@@ -195,7 +200,7 @@ void GdbServerProviderModel::markForAddition(GdbServerProvider *provider)
GdbServerProviderNode *GdbServerProviderModel::createNode( GdbServerProviderNode *GdbServerProviderModel::createNode(
GdbServerProvider *provider, bool changed) GdbServerProvider *provider, bool changed)
{ {
auto node = new GdbServerProviderNode(provider, changed); const auto node = new GdbServerProviderNode(provider, changed);
node->widget = provider->configurationWidget(); node->widget = provider->configurationWidget();
connect(node->widget, &GdbServerProviderConfigWidget::dirty, this, [node] { connect(node->widget, &GdbServerProviderConfigWidget::dirty, this, [node] {
node->changed = true; node->changed = true;
@@ -223,12 +228,14 @@ void GdbServerProviderModel::removeProvider(GdbServerProvider *provider)
emit providerStateChanged(); emit providerStateChanged();
} }
class GdbServerProvidersSettingsWidget : public QWidget // GdbServerProvidersSettingsWidget
class GdbServerProvidersSettingsWidget final : public QWidget
{ {
Q_DECLARE_TR_FUNCTIONS(BareMetal::Internal::GdbServerProvidersSettingsPage) Q_DECLARE_TR_FUNCTIONS(BareMetal::Internal::GdbServerProvidersSettingsPage)
public: public:
GdbServerProvidersSettingsWidget(GdbServerProvidersSettingsPage *page); explicit GdbServerProvidersSettingsWidget(GdbServerProvidersSettingsPage *page);
void providerSelectionChanged(); void providerSelectionChanged();
void removeProvider(); void removeProvider();
@@ -238,14 +245,14 @@ public:
QModelIndex currentIndex() const; QModelIndex currentIndex() const;
public: public:
GdbServerProvidersSettingsPage *m_page; GdbServerProvidersSettingsPage *m_page = nullptr;
GdbServerProviderModel m_model; GdbServerProviderModel m_model;
QItemSelectionModel *m_selectionModel; QItemSelectionModel *m_selectionModel = nullptr;
QTreeView *m_providerView; QTreeView *m_providerView = nullptr;
Utils::DetailsWidget *m_container; Utils::DetailsWidget *m_container = nullptr;
QPushButton *m_addButton; QPushButton *m_addButton = nullptr;
QPushButton *m_cloneButton; QPushButton *m_cloneButton = nullptr;
QPushButton *m_delButton; QPushButton *m_delButton = nullptr;
}; };
GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget
@@ -265,27 +272,27 @@ GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget
m_container->setMinimumWidth(500); m_container->setMinimumWidth(500);
m_container->setVisible(false); m_container->setVisible(false);
auto buttonLayout = new QHBoxLayout(); const auto buttonLayout = new QHBoxLayout;
buttonLayout->setSpacing(6); buttonLayout->setSpacing(6);
buttonLayout->setContentsMargins(0, 0, 0, 0); buttonLayout->setContentsMargins(0, 0, 0, 0);
buttonLayout->addWidget(m_addButton); buttonLayout->addWidget(m_addButton);
buttonLayout->addWidget(m_cloneButton); buttonLayout->addWidget(m_cloneButton);
buttonLayout->addWidget(m_delButton); buttonLayout->addWidget(m_delButton);
auto spacerItem = new QSpacerItem(40, 10, QSizePolicy::Expanding, QSizePolicy::Minimum); const auto spacerItem = new QSpacerItem(40, 10, QSizePolicy::Expanding, QSizePolicy::Minimum);
buttonLayout->addItem(spacerItem); buttonLayout->addItem(spacerItem);
auto verticalLayout = new QVBoxLayout(); const auto verticalLayout = new QVBoxLayout;
verticalLayout->addWidget(m_providerView); verticalLayout->addWidget(m_providerView);
verticalLayout->addLayout(buttonLayout); verticalLayout->addLayout(buttonLayout);
auto horizontalLayout = new QHBoxLayout(); const auto horizontalLayout = new QHBoxLayout;
horizontalLayout->addLayout(verticalLayout); horizontalLayout->addLayout(verticalLayout);
horizontalLayout->addWidget(m_container); horizontalLayout->addWidget(m_container);
auto groupBox = new QGroupBox(tr("GDB Server Providers"), this); const auto groupBox = new QGroupBox(tr("GDB Server Providers"), this);
groupBox->setLayout(horizontalLayout); groupBox->setLayout(horizontalLayout);
auto topLayout = new QVBoxLayout(this); const auto topLayout = new QVBoxLayout(this);
topLayout->addWidget(groupBox); topLayout->addWidget(groupBox);
connect(&m_model, &GdbServerProviderModel::providerStateChanged, connect(&m_model, &GdbServerProviderModel::providerStateChanged,
@@ -293,7 +300,7 @@ GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget
m_providerView->setModel(&m_model); m_providerView->setModel(&m_model);
auto headerView = m_providerView->header(); const auto headerView = m_providerView->header();
headerView->setSectionResizeMode(0, QHeaderView::ResizeToContents); headerView->setSectionResizeMode(0, QHeaderView::ResizeToContents);
headerView->setSectionResizeMode(1, QHeaderView::Stretch); headerView->setSectionResizeMode(1, QHeaderView::Stretch);
m_providerView->expandAll(); m_providerView->expandAll();
@@ -307,10 +314,10 @@ GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget
this, &GdbServerProvidersSettingsWidget::providerSelectionChanged); this, &GdbServerProvidersSettingsWidget::providerSelectionChanged);
// Set up add menu: // Set up add menu:
auto addMenu = new QMenu(m_addButton); const auto addMenu = new QMenu(m_addButton);
for (const auto f : GdbServerProviderManager::factories()) { for (const auto f : GdbServerProviderManager::factories()) {
auto action = new QAction(addMenu); const auto action = new QAction(addMenu);
action->setText(f->displayName()); action->setText(f->displayName());
connect(action, &QAction::triggered, this, [this, f] { createProvider(f); }); connect(action, &QAction::triggered, this, [this, f] { createProvider(f); });
addMenu->addAction(action); addMenu->addAction(action);
@@ -390,11 +397,11 @@ void GdbServerProvidersSettingsWidget::updateState()
QModelIndex GdbServerProvidersSettingsWidget::currentIndex() const QModelIndex GdbServerProvidersSettingsWidget::currentIndex() const
{ {
if (!m_selectionModel) if (!m_selectionModel)
return QModelIndex(); return {};
const QModelIndexList rows = m_selectionModel->selectedRows(); const QModelIndexList rows = m_selectionModel->selectedRows();
if (rows.count() != 1) if (rows.count() != 1)
return QModelIndex(); return {};
return rows.at(0); return rows.at(0);
} }

View File

@@ -46,13 +46,15 @@ class GdbServerProviderFactory;
class GdbServerProviderNode; class GdbServerProviderNode;
class GdbServerProvidersSettingsWidget; class GdbServerProvidersSettingsWidget;
class GdbServerProviderModel // GdbServerProviderModel
class GdbServerProviderModel final
: public Utils::TreeModel<Utils::TypedTreeItem<GdbServerProviderNode>, GdbServerProviderNode> : public Utils::TreeModel<Utils::TypedTreeItem<GdbServerProviderNode>, GdbServerProviderNode>
{ {
Q_OBJECT Q_OBJECT
public: public:
GdbServerProviderModel(); explicit GdbServerProviderModel();
GdbServerProvider *provider(const QModelIndex &) const; GdbServerProvider *provider(const QModelIndex &) const;
GdbServerProviderConfigWidget *widget(const QModelIndex &) const; GdbServerProviderConfigWidget *widget(const QModelIndex &) const;
@@ -78,7 +80,9 @@ private:
QList<GdbServerProvider *> m_providersToRemove; QList<GdbServerProvider *> m_providersToRemove;
}; };
class GdbServerProvidersSettingsPage : public Core::IOptionsPage // GdbServerProvidersSettingsPage
class GdbServerProvidersSettingsPage final : public Core::IOptionsPage
{ {
Q_OBJECT Q_OBJECT
@@ -86,9 +90,9 @@ public:
explicit GdbServerProvidersSettingsPage(QObject *parent = nullptr); explicit GdbServerProvidersSettingsPage(QObject *parent = nullptr);
private: private:
QWidget *widget() override; QWidget *widget() final;
void apply() override; void apply() final;
void finish() override; void finish() final;
GdbServerProvidersSettingsWidget *m_configWidget = nullptr; GdbServerProvidersSettingsWidget *m_configWidget = nullptr;
}; };

View File

@@ -38,6 +38,8 @@ using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// Helpers:
static Task::TaskType taskType(const QString &msgType) static Task::TaskType taskType(const QString &msgType)
{ {
if (msgType == "Warning") if (msgType == "Warning")
@@ -47,6 +49,8 @@ static Task::TaskType taskType(const QString &msgType)
return Task::TaskType::Unknown; return Task::TaskType::Unknown;
} }
// IarParser
IarParser::IarParser() IarParser::IarParser()
{ {
setObjectName("IarParser"); setObjectName("IarParser");

View File

@@ -38,7 +38,7 @@ class IarParser final : public ProjectExplorer::IOutputParser
Q_OBJECT Q_OBJECT
public: public:
IarParser(); explicit IarParser();
static Core::Id id(); static Core::Id id();
private: private:
@@ -46,9 +46,9 @@ private:
void amendDescription(); void amendDescription();
void amendFilePath(); void amendFilePath();
void stdError(const QString &line) override; void stdError(const QString &line) final;
void stdOutput(const QString &line) override; void stdOutput(const QString &line) final;
void doFlush() override; void doFlush() final;
ProjectExplorer::Task m_lastTask; ProjectExplorer::Task m_lastTask;
int m_lines = 0; int m_lines = 0;

View File

@@ -24,6 +24,7 @@
****************************************************************************/ ****************************************************************************/
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "iarewparser.h" #include "iarewparser.h"
#include "iarewtoolchain.h" #include "iarewtoolchain.h"

View File

@@ -53,40 +53,40 @@ class IarToolChain final : public ProjectExplorer::ToolChain
Q_DECLARE_TR_FUNCTIONS(IarToolChain) Q_DECLARE_TR_FUNCTIONS(IarToolChain)
public: public:
QString typeDisplayName() const override; QString typeDisplayName() const final;
void setTargetAbi(const ProjectExplorer::Abi &abi); void setTargetAbi(const ProjectExplorer::Abi &abi);
ProjectExplorer::Abi targetAbi() const override; ProjectExplorer::Abi targetAbi() const final;
bool isValid() const override; bool isValid() const final;
MacroInspectionRunner createMacroInspectionRunner() const override; MacroInspectionRunner createMacroInspectionRunner() const final;
ProjectExplorer::Macros predefinedMacros(const QStringList &cxxflags) const override; ProjectExplorer::Macros predefinedMacros(const QStringList &cxxflags) const final;
Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const override; Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const final;
ProjectExplorer::WarningFlags warningFlags(const QStringList &cxxflags) const override; ProjectExplorer::WarningFlags warningFlags(const QStringList &cxxflags) const final;
BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const override; BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const final;
ProjectExplorer::HeaderPaths builtInHeaderPaths(const QStringList &cxxFlags, ProjectExplorer::HeaderPaths builtInHeaderPaths(const QStringList &cxxFlags,
const Utils::FileName &) const override; const Utils::FileName &) const final;
void addToEnvironment(Utils::Environment &env) const override; void addToEnvironment(Utils::Environment &env) const final;
ProjectExplorer::IOutputParser *outputParser() const override; ProjectExplorer::IOutputParser *outputParser() const final;
QVariantMap toMap() const override; QVariantMap toMap() const final;
bool fromMap(const QVariantMap &data) override; bool fromMap(const QVariantMap &data) final;
std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() override; std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() final;
bool operator ==(const ToolChain &other) const override; bool operator ==(const ToolChain &other) const final;
void setCompilerCommand(const Utils::FileName &file); void setCompilerCommand(const Utils::FileName &file);
Utils::FileName compilerCommand() const override; Utils::FileName compilerCommand() const final;
QString makeCommand(const Utils::Environment &env) const override; QString makeCommand(const Utils::Environment &env) const final;
ToolChain *clone() const override; ToolChain *clone() const final;
void toolChainUpdated() override; void toolChainUpdated() final;
protected: protected:
IarToolChain(const IarToolChain &tc) = default; IarToolChain(const IarToolChain &tc) = default;
@@ -116,17 +116,17 @@ class IarToolChainFactory final : public ProjectExplorer::ToolChainFactory
Q_OBJECT Q_OBJECT
public: public:
IarToolChainFactory(); explicit IarToolChainFactory();
QSet<Core::Id> supportedLanguages() const override; QSet<Core::Id> supportedLanguages() const final;
QList<ProjectExplorer::ToolChain *> autoDetect( QList<ProjectExplorer::ToolChain *> autoDetect(
const QList<ProjectExplorer::ToolChain *> &alreadyKnown) override; const QList<ProjectExplorer::ToolChain *> &alreadyKnown) final;
bool canCreate() override; bool canCreate() final;
ProjectExplorer::ToolChain *create(Core::Id language) override; ProjectExplorer::ToolChain *create(Core::Id language) final;
bool canRestore(const QVariantMap &data) override; bool canRestore(const QVariantMap &data) final;
ProjectExplorer::ToolChain *restore(const QVariantMap &data) override; ProjectExplorer::ToolChain *restore(const QVariantMap &data) final;
private: private:
// File path + version. // File path + version.
@@ -149,10 +149,10 @@ public:
explicit IarToolChainConfigWidget(IarToolChain *tc); explicit IarToolChainConfigWidget(IarToolChain *tc);
private: private:
void applyImpl() override; void applyImpl() final;
void discardImpl() override { setFromToolchain(); } void discardImpl() final { setFromToolchain(); }
bool isDirtyImpl() const override; bool isDirtyImpl() const final;
void makeReadOnlyImpl() override; void makeReadOnlyImpl() final;
void setFromToolchain(); void setFromToolchain();
void handleCompilerCommandChange(); void handleCompilerCommandChange();

View File

@@ -38,6 +38,8 @@ using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// Helpers:
static Task::TaskType taskType(const QString &msgType) static Task::TaskType taskType(const QString &msgType)
{ {
if (msgType == "Warning" || msgType == "WARNING") { if (msgType == "Warning" || msgType == "WARNING") {
@@ -49,6 +51,8 @@ static Task::TaskType taskType(const QString &msgType)
return Task::TaskType::Unknown; return Task::TaskType::Unknown;
} }
// KeilParser
KeilParser::KeilParser() KeilParser::KeilParser()
{ {
setObjectName("KeilParser"); setObjectName("KeilParser");

View File

@@ -38,16 +38,16 @@ class KeilParser final : public ProjectExplorer::IOutputParser
Q_OBJECT Q_OBJECT
public: public:
KeilParser(); explicit KeilParser();
static Core::Id id(); static Core::Id id();
private: private:
void newTask(const ProjectExplorer::Task &task); void newTask(const ProjectExplorer::Task &task);
void amendDescription(const QString &desc); void amendDescription(const QString &desc);
void stdError(const QString &line) override; void stdError(const QString &line) final;
void stdOutput(const QString &line) override; void stdOutput(const QString &line) final;
void doFlush() override; void doFlush() final;
ProjectExplorer::Task m_lastTask; ProjectExplorer::Task m_lastTask;
int m_lines = 0; int m_lines = 0;

View File

@@ -24,6 +24,7 @@
****************************************************************************/ ****************************************************************************/
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "keilparser.h" #include "keilparser.h"
#include "keiltoolchain.h" #include "keiltoolchain.h"

View File

@@ -53,40 +53,40 @@ class KeilToolchain final : public ProjectExplorer::ToolChain
Q_DECLARE_TR_FUNCTIONS(KeilToolchain) Q_DECLARE_TR_FUNCTIONS(KeilToolchain)
public: public:
QString typeDisplayName() const override; QString typeDisplayName() const final;
void setTargetAbi(const ProjectExplorer::Abi &abi); void setTargetAbi(const ProjectExplorer::Abi &abi);
ProjectExplorer::Abi targetAbi() const override; ProjectExplorer::Abi targetAbi() const final;
bool isValid() const override; bool isValid() const final;
MacroInspectionRunner createMacroInspectionRunner() const override; MacroInspectionRunner createMacroInspectionRunner() const final;
ProjectExplorer::Macros predefinedMacros(const QStringList &cxxflags) const override; ProjectExplorer::Macros predefinedMacros(const QStringList &cxxflags) const final;
Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const override; Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const final;
ProjectExplorer::WarningFlags warningFlags(const QStringList &cxxflags) const override; ProjectExplorer::WarningFlags warningFlags(const QStringList &cxxflags) const final;
BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const override; BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const final;
ProjectExplorer::HeaderPaths builtInHeaderPaths(const QStringList &cxxFlags, ProjectExplorer::HeaderPaths builtInHeaderPaths(const QStringList &cxxFlags,
const Utils::FileName &) const override; const Utils::FileName &) const final;
void addToEnvironment(Utils::Environment &env) const override; void addToEnvironment(Utils::Environment &env) const final;
ProjectExplorer::IOutputParser *outputParser() const override; ProjectExplorer::IOutputParser *outputParser() const final;
QVariantMap toMap() const override; QVariantMap toMap() const final;
bool fromMap(const QVariantMap &data) override; bool fromMap(const QVariantMap &data) final;
std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() override; std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() final;
bool operator ==(const ToolChain &other) const override; bool operator ==(const ToolChain &other) const final;
void setCompilerCommand(const Utils::FileName &file); void setCompilerCommand(const Utils::FileName &file);
Utils::FileName compilerCommand() const override; Utils::FileName compilerCommand() const final;
QString makeCommand(const Utils::Environment &env) const override; QString makeCommand(const Utils::Environment &env) const final;
ToolChain *clone() const override; ToolChain *clone() const final;
void toolChainUpdated() override; void toolChainUpdated() final;
protected: protected:
KeilToolchain(const KeilToolchain &tc) = default; KeilToolchain(const KeilToolchain &tc) = default;
@@ -116,17 +116,17 @@ class KeilToolchainFactory final : public ProjectExplorer::ToolChainFactory
Q_OBJECT Q_OBJECT
public: public:
KeilToolchainFactory(); explicit KeilToolchainFactory();
QSet<Core::Id> supportedLanguages() const override; QSet<Core::Id> supportedLanguages() const final;
QList<ProjectExplorer::ToolChain *> autoDetect( QList<ProjectExplorer::ToolChain *> autoDetect(
const QList<ProjectExplorer::ToolChain *> &alreadyKnown) override; const QList<ProjectExplorer::ToolChain *> &alreadyKnown) final;
bool canCreate() override; bool canCreate() final;
ProjectExplorer::ToolChain *create(Core::Id language) override; ProjectExplorer::ToolChain *create(Core::Id language) final;
bool canRestore(const QVariantMap &data) override; bool canRestore(const QVariantMap &data) final;
ProjectExplorer::ToolChain *restore(const QVariantMap &data) override; ProjectExplorer::ToolChain *restore(const QVariantMap &data) final;
private: private:
// File path + version. // File path + version.
@@ -149,10 +149,10 @@ public:
explicit KeilToolchainConfigWidget(KeilToolchain *tc); explicit KeilToolchainConfigWidget(KeilToolchain *tc);
private: private:
void applyImpl() override; void applyImpl() final;
void discardImpl() override { setFromToolchain(); } void discardImpl() final { setFromToolchain(); }
bool isDirtyImpl() const override; bool isDirtyImpl() const final;
void makeReadOnlyImpl() override; void makeReadOnlyImpl() final;
void setFromToolchain(); void setFromToolchain();
void handleCompilerCommandChange(); void handleCompilerCommandChange();

View File

@@ -23,24 +23,24 @@
** **
****************************************************************************/ ****************************************************************************/
#include "openocdgdbserverprovider.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "gdbserverprovidermanager.h"
#include "gdbserverprovidermanager.h"
#include "openocdgdbserverprovider.h"
#include <utils/fileutils.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
#include <coreplugin/variablechooser.h> #include <coreplugin/variablechooser.h>
#include <QString> #include <QComboBox>
#include <QFileInfo> #include <QFileInfo>
#include <QFormLayout> #include <QFormLayout>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QString>
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
@@ -52,11 +52,10 @@ const char rootScriptsDirKeyC[] = "BareMetal.OpenOcdGdbServerProvider.RootScript
const char configurationFileKeyC[] = "BareMetal.OpenOcdGdbServerProvider.ConfigurationPath"; const char configurationFileKeyC[] = "BareMetal.OpenOcdGdbServerProvider.ConfigurationPath";
const char additionalArgumentsKeyC[] = "BareMetal.OpenOcdGdbServerProvider.AdditionalArguments"; const char additionalArgumentsKeyC[] = "BareMetal.OpenOcdGdbServerProvider.AdditionalArguments";
// OpenOcdGdbServerProvider
OpenOcdGdbServerProvider::OpenOcdGdbServerProvider() OpenOcdGdbServerProvider::OpenOcdGdbServerProvider()
: GdbServerProvider(QLatin1String(Constants::OPENOCD_PROVIDER_ID)) : GdbServerProvider(QLatin1String(Constants::OPENOCD_PROVIDER_ID))
, m_host(QLatin1String("localhost"))
, m_port(3333)
, m_executableFile(QLatin1String("openocd"))
{ {
setInitCommands(defaultInitCommands()); setInitCommands(defaultInitCommands());
setResetCommands(defaultResetCommands()); setResetCommands(defaultResetCommands());
@@ -212,6 +211,8 @@ GdbServerProviderConfigWidget *OpenOcdGdbServerProvider::configurationWidget()
return new OpenOcdGdbServerProviderConfigWidget(this); return new OpenOcdGdbServerProviderConfigWidget(this);
} }
// OpenOcdGdbServerProviderFactory
OpenOcdGdbServerProviderFactory::OpenOcdGdbServerProviderFactory() OpenOcdGdbServerProviderFactory::OpenOcdGdbServerProviderFactory()
{ {
setId(QLatin1String(Constants::OPENOCD_PROVIDER_ID)); setId(QLatin1String(Constants::OPENOCD_PROVIDER_ID));
@@ -232,7 +233,7 @@ bool OpenOcdGdbServerProviderFactory::canRestore(const QVariantMap &data) const
GdbServerProvider *OpenOcdGdbServerProviderFactory::restore(const QVariantMap &data) GdbServerProvider *OpenOcdGdbServerProviderFactory::restore(const QVariantMap &data)
{ {
auto p = new OpenOcdGdbServerProvider; const auto p = new OpenOcdGdbServerProvider;
auto updated = data; auto updated = data;
if (p->fromMap(updated)) if (p->fromMap(updated))
return p; return p;
@@ -240,6 +241,8 @@ GdbServerProvider *OpenOcdGdbServerProviderFactory::restore(const QVariantMap &d
return nullptr; return nullptr;
} }
// OpenOcdGdbServerProviderConfigWidget
OpenOcdGdbServerProviderConfigWidget::OpenOcdGdbServerProviderConfigWidget( OpenOcdGdbServerProviderConfigWidget::OpenOcdGdbServerProviderConfigWidget(
OpenOcdGdbServerProvider *p) OpenOcdGdbServerProvider *p)
: GdbServerProviderConfigWidget(p) : GdbServerProviderConfigWidget(p)
@@ -276,7 +279,7 @@ OpenOcdGdbServerProviderConfigWidget::OpenOcdGdbServerProviderConfigWidget(
addErrorLabel(); addErrorLabel();
setFromProvider(); setFromProvider();
auto chooser = new Core::VariableChooser(this); const auto chooser = new Core::VariableChooser(this);
chooser->addSupportedWidget(m_initCommandsTextEdit); chooser->addSupportedWidget(m_initCommandsTextEdit);
chooser->addSupportedWidget(m_resetCommandsTextEdit); chooser->addSupportedWidget(m_resetCommandsTextEdit);
@@ -318,7 +321,7 @@ void OpenOcdGdbServerProviderConfigWidget::startupModeChanged()
void OpenOcdGdbServerProviderConfigWidget::applyImpl() void OpenOcdGdbServerProviderConfigWidget::applyImpl()
{ {
auto p = static_cast<OpenOcdGdbServerProvider *>(provider()); const auto p = static_cast<OpenOcdGdbServerProvider *>(provider());
Q_ASSERT(p); Q_ASSERT(p);
p->m_host = m_hostWidget->host(); p->m_host = m_hostWidget->host();

View File

@@ -35,7 +35,9 @@ namespace Internal {
class OpenOcdGdbServerProviderConfigWidget; class OpenOcdGdbServerProviderConfigWidget;
class OpenOcdGdbServerProviderFactory; class OpenOcdGdbServerProviderFactory;
class OpenOcdGdbServerProvider : public GdbServerProvider // OpenOcdGdbServerProvider
class OpenOcdGdbServerProvider final : public GdbServerProvider
{ {
public: public:
QString typeDisplayName() const final; QString typeDisplayName() const final;
@@ -62,9 +64,9 @@ private:
static QString defaultInitCommands(); static QString defaultInitCommands();
static QString defaultResetCommands(); static QString defaultResetCommands();
QString m_host; QString m_host = QLatin1String("localhost");
quint16 m_port; quint16 m_port = 3333;
QString m_executableFile; QString m_executableFile = QLatin1String("openocd");
QString m_rootScriptsDir; QString m_rootScriptsDir;
QString m_configurationFile; QString m_configurationFile;
QString m_additionalArguments; QString m_additionalArguments;
@@ -73,7 +75,9 @@ private:
friend class OpenOcdGdbServerProviderFactory; friend class OpenOcdGdbServerProviderFactory;
}; };
class OpenOcdGdbServerProviderFactory : public GdbServerProviderFactory // OpenOcdGdbServerProviderFactory
class OpenOcdGdbServerProviderFactory final : public GdbServerProviderFactory
{ {
Q_OBJECT Q_OBJECT
@@ -88,7 +92,9 @@ public:
GdbServerProviderConfigWidget *configurationWidget(GdbServerProvider *); GdbServerProviderConfigWidget *configurationWidget(GdbServerProvider *);
}; };
class OpenOcdGdbServerProviderConfigWidget : public GdbServerProviderConfigWidget // OpenOcdGdbServerProviderConfigWidget
class OpenOcdGdbServerProviderConfigWidget final : public GdbServerProviderConfigWidget
{ {
Q_OBJECT Q_OBJECT
@@ -103,13 +109,13 @@ private:
void setFromProvider(); void setFromProvider();
HostWidget *m_hostWidget; HostWidget *m_hostWidget = nullptr;
Utils::PathChooser *m_executableFileChooser; Utils::PathChooser *m_executableFileChooser = nullptr;
Utils::PathChooser *m_rootScriptsDirChooser; Utils::PathChooser *m_rootScriptsDirChooser = nullptr;
Utils::PathChooser *m_configurationFileChooser; Utils::PathChooser *m_configurationFileChooser = nullptr;
QLineEdit *m_additionalArgumentsLineEdit; QLineEdit *m_additionalArgumentsLineEdit = nullptr;
QPlainTextEdit *m_initCommandsTextEdit; QPlainTextEdit *m_initCommandsTextEdit = nullptr;
QPlainTextEdit *m_resetCommandsTextEdit; QPlainTextEdit *m_resetCommandsTextEdit = nullptr;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -38,6 +38,8 @@ using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
// Helpers:
static Task::TaskType taskType(const QString &msgType) static Task::TaskType taskType(const QString &msgType)
{ {
if (msgType == "warning" || msgType == "Warning") { if (msgType == "warning" || msgType == "Warning") {
@@ -49,6 +51,8 @@ static Task::TaskType taskType(const QString &msgType)
return Task::TaskType::Unknown; return Task::TaskType::Unknown;
} }
// SdccParser
SdccParser::SdccParser() SdccParser::SdccParser()
{ {
setObjectName("SdccParser"); setObjectName("SdccParser");

View File

@@ -38,16 +38,16 @@ class SdccParser final : public ProjectExplorer::IOutputParser
Q_OBJECT Q_OBJECT
public: public:
SdccParser(); explicit SdccParser();
static Core::Id id(); static Core::Id id();
private: private:
void newTask(const ProjectExplorer::Task &task); void newTask(const ProjectExplorer::Task &task);
void amendDescription(const QString &desc); void amendDescription(const QString &desc);
void stdError(const QString &line) override; void stdError(const QString &line) final;
void stdOutput(const QString &line) override; void stdOutput(const QString &line) final;
void doFlush() override; void doFlush() final;
ProjectExplorer::Task m_lastTask; ProjectExplorer::Task m_lastTask;
int m_lines = 0; int m_lines = 0;

View File

@@ -24,6 +24,7 @@
****************************************************************************/ ****************************************************************************/
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "sdccparser.h" #include "sdccparser.h"
#include "sdcctoolchain.h" #include "sdcctoolchain.h"

View File

@@ -53,40 +53,40 @@ class SdccToolChain final : public ProjectExplorer::ToolChain
Q_DECLARE_TR_FUNCTIONS(SdccToolChain) Q_DECLARE_TR_FUNCTIONS(SdccToolChain)
public: public:
QString typeDisplayName() const override; QString typeDisplayName() const final;
void setTargetAbi(const ProjectExplorer::Abi &abi); void setTargetAbi(const ProjectExplorer::Abi &abi);
ProjectExplorer::Abi targetAbi() const override; ProjectExplorer::Abi targetAbi() const final;
bool isValid() const override; bool isValid() const final;
MacroInspectionRunner createMacroInspectionRunner() const override; MacroInspectionRunner createMacroInspectionRunner() const final;
ProjectExplorer::Macros predefinedMacros(const QStringList &cxxflags) const override; ProjectExplorer::Macros predefinedMacros(const QStringList &cxxflags) const final;
Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const override; Utils::LanguageExtensions languageExtensions(const QStringList &cxxflags) const final;
ProjectExplorer::WarningFlags warningFlags(const QStringList &cxxflags) const override; ProjectExplorer::WarningFlags warningFlags(const QStringList &cxxflags) const final;
BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const override; BuiltInHeaderPathsRunner createBuiltInHeaderPathsRunner() const final;
ProjectExplorer::HeaderPaths builtInHeaderPaths(const QStringList &cxxFlags, ProjectExplorer::HeaderPaths builtInHeaderPaths(const QStringList &cxxFlags,
const Utils::FileName &) const override; const Utils::FileName &) const final;
void addToEnvironment(Utils::Environment &env) const override; void addToEnvironment(Utils::Environment &env) const final;
ProjectExplorer::IOutputParser *outputParser() const override; ProjectExplorer::IOutputParser *outputParser() const final;
QVariantMap toMap() const override; QVariantMap toMap() const final;
bool fromMap(const QVariantMap &data) override; bool fromMap(const QVariantMap &data) final;
std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() override; std::unique_ptr<ProjectExplorer::ToolChainConfigWidget> createConfigurationWidget() final;
bool operator ==(const ToolChain &other) const override; bool operator ==(const ToolChain &other) const final;
void setCompilerCommand(const Utils::FileName &file); void setCompilerCommand(const Utils::FileName &file);
Utils::FileName compilerCommand() const override; Utils::FileName compilerCommand() const final;
QString makeCommand(const Utils::Environment &env) const override; QString makeCommand(const Utils::Environment &env) const final;
ToolChain *clone() const override; ToolChain *clone() const final;
void toolChainUpdated() override; void toolChainUpdated() final;
protected: protected:
SdccToolChain(const SdccToolChain &tc) = default; SdccToolChain(const SdccToolChain &tc) = default;
@@ -116,17 +116,17 @@ class SdccToolChainFactory final : public ProjectExplorer::ToolChainFactory
Q_OBJECT Q_OBJECT
public: public:
SdccToolChainFactory(); explicit SdccToolChainFactory();
QSet<Core::Id> supportedLanguages() const override; QSet<Core::Id> supportedLanguages() const final;
QList<ProjectExplorer::ToolChain *> autoDetect( QList<ProjectExplorer::ToolChain *> autoDetect(
const QList<ProjectExplorer::ToolChain *> &alreadyKnown) override; const QList<ProjectExplorer::ToolChain *> &alreadyKnown) final;
bool canCreate() override; bool canCreate() final;
ProjectExplorer::ToolChain *create(Core::Id language) override; ProjectExplorer::ToolChain *create(Core::Id language) final;
bool canRestore(const QVariantMap &data) override; bool canRestore(const QVariantMap &data) final;
ProjectExplorer::ToolChain *restore(const QVariantMap &data) override; ProjectExplorer::ToolChain *restore(const QVariantMap &data) final;
private: private:
// File path + version. // File path + version.
@@ -149,10 +149,10 @@ public:
explicit SdccToolChainConfigWidget(SdccToolChain *tc); explicit SdccToolChainConfigWidget(SdccToolChain *tc);
private: private:
void applyImpl() override; void applyImpl() final;
void discardImpl() override { setFromToolchain(); } void discardImpl() final { setFromToolchain(); }
bool isDirtyImpl() const override; bool isDirtyImpl() const final;
void makeReadOnlyImpl() override; void makeReadOnlyImpl() final;
void setFromToolchain(); void setFromToolchain();
void handleCompilerCommandChange(); void handleCompilerCommandChange();

View File

@@ -23,25 +23,25 @@
** **
****************************************************************************/ ****************************************************************************/
#include "stlinkutilgdbserverprovider.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "gdbserverprovidermanager.h"
#include "gdbserverprovidermanager.h"
#include "stlinkutilgdbserverprovider.h"
#include <utils/fileutils.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/fileutils.h>
#include <coreplugin/variablechooser.h> #include <coreplugin/variablechooser.h>
#include <QString> #include <QCheckBox>
#include <QComboBox>
#include <QFileInfo> #include <QFileInfo>
#include <QFormLayout> #include <QFormLayout>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox>
#include <QSpinBox>
#include <QCheckBox>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QSpinBox>
#include <QString>
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
@@ -54,15 +54,10 @@ const char extendedModeKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.ExtendedM
const char resetBoardKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.ResetBoard"; const char resetBoardKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.ResetBoard";
const char transportLayerKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.TransportLayer"; const char transportLayerKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.TransportLayer";
// StLinkUtilGdbServerProvider
StLinkUtilGdbServerProvider::StLinkUtilGdbServerProvider() StLinkUtilGdbServerProvider::StLinkUtilGdbServerProvider()
: GdbServerProvider(QLatin1String(Constants::STLINK_UTIL_PROVIDER_ID)) : GdbServerProvider(QLatin1String(Constants::STLINK_UTIL_PROVIDER_ID))
, m_host(QLatin1String("localhost"))
, m_port(4242)
, m_executableFile(QLatin1String("st-util"))
, m_verboseLevel(0)
, m_extendedMode(false)
, m_resetBoard(true)
, m_transport(RawUsb)
{ {
setInitCommands(defaultInitCommands()); setInitCommands(defaultInitCommands());
setResetCommands(defaultResetCommands()); setResetCommands(defaultResetCommands());
@@ -213,6 +208,8 @@ GdbServerProviderConfigWidget *StLinkUtilGdbServerProvider::configurationWidget(
return new StLinkUtilGdbServerProviderConfigWidget(this); return new StLinkUtilGdbServerProviderConfigWidget(this);
} }
// StLinkUtilGdbServerProviderFactory
StLinkUtilGdbServerProviderFactory::StLinkUtilGdbServerProviderFactory() StLinkUtilGdbServerProviderFactory::StLinkUtilGdbServerProviderFactory()
{ {
setId(QLatin1String(Constants::STLINK_UTIL_PROVIDER_ID)); setId(QLatin1String(Constants::STLINK_UTIL_PROVIDER_ID));
@@ -233,7 +230,7 @@ bool StLinkUtilGdbServerProviderFactory::canRestore(const QVariantMap &data) con
GdbServerProvider *StLinkUtilGdbServerProviderFactory::restore(const QVariantMap &data) GdbServerProvider *StLinkUtilGdbServerProviderFactory::restore(const QVariantMap &data)
{ {
auto p = new StLinkUtilGdbServerProvider; const auto p = new StLinkUtilGdbServerProvider;
auto updated = data; auto updated = data;
if (p->fromMap(updated)) if (p->fromMap(updated))
return p; return p;
@@ -241,6 +238,8 @@ GdbServerProvider *StLinkUtilGdbServerProviderFactory::restore(const QVariantMap
return nullptr; return nullptr;
} }
// StLinkUtilGdbServerProviderConfigWidget
StLinkUtilGdbServerProviderConfigWidget::StLinkUtilGdbServerProviderConfigWidget( StLinkUtilGdbServerProviderConfigWidget::StLinkUtilGdbServerProviderConfigWidget(
StLinkUtilGdbServerProvider *p) StLinkUtilGdbServerProvider *p)
: GdbServerProviderConfigWidget(p) : GdbServerProviderConfigWidget(p)
@@ -283,7 +282,7 @@ StLinkUtilGdbServerProviderConfigWidget::StLinkUtilGdbServerProviderConfigWidget
addErrorLabel(); addErrorLabel();
setFromProvider(); setFromProvider();
auto chooser = new Core::VariableChooser(this); const auto chooser = new Core::VariableChooser(this);
chooser->addSupportedWidget(m_initCommandsTextEdit); chooser->addSupportedWidget(m_initCommandsTextEdit);
chooser->addSupportedWidget(m_resetCommandsTextEdit); chooser->addSupportedWidget(m_resetCommandsTextEdit);
@@ -332,7 +331,7 @@ void StLinkUtilGdbServerProviderConfigWidget::startupModeChanged()
void StLinkUtilGdbServerProviderConfigWidget::applyImpl() void StLinkUtilGdbServerProviderConfigWidget::applyImpl()
{ {
auto p = static_cast<StLinkUtilGdbServerProvider *>(provider()); const auto p = static_cast<StLinkUtilGdbServerProvider *>(provider());
Q_ASSERT(p); Q_ASSERT(p);
p->m_host = m_hostWidget->host(); p->m_host = m_hostWidget->host();

View File

@@ -39,7 +39,9 @@ namespace Internal {
class StLinkUtilGdbServerProviderConfigWidget; class StLinkUtilGdbServerProviderConfigWidget;
class StLinkUtilGdbServerProviderFactory; class StLinkUtilGdbServerProviderFactory;
class StLinkUtilGdbServerProvider : public GdbServerProvider // StLinkUtilGdbServerProvider
class StLinkUtilGdbServerProvider final : public GdbServerProvider
{ {
public: public:
enum TransportLayer { ScsiOverUsb = 1, RawUsb = 2 }; enum TransportLayer { ScsiOverUsb = 1, RawUsb = 2 };
@@ -67,19 +69,21 @@ private:
static QString defaultInitCommands(); static QString defaultInitCommands();
static QString defaultResetCommands(); static QString defaultResetCommands();
QString m_host; QString m_host = QLatin1String("localhost");
quint16 m_port; quint16 m_port = 4242;
QString m_executableFile; QString m_executableFile = QLatin1String("st-util");
int m_verboseLevel; // 0..99 int m_verboseLevel = 0; // 0..99
bool m_extendedMode; // Listening for connections after disconnect bool m_extendedMode = false; // Listening for connections after disconnect
bool m_resetBoard; bool m_resetBoard = true;
TransportLayer m_transport; TransportLayer m_transport = RawUsb;
friend class StLinkUtilGdbServerProviderConfigWidget; friend class StLinkUtilGdbServerProviderConfigWidget;
friend class StLinkUtilGdbServerProviderFactory; friend class StLinkUtilGdbServerProviderFactory;
}; };
class StLinkUtilGdbServerProviderFactory : public GdbServerProviderFactory // StLinkUtilGdbServerProviderFactory
class StLinkUtilGdbServerProviderFactory final : public GdbServerProviderFactory
{ {
Q_OBJECT Q_OBJECT
@@ -94,7 +98,10 @@ public:
GdbServerProviderConfigWidget *configurationWidget(GdbServerProvider *); GdbServerProviderConfigWidget *configurationWidget(GdbServerProvider *);
}; };
class StLinkUtilGdbServerProviderConfigWidget : public GdbServerProviderConfigWidget // StLinkUtilGdbServerProviderConfigWidget
class StLinkUtilGdbServerProviderConfigWidget final
: public GdbServerProviderConfigWidget
{ {
Q_OBJECT Q_OBJECT
@@ -114,14 +121,14 @@ private:
void populateTransportLayers(); void populateTransportLayers();
void setFromProvider(); void setFromProvider();
HostWidget *m_hostWidget; HostWidget *m_hostWidget = nullptr;
Utils::PathChooser *m_executableFileChooser; Utils::PathChooser *m_executableFileChooser = nullptr;
QSpinBox *m_verboseLevelSpinBox; QSpinBox *m_verboseLevelSpinBox = nullptr;
QCheckBox *m_extendedModeCheckBox; QCheckBox *m_extendedModeCheckBox = nullptr;
QCheckBox *m_resetBoardCheckBox; QCheckBox *m_resetBoardCheckBox = nullptr;
QComboBox *m_transportLayerComboBox; QComboBox *m_transportLayerComboBox = nullptr;
QPlainTextEdit *m_initCommandsTextEdit; QPlainTextEdit *m_initCommandsTextEdit = nullptr;
QPlainTextEdit *m_resetCommandsTextEdit; QPlainTextEdit *m_resetCommandsTextEdit = nullptr;
}; };
} // namespace Internal } // namespace Internal