forked from qt-creator/qt-creator
ProjectExplorer: Base IDevice::osType on a data member
Change-Id: I969563e6e62895a51fb4692c8eb0bab278f0ecae Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -53,6 +53,8 @@ AndroidDevice::AndroidDevice()
|
||||
"Run on Android"));
|
||||
setDisplayType(QCoreApplication::translate("Android::Internal::AndroidDevice", "Android"));
|
||||
setMachineType(IDevice::Hardware);
|
||||
setOsType(Utils::OsTypeOtherUnix);
|
||||
|
||||
setDeviceState(DeviceReadyToUse);
|
||||
QString activityPath;
|
||||
const AndroidConfig &config = AndroidConfigurations::currentConfig();
|
||||
@@ -82,11 +84,6 @@ DeviceProcessSignalOperation::Ptr AndroidDevice::signalOperation() const
|
||||
return DeviceProcessSignalOperation::Ptr(new AndroidSignalOperation());
|
||||
}
|
||||
|
||||
Utils::OsType AndroidDevice::osType() const
|
||||
{
|
||||
return Utils::OsTypeOtherUnix;
|
||||
}
|
||||
|
||||
QUrl AndroidDevice::toolControlChannel(const ControlChannelHint &) const
|
||||
{
|
||||
QUrl url;
|
||||
|
@@ -34,7 +34,7 @@ namespace Internal {
|
||||
class AndroidDevice : public ProjectExplorer::IDevice
|
||||
{
|
||||
public:
|
||||
static IDevice::Ptr create() { return IDevice::Ptr(new AndroidDevice); };
|
||||
static IDevice::Ptr create() { return IDevice::Ptr(new AndroidDevice); }
|
||||
|
||||
private:
|
||||
AndroidDevice();
|
||||
@@ -44,7 +44,6 @@ private:
|
||||
ProjectExplorer::IDeviceWidget *createWidget() override;
|
||||
bool canAutoDetectPorts() const override;
|
||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||
Utils::OsType osType() const override;
|
||||
|
||||
QUrl toolControlChannel(const ControlChannelHint &) const override;
|
||||
};
|
||||
|
@@ -54,6 +54,7 @@ BareMetalDevice::BareMetalDevice()
|
||||
{
|
||||
setDisplayType(QCoreApplication::translate("BareMetal::Internal::BareMetalDevice", "Bare Metal"));
|
||||
setDefaultDisplayName(defaultDisplayName());
|
||||
setOsType(Utils::OsTypeOther);
|
||||
}
|
||||
|
||||
BareMetalDevice::~BareMetalDevice()
|
||||
@@ -150,11 +151,6 @@ IDeviceWidget *BareMetalDevice::createWidget()
|
||||
return new BareMetalDeviceConfigurationWidget(sharedFromThis());
|
||||
}
|
||||
|
||||
Utils::OsType BareMetalDevice::osType() const
|
||||
{
|
||||
return Utils::OsTypeOther;
|
||||
}
|
||||
|
||||
DeviceProcess *BareMetalDevice::createProcess(QObject *parent) const
|
||||
{
|
||||
return new GdbServerProviderProcess(sharedFromThis(), parent);
|
||||
|
@@ -48,7 +48,6 @@ public:
|
||||
static QString defaultDisplayName();
|
||||
|
||||
ProjectExplorer::IDeviceWidget *createWidget() final;
|
||||
Utils::OsType osType() const final;
|
||||
|
||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const final;
|
||||
|
||||
|
@@ -86,6 +86,7 @@ IosDevice::IosDevice()
|
||||
setDefaultDisplayName(IosDevice::name());
|
||||
setDisplayType(QCoreApplication::translate("Ios::Internal::IosDevice", "iOS"));
|
||||
setMachineType(IDevice::Hardware);
|
||||
setOsType(Utils::OsTypeMac);
|
||||
setDeviceState(DeviceDisconnected);
|
||||
Utils::PortList ports;
|
||||
ports.addRange(Utils::Port(Constants::IOS_DEVICE_PORT_START),
|
||||
@@ -101,6 +102,7 @@ IosDevice::IosDevice(const QString &uid)
|
||||
setDefaultDisplayName(IosDevice::name());
|
||||
setDisplayType(QCoreApplication::translate("Ios::Internal::IosDevice", "iOS"));
|
||||
setMachineType(IDevice::Hardware);
|
||||
setOsType(Utils::OsTypeMac);
|
||||
setDeviceState(DeviceDisconnected);
|
||||
}
|
||||
|
||||
@@ -174,11 +176,6 @@ bool IosDevice::canAutoDetectPorts() const
|
||||
return true;
|
||||
}
|
||||
|
||||
Utils::OsType IosDevice::osType() const
|
||||
{
|
||||
return Utils::OsTypeMac;
|
||||
}
|
||||
|
||||
|
||||
// IosDeviceManager
|
||||
|
||||
|
@@ -59,7 +59,6 @@ public:
|
||||
QString osVersion() const;
|
||||
Utils::Port nextPort() const;
|
||||
bool canAutoDetectPorts() const override;
|
||||
Utils::OsType osType() const override;
|
||||
|
||||
static QString name();
|
||||
|
||||
|
@@ -50,6 +50,7 @@ IosSimulator::IosSimulator(Core::Id id)
|
||||
setupId(IDevice::AutoDetected, id);
|
||||
setType(Constants::IOS_SIMULATOR_TYPE);
|
||||
setMachineType(IDevice::Emulator);
|
||||
setOsType(Utils::OsTypeMac);
|
||||
setDefaultDisplayName(QCoreApplication::translate("Ios::Internal::IosSimulator",
|
||||
"iOS Simulator"));
|
||||
setDisplayType(QCoreApplication::translate("Ios::Internal::IosSimulator", "iOS Simulator"));
|
||||
@@ -102,11 +103,6 @@ bool IosSimulator::canAutoDetectPorts() const
|
||||
return true;
|
||||
}
|
||||
|
||||
Utils::OsType IosSimulator::osType() const
|
||||
{
|
||||
return Utils::OsTypeMac;
|
||||
}
|
||||
|
||||
// IosDeviceType
|
||||
|
||||
IosDeviceType::IosDeviceType(IosDeviceType::Type type, const QString &identifier, const QString &displayName) :
|
||||
|
@@ -73,7 +73,6 @@ public:
|
||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||
Utils::Port nextPort() const;
|
||||
bool canAutoDetectPorts() const override;
|
||||
Utils::OsType osType() const override;
|
||||
|
||||
protected:
|
||||
friend class IosSimulatorFactory;
|
||||
|
@@ -60,6 +60,8 @@ DesktopDevice::DesktopDevice()
|
||||
|
||||
setDeviceState(IDevice::DeviceStateUnknown);
|
||||
setMachineType(IDevice::Hardware);
|
||||
setOsType(HostOsInfo::hostOs());
|
||||
|
||||
const QString portRange =
|
||||
QString::fromLatin1("%1-%2").arg(DESKTOP_PORT_START).arg(DESKTOP_PORT_END);
|
||||
setFreePorts(Utils::PortList::fromString(portRange));
|
||||
@@ -173,9 +175,4 @@ QUrl DesktopDevice::toolControlChannel(const ControlChannelHint &) const
|
||||
return url;
|
||||
}
|
||||
|
||||
Utils::OsType DesktopDevice::osType() const
|
||||
{
|
||||
return Utils::HostOsInfo::hostOs();
|
||||
}
|
||||
|
||||
} // namespace ProjectExplorer
|
||||
|
@@ -50,7 +50,6 @@ public:
|
||||
DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||
DeviceEnvironmentFetcher::Ptr environmentFetcher() const override;
|
||||
QUrl toolControlChannel(const ControlChannelHint &) const override;
|
||||
Utils::OsType osType() const override;
|
||||
|
||||
protected:
|
||||
DesktopDevice();
|
||||
|
@@ -47,6 +47,8 @@
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace ProjectExplorer {
|
||||
namespace Internal {
|
||||
|
||||
@@ -410,6 +412,7 @@ public:
|
||||
setupId(AutoDetected, Core::Id::fromString(QUuid::createUuid().toString()));
|
||||
setType(testTypeId());
|
||||
setMachineType(Hardware);
|
||||
setOsType(HostOsInfo::hostOs());
|
||||
setDisplayType("blubb");
|
||||
}
|
||||
|
||||
@@ -420,7 +423,6 @@ private:
|
||||
{
|
||||
return DeviceProcessSignalOperation::Ptr();
|
||||
}
|
||||
Utils::OsType osType() const override { return Utils::HostOsInfo::hostOs(); }
|
||||
};
|
||||
|
||||
class TestDeviceFactory : public IDeviceFactory
|
||||
|
@@ -146,6 +146,7 @@ public:
|
||||
Core::Id id;
|
||||
IDevice::DeviceState deviceState = IDevice::DeviceStateUnknown;
|
||||
IDevice::MachineType machineType = IDevice::Hardware;
|
||||
Utils::OsType osType = Utils::OsTypeOther;
|
||||
int version = 0; // This is used by devices that have been added by the SDK.
|
||||
|
||||
QSsh::SshConnectionParameters sshParameters;
|
||||
@@ -221,6 +222,11 @@ void IDevice::setDisplayType(const QString &type)
|
||||
d->displayType = type;
|
||||
}
|
||||
|
||||
void IDevice::setOsType(Utils::OsType osType)
|
||||
{
|
||||
d->osType = osType;
|
||||
}
|
||||
|
||||
IDevice::DeviceInfo IDevice::deviceInformation() const
|
||||
{
|
||||
const QString key = QCoreApplication::translate("ProjectExplorer::IDevice", "Device");
|
||||
@@ -310,7 +316,7 @@ DeviceTester *IDevice::createDeviceTester() const
|
||||
|
||||
Utils::OsType IDevice::osType() const
|
||||
{
|
||||
return Utils::OsTypeOther;
|
||||
return d->osType;
|
||||
}
|
||||
|
||||
DeviceProcess *IDevice::createProcess(QObject * /* parent */) const
|
||||
@@ -434,6 +440,10 @@ IDevice::Ptr IDevice::clone() const
|
||||
device->d->deviceState = d->deviceState;
|
||||
device->d->deviceActions = d->deviceActions;
|
||||
device->d->deviceIcons = d->deviceIcons;
|
||||
// Os type is only set in the constructor, always to the same value.
|
||||
// But make sure we notice if that changes in the future (which it shouldn't).
|
||||
QTC_CHECK(device->d->osType == d->osType);
|
||||
device->d->osType = d->osType;
|
||||
device->fromMap(toMap());
|
||||
return device;
|
||||
}
|
||||
|
@@ -157,6 +157,7 @@ public:
|
||||
virtual bool isCompatibleWith(const Kit *k) const;
|
||||
|
||||
QString displayType() const;
|
||||
Utils::OsType osType() const;
|
||||
|
||||
virtual IDeviceWidget *createWidget() = 0;
|
||||
|
||||
@@ -175,7 +176,6 @@ public:
|
||||
virtual DeviceProcessList *createProcessListModel(QObject *parent = nullptr) const;
|
||||
virtual bool hasDeviceTester() const { return false; }
|
||||
virtual DeviceTester *createDeviceTester() const;
|
||||
virtual Utils::OsType osType() const;
|
||||
|
||||
virtual bool canCreateProcess() const { return false; }
|
||||
virtual DeviceProcess *createProcess(QObject *parent) const;
|
||||
@@ -233,6 +233,7 @@ protected:
|
||||
using OpenTerminal = std::function<void(const Utils::Environment &, const QString &)>;
|
||||
void setOpenTerminal(const OpenTerminal &openTerminal);
|
||||
void setDisplayType(const QString &type);
|
||||
void setOsType(Utils::OsType osType);
|
||||
|
||||
private:
|
||||
IDevice(const IDevice &) = delete;
|
||||
|
@@ -84,17 +84,14 @@ QnxDevice::QnxDevice()
|
||||
{
|
||||
setDisplayType(tr("QNX"));
|
||||
setDefaultDisplayName(tr("QNX Device"));
|
||||
setOsType(OsTypeOtherUnix);
|
||||
|
||||
addDeviceAction({tr("Deploy Qt libraries..."), [](const IDevice::Ptr &device, QWidget *parent) {
|
||||
QnxDeployQtLibrariesDialog dialog(device, parent);
|
||||
dialog.exec();
|
||||
}});
|
||||
}
|
||||
|
||||
OsType QnxDevice::osType() const
|
||||
{
|
||||
return OsTypeOtherUnix;
|
||||
}
|
||||
|
||||
int QnxDevice::qnxVersion() const
|
||||
{
|
||||
if (m_versionNumber == 0)
|
||||
|
@@ -49,8 +49,6 @@ public:
|
||||
ProjectExplorer::DeviceTester *createDeviceTester() const override;
|
||||
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const override;
|
||||
|
||||
Utils::OsType osType() const override;
|
||||
|
||||
int qnxVersion() const;
|
||||
|
||||
void fromMap(const QVariantMap &map) override;
|
||||
|
@@ -178,15 +178,12 @@ IDeviceWidget *LinuxDevice::createWidget()
|
||||
return new GenericLinuxDeviceConfigurationWidget(sharedFromThis());
|
||||
}
|
||||
|
||||
Utils::OsType LinuxDevice::osType() const
|
||||
{
|
||||
return Utils::OsTypeLinux;
|
||||
}
|
||||
|
||||
LinuxDevice::LinuxDevice()
|
||||
{
|
||||
setDisplayType(tr("Generic Linux"));
|
||||
setDefaultDisplayName(tr("Generic Linux Device"));
|
||||
setOsType(OsTypeLinux);
|
||||
|
||||
addDeviceAction({tr("Deploy Public Key..."), [](const IDevice::Ptr &device, QWidget *parent) {
|
||||
if (auto d = PublicKeyDeploymentDialog::createDialog(device, parent)) {
|
||||
d->exec();
|
||||
|
@@ -45,7 +45,6 @@ public:
|
||||
static Ptr create() { return Ptr(new LinuxDevice); }
|
||||
|
||||
ProjectExplorer::IDeviceWidget *createWidget() override;
|
||||
Utils::OsType osType() const override;
|
||||
|
||||
bool canCreateProcess() const override { return true; }
|
||||
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const override;
|
||||
|
@@ -44,6 +44,7 @@ WebAssemblyDevice::WebAssemblyDevice()
|
||||
setDisplayType(displayNameAndType);
|
||||
setDeviceState(IDevice::DeviceStateUnknown);
|
||||
setMachineType(IDevice::Hardware);
|
||||
setOsType(OsTypeOther);
|
||||
}
|
||||
|
||||
ProjectExplorer::IDevice::Ptr WebAssemblyDevice::create()
|
||||
@@ -52,12 +53,6 @@ ProjectExplorer::IDevice::Ptr WebAssemblyDevice::create()
|
||||
return ProjectExplorer::IDevice::Ptr(device);
|
||||
}
|
||||
|
||||
Utils::OsType WebAssemblyDevice::osType() const
|
||||
{
|
||||
return Utils::OsTypeOther;
|
||||
}
|
||||
|
||||
|
||||
WebAssemblyDeviceFactory::WebAssemblyDeviceFactory()
|
||||
: ProjectExplorer::IDeviceFactory(Constants::WEBASSEMBLY_DEVICE_TYPE)
|
||||
{
|
||||
|
@@ -39,8 +39,6 @@ class WebAssemblyDevice : public ProjectExplorer::DesktopDevice
|
||||
public:
|
||||
static ProjectExplorer::IDevice::Ptr create();
|
||||
|
||||
Utils::OsType osType() const override;
|
||||
|
||||
private:
|
||||
WebAssemblyDevice();
|
||||
};
|
||||
|
@@ -61,6 +61,8 @@ Q_LOGGING_CATEGORY(winrtDeviceLog, "qtc.winrt.deviceParser", QtWarningMsg)
|
||||
WinRtDevice::WinRtDevice()
|
||||
{
|
||||
setDisplayType(displayNameForType(type()));
|
||||
setOsType(OsTypeWindows);
|
||||
|
||||
Utils::PortList portList;
|
||||
portList.addRange(Utils::Port(ProjectExplorer::Constants::DESKTOP_PORT_START),
|
||||
Utils::Port(ProjectExplorer::Constants::DESKTOP_PORT_END));
|
||||
@@ -97,11 +99,6 @@ QVariantMap WinRtDevice::toMap() const
|
||||
return map;
|
||||
}
|
||||
|
||||
Utils::OsType WinRtDevice::osType() const
|
||||
{
|
||||
return Utils::OsTypeWindows;
|
||||
}
|
||||
|
||||
QString WinRtDevice::displayNameForType(Core::Id type)
|
||||
{
|
||||
if (type == Constants::WINRT_DEVICE_TYPE_LOCAL)
|
||||
|
@@ -45,7 +45,6 @@ public:
|
||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||
void fromMap(const QVariantMap &map) override;
|
||||
QVariantMap toMap() const override;
|
||||
Utils::OsType osType() const override;
|
||||
|
||||
static QString displayNameForType(Core::Id type);
|
||||
int deviceId() const { return m_deviceId; }
|
||||
|
Reference in New Issue
Block a user