Add support for device parenting in discovery phase
This commit is contained in:
parent
a2c53a762d
commit
2ab082bbc4
@ -1365,10 +1365,15 @@ void DeviceManager::onAutoDevicesAppeared(const DeviceClassId &deviceClassId, co
|
||||
}
|
||||
|
||||
foreach (const DeviceDescriptor &deviceDescriptor, deviceDescriptors) {
|
||||
if (!deviceDescriptor.parentDeviceId().isNull() && !m_configuredDevices.contains(deviceDescriptor.parentDeviceId())) {
|
||||
qCWarning(dcDeviceManager()) << "Invalid parent device id. Not adding device to the system.";
|
||||
continue;
|
||||
}
|
||||
Device *device = new Device(plugin->pluginId(), deviceClassId, this);
|
||||
device->m_autoCreated = true;
|
||||
device->setName(deviceDescriptor.title());
|
||||
device->setParams(deviceDescriptor.params());
|
||||
device->setParentId(deviceDescriptor.parentDeviceId());
|
||||
|
||||
DeviceSetupStatus setupStatus = setupDevice(device);
|
||||
switch (setupStatus) {
|
||||
|
||||
@ -44,22 +44,24 @@ DeviceDescriptor::DeviceDescriptor():
|
||||
|
||||
}
|
||||
|
||||
/*! Construct a DeviceDescriptor with the given \a deviceClassId, \a title and \a description.*/
|
||||
DeviceDescriptor::DeviceDescriptor(const DeviceClassId &deviceClassId, const QString &title, const QString &description):
|
||||
/*! Construct a DeviceDescriptor with the given \a deviceClassId, \a title, \a description and \a parentDeviceId.*/
|
||||
DeviceDescriptor::DeviceDescriptor(const DeviceClassId &deviceClassId, const QString &title, const QString &description, const DeviceId &parentDeviceId):
|
||||
m_id(DeviceDescriptorId::createDeviceDescriptorId()),
|
||||
m_deviceClassId(deviceClassId),
|
||||
m_title(title),
|
||||
m_description(description)
|
||||
m_description(description),
|
||||
m_parentDeviceId(parentDeviceId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*! Construct a DeviceDescriptor with the given \a id, \a deviceClassId, \a title and \a description.*/
|
||||
DeviceDescriptor::DeviceDescriptor(const DeviceDescriptorId &id, const DeviceClassId &deviceClassId, const QString &title, const QString &description) :
|
||||
/*! Construct a DeviceDescriptor with the given \a id, \a deviceClassId, \a title, \a description and \a parentDeviceId.*/
|
||||
DeviceDescriptor::DeviceDescriptor(const DeviceDescriptorId &id, const DeviceClassId &deviceClassId, const QString &title, const QString &description, const DeviceId &parentDeviceId) :
|
||||
m_id(id),
|
||||
m_deviceClassId(deviceClassId),
|
||||
m_title(title),
|
||||
m_description(description)
|
||||
m_description(description),
|
||||
m_parentDeviceId(parentDeviceId)
|
||||
{
|
||||
}
|
||||
|
||||
@ -106,6 +108,18 @@ void DeviceDescriptor::setDescription(const QString &description)
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
/*! Returns the parent device id for devices created from this DeviceDescriptor. */
|
||||
DeviceId DeviceDescriptor::parentDeviceId() const
|
||||
{
|
||||
return m_parentDeviceId;
|
||||
}
|
||||
|
||||
/*! Sets the parent device Id for devices created from this DeviceDescriptor. */
|
||||
void DeviceDescriptor::setParentDeviceId(const DeviceId &parentDeviceId)
|
||||
{
|
||||
m_parentDeviceId = parentDeviceId;
|
||||
}
|
||||
|
||||
/*! Returns the list of \l{Param}{Params} of this DeviceDescriptor. */
|
||||
ParamList DeviceDescriptor::params() const
|
||||
{
|
||||
|
||||
@ -34,8 +34,8 @@ class LIBNYMEA_EXPORT DeviceDescriptor
|
||||
{
|
||||
public:
|
||||
DeviceDescriptor();
|
||||
DeviceDescriptor(const DeviceClassId &deviceClassId, const QString &title = QString(), const QString &description = QString());
|
||||
DeviceDescriptor(const DeviceDescriptorId &id, const DeviceClassId &deviceClassId, const QString &title = QString(), const QString &description = QString());
|
||||
DeviceDescriptor(const DeviceClassId &deviceClassId, const QString &title = QString(), const QString &description = QString(), const DeviceId &parentDeviceId = DeviceId());
|
||||
DeviceDescriptor(const DeviceDescriptorId &id, const DeviceClassId &deviceClassId, const QString &title = QString(), const QString &description = QString(), const DeviceId &parentDeviceId = DeviceId());
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
@ -48,6 +48,9 @@ public:
|
||||
QString description() const;
|
||||
void setDescription(const QString &description);
|
||||
|
||||
DeviceId parentDeviceId() const;
|
||||
void setParentDeviceId(const DeviceId &parentDeviceId);
|
||||
|
||||
ParamList params() const;
|
||||
void setParams(const ParamList ¶ms);
|
||||
|
||||
@ -56,6 +59,7 @@ private:
|
||||
DeviceClassId m_deviceClassId;
|
||||
QString m_title;
|
||||
QString m_description;
|
||||
DeviceId m_parentDeviceId;
|
||||
ParamList m_params;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user