From bd0988f32738cb311907f26c816f8c4b46ae2184 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 6 Dec 2024 16:44:47 +0100 Subject: [PATCH] ProjectExplorer: Add more Device{Const,}Ref interface Change-Id: Iada993c11c645bbaf97ebdd269ce5929fa66c62f Reviewed-by: Christian Kandeler --- .../projectexplorer/devicesupport/idevice.cpp | 24 +++++++++++++++++++ .../projectexplorer/devicesupport/idevice.h | 6 +++++ 2 files changed, 30 insertions(+) diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index 35235cba2a4..411398bfdef 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -794,6 +794,11 @@ DeviceConstRef::DeviceConstRef(const IDevice::Ptr &device) : m_constDevice(device) {} +IDevice::ConstPtr DeviceConstRef::lock() const +{ + return m_constDevice.lock(); +} + DeviceConstRef::~DeviceConstRef() = default; Id DeviceConstRef::id() const @@ -817,12 +822,31 @@ SshParameters DeviceConstRef::sshParameters() const return device->sshParameters(); } +QVariant DeviceConstRef::extraData(Id kind) const +{ + const IDevice::ConstPtr device = m_constDevice.lock(); + QTC_ASSERT(device, return {}); + return device->extraData(kind); +} + +FilePath DeviceConstRef::filePath(const QString &pathOnDevice) const +{ + const IDevice::ConstPtr device = m_constDevice.lock(); + QTC_ASSERT(device, return {}); + return device->filePath(pathOnDevice); +} + // DeviceRef, mutable DeviceRef::DeviceRef(const IDevice::Ptr &device) : DeviceConstRef(device), m_mutableDevice(device) {} +IDevice::Ptr DeviceRef::lock() const +{ + return m_mutableDevice.lock(); +} + void DeviceRef::setDisplayName(const QString &displayName) { const IDevice::Ptr device = m_mutableDevice.lock(); diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index 77b09e3afd2..5892ba36c55 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -251,9 +251,13 @@ public: DeviceConstRef(const IDevice::Ptr &device); virtual ~DeviceConstRef(); + IDevice::ConstPtr lock() const; + Utils::Id id() const; QString displayName() const; SshParameters sshParameters() const; + Utils::FilePath filePath(const QString &pathOnDevice) const; + QVariant extraData(Utils::Id kind) const; private: std::weak_ptr m_constDevice; @@ -264,6 +268,8 @@ class PROJECTEXPLORER_EXPORT DeviceRef : public DeviceConstRef public: DeviceRef(const IDevice::Ptr &device); + IDevice::Ptr lock() const; + void setDisplayName(const QString &displayName); void setSshParameters(const SshParameters ¶ms);