aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/ios/iosdevice.cpp
diff options
context:
space:
mode:
authorhjk <[email protected]>2024-02-02 18:32:12 +0100
committerhjk <[email protected]>2024-02-05 07:06:55 +0000
commit435b35ccfea00c6ce302545d2cc9740210232406 (patch)
treee53e34fe5996a63b976387d5d277c1e19be97efe /src/plugins/ios/iosdevice.cpp
parent508189339deb61c245333fa9bbd6532b079fb9b3 (diff)
Ios: Use setup functions for a few factories
Change-Id: Ide05c2ca859454c1745e5c243af6a3d05131194c Reviewed-by: Jarek Kobus <[email protected]>
Diffstat (limited to 'src/plugins/ios/iosdevice.cpp')
-rw-r--r--src/plugins/ios/iosdevice.cpp66
1 files changed, 37 insertions, 29 deletions
diff --git a/src/plugins/ios/iosdevice.cpp b/src/plugins/ios/iosdevice.cpp
index 1bfc4b7d9f0..70de6c0b0db 100644
--- a/src/plugins/ios/iosdevice.cpp
+++ b/src/plugins/ios/iosdevice.cpp
@@ -13,6 +13,7 @@
#include <coreplugin/helpmanager.h>
#include <projectexplorer/devicesupport/devicemanager.h>
+#include <projectexplorer/devicesupport/idevicefactory.h>
#include <projectexplorer/devicesupport/idevicewidget.h>
#include <projectexplorer/kitaspects.h>
@@ -78,10 +79,24 @@ namespace Ios::Internal {
const char kHandler[] = "Handler";
-class IosDeviceInfoWidget : public IDeviceWidget
+class IosDeviceInfoWidget final : public IDeviceWidget
{
public:
- IosDeviceInfoWidget(const ProjectExplorer::IDevice::Ptr &device);
+ IosDeviceInfoWidget(const IDevice::Ptr &device)
+ : IDeviceWidget(device)
+ {
+ const auto iosDevice = std::static_pointer_cast<IosDevice>(device);
+ using namespace Layouting;
+ // clang-format off
+ Form {
+ Tr::tr("Device name:"), iosDevice->deviceName(), br,
+ Tr::tr("Identifier:"), iosDevice->uniqueInternalDeviceId(), br,
+ Tr::tr("OS Version:"), iosDevice->osVersion(), br,
+ Tr::tr("CPU Architecture:"), iosDevice->cpuArchitecture(),
+ noMargin
+ }.attachTo(this);
+ // clang-format on
+ }
void updateDeviceFromUi() final {}
};
@@ -584,37 +599,30 @@ void IosDeviceManager::updateAvailableDevices(const QStringList &devices)
// Factory
-IosDeviceFactory::IosDeviceFactory()
- : IDeviceFactory(Constants::IOS_DEVICE_TYPE)
+class IosDeviceFactory final : public IDeviceFactory
{
- setDisplayName(IosDevice::name());
- setCombinedIcon(":/ios/images/iosdevicesmall.png",
- ":/ios/images/iosdevice.png");
- setConstructionFunction([] { return IDevice::Ptr(new IosDevice); });
-}
+public:
+ IosDeviceFactory()
+ : IDeviceFactory(Constants::IOS_DEVICE_TYPE)
+ {
+ setDisplayName(IosDevice::name());
+ setCombinedIcon(":/ios/images/iosdevicesmall.png",
+ ":/ios/images/iosdevice.png");
+ setConstructionFunction([] { return IDevice::Ptr(new IosDevice); });
+ }
-bool IosDeviceFactory::canRestore(const Store &map) const
-{
- Store vMap = map.value(Constants::EXTRA_INFO_KEY).value<Store>();
- if (vMap.isEmpty() || vMap.value(kDeviceName).toString() == QLatin1String("*unknown*"))
- return false; // transient device (probably generated during an activation)
- return true;
-}
+ bool canRestore(const Utils::Store &map) const override
+ {
+ Store vMap = map.value(Constants::EXTRA_INFO_KEY).value<Store>();
+ if (vMap.isEmpty() || vMap.value(kDeviceName).toString() == QLatin1String("*unknown*"))
+ return false; // transient device (probably generated during an activation)
+ return true;
+ }
+};
-IosDeviceInfoWidget::IosDeviceInfoWidget(const IDevice::Ptr &device)
- : IDeviceWidget(device)
+void setupIosDevice()
{
- const auto iosDevice = std::static_pointer_cast<IosDevice>(device);
- using namespace Layouting;
- // clang-format off
- Form {
- Tr::tr("Device name:"), iosDevice->deviceName(), br,
- Tr::tr("Identifier:"), iosDevice->uniqueInternalDeviceId(), br,
- Tr::tr("OS Version:"), iosDevice->osVersion(), br,
- Tr::tr("CPU Architecture:"), iosDevice->cpuArchitecture(),
- noMargin
- }.attachTo(this);
- // clang-format on
+ static IosDeviceFactory theIosDeviceFactory;
}
} // Ios::Internal