forked from qt-creator/qt-creator
WinRt: Streamline WinRt device construction
Remove create() and init() functions and ctors except default constructor. Change-Id: I2746ca88bc1e63bdfb05d027c0816b3c8af5ea35 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
@@ -43,24 +43,6 @@ namespace WinRt {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
WinRtDevice::WinRtDevice()
|
WinRtDevice::WinRtDevice()
|
||||||
{
|
|
||||||
initFreePorts();
|
|
||||||
}
|
|
||||||
|
|
||||||
WinRtDevice::WinRtDevice(Core::Id internalId, int deviceId)
|
|
||||||
: m_deviceId(deviceId)
|
|
||||||
{
|
|
||||||
setupId(AutoDetected, internalId);
|
|
||||||
initFreePorts();
|
|
||||||
}
|
|
||||||
|
|
||||||
WinRtDevice::WinRtDevice(const WinRtDevice &other)
|
|
||||||
: IDevice(other), m_deviceId(other.m_deviceId)
|
|
||||||
{
|
|
||||||
initFreePorts();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WinRtDevice::initFreePorts()
|
|
||||||
{
|
{
|
||||||
Utils::PortList portList;
|
Utils::PortList portList;
|
||||||
portList.addRange(Utils::Port(ProjectExplorer::Constants::DESKTOP_PORT_START),
|
portList.addRange(Utils::Port(ProjectExplorer::Constants::DESKTOP_PORT_START),
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ namespace Internal {
|
|||||||
|
|
||||||
class WinRtDevice : public ProjectExplorer::IDevice
|
class WinRtDevice : public ProjectExplorer::IDevice
|
||||||
{
|
{
|
||||||
friend class WinRtDeviceFactory;
|
|
||||||
public:
|
public:
|
||||||
typedef QSharedPointer<WinRtDevice> Ptr;
|
typedef QSharedPointer<WinRtDevice> Ptr;
|
||||||
typedef QSharedPointer<const WinRtDevice> ConstPtr;
|
typedef QSharedPointer<const WinRtDevice> ConstPtr;
|
||||||
|
|
||||||
|
static Ptr create() { return Ptr(new WinRtDevice); }
|
||||||
|
|
||||||
QString displayType() const override;
|
QString displayType() const override;
|
||||||
ProjectExplorer::IDeviceWidget *createWidget() override;
|
ProjectExplorer::IDeviceWidget *createWidget() override;
|
||||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||||
@@ -47,16 +48,11 @@ public:
|
|||||||
|
|
||||||
static QString displayNameForType(Core::Id type);
|
static QString displayNameForType(Core::Id type);
|
||||||
int deviceId() const { return m_deviceId; }
|
int deviceId() const { return m_deviceId; }
|
||||||
|
void setDeviceId(int deviceId) { m_deviceId = deviceId; }
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
WinRtDevice();
|
WinRtDevice();
|
||||||
WinRtDevice(Core::Id internalId, int deviceId);
|
|
||||||
WinRtDevice(const WinRtDevice &other);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void initFreePorts();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_deviceId = -1;
|
int m_deviceId = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ WinRtDeviceFactory::WinRtDeviceFactory(Core::Id deviceType)
|
|||||||
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
|
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
setDisplayName(WinRtDevice::displayNameForType(deviceType));
|
setDisplayName(WinRtDevice::displayNameForType(deviceType));
|
||||||
setConstructionFunction([] { return IDevice::Ptr(new WinRtDevice); });
|
setConstructionFunction(&WinRtDevice::create);
|
||||||
setCombinedIcon(":/winrt/images/winrtdevicesmall.png",
|
setCombinedIcon(":/winrt/images/winrtdevicesmall.png",
|
||||||
":/winrt/images/winrtdevice.png");
|
":/winrt/images/winrtdevice.png");
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,9 @@ void WinRtDeviceFactory::parseRunnerOutput(const QByteArray &output) const
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
WinRtDevice *device = new WinRtDevice(internalId, deviceId);
|
auto device = WinRtDevice::create();
|
||||||
|
device->setupId(IDevice::AutoDetected, internalId);
|
||||||
|
device->setDeviceId(deviceId);
|
||||||
device->setType(deviceType);
|
device->setType(deviceType);
|
||||||
device->setMachineType(machineType);
|
device->setMachineType(machineType);
|
||||||
device->setDisplayName(name);
|
device->setDisplayName(name);
|
||||||
|
|||||||
Reference in New Issue
Block a user