forked from qt-creator/qt-creator
ProjectExplorer: Use setter for IDevice::machineType
First step towards streamlining the IDevice::ctor/create lines of functions. Change-Id: I44226f8a05902cadd40c8820ab67752070d186c0 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -47,11 +47,11 @@ namespace Internal {
|
||||
|
||||
AndroidDevice::AndroidDevice()
|
||||
: IDevice(Core::Id(Constants::ANDROID_DEVICE_TYPE),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Hardware,
|
||||
Core::Id(Constants::ANDROID_DEVICE_ID))
|
||||
IDevice::AutoDetected,
|
||||
Core::Id(Constants::ANDROID_DEVICE_ID))
|
||||
{
|
||||
setDisplayName(QCoreApplication::translate("Android::Internal::AndroidDevice", "Run on Android"));
|
||||
setMachineType(IDevice::Hardware);
|
||||
setDeviceState(DeviceReadyToUse);
|
||||
QString activityPath;
|
||||
const AndroidConfig &config = AndroidConfigurations::currentConfig();
|
||||
|
||||
@@ -49,9 +49,9 @@ BareMetalDevice::Ptr BareMetalDevice::create()
|
||||
return Ptr(new BareMetalDevice);
|
||||
}
|
||||
|
||||
BareMetalDevice::Ptr BareMetalDevice::create(const QString &name, Core::Id type, MachineType machineType, Origin origin, Core::Id id)
|
||||
BareMetalDevice::Ptr BareMetalDevice::create(const QString &name, Core::Id type, Origin origin, Core::Id id)
|
||||
{
|
||||
return Ptr(new BareMetalDevice(name, type, machineType, origin, id));
|
||||
return Ptr(new BareMetalDevice(name, type, origin, id));
|
||||
}
|
||||
|
||||
BareMetalDevice::Ptr BareMetalDevice::create(const BareMetalDevice &other)
|
||||
@@ -169,8 +169,8 @@ DeviceProcess *BareMetalDevice::createProcess(QObject *parent) const
|
||||
return new GdbServerProviderProcess(sharedFromThis(), parent);
|
||||
}
|
||||
|
||||
BareMetalDevice::BareMetalDevice(const QString &name, Core::Id type, MachineType machineType, Origin origin, Core::Id id)
|
||||
: IDevice(type, origin, machineType, id)
|
||||
BareMetalDevice::BareMetalDevice(const QString &name, Core::Id type, Origin origin, Core::Id id)
|
||||
: IDevice(type, origin, id)
|
||||
{
|
||||
setDisplayName(name);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
using ConstPtr = QSharedPointer<const BareMetalDevice>;
|
||||
|
||||
static Ptr create();
|
||||
static Ptr create(const QString &name, Core::Id type, MachineType machineType,
|
||||
static Ptr create(const QString &name, Core::Id type,
|
||||
Origin origin = ManuallyAdded, Core::Id id = Core::Id());
|
||||
static Ptr create(const BareMetalDevice &other);
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
protected:
|
||||
BareMetalDevice() = default;
|
||||
BareMetalDevice(const QString &name, Core::Id type,
|
||||
MachineType machineType, Origin origin, Core::Id id);
|
||||
Origin origin, Core::Id id);
|
||||
BareMetalDevice(const BareMetalDevice &other);
|
||||
|
||||
private:
|
||||
|
||||
@@ -46,9 +46,8 @@ BareMetalDeviceConfigurationWizard::BareMetalDeviceConfigurationWizard(QWidget *
|
||||
ProjectExplorer::IDevice::Ptr BareMetalDeviceConfigurationWizard::device() const
|
||||
{
|
||||
auto dev = BareMetalDevice::create(m_setupPage->configurationName(),
|
||||
Constants::BareMetalOsType,
|
||||
ProjectExplorer::IDevice::Hardware);
|
||||
|
||||
Constants::BareMetalOsType);
|
||||
dev->setMachineType(ProjectExplorer::IDevice::Hardware);
|
||||
dev->setGdbServerProviderId(m_setupPage->gdbServerProviderId());
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -81,11 +81,11 @@ namespace Internal {
|
||||
IosDevice::IosDevice()
|
||||
: IDevice(Core::Id(Constants::IOS_DEVICE_TYPE),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Hardware,
|
||||
Constants::IOS_DEVICE_ID),
|
||||
m_lastPort(Constants::IOS_DEVICE_PORT_START)
|
||||
{
|
||||
setDisplayName(IosDevice::name());
|
||||
setMachineType(IDevice::Hardware);
|
||||
setDeviceState(DeviceDisconnected);
|
||||
Utils::PortList ports;
|
||||
ports.addRange(Utils::Port(Constants::IOS_DEVICE_PORT_START),
|
||||
@@ -98,11 +98,11 @@ IosDevice::IosDevice(const IosDevice &other) = default;
|
||||
IosDevice::IosDevice(const QString &uid)
|
||||
: IDevice(Core::Id(Constants::IOS_DEVICE_TYPE),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Hardware,
|
||||
Core::Id(Constants::IOS_DEVICE_ID).withSuffix(uid)),
|
||||
m_lastPort(Constants::IOS_DEVICE_PORT_START)
|
||||
{
|
||||
setDisplayName(IosDevice::name());
|
||||
setMachineType(IDevice::Hardware);
|
||||
setDeviceState(DeviceDisconnected);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,21 +47,21 @@ static const QLatin1String iosDeviceTypeIdentifierKey = QLatin1String("identifie
|
||||
IosSimulator::IosSimulator(Core::Id id)
|
||||
: IDevice(Core::Id(Constants::IOS_SIMULATOR_TYPE),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Emulator,
|
||||
id),
|
||||
m_lastPort(Constants::IOS_SIMULATOR_PORT_START)
|
||||
{
|
||||
setMachineType(IDevice::Emulator);
|
||||
setDisplayName(QCoreApplication::translate("Ios::Internal::IosSimulator", "iOS Simulator"));
|
||||
setDeviceState(DeviceReadyToUse);
|
||||
}
|
||||
|
||||
IosSimulator::IosSimulator()
|
||||
: IDevice(Core::Id(Constants::IOS_SIMULATOR_TYPE),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Emulator,
|
||||
Core::Id(Constants::IOS_SIMULATOR_DEVICE_ID)),
|
||||
IDevice::AutoDetected,
|
||||
Core::Id(Constants::IOS_SIMULATOR_DEVICE_ID)),
|
||||
m_lastPort(Constants::IOS_SIMULATOR_PORT_START)
|
||||
{
|
||||
setMachineType(IDevice::Emulator);
|
||||
setDisplayName(QCoreApplication::translate("Ios::Internal::IosSimulator", "iOS Simulator"));
|
||||
setDeviceState(DeviceReadyToUse);
|
||||
}
|
||||
|
||||
@@ -50,11 +50,11 @@ namespace ProjectExplorer {
|
||||
|
||||
DesktopDevice::DesktopDevice() : IDevice(Core::Id(DESKTOP_DEVICE_TYPE),
|
||||
IDevice::AutoDetected,
|
||||
IDevice::Hardware,
|
||||
Core::Id(DESKTOP_DEVICE_ID))
|
||||
{
|
||||
setDisplayName(QCoreApplication::translate("ProjectExplorer::DesktopDevice", "Local PC"));
|
||||
setDeviceState(IDevice::DeviceStateUnknown);
|
||||
setMachineType(IDevice::Hardware);
|
||||
const QString portRange =
|
||||
QString::fromLatin1("%1-%2").arg(DESKTOP_PORT_START).arg(DESKTOP_PORT_END);
|
||||
setFreePorts(Utils::PortList::fromString(portRange));
|
||||
|
||||
@@ -406,7 +406,10 @@ class TestDevice : public IDevice
|
||||
{
|
||||
public:
|
||||
TestDevice()
|
||||
: IDevice(testTypeId(), AutoDetected, Hardware, Core::Id::fromString(QUuid::createUuid().toString())) {}
|
||||
: IDevice(testTypeId(), AutoDetected, Core::Id::fromString(QUuid::createUuid().toString()))
|
||||
{
|
||||
setMachineType(Hardware);
|
||||
}
|
||||
|
||||
static Core::Id testTypeId() { return "TestType"; }
|
||||
private:
|
||||
|
||||
@@ -161,12 +161,11 @@ IDevice::IDevice() : d(new Internal::IDevicePrivate)
|
||||
{
|
||||
}
|
||||
|
||||
IDevice::IDevice(Core::Id type, Origin origin, MachineType machineType, Core::Id id)
|
||||
IDevice::IDevice(Core::Id type, Origin origin, Core::Id id)
|
||||
: d(std::make_unique<Internal::IDevicePrivate>())
|
||||
{
|
||||
d->type = type;
|
||||
d->origin = origin;
|
||||
d->machineType = machineType;
|
||||
QTC_CHECK(origin == ManuallyAdded || id.isValid());
|
||||
d->id = id.isValid() ? id : newId();
|
||||
}
|
||||
@@ -438,6 +437,11 @@ IDevice::MachineType IDevice::machineType() const
|
||||
return d->machineType;
|
||||
}
|
||||
|
||||
void IDevice::setMachineType(MachineType machineType)
|
||||
{
|
||||
d->machineType = machineType;
|
||||
}
|
||||
|
||||
QString IDevice::debugServerPath() const
|
||||
{
|
||||
return d->debugServerPath;
|
||||
|
||||
@@ -203,6 +203,7 @@ public:
|
||||
void setFreePorts(const Utils::PortList &freePorts);
|
||||
|
||||
MachineType machineType() const;
|
||||
void setMachineType(MachineType machineType);
|
||||
|
||||
QString debugServerPath() const;
|
||||
void setDebugServerPath(const QString &path);
|
||||
@@ -215,7 +216,7 @@ public:
|
||||
|
||||
protected:
|
||||
IDevice();
|
||||
IDevice(Core::Id type, Origin origin, MachineType machineType, Core::Id id = Core::Id());
|
||||
IDevice(Core::Id type, Origin origin, Core::Id id = Core::Id());
|
||||
IDevice(const IDevice &other);
|
||||
|
||||
private:
|
||||
|
||||
@@ -82,8 +82,8 @@ QnxDevice::QnxDevice()
|
||||
init();
|
||||
}
|
||||
|
||||
QnxDevice::QnxDevice(const QString &name, Core::Id type, MachineType machineType, Origin origin, Core::Id id)
|
||||
: RemoteLinux::LinuxDevice(name, type, machineType, origin, id)
|
||||
QnxDevice::QnxDevice(const QString &name, Core::Id type, Origin origin, Core::Id id)
|
||||
: RemoteLinux::LinuxDevice(name, type, origin, id)
|
||||
{
|
||||
init();
|
||||
}
|
||||
@@ -103,9 +103,9 @@ QnxDevice::Ptr QnxDevice::create()
|
||||
return Ptr(new QnxDevice);
|
||||
}
|
||||
|
||||
QnxDevice::Ptr QnxDevice::create(const QString &name, Core::Id type, MachineType machineType, Origin origin, Core::Id id)
|
||||
QnxDevice::Ptr QnxDevice::create(const QString &name, Core::Id type, Origin origin, Core::Id id)
|
||||
{
|
||||
return Ptr(new QnxDevice(name, type, machineType, origin, id));
|
||||
return Ptr(new QnxDevice(name, type, origin, id));
|
||||
}
|
||||
|
||||
QString QnxDevice::displayType() const
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
using ConstPtr = QSharedPointer<const QnxDevice>;
|
||||
|
||||
static Ptr create();
|
||||
static Ptr create(const QString &name, Core::Id type, MachineType machineType,
|
||||
static Ptr create(const QString &name, Core::Id type,
|
||||
Origin origin = ManuallyAdded, Core::Id id = Core::Id());
|
||||
ProjectExplorer::IDevice::Ptr clone() const override;
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
protected:
|
||||
QnxDevice();
|
||||
QnxDevice(const QString &name, Core::Id type, MachineType machineType,
|
||||
QnxDevice(const QString &name, Core::Id type,
|
||||
Origin origin, Core::Id id);
|
||||
QnxDevice(const QnxDevice &other);
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ QnxDeviceWizard::QnxDeviceWizard(QWidget *parent) :
|
||||
m_finalPage->setCommitPage(true);
|
||||
QSsh::SshConnectionParameters sshParams;
|
||||
sshParams.timeout = 10;
|
||||
m_device = QnxDevice::create(tr("QNX Device"), Core::Id(Constants::QNX_QNX_OS_TYPE),
|
||||
IDevice::Hardware);
|
||||
m_device = QnxDevice::create(tr("QNX Device"), Core::Id(Constants::QNX_QNX_OS_TYPE));
|
||||
m_device->setMachineType(IDevice::Hardware);
|
||||
m_device->setSshParameters(sshParams);
|
||||
m_device->setFreePorts(Utils::PortList::fromString(QLatin1String("10000-10100")));
|
||||
m_setupPage->setDevice(m_device);
|
||||
|
||||
@@ -63,7 +63,8 @@ GenericLinuxDeviceConfigurationWizard::GenericLinuxDeviceConfigurationWizard(QWi
|
||||
setPage(Internal::FinalPageId, &d->finalPage);
|
||||
d->finalPage.setCommitPage(true);
|
||||
d->device = LinuxDevice::create(tr("Generic Linux Device"),
|
||||
Core::Id(Constants::GenericLinuxOsType), IDevice::Hardware);
|
||||
Core::Id(Constants::GenericLinuxOsType));
|
||||
d->device->setMachineType(IDevice::Hardware);
|
||||
d->device->setFreePorts(Utils::PortList::fromString(QLatin1String("10000-10100")));
|
||||
SshConnectionParameters sshParams;
|
||||
sshParams.timeout = 10;
|
||||
|
||||
@@ -166,10 +166,9 @@ class LinuxPortsGatheringMethod : public PortsGatheringMethod
|
||||
};
|
||||
|
||||
|
||||
LinuxDevice::Ptr LinuxDevice::create(const QString &name,
|
||||
Core::Id type, MachineType machineType, Origin origin, Core::Id id)
|
||||
LinuxDevice::Ptr LinuxDevice::create(const QString &name, Core::Id type, Origin origin, Core::Id id)
|
||||
{
|
||||
return Ptr(new LinuxDevice(name, type, machineType, origin, id));
|
||||
return Ptr(new LinuxDevice(name, type, origin, id));
|
||||
}
|
||||
|
||||
QString LinuxDevice::displayType() const
|
||||
@@ -187,9 +186,8 @@ Utils::OsType LinuxDevice::osType() const
|
||||
return Utils::OsTypeLinux;
|
||||
}
|
||||
|
||||
LinuxDevice::LinuxDevice(const QString &name, Core::Id type, MachineType machineType,
|
||||
Origin origin, Core::Id id)
|
||||
: IDevice(type, origin, machineType, id)
|
||||
LinuxDevice::LinuxDevice(const QString &name, Core::Id type, Origin origin, Core::Id id)
|
||||
: IDevice(type, origin, id)
|
||||
{
|
||||
setDisplayName(name);
|
||||
init();
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
using ConstPtr = QSharedPointer<const LinuxDevice>;
|
||||
|
||||
static Ptr create();
|
||||
static Ptr create(const QString &name, Core::Id type, MachineType machineType,
|
||||
static Ptr create(const QString &name, Core::Id type,
|
||||
Origin origin = ManuallyAdded, Core::Id id = Core::Id());
|
||||
|
||||
QString displayType() const override;
|
||||
@@ -67,8 +67,7 @@ public:
|
||||
|
||||
protected:
|
||||
LinuxDevice() { init(); }
|
||||
LinuxDevice(const QString &name, Core::Id type,
|
||||
MachineType machineType, Origin origin, Core::Id id);
|
||||
LinuxDevice(const QString &name, Core::Id type, Origin origin, Core::Id id);
|
||||
LinuxDevice(const LinuxDevice &other);
|
||||
|
||||
private:
|
||||
|
||||
@@ -47,8 +47,8 @@ WinRtDevice::WinRtDevice()
|
||||
initFreePorts();
|
||||
}
|
||||
|
||||
WinRtDevice::WinRtDevice(Core::Id type, MachineType machineType, Core::Id internalId, int deviceId)
|
||||
: IDevice(type, AutoDetected, machineType, internalId), m_deviceId(deviceId)
|
||||
WinRtDevice::WinRtDevice(Core::Id type, Core::Id internalId, int deviceId)
|
||||
: IDevice(type, AutoDetected, internalId), m_deviceId(deviceId)
|
||||
{
|
||||
initFreePorts();
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
|
||||
protected:
|
||||
WinRtDevice();
|
||||
WinRtDevice(Core::Id type, MachineType machineType, Core::Id internalId, int deviceId);
|
||||
WinRtDevice(Core::Id type, Core::Id internalId, int deviceId);
|
||||
WinRtDevice(const WinRtDevice &other);
|
||||
|
||||
private:
|
||||
|
||||
@@ -281,8 +281,8 @@ void WinRtDeviceFactory::parseRunnerOutput(const QByteArray &output) const
|
||||
continue;
|
||||
}
|
||||
|
||||
WinRtDevice *device = new WinRtDevice(deviceType, machineType,
|
||||
internalId, deviceId);
|
||||
WinRtDevice *device = new WinRtDevice(deviceType, internalId, deviceId);
|
||||
device->setMachineType(machineType);
|
||||
device->setDisplayName(name);
|
||||
deviceManager->addDevice(ProjectExplorer::IDevice::ConstPtr(device));
|
||||
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Added device" << name << "(internal name:"
|
||||
|
||||
Reference in New Issue
Block a user