ProjectExplorer: Use a lambda for DeviceFactory::create()

Somewhat slimmer interface on the user code side and follows
existing practice.

Change-Id: I20ed8f5a00591265d32ea9ce93e1f1bbc76d2437
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2022-01-26 09:05:35 +01:00
parent f6cb638345
commit 2b6f26dee2
20 changed files with 96 additions and 125 deletions

View File

@@ -51,20 +51,18 @@ TestLinuxDeviceFactory::TestLinuxDeviceFactory()
{
setDisplayName("Generic Linux Device");
setIcon(QIcon());
setCanCreate(true);
setConstructionFunction(&LinuxDevice::create);
}
IDevice::Ptr TestLinuxDeviceFactory::create() const
{
LinuxDevice::Ptr newDev = LinuxDevice::create();
qDebug() << "device : " << newDev->type();
newDev->setType("test");
QSsh::SshConnectionParameters sshParams = newDev->sshParameters();
sshParams.setHost(TEST_IP);
sshParams.setPort(22);
newDev->setSshParameters(sshParams);
return newDev;
setCanCreate(true);
setCreator([] {
LinuxDevice::Ptr newDev = LinuxDevice::create();
qDebug() << "device : " << newDev->type();
newDev->setType("test");
QSsh::SshConnectionParameters sshParams = newDev->sshParameters();
sshParams.setHost(TEST_IP);
sshParams.setPort(22);
newDev->setSshParameters(sshParams);
return newDev;
});
}
FilePath createFile(const QString &name)