BareMetal: Code cosmetics

Change-Id: Ib98280a5913649f26625761584bd40b20ae7a20f
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: Tim Sander <tim@krieglstein.org>
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hjk
2014-06-19 19:14:56 +02:00
parent 4ae01e973a
commit c12a74aa52
11 changed files with 88 additions and 112 deletions

View File

@@ -38,6 +38,7 @@
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal {
BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory(QObject *parent) BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory(QObject *parent)
: IDeviceFactory(parent) : IDeviceFactory(parent)
@@ -72,9 +73,10 @@ bool BareMetalDeviceConfigurationFactory::canRestore(const QVariantMap &map) con
IDevice::Ptr BareMetalDeviceConfigurationFactory::restore(const QVariantMap &map) const IDevice::Ptr BareMetalDeviceConfigurationFactory::restore(const QVariantMap &map) const
{ {
QTC_ASSERT(canRestore(map), return IDevice::Ptr()); QTC_ASSERT(canRestore(map), return IDevice::Ptr());
const IDevice::Ptr device = Internal::BareMetalDevice::create(); const IDevice::Ptr device = BareMetalDevice::create();
device->fromMap(map); device->fromMap(map);
return device; return device;
} }
} // namespace Internal
} // namespace BareMetal } // namespace BareMetal

View File

@@ -33,6 +33,7 @@
#include <projectexplorer/devicesupport/idevicefactory.h> #include <projectexplorer/devicesupport/idevicefactory.h>
namespace BareMetal { namespace BareMetal {
namespace Internal {
class BareMetalDeviceConfigurationFactory class BareMetalDeviceConfigurationFactory
: public ProjectExplorer::IDeviceFactory : public ProjectExplorer::IDeviceFactory
@@ -50,5 +51,7 @@ public:
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const; ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const;
}; };
} // namespace Internal
} // namespace BareMetal } // namespace BareMetal
#endif // BAREMETALDEVICECONFIGURATIONFACTORY_H #endif // BAREMETALDEVICECONFIGURATIONFACTORY_H

View File

@@ -37,50 +37,32 @@ using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
namespace {
enum PageId { SetupPageId }; enum PageId { SetupPageId };
} // anonymous namespace
class BareMetalDeviceConfigrationWizardPrivate
{
public:
BareMetalDeviceConfigrationWizardPrivate(QWidget *parent):
m_setupPage(parent)
{ }
BareMetalDeviceConfigurationWizardSetupPage m_setupPage;
};
} //namespace Internal
BareMetalDeviceConfigurationWizard::BareMetalDeviceConfigurationWizard(QWidget *parent) : BareMetalDeviceConfigurationWizard::BareMetalDeviceConfigurationWizard(QWidget *parent) :
Utils::Wizard(parent), Utils::Wizard(parent),
d(new Internal::BareMetalDeviceConfigrationWizardPrivate(this)) m_setupPage(new BareMetalDeviceConfigurationWizardSetupPage(this))
{ {
setWindowTitle(tr("New Bare Metal Device Configuration Setup")); setWindowTitle(tr("New Bare Metal Device Configuration Setup"));
setPage(Internal::SetupPageId, &d->m_setupPage); setPage(SetupPageId, m_setupPage);
d->m_setupPage.setCommitPage(true); m_setupPage->setCommitPage(true);
}
BareMetalDeviceConfigurationWizard::~BareMetalDeviceConfigurationWizard()
{
delete d;
} }
IDevice::Ptr BareMetalDeviceConfigurationWizard::device() const IDevice::Ptr BareMetalDeviceConfigurationWizard::device() const
{ {
//sshParams is not really used as ssh parameters but as debugger parameters //sshParams is not really used as ssh parameters but as debugger parameters
QSsh::SshConnectionParameters sshParams; QSsh::SshConnectionParameters sshParams;
sshParams.host = d->m_setupPage.gdbHostname(); sshParams.host = m_setupPage->gdbHostname();
sshParams.port = d->m_setupPage.gdbPort(); sshParams.port = m_setupPage->gdbPort();
Internal::BareMetalDevice::Ptr device = Internal::BareMetalDevice::create(d->m_setupPage.configurationName(), BareMetalDevice::Ptr device = BareMetalDevice::create(m_setupPage->configurationName(),
Core::Id(Constants::BareMetalOsType), Constants::BareMetalOsType,
IDevice::Hardware); IDevice::Hardware);
device->setSshParameters(sshParams); device->setSshParameters(sshParams);
device->setGdbResetCommands(d->m_setupPage.gdbResetCommands()); device->setGdbResetCommands(m_setupPage->gdbResetCommands());
device->setGdbInitCommands(d->m_setupPage.gdbInitCommands()); device->setGdbInitCommands(m_setupPage->gdbInitCommands());
return device; return device;
} }
} //namespace BareMetal } // namespace Internal
} // namespace BareMetal

View File

@@ -34,22 +34,24 @@
#include <utils/wizard.h> #include <utils/wizard.h>
namespace BareMetal { namespace BareMetal {
namespace Internal { class BareMetalDeviceConfigrationWizardPrivate; } namespace Internal {
class BareMetalDeviceConfigurationWizardSetupPage;
class BareMetalDeviceConfigurationWizard : public Utils::Wizard class BareMetalDeviceConfigurationWizard : public Utils::Wizard
{ {
Q_OBJECT Q_OBJECT
public: public:
BareMetalDeviceConfigurationWizard(QWidget *parent = 0); BareMetalDeviceConfigurationWizard(QWidget *parent = 0);
~BareMetalDeviceConfigurationWizard();
ProjectExplorer::IDevice::Ptr device() const; ProjectExplorer::IDevice::Ptr device() const;
private: private:
Internal::BareMetalDeviceConfigrationWizardPrivate * const d; BareMetalDeviceConfigurationWizardSetupPage *m_setupPage;
}; };
} //namespace BareMetal } // namespace Internal
} // namespace BareMetal
#endif // BAREMETALDEVICECONFIGURATIONWIZARD_H #endif // BAREMETALDEVICECONFIGURATIONWIZARD_H

View File

@@ -29,6 +29,8 @@
#include "baremetalgdbcommandsdeploystep.h" #include "baremetalgdbcommandsdeploystep.h"
#include <QFormLayout>
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace BareMetal { namespace BareMetal {
@@ -62,8 +64,6 @@ QString BareMetalGdbCommandsDeployStepWidget::summaryText() const
return displayName(); return displayName();
} }
} // namespace Internal
BareMetalGdbCommandsDeployStep::BareMetalGdbCommandsDeployStep(BuildStepList *bsl, BareMetalGdbCommandsDeployStep::BareMetalGdbCommandsDeployStep(BuildStepList *bsl,
const Core::Id id) const Core::Id id)
: BuildStep(bsl, id) : BuildStep(bsl, id)
@@ -97,20 +97,20 @@ bool BareMetalGdbCommandsDeployStep::fromMap(const QVariantMap &map)
{ {
if (!BuildStep::fromMap(map)) if (!BuildStep::fromMap(map))
return false; return false;
m_gdbCommands = map.value(QLatin1String(Internal::GdbCommandsKey)).toString(); m_gdbCommands = map.value(QLatin1String(GdbCommandsKey)).toString();
return true; return true;
} }
QVariantMap BareMetalGdbCommandsDeployStep::toMap() const QVariantMap BareMetalGdbCommandsDeployStep::toMap() const
{ {
QVariantMap map = BuildStep::toMap(); QVariantMap map = BuildStep::toMap();
map.insert(QLatin1String(Internal::GdbCommandsKey),m_gdbCommands); map.insert(QLatin1String(GdbCommandsKey),m_gdbCommands);
return map; return map;
} }
ProjectExplorer::BuildStepConfigWidget *BareMetalGdbCommandsDeployStep::createConfigWidget() ProjectExplorer::BuildStepConfigWidget *BareMetalGdbCommandsDeployStep::createConfigWidget()
{ {
return new Internal::BareMetalGdbCommandsDeployStepWidget(*this); return new BareMetalGdbCommandsDeployStepWidget(*this);
} }
Core::Id BareMetalGdbCommandsDeployStep::stepId() Core::Id BareMetalGdbCommandsDeployStep::stepId()
@@ -138,4 +138,5 @@ bool BareMetalGdbCommandsDeployStep::init()
return true; return true;
} }
} // namespace Internal
} // namespace BareMetal } // namespace BareMetal

View File

@@ -33,10 +33,10 @@
#include <projectexplorer/buildstep.h> #include <projectexplorer/buildstep.h>
#include <QVariantMap> #include <QVariantMap>
#include <QFormLayout>
#include <QPlainTextEdit> #include <QPlainTextEdit>
namespace BareMetal { namespace BareMetal {
namespace Internal {
class BareMetalGdbCommandsDeployStep : public ProjectExplorer::BuildStep class BareMetalGdbCommandsDeployStep : public ProjectExplorer::BuildStep
{ {
@@ -68,21 +68,23 @@ private:
QString m_gdbCommands; QString m_gdbCommands;
}; };
namespace Internal {
const char GdbCommandsKey[] = "BareMetal.GdbCommandsStep.Commands"; const char GdbCommandsKey[] = "BareMetal.GdbCommandsStep.Commands";
class BareMetalGdbCommandsDeployStepWidget: public ProjectExplorer::BuildStepConfigWidget class BareMetalGdbCommandsDeployStepWidget: public ProjectExplorer::BuildStepConfigWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BareMetalGdbCommandsDeployStepWidget(BareMetal::BareMetalGdbCommandsDeployStep &step); explicit BareMetalGdbCommandsDeployStepWidget(BareMetalGdbCommandsDeployStep &step);
public slots: public slots:
void update(); void update();
private: private:
QString displayName() const; QString displayName() const;
QString summaryText() const; QString summaryText() const;
BareMetal::BareMetalGdbCommandsDeployStep &m_step;
BareMetalGdbCommandsDeployStep &m_step;
QPlainTextEdit *m_commands; QPlainTextEdit *m_commands;
}; };

View File

@@ -48,36 +48,13 @@ const char ArgumentsKey[] = "Qt4ProjectManager.MaemoRunConfiguration.Arguments";
const char ProFileKey[] = "Qt4ProjectManager.MaemoRunConfiguration.ProFile"; const char ProFileKey[] = "Qt4ProjectManager.MaemoRunConfiguration.ProFile";
const char WorkingDirectoryKey[] = "BareMetal.RunConfig.WorkingDirectory"; const char WorkingDirectoryKey[] = "BareMetal.RunConfig.WorkingDirectory";
class BareMetalRunConfigurationPrivate
{
public:
BareMetalRunConfigurationPrivate(const QString &projectFilePath)
: projectFilePath(projectFilePath)
{
}
BareMetalRunConfigurationPrivate(const BareMetalRunConfigurationPrivate *other) BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent, BareMetalRunConfiguration *other)
: projectFilePath(other->projectFilePath), : RunConfiguration(parent, other),
gdbPath(other->gdbPath), m_projectFilePath(other->m_projectFilePath),
arguments(other->arguments), m_gdbPath(other->m_gdbPath),
workingDirectory(other->workingDirectory) m_arguments(other->m_arguments),
{ m_workingDirectory(other->m_workingDirectory)
}
QString projectFilePath;
QString gdbPath;
QString arguments;
QString disabledReason;
QString workingDirectory;
};
} // namespace Internal
using namespace Internal;
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent, BareMetalRunConfiguration *source)
: RunConfiguration(parent, source),
d(new BareMetalRunConfigurationPrivate(source->d))
{ {
init(); init();
} }
@@ -85,17 +62,12 @@ BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent, BareMetalRu
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent, BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent,
const Core::Id id, const Core::Id id,
const QString &projectFilePath) const QString &projectFilePath)
: RunConfiguration(parent,id), : RunConfiguration(parent, id),
d(new BareMetalRunConfigurationPrivate(projectFilePath)) m_projectFilePath(projectFilePath)
{ {
init(); init();
} }
BareMetalRunConfiguration::~BareMetalRunConfiguration()
{
delete d;
}
void BareMetalRunConfiguration::init() void BareMetalRunConfiguration::init()
{ {
setDefaultDisplayName(defaultDisplayName()); setDefaultDisplayName(defaultDisplayName());
@@ -108,13 +80,13 @@ void BareMetalRunConfiguration::init()
bool BareMetalRunConfiguration::isEnabled() const bool BareMetalRunConfiguration::isEnabled() const
{ {
d->disabledReason.clear(); m_disabledReason.clear(); // FIXME: Check this makes sense.
return true; return true;
} }
QString BareMetalRunConfiguration::disabledReason() const QString BareMetalRunConfiguration::disabledReason() const
{ {
return d->disabledReason; return m_disabledReason;
} }
QWidget *BareMetalRunConfiguration::createConfigurationWidget() QWidget *BareMetalRunConfiguration::createConfigurationWidget()
@@ -130,10 +102,10 @@ OutputFormatter *BareMetalRunConfiguration::createOutputFormatter() const
QVariantMap BareMetalRunConfiguration::toMap() const QVariantMap BareMetalRunConfiguration::toMap() const
{ {
QVariantMap map(RunConfiguration::toMap()); QVariantMap map(RunConfiguration::toMap());
map.insert(QLatin1String(ArgumentsKey), d->arguments); map.insert(QLatin1String(ArgumentsKey), m_arguments);
const QDir dir = QDir(target()->project()->projectDirectory().toString()); const QDir dir = QDir(target()->project()->projectDirectory().toString());
map.insert(QLatin1String(ProFileKey), dir.relativeFilePath(d->projectFilePath)); map.insert(QLatin1String(ProFileKey), dir.relativeFilePath(m_projectFilePath));
map.insert(QLatin1String(WorkingDirectoryKey), d->workingDirectory); map.insert(QLatin1String(WorkingDirectoryKey), m_workingDirectory);
return map; return map;
} }
@@ -142,11 +114,11 @@ bool BareMetalRunConfiguration::fromMap(const QVariantMap &map)
if (!RunConfiguration::fromMap(map)) if (!RunConfiguration::fromMap(map))
return false; return false;
d->arguments = map.value(QLatin1String(ArgumentsKey)).toString(); m_arguments = map.value(QLatin1String(ArgumentsKey)).toString();
const QDir dir = QDir(target()->project()->projectDirectory().toString()); const QDir dir = QDir(target()->project()->projectDirectory().toString());
d->projectFilePath m_projectFilePath
= QDir::cleanPath(dir.filePath(map.value(QLatin1String(ProFileKey)).toString())); = QDir::cleanPath(dir.filePath(map.value(QLatin1String(ProFileKey)).toString()));
d->workingDirectory = map.value(QLatin1String(WorkingDirectoryKey)).toString(); m_workingDirectory = map.value(QLatin1String(WorkingDirectoryKey)).toString();
setDefaultDisplayName(defaultDisplayName()); setDefaultDisplayName(defaultDisplayName());
@@ -155,9 +127,9 @@ bool BareMetalRunConfiguration::fromMap(const QVariantMap &map)
QString BareMetalRunConfiguration::defaultDisplayName() QString BareMetalRunConfiguration::defaultDisplayName()
{ {
if (!d->projectFilePath.isEmpty()) if (!m_projectFilePath.isEmpty())
//: %1 is the name of the project run via hardware debugger //: %1 is the name of the project run via hardware debugger
return tr("%1 (via GDB server or hardware debugger)").arg(QFileInfo(d->projectFilePath).completeBaseName()); return tr("%1 (via GDB server or hardware debugger)").arg(QFileInfo(m_projectFilePath).completeBaseName());
//: Bare Metal run configuration default run name //: Bare Metal run configuration default run name
return tr("Run on GDB server or hardware debugger"); return tr("Run on GDB server or hardware debugger");
} }
@@ -165,37 +137,37 @@ QString BareMetalRunConfiguration::defaultDisplayName()
QString BareMetalRunConfiguration::localExecutableFilePath() const QString BareMetalRunConfiguration::localExecutableFilePath() const
{ {
return target()->applicationTargets() return target()->applicationTargets()
.targetForProject(Utils::FileName::fromString(d->projectFilePath)).toString(); .targetForProject(Utils::FileName::fromString(m_projectFilePath)).toString();
} }
QString BareMetalRunConfiguration::arguments() const QString BareMetalRunConfiguration::arguments() const
{ {
return d->arguments; return m_arguments;
} }
void BareMetalRunConfiguration::setArguments(const QString &args) void BareMetalRunConfiguration::setArguments(const QString &args)
{ {
d->arguments = args; m_arguments = args;
} }
QString BareMetalRunConfiguration::workingDirectory() const QString BareMetalRunConfiguration::workingDirectory() const
{ {
return d->workingDirectory; return m_workingDirectory;
} }
void BareMetalRunConfiguration::setWorkingDirectory(const QString &wd) void BareMetalRunConfiguration::setWorkingDirectory(const QString &wd)
{ {
d->workingDirectory = wd; m_workingDirectory = wd;
} }
QString BareMetalRunConfiguration::projectFilePath() const QString BareMetalRunConfiguration::projectFilePath() const
{ {
return d->projectFilePath; return m_projectFilePath;
} }
void BareMetalRunConfiguration::setDisabledReason(const QString &reason) const void BareMetalRunConfiguration::setDisabledReason(const QString &reason) const
{ {
d->disabledReason = reason; m_disabledReason = reason;
} }
void BareMetalRunConfiguration::handleBuildSystemDataUpdated() void BareMetalRunConfiguration::handleBuildSystemDataUpdated()
@@ -206,5 +178,6 @@ void BareMetalRunConfiguration::handleBuildSystemDataUpdated()
const char *BareMetalRunConfiguration::IdPrefix = "BareMetalRunConfiguration"; const char *BareMetalRunConfiguration::IdPrefix = "BareMetalRunConfiguration";
} // namespace Internal
} // namespace BareMetal } // namespace BareMetal

View File

@@ -32,25 +32,22 @@
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
namespace Utils { class PortList; }
namespace BareMetal { namespace BareMetal {
class BareMetalRunConfigurationWidget;
namespace Internal { namespace Internal {
class BareMetalRunConfigurationPrivate;
class BareMetalRunConfigurationFactory; class BareMetalRunConfigurationWidget;
} // namespace Internal
class BareMetalRunConfiguration : public ProjectExplorer::RunConfiguration class BareMetalRunConfiguration : public ProjectExplorer::RunConfiguration
{ {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(BareMetalRunConfiguration) Q_DISABLE_COPY(BareMetalRunConfiguration)
friend class Internal::BareMetalRunConfigurationFactory;
friend class BareMetalRunConfigurationFactory;
friend class BareMetalRunConfigurationWidget; friend class BareMetalRunConfigurationWidget;
public: public:
explicit BareMetalRunConfiguration(ProjectExplorer::Target *parent, const Core::Id id, explicit BareMetalRunConfiguration(ProjectExplorer::Target *parent, const Core::Id id,
const QString &projectFilePath); const QString &projectFilePath);
~BareMetalRunConfiguration();
bool isEnabled() const; bool isEnabled() const;
QString disabledReason() const; QString disabledReason() const;
@@ -68,6 +65,7 @@ public:
QString projectFilePath() const; QString projectFilePath() const;
static const char *IdPrefix; static const char *IdPrefix;
signals: signals:
void deploySpecsChanged(); void deploySpecsChanged();
void targetInformationChanged() const; void targetInformationChanged() const;
@@ -87,8 +85,14 @@ private slots:
private: private:
void init(); void init();
Internal::BareMetalRunConfigurationPrivate * const d; QString m_projectFilePath;
QString m_gdbPath;
QString m_arguments;
mutable QString m_disabledReason;
QString m_workingDirectory;
}; };
} // namespace Internal
} // namespace BareMetal } // namespace BareMetal
#endif // BAREMETALRUNCONFIGURATION_H #endif // BAREMETALRUNCONFIGURATION_H

View File

@@ -34,9 +34,11 @@
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
class BareMetalRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory class BareMetalRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BareMetalRunConfigurationFactory(QObject *parent = 0); explicit BareMetalRunConfigurationFactory(QObject *parent = 0);
~BareMetalRunConfigurationFactory(); ~BareMetalRunConfigurationFactory();

View File

@@ -38,13 +38,15 @@ class QVBoxLayout;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace BareMetal { namespace BareMetal {
class BareMetalRunConfiguration; namespace Internal {
namespace Internal { class BareMetalRunConfigurationWidgetPrivate; } class BareMetalRunConfiguration;
class BareMetalRunConfigurationWidgetPrivate;
class BareMetalRunConfigurationWidget : public QWidget class BareMetalRunConfigurationWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BareMetalRunConfigurationWidget(BareMetalRunConfiguration *runConfiguration, explicit BareMetalRunConfigurationWidget(BareMetalRunConfiguration *runConfiguration,
QWidget *parent = 0); QWidget *parent = 0);
@@ -62,8 +64,10 @@ private:
void addGenericWidgets(QVBoxLayout *mainLayout); void addGenericWidgets(QVBoxLayout *mainLayout);
void setLabelText(QLabel &label, const QString &regularText, const QString &errorText); void setLabelText(QLabel &label, const QString &regularText, const QString &errorText);
Internal::BareMetalRunConfigurationWidgetPrivate * const d; BareMetalRunConfigurationWidgetPrivate * const d;
}; };
} // namespace Internal
} // namespace BareMetal } // namespace BareMetal
#endif // BAREMETALRUNCONFIGURATIONWIDGET_H #endif // BAREMETALRUNCONFIGURATIONWIDGET_H

View File

@@ -42,6 +42,7 @@ namespace Internal {
class BareMetalRunControlFactory : public ProjectExplorer::IRunControlFactory class BareMetalRunControlFactory : public ProjectExplorer::IRunControlFactory
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BareMetalRunControlFactory(QObject *parent = 0); explicit BareMetalRunControlFactory(QObject *parent = 0);
~BareMetalRunControlFactory(); ~BareMetalRunControlFactory();