simplify api

This commit is contained in:
Michael Zanetti 2013-12-31 02:12:26 +01:00
parent 0faa329df9
commit 085f02ce30
3 changed files with 9 additions and 6 deletions

View File

@ -53,11 +53,11 @@ QList<Device *> DeviceManager::configuredDevices() const
return m_configuredDevices; return m_configuredDevices;
} }
QList<Device *> DeviceManager::findConfiguredDevices(const DeviceClass &deviceClass) QList<Device *> DeviceManager::findConfiguredDevices(const QUuid &deviceClassId)
{ {
QList<Device*> ret; QList<Device*> ret;
foreach (Device *device, m_configuredDevices) { foreach (Device *device, m_configuredDevices) {
if (device->deviceClassId() == deviceClass.id()) { if (device->deviceClassId() == deviceClassId) {
ret << device; ret << device;
} }
} }

View File

@ -28,7 +28,7 @@ public:
QList<Device*> configuredDevices() const; QList<Device*> configuredDevices() const;
DeviceError addConfiguredDevice(const QUuid &deviceClassId, const QVariantMap &params); DeviceError addConfiguredDevice(const QUuid &deviceClassId, const QVariantMap &params);
QList<Device*> findConfiguredDevices(const DeviceClass &deviceClass); QList<Device*> findConfiguredDevices(const QUuid &deviceClassId);
DeviceClass findDeviceClass(const QUuid &deviceClassId); DeviceClass findDeviceClass(const QUuid &deviceClassId);
Radio433 *radio433() const; Radio433 *radio433() const;

View File

@ -6,6 +6,9 @@
#include <QDebug> #include <QDebug>
QUuid mumbiRemote = QUuid("d85c1ef4-197c-4053-8e40-707aa671d302");
QUuid mumbiRfSwitch = QUuid("308ae6e6-38b3-4b3a-a513-3199da2764f8");
RfSwitch::RfSwitch() RfSwitch::RfSwitch()
{ {
} }
@ -20,7 +23,7 @@ QList<DeviceClass> RfSwitch::supportedDevices() const
// TODO: load list from config with static uuid // TODO: load list from config with static uuid
QList<DeviceClass> ret; QList<DeviceClass> ret;
DeviceClass deviceClassRfRemote(QUuid::createUuid()); DeviceClass deviceClassRfRemote(mumbiRemote);
deviceClassRfRemote.setName("RF Remote"); deviceClassRfRemote.setName("RF Remote");
QVariantList deviceParams; QVariantList deviceParams;
@ -77,7 +80,7 @@ QList<DeviceClass> RfSwitch::supportedDevices() const
ret.append(deviceClassRfRemote); ret.append(deviceClassRfRemote);
DeviceClass deviceClassRfSwitch(QUuid::createUuid()); DeviceClass deviceClassRfSwitch(mumbiRfSwitch);
deviceClassRfSwitch.setName("RF Switch"); deviceClassRfSwitch.setName("RF Switch");
ret.append(deviceClassRfSwitch); ret.append(deviceClassRfSwitch);
@ -101,7 +104,7 @@ void RfSwitch::dataReceived(QList<int> rawData)
group << true << false << false << false << false; group << true << false << false << false << false;
Device *device = 0; Device *device = 0;
QList<Device*> deviceList = deviceManager()->findConfiguredDevices(deviceClassRfRemote); QList<Device*> deviceList = deviceManager()->findConfiguredDevices(deviceClassRfRemote.id());
foreach (Device *dev, deviceList) { foreach (Device *dev, deviceList) {
if (dev->params().contains("channel1") && dev->params().value("channel1").toBool() == group.at(0) && if (dev->params().contains("channel1") && dev->params().value("channel1").toBool() == group.at(0) &&
dev->params().contains("channel2") && dev->params().value("channel2").toBool() == group.at(1) && dev->params().contains("channel2") && dev->params().value("channel2").toBool() == group.at(1) &&