ProjectExplorer: Change IDevice::toMap signature

From  Store toMap()  to  toMap(Store).

More symmetric code on the user side and better in line with
ProjectConfiguration/AspectContainer at the price of a few
more lines in the base.

Change-Id: I6069c96c250c1846e870879bcb52c58fdd806478
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2024-08-01 12:52:36 +02:00
parent 54333873f4
commit b6eff1b9cf
13 changed files with 32 additions and 32 deletions

View File

@@ -81,11 +81,10 @@ void BareMetalDevice::fromMap(const Store &map)
} }
} }
Store BareMetalDevice::toMap() const void BareMetalDevice::toMap(Store &map) const
{ {
Store map = IDevice::toMap(); IDevice::toMap(map);
map.insert(debugServerProviderIdKeyC, debugServerProviderId()); map.insert(debugServerProviderIdKeyC, debugServerProviderId());
return map;
} }
IDeviceWidget *BareMetalDevice::createWidget() IDeviceWidget *BareMetalDevice::createWidget()

View File

@@ -27,7 +27,7 @@ public:
protected: protected:
void fromMap(const Utils::Store &map) final; void fromMap(const Utils::Store &map) final;
Utils::Store toMap() const final; void toMap(Utils::Store &map) const final;
private: private:
BareMetalDevice(); BareMetalDevice();

View File

@@ -143,15 +143,14 @@ QString QdbDevice::serialNumber() const
void QdbDevice::fromMap(const Store &map) void QdbDevice::fromMap(const Store &map)
{ {
ProjectExplorer::IDevice::fromMap(map); IDevice::fromMap(map);
setSerialNumber(map.value("Qdb.SerialNumber").toString()); setSerialNumber(map.value("Qdb.SerialNumber").toString());
} }
Store QdbDevice::toMap() const void QdbDevice::toMap(Store &map) const
{ {
Store map = ProjectExplorer::IDevice::toMap(); IDevice::toMap(map);
map.insert("Qdb.SerialNumber", serialNumber()); map.insert("Qdb.SerialNumber", serialNumber());
return map;
} }
void QdbDevice::setupDefaultNetworkSettings(const QString &host) void QdbDevice::setupDefaultNetworkSettings(const QString &host)

View File

@@ -27,7 +27,7 @@ public:
protected: protected:
void fromMap(const Utils::Store &map) final; void fromMap(const Utils::Store &map) final;
Utils::Store toMap() const final; void toMap(Utils::Store &map) const final;
private: private:
QdbDevice(); QdbDevice();

View File

@@ -1022,11 +1022,10 @@ void DockerDevice::fromMap(const Store &map)
d->deviceSettings->fromMap(map); d->deviceSettings->fromMap(map);
} }
Store DockerDevice::toMap() const void DockerDevice::toMap(Store &map) const
{ {
Store map = ProjectExplorer::IDevice::toMap(); IDevice::toMap(map);
d->deviceSettings->toMap(map); d->deviceSettings->toMap(map);
return map;
} }
ProcessInterface *DockerDevice::createProcessInterface() const ProcessInterface *DockerDevice::createProcessInterface() const

View File

@@ -87,7 +87,7 @@ public:
protected: protected:
void fromMap(const Utils::Store &map) final; void fromMap(const Utils::Store &map) final;
Utils::Store toMap() const final; void toMap(Utils::Store &map) const final;
private: private:
void aboutToBeRemoved() const final; void aboutToBeRemoved() const final;

View File

@@ -158,15 +158,15 @@ void IosDevice::fromMap(const Store &map)
m_handler = Handler(map.value(kHandler).toInt()); m_handler = Handler(map.value(kHandler).toInt());
} }
Store IosDevice::toMap() const void IosDevice::toMap(Store &map) const
{ {
Store res = IDevice::toMap(); IDevice::toMap(map);
Store vMap; Store vMap;
for (auto i = m_extraInfo.cbegin(), end = m_extraInfo.cend(); i != end; ++i) for (auto i = m_extraInfo.cbegin(), end = m_extraInfo.cend(); i != end; ++i)
vMap.insert(keyFromString(i.key()), i.value()); vMap.insert(keyFromString(i.key()), i.value());
res.insert(Constants::EXTRA_INFO_KEY, variantFromStore(vMap)); map.insert(Constants::EXTRA_INFO_KEY, variantFromStore(vMap));
res.insert(kHandler, int(m_handler)); map.insert(kHandler, int(m_handler));
return res;
} }
QString IosDevice::deviceName() const QString IosDevice::deviceName() const
@@ -354,8 +354,10 @@ void IosDeviceManager::deviceInfo(const QString &uid,
skipUpdate = true; skipUpdate = true;
newDev = const_cast<IosDevice *>(iosDev); newDev = const_cast<IosDevice *>(iosDev);
} else { } else {
Store store;
iosDev->toMap(store);
newDev = new IosDevice(); newDev = new IosDevice();
newDev->fromMap(iosDev->toMap()); newDev->fromMap(store);
} }
} else { } else {
newDev = new IosDevice(uid); newDev = new IosDevice(uid);

View File

@@ -46,7 +46,7 @@ public:
protected: protected:
void fromMap(const Utils::Store &map) final; void fromMap(const Utils::Store &map) final;
Utils::Store toMap() const final; void toMap(Utils::Store &map) const final;
friend class IosDeviceFactory; friend class IosDeviceFactory;
friend class Ios::Internal::IosDeviceManager; friend class Ios::Internal::IosDeviceManager;

View File

@@ -241,8 +241,11 @@ Store DeviceManager::toMap() const
map.insert(DefaultDevicesKey, variantFromStore(defaultDeviceMap)); map.insert(DefaultDevicesKey, variantFromStore(defaultDeviceMap));
QVariantList deviceList; QVariantList deviceList;
for (const IDevice::Ptr &device : std::as_const(d->devices)) for (const IDevice::Ptr &device : std::as_const(d->devices)) {
deviceList << variantFromStore(device->toMap()); Store store;
device->toMap(store);
deviceList << variantFromStore(store);
}
map.insert(DeviceListKey, deviceList); map.insert(DeviceListKey, deviceList);
return map; return map;
} }

View File

@@ -541,9 +541,8 @@ void IDevice::fromMap(const Store &map)
call the base class implementation. call the base class implementation.
*/ */
Store IDevice::toMap() const void IDevice::toMap(Store &map) const
{ {
Store map;
d->settings->toMap(map); d->settings->toMap(map);
map.insert(TypeKey, d->type.toString()); map.insert(TypeKey, d->type.toString());
@@ -570,21 +569,21 @@ Store IDevice::toMap() const
map.insert(QmlRuntimeKey, d->qmlRunCommand.toSettings()); map.insert(QmlRuntimeKey, d->qmlRunCommand.toSettings());
map.insert(ExtraDataKey, variantFromStore(d->extraData)); map.insert(ExtraDataKey, variantFromStore(d->extraData));
return map;
} }
IDevice::Ptr IDevice::clone() const IDevice::Ptr IDevice::clone() const
{ {
IDeviceFactory *factory = IDeviceFactory::find(d->type); IDeviceFactory *factory = IDeviceFactory::find(d->type);
QTC_ASSERT(factory, return {}); QTC_ASSERT(factory, return {});
Store store;
toMap(store);
IDevice::Ptr device = factory->construct(); IDevice::Ptr device = factory->construct();
QTC_ASSERT(device, return {}); QTC_ASSERT(device, return {});
device->d->deviceState = d->deviceState; device->d->deviceState = d->deviceState;
device->d->deviceActions = d->deviceActions; device->d->deviceActions = d->deviceActions;
device->d->deviceIcons = d->deviceIcons; device->d->deviceIcons = d->deviceIcons;
device->d->osType = d->osType; device->d->osType = d->osType;
device->fromMap(toMap()); device->fromMap(store);
return device; return device;
} }

View File

@@ -233,7 +233,7 @@ protected:
IDevice(std::unique_ptr<DeviceSettings> settings = nullptr); IDevice(std::unique_ptr<DeviceSettings> settings = nullptr);
virtual void fromMap(const Utils::Store &map); virtual void fromMap(const Utils::Store &map);
virtual Utils::Store toMap() const; virtual void toMap(Utils::Store &map) const;
using OpenTerminal = std::function<Utils::expected_str<void>(const Utils::Environment &, using OpenTerminal = std::function<Utils::expected_str<void>(const Utils::Environment &,
const Utils::FilePath &)>; const Utils::FilePath &)>;

View File

@@ -1082,11 +1082,10 @@ void LinuxDevice::fromMap(const Utils::Store &map)
d->m_disconnected = map.value(DisconnectedKey, false).toBool(); d->m_disconnected = map.value(DisconnectedKey, false).toBool();
} }
Store LinuxDevice::toMap() const void LinuxDevice::toMap(Utils::Store &map) const
{ {
Store map = IDevice::toMap(); IDevice::toMap(map);
map.insert(DisconnectedKey, d->m_disconnected); map.insert(DisconnectedKey, d->m_disconnected);
return map;
} }
void LinuxDevice::_setOsType(Utils::OsType osType) void LinuxDevice::_setOsType(Utils::OsType osType)

View File

@@ -56,7 +56,7 @@ protected:
LinuxDevice(); LinuxDevice();
void fromMap(const Utils::Store &map) override; void fromMap(const Utils::Store &map) override;
Utils::Store toMap() const override; void toMap(Utils::Store &map) const override;
void _setOsType(Utils::OsType osType); void _setOsType(Utils::OsType osType);