forked from qt-creator/qt-creator
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:
@@ -38,6 +38,7 @@
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace BareMetal {
|
||||
namespace Internal {
|
||||
|
||||
BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory(QObject *parent)
|
||||
: IDeviceFactory(parent)
|
||||
@@ -72,9 +73,10 @@ bool BareMetalDeviceConfigurationFactory::canRestore(const QVariantMap &map) con
|
||||
IDevice::Ptr BareMetalDeviceConfigurationFactory::restore(const QVariantMap &map) const
|
||||
{
|
||||
QTC_ASSERT(canRestore(map), return IDevice::Ptr());
|
||||
const IDevice::Ptr device = Internal::BareMetalDevice::create();
|
||||
const IDevice::Ptr device = BareMetalDevice::create();
|
||||
device->fromMap(map);
|
||||
return device;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace BareMetal
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <projectexplorer/devicesupport/idevicefactory.h>
|
||||
|
||||
namespace BareMetal {
|
||||
namespace Internal {
|
||||
|
||||
class BareMetalDeviceConfigurationFactory
|
||||
: public ProjectExplorer::IDeviceFactory
|
||||
@@ -50,5 +51,7 @@ public:
|
||||
ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace BareMetal
|
||||
|
||||
#endif // BAREMETALDEVICECONFIGURATIONFACTORY_H
|
||||
|
||||
@@ -37,50 +37,32 @@ using namespace ProjectExplorer;
|
||||
|
||||
namespace BareMetal {
|
||||
namespace Internal {
|
||||
namespace {
|
||||
|
||||
enum PageId { SetupPageId };
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
class BareMetalDeviceConfigrationWizardPrivate
|
||||
{
|
||||
public:
|
||||
BareMetalDeviceConfigrationWizardPrivate(QWidget *parent):
|
||||
m_setupPage(parent)
|
||||
{ }
|
||||
|
||||
BareMetalDeviceConfigurationWizardSetupPage m_setupPage;
|
||||
};
|
||||
|
||||
} //namespace Internal
|
||||
|
||||
BareMetalDeviceConfigurationWizard::BareMetalDeviceConfigurationWizard(QWidget *parent) :
|
||||
Utils::Wizard(parent),
|
||||
d(new Internal::BareMetalDeviceConfigrationWizardPrivate(this))
|
||||
m_setupPage(new BareMetalDeviceConfigurationWizardSetupPage(this))
|
||||
{
|
||||
setWindowTitle(tr("New Bare Metal Device Configuration Setup"));
|
||||
setPage(Internal::SetupPageId, &d->m_setupPage);
|
||||
d->m_setupPage.setCommitPage(true);
|
||||
}
|
||||
|
||||
BareMetalDeviceConfigurationWizard::~BareMetalDeviceConfigurationWizard()
|
||||
{
|
||||
delete d;
|
||||
setPage(SetupPageId, m_setupPage);
|
||||
m_setupPage->setCommitPage(true);
|
||||
}
|
||||
|
||||
IDevice::Ptr BareMetalDeviceConfigurationWizard::device() const
|
||||
{
|
||||
//sshParams is not really used as ssh parameters but as debugger parameters
|
||||
QSsh::SshConnectionParameters sshParams;
|
||||
sshParams.host = d->m_setupPage.gdbHostname();
|
||||
sshParams.port = d->m_setupPage.gdbPort();
|
||||
Internal::BareMetalDevice::Ptr device = Internal::BareMetalDevice::create(d->m_setupPage.configurationName(),
|
||||
Core::Id(Constants::BareMetalOsType),
|
||||
sshParams.host = m_setupPage->gdbHostname();
|
||||
sshParams.port = m_setupPage->gdbPort();
|
||||
BareMetalDevice::Ptr device = BareMetalDevice::create(m_setupPage->configurationName(),
|
||||
Constants::BareMetalOsType,
|
||||
IDevice::Hardware);
|
||||
device->setSshParameters(sshParams);
|
||||
device->setGdbResetCommands(d->m_setupPage.gdbResetCommands());
|
||||
device->setGdbInitCommands(d->m_setupPage.gdbInitCommands());
|
||||
device->setGdbResetCommands(m_setupPage->gdbResetCommands());
|
||||
device->setGdbInitCommands(m_setupPage->gdbInitCommands());
|
||||
return device;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace BareMetal
|
||||
|
||||
@@ -34,22 +34,24 @@
|
||||
#include <utils/wizard.h>
|
||||
|
||||
namespace BareMetal {
|
||||
namespace Internal { class BareMetalDeviceConfigrationWizardPrivate; }
|
||||
namespace Internal {
|
||||
|
||||
class BareMetalDeviceConfigurationWizardSetupPage;
|
||||
|
||||
class BareMetalDeviceConfigurationWizard : public Utils::Wizard
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BareMetalDeviceConfigurationWizard(QWidget *parent = 0);
|
||||
~BareMetalDeviceConfigurationWizard();
|
||||
|
||||
ProjectExplorer::IDevice::Ptr device() const;
|
||||
|
||||
private:
|
||||
Internal::BareMetalDeviceConfigrationWizardPrivate * const d;
|
||||
|
||||
BareMetalDeviceConfigurationWizardSetupPage *m_setupPage;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace BareMetal
|
||||
|
||||
#endif // BAREMETALDEVICECONFIGURATIONWIZARD_H
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
#include "baremetalgdbcommandsdeploystep.h"
|
||||
|
||||
#include <QFormLayout>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace BareMetal {
|
||||
@@ -62,8 +64,6 @@ QString BareMetalGdbCommandsDeployStepWidget::summaryText() const
|
||||
return displayName();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
BareMetalGdbCommandsDeployStep::BareMetalGdbCommandsDeployStep(BuildStepList *bsl,
|
||||
const Core::Id id)
|
||||
: BuildStep(bsl, id)
|
||||
@@ -97,20 +97,20 @@ bool BareMetalGdbCommandsDeployStep::fromMap(const QVariantMap &map)
|
||||
{
|
||||
if (!BuildStep::fromMap(map))
|
||||
return false;
|
||||
m_gdbCommands = map.value(QLatin1String(Internal::GdbCommandsKey)).toString();
|
||||
m_gdbCommands = map.value(QLatin1String(GdbCommandsKey)).toString();
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariantMap BareMetalGdbCommandsDeployStep::toMap() const
|
||||
{
|
||||
QVariantMap map = BuildStep::toMap();
|
||||
map.insert(QLatin1String(Internal::GdbCommandsKey),m_gdbCommands);
|
||||
map.insert(QLatin1String(GdbCommandsKey),m_gdbCommands);
|
||||
return map;
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStepConfigWidget *BareMetalGdbCommandsDeployStep::createConfigWidget()
|
||||
{
|
||||
return new Internal::BareMetalGdbCommandsDeployStepWidget(*this);
|
||||
return new BareMetalGdbCommandsDeployStepWidget(*this);
|
||||
}
|
||||
|
||||
Core::Id BareMetalGdbCommandsDeployStep::stepId()
|
||||
@@ -138,4 +138,5 @@ bool BareMetalGdbCommandsDeployStep::init()
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace BareMetal
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
#include <projectexplorer/buildstep.h>
|
||||
|
||||
#include <QVariantMap>
|
||||
#include <QFormLayout>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
namespace BareMetal {
|
||||
namespace Internal {
|
||||
|
||||
class BareMetalGdbCommandsDeployStep : public ProjectExplorer::BuildStep
|
||||
{
|
||||
@@ -68,21 +68,23 @@ private:
|
||||
QString m_gdbCommands;
|
||||
};
|
||||
|
||||
namespace Internal {
|
||||
|
||||
const char GdbCommandsKey[] = "BareMetal.GdbCommandsStep.Commands";
|
||||
|
||||
class BareMetalGdbCommandsDeployStepWidget: public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BareMetalGdbCommandsDeployStepWidget(BareMetal::BareMetalGdbCommandsDeployStep &step);
|
||||
explicit BareMetalGdbCommandsDeployStepWidget(BareMetalGdbCommandsDeployStep &step);
|
||||
|
||||
public slots:
|
||||
void update();
|
||||
|
||||
private:
|
||||
QString displayName() const;
|
||||
QString summaryText() const;
|
||||
BareMetal::BareMetalGdbCommandsDeployStep &m_step;
|
||||
|
||||
BareMetalGdbCommandsDeployStep &m_step;
|
||||
QPlainTextEdit *m_commands;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,36 +48,13 @@ const char ArgumentsKey[] = "Qt4ProjectManager.MaemoRunConfiguration.Arguments";
|
||||
const char ProFileKey[] = "Qt4ProjectManager.MaemoRunConfiguration.ProFile";
|
||||
const char WorkingDirectoryKey[] = "BareMetal.RunConfig.WorkingDirectory";
|
||||
|
||||
class BareMetalRunConfigurationPrivate
|
||||
{
|
||||
public:
|
||||
BareMetalRunConfigurationPrivate(const QString &projectFilePath)
|
||||
: projectFilePath(projectFilePath)
|
||||
{
|
||||
}
|
||||
|
||||
BareMetalRunConfigurationPrivate(const BareMetalRunConfigurationPrivate *other)
|
||||
: projectFilePath(other->projectFilePath),
|
||||
gdbPath(other->gdbPath),
|
||||
arguments(other->arguments),
|
||||
workingDirectory(other->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))
|
||||
BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent, BareMetalRunConfiguration *other)
|
||||
: RunConfiguration(parent, other),
|
||||
m_projectFilePath(other->m_projectFilePath),
|
||||
m_gdbPath(other->m_gdbPath),
|
||||
m_arguments(other->m_arguments),
|
||||
m_workingDirectory(other->m_workingDirectory)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -86,16 +63,11 @@ BareMetalRunConfiguration::BareMetalRunConfiguration(Target *parent,
|
||||
const Core::Id id,
|
||||
const QString &projectFilePath)
|
||||
: RunConfiguration(parent, id),
|
||||
d(new BareMetalRunConfigurationPrivate(projectFilePath))
|
||||
m_projectFilePath(projectFilePath)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
BareMetalRunConfiguration::~BareMetalRunConfiguration()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void BareMetalRunConfiguration::init()
|
||||
{
|
||||
setDefaultDisplayName(defaultDisplayName());
|
||||
@@ -108,13 +80,13 @@ void BareMetalRunConfiguration::init()
|
||||
|
||||
bool BareMetalRunConfiguration::isEnabled() const
|
||||
{
|
||||
d->disabledReason.clear();
|
||||
m_disabledReason.clear(); // FIXME: Check this makes sense.
|
||||
return true;
|
||||
}
|
||||
|
||||
QString BareMetalRunConfiguration::disabledReason() const
|
||||
{
|
||||
return d->disabledReason;
|
||||
return m_disabledReason;
|
||||
}
|
||||
|
||||
QWidget *BareMetalRunConfiguration::createConfigurationWidget()
|
||||
@@ -130,10 +102,10 @@ OutputFormatter *BareMetalRunConfiguration::createOutputFormatter() const
|
||||
QVariantMap BareMetalRunConfiguration::toMap() const
|
||||
{
|
||||
QVariantMap map(RunConfiguration::toMap());
|
||||
map.insert(QLatin1String(ArgumentsKey), d->arguments);
|
||||
map.insert(QLatin1String(ArgumentsKey), m_arguments);
|
||||
const QDir dir = QDir(target()->project()->projectDirectory().toString());
|
||||
map.insert(QLatin1String(ProFileKey), dir.relativeFilePath(d->projectFilePath));
|
||||
map.insert(QLatin1String(WorkingDirectoryKey), d->workingDirectory);
|
||||
map.insert(QLatin1String(ProFileKey), dir.relativeFilePath(m_projectFilePath));
|
||||
map.insert(QLatin1String(WorkingDirectoryKey), m_workingDirectory);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -142,11 +114,11 @@ bool BareMetalRunConfiguration::fromMap(const QVariantMap &map)
|
||||
if (!RunConfiguration::fromMap(map))
|
||||
return false;
|
||||
|
||||
d->arguments = map.value(QLatin1String(ArgumentsKey)).toString();
|
||||
m_arguments = map.value(QLatin1String(ArgumentsKey)).toString();
|
||||
const QDir dir = QDir(target()->project()->projectDirectory().toString());
|
||||
d->projectFilePath
|
||||
m_projectFilePath
|
||||
= 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());
|
||||
|
||||
@@ -155,9 +127,9 @@ bool BareMetalRunConfiguration::fromMap(const QVariantMap &map)
|
||||
|
||||
QString BareMetalRunConfiguration::defaultDisplayName()
|
||||
{
|
||||
if (!d->projectFilePath.isEmpty())
|
||||
if (!m_projectFilePath.isEmpty())
|
||||
//: %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
|
||||
return tr("Run on GDB server or hardware debugger");
|
||||
}
|
||||
@@ -165,37 +137,37 @@ QString BareMetalRunConfiguration::defaultDisplayName()
|
||||
QString BareMetalRunConfiguration::localExecutableFilePath() const
|
||||
{
|
||||
return target()->applicationTargets()
|
||||
.targetForProject(Utils::FileName::fromString(d->projectFilePath)).toString();
|
||||
.targetForProject(Utils::FileName::fromString(m_projectFilePath)).toString();
|
||||
}
|
||||
|
||||
QString BareMetalRunConfiguration::arguments() const
|
||||
{
|
||||
return d->arguments;
|
||||
return m_arguments;
|
||||
}
|
||||
|
||||
void BareMetalRunConfiguration::setArguments(const QString &args)
|
||||
{
|
||||
d->arguments = args;
|
||||
m_arguments = args;
|
||||
}
|
||||
|
||||
QString BareMetalRunConfiguration::workingDirectory() const
|
||||
{
|
||||
return d->workingDirectory;
|
||||
return m_workingDirectory;
|
||||
}
|
||||
|
||||
void BareMetalRunConfiguration::setWorkingDirectory(const QString &wd)
|
||||
{
|
||||
d->workingDirectory = wd;
|
||||
m_workingDirectory = wd;
|
||||
}
|
||||
|
||||
QString BareMetalRunConfiguration::projectFilePath() const
|
||||
{
|
||||
return d->projectFilePath;
|
||||
return m_projectFilePath;
|
||||
}
|
||||
|
||||
void BareMetalRunConfiguration::setDisabledReason(const QString &reason) const
|
||||
{
|
||||
d->disabledReason = reason;
|
||||
m_disabledReason = reason;
|
||||
}
|
||||
|
||||
void BareMetalRunConfiguration::handleBuildSystemDataUpdated()
|
||||
@@ -206,5 +178,6 @@ void BareMetalRunConfiguration::handleBuildSystemDataUpdated()
|
||||
|
||||
const char *BareMetalRunConfiguration::IdPrefix = "BareMetalRunConfiguration";
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace BareMetal
|
||||
|
||||
|
||||
@@ -32,25 +32,22 @@
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
namespace Utils { class PortList; }
|
||||
|
||||
namespace BareMetal {
|
||||
class BareMetalRunConfigurationWidget;
|
||||
namespace Internal {
|
||||
class BareMetalRunConfigurationPrivate;
|
||||
class BareMetalRunConfigurationFactory;
|
||||
} // namespace Internal
|
||||
|
||||
class BareMetalRunConfigurationWidget;
|
||||
|
||||
class BareMetalRunConfiguration : public ProjectExplorer::RunConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(BareMetalRunConfiguration)
|
||||
friend class Internal::BareMetalRunConfigurationFactory;
|
||||
|
||||
friend class BareMetalRunConfigurationFactory;
|
||||
friend class BareMetalRunConfigurationWidget;
|
||||
|
||||
public:
|
||||
explicit BareMetalRunConfiguration(ProjectExplorer::Target *parent, const Core::Id id,
|
||||
const QString &projectFilePath);
|
||||
~BareMetalRunConfiguration();
|
||||
|
||||
bool isEnabled() const;
|
||||
QString disabledReason() const;
|
||||
@@ -68,6 +65,7 @@ public:
|
||||
QString projectFilePath() const;
|
||||
|
||||
static const char *IdPrefix;
|
||||
|
||||
signals:
|
||||
void deploySpecsChanged();
|
||||
void targetInformationChanged() const;
|
||||
@@ -87,8 +85,14 @@ private slots:
|
||||
private:
|
||||
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
|
||||
|
||||
#endif // BAREMETALRUNCONFIGURATION_H
|
||||
|
||||
@@ -34,9 +34,11 @@
|
||||
|
||||
namespace BareMetal {
|
||||
namespace Internal {
|
||||
|
||||
class BareMetalRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BareMetalRunConfigurationFactory(QObject *parent = 0);
|
||||
~BareMetalRunConfigurationFactory();
|
||||
|
||||
@@ -38,13 +38,15 @@ class QVBoxLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace BareMetal {
|
||||
class BareMetalRunConfiguration;
|
||||
namespace Internal {
|
||||
|
||||
namespace Internal { class BareMetalRunConfigurationWidgetPrivate; }
|
||||
class BareMetalRunConfiguration;
|
||||
class BareMetalRunConfigurationWidgetPrivate;
|
||||
|
||||
class BareMetalRunConfigurationWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BareMetalRunConfigurationWidget(BareMetalRunConfiguration *runConfiguration,
|
||||
QWidget *parent = 0);
|
||||
@@ -62,8 +64,10 @@ private:
|
||||
void addGenericWidgets(QVBoxLayout *mainLayout);
|
||||
void setLabelText(QLabel &label, const QString ®ularText, const QString &errorText);
|
||||
|
||||
Internal::BareMetalRunConfigurationWidgetPrivate * const d;
|
||||
BareMetalRunConfigurationWidgetPrivate * const d;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace BareMetal
|
||||
|
||||
#endif // BAREMETALRUNCONFIGURATIONWIDGET_H
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace Internal {
|
||||
class BareMetalRunControlFactory : public ProjectExplorer::IRunControlFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BareMetalRunControlFactory(QObject *parent = 0);
|
||||
~BareMetalRunControlFactory();
|
||||
|
||||
Reference in New Issue
Block a user