diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index 89b8eeba46e..c74c87cc3e6 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -331,28 +330,6 @@ DeviceEnvironmentFetcher::Ptr IDevice::environmentFetcher() const return DeviceEnvironmentFetcher::Ptr(); } -void IDevice::addToMacroExpander(Utils::MacroExpander *expander) const -{ - expander->registerVariable("Device:HostAddress", - QCoreApplication::translate("ProjectExplorer::IDevice", - "Host address"), - [this]() { return sshParameters().host(); }); - expander->registerVariable("Device:SshPort", - QCoreApplication::translate("ProjectExplorer::IDevice", "SSH port"), - [this]() { return QString::number(sshParameters().port()); }); - expander->registerVariable("Device:UserName", - QCoreApplication::translate("ProjectExplorer::IDevice", "User name"), - [this]() { return sshParameters().userName(); }); - expander->registerVariable("Device:KeyFile", - QCoreApplication::translate("ProjectExplorer::IDevice", - "Private key file"), - [this]() { return sshParameters().privateKeyFile; }); - expander->registerVariable("Device:Name", - QCoreApplication::translate("ProjectExplorer::IDevice", - "Device name"), - [this]() { return displayName(); }); -} - IDevice::DeviceState IDevice::deviceState() const { return d->deviceState; diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index b091a4ee4c7..65e739950f6 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -49,7 +49,6 @@ namespace QSsh { class SshConnectionParameters; } namespace Utils { class Environment; class Icon; -class MacroExpander; class PortList; class Port; } // Utils @@ -181,8 +180,6 @@ public: virtual DeviceProcessSignalOperation::Ptr signalOperation() const = 0; virtual DeviceEnvironmentFetcher::Ptr environmentFetcher() const; - virtual void addToMacroExpander(Utils::MacroExpander *expander) const; - enum DeviceState { DeviceReadyToUse, DeviceConnected, DeviceDisconnected, DeviceStateUnknown }; DeviceState deviceState() const; void setDeviceState(const DeviceState state); diff --git a/src/plugins/projectexplorer/kitinformation.cpp b/src/plugins/projectexplorer/kitinformation.cpp index a5c321dfd3c..d3c14a0250a 100644 --- a/src/plugins/projectexplorer/kitinformation.cpp +++ b/src/plugins/projectexplorer/kitinformation.cpp @@ -1028,9 +1028,31 @@ KitAspect::ItemList DeviceKitAspect::toUserOutput(const Kit *k) const void DeviceKitAspect::addToMacroExpander(Kit *kit, Utils::MacroExpander *expander) const { QTC_ASSERT(kit, return); - const IDevice::ConstPtr device = DeviceKitAspect::device(kit); - if (device) - device->addToMacroExpander(expander); + expander->registerVariable("Device:HostAddress", tr("Host address"), + [kit]() -> QString { + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); + return device ? device->sshParameters().host() : QString(); + }); + expander->registerVariable("Device:SshPort", tr("SSH port"), + [kit]() -> QString { + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); + return device ? QString::number(device->sshParameters().port()) : QString(); + }); + expander->registerVariable("Device:UserName", tr("User name"), + [kit]() -> QString { + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); + return device ? device->sshParameters().userName() : QString(); + }); + expander->registerVariable("Device:KeyFile", tr("Private key file"), + [kit]() -> QString { + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); + return device ? device->sshParameters().privateKeyFile : QString(); + }); + expander->registerVariable("Device:Name", tr("Device name"), + [kit]() -> QString { + const IDevice::ConstPtr device = DeviceKitAspect::device(kit); + return device ? device->displayName() : QString(); + }); } Core::Id DeviceKitAspect::id()