| 64 | } |
| 65 | |
| 66 | QString DeviceManager::createDevice(QString category, QString param, bool async, QList<QString> plugins) |
| 67 | { |
| 68 | for(Device *val : qAsConst(map)) { |
| 69 | if(val->param() == param) { |
| 70 | return ""; |
| 71 | } |
| 72 | } |
| 73 | qInfo(CAT_DEVICEMANAGER) << category << "device with params" << param << "added"; |
| 74 | Q_EMIT deviceAddStarted(param); |
| 75 | |
| 76 | DeviceImpl *d = DeviceFactory::build(param, category); |
| 77 | DeviceLoader *dl = new DeviceLoader(d, this); |
| 78 | |
| 79 | connect(dl, &DeviceLoader::initialized, this, [=]() { |
| 80 | QList<Plugin *> availablePlugins = d->plugins(); |
| 81 | if(!plugins.isEmpty()) { |
| 82 | for(Plugin *p : qAsConst(availablePlugins)) { |
| 83 | bool enablePlugin = plugins.contains(p->name()); |
| 84 | p->setEnabled(enablePlugin); |
| 85 | } |
| 86 | } |
| 87 | addDevice(d); |
| 88 | }); // add device to manager once it is initialized |
| 89 | connect(dl, &DeviceLoader::initialized, dl, |
| 90 | &QObject::deleteLater); // don't forget to delete loader once we're done |
| 91 | dl->init(async); |
| 92 | |
| 93 | return d->id(); |
| 94 | } |
| 95 | |
| 96 | // This is only used by scan context collector - should I rethink this ? |
| 97 | // Map all devices to uris in scan context collector |