From 46f5b514fb9a3f7330e71557db2acc196d1ff6a5 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Wed, 4 Apr 2018 14:05:33 +0200 Subject: [PATCH] switch netatmo plugin to use new parenting mechanism --- netatmo/devicepluginnetatmo.cpp | 14 +++++--------- netatmo/devicepluginnetatmo.json | 16 ---------------- netatmo/netatmobasestation.cpp | 10 ++-------- netatmo/netatmobasestation.h | 3 +-- netatmo/netatmooutdoormodule.cpp | 8 +------- netatmo/netatmooutdoormodule.h | 4 +--- 6 files changed, 10 insertions(+), 45 deletions(-) diff --git a/netatmo/devicepluginnetatmo.cpp b/netatmo/devicepluginnetatmo.cpp index 1dbf4e06..632c050b 100644 --- a/netatmo/devicepluginnetatmo.cpp +++ b/netatmo/devicepluginnetatmo.cpp @@ -86,9 +86,8 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device qCDebug(dcNetatmo) << "Setup netatmo indoor base station" << device->params(); NetatmoBaseStation *indoor = new NetatmoBaseStation(device->paramValue(indoorNameParamTypeId).toString(), device->paramValue(indoorMacParamTypeId).toString(), - device->paramValue(indoorConnectionParamTypeId).toString(), this); + this); - device->setParentId(DeviceId(indoor->connectionId())); m_indoorDevices.insert(indoor, device); connect(indoor, SIGNAL(statesChanged()), this, SLOT(onIndoorStatesChanged())); @@ -97,10 +96,9 @@ DeviceManager::DeviceSetupStatus DevicePluginNetatmo::setupDevice(Device *device qCDebug(dcNetatmo) << "Setup netatmo outdoor module" << device->params(); NetatmoOutdoorModule *outdoor = new NetatmoOutdoorModule(device->paramValue(outdoorNameParamTypeId).toString(), device->paramValue(outdoorMacParamTypeId).toString(), - device->paramValue(outdoorConnectionParamTypeId).toString(), - device->paramValue(outdoorBaseStationParamTypeId).toString(),this); + device->paramValue(outdoorBaseStationParamTypeId).toString(), + this); - device->setParentId(DeviceId(outdoor->connectionId())); m_outdoorDevices.insert(outdoor, device); connect(outdoor, SIGNAL(statesChanged()), this, SLOT(onOutdoorStatesChanged())); @@ -163,11 +161,10 @@ void DevicePluginNetatmo::processRefreshData(const QVariantMap &data, const QStr Device *indoorDevice = findIndoorDevice(deviceMap.value("_id").toString()); // check if we have to create the device (auto) if (!indoorDevice) { - DeviceDescriptor descriptor(indoorDeviceClassId, "Indoor Station", deviceMap.value("station_name").toString()); + DeviceDescriptor descriptor(indoorDeviceClassId, "Indoor Station", deviceMap.value("station_name").toString(), connectionId); ParamList params; params.append(Param(indoorNameParamTypeId, deviceMap.value("station_name").toString())); params.append(Param(indoorMacParamTypeId, deviceMap.value("_id").toString())); - params.append(Param(indoorConnectionParamTypeId, connectionId)); descriptor.setParams(params); emit autoDevicesAppeared(indoorDeviceClassId, QList() << descriptor); } else { @@ -190,11 +187,10 @@ void DevicePluginNetatmo::processRefreshData(const QVariantMap &data, const QStr Device *outdoorDevice = findOutdoorDevice(moduleMap.value("_id").toString()); // check if we have to create the device (auto) if (!outdoorDevice) { - DeviceDescriptor descriptor(outdoorDeviceClassId, "Outdoor Module", moduleMap.value("module_name").toString()); + DeviceDescriptor descriptor(outdoorDeviceClassId, "Outdoor Module", moduleMap.value("module_name").toString(), connectionId); ParamList params; params.append(Param(outdoorNameParamTypeId, moduleMap.value("module_name").toString())); params.append(Param(outdoorMacParamTypeId, moduleMap.value("_id").toString())); - params.append(Param(outdoorConnectionParamTypeId, connectionId)); params.append(Param(outdoorBaseStationParamTypeId, moduleMap.value("main_device").toString())); descriptor.setParams(params); emit autoDevicesAppeared(outdoorDeviceClassId, QList() << descriptor); diff --git a/netatmo/devicepluginnetatmo.json b/netatmo/devicepluginnetatmo.json index 3b73f6f8..cb2a1a08 100644 --- a/netatmo/devicepluginnetatmo.json +++ b/netatmo/devicepluginnetatmo.json @@ -75,14 +75,6 @@ "type": "QString", "inputType": "TextLine", "readOnly": true - }, - { - "id": "c15e5dea-10f2-4c96-afab-649872f43d5c", - "name": "connection", - "displayName": "connection", - "type": "QString", - "inputType": "TextLine", - "readOnly": true } ], "stateTypes": [ @@ -206,14 +198,6 @@ "inputType": "TextLine", "readOnly": true }, - { - "id": "c15e5dea-10f2-4c96-afab-649872f43d5c", - "name": "connection", - "displayName": "connection", - "type": "QString", - "inputType": "TextLine", - "readOnly": true - }, { "id": "d7a0ec46-760c-4fdc-9753-fe10c86fe1b9", "name": "baseStation", diff --git a/netatmo/netatmobasestation.cpp b/netatmo/netatmobasestation.cpp index f52df09d..802336b1 100644 --- a/netatmo/netatmobasestation.cpp +++ b/netatmo/netatmobasestation.cpp @@ -24,11 +24,10 @@ #include -NetatmoBaseStation::NetatmoBaseStation(const QString &name, const QString &macAddress, const QString &connectionId, QObject *parent) : +NetatmoBaseStation::NetatmoBaseStation(const QString &name, const QString &macAddress, QObject *parent) : QObject(parent), m_name(name), - m_macAddress(macAddress), - m_connectionId(connectionId) + m_macAddress(macAddress) { } @@ -42,11 +41,6 @@ QString NetatmoBaseStation::macAddress() const return m_macAddress; } -QString NetatmoBaseStation::connectionId() const -{ - return m_connectionId; -} - int NetatmoBaseStation::lastUpdate() const { return m_lastUpdate; diff --git a/netatmo/netatmobasestation.h b/netatmo/netatmobasestation.h index 6b1ce9b1..6c970bdc 100644 --- a/netatmo/netatmobasestation.h +++ b/netatmo/netatmobasestation.h @@ -30,7 +30,7 @@ class NetatmoBaseStation : public QObject { Q_OBJECT public: - explicit NetatmoBaseStation(const QString &name, const QString &macAddress, const QString &connectionId, QObject *parent = 0); + explicit NetatmoBaseStation(const QString &name, const QString &macAddress, QObject *parent = 0); // Params QString name() const; @@ -54,7 +54,6 @@ private: // Params QString m_name; QString m_macAddress; - QString m_connectionId; // States int m_lastUpdate; diff --git a/netatmo/netatmooutdoormodule.cpp b/netatmo/netatmooutdoormodule.cpp index f989b5f9..839ce08d 100644 --- a/netatmo/netatmooutdoormodule.cpp +++ b/netatmo/netatmooutdoormodule.cpp @@ -24,11 +24,10 @@ #include -NetatmoOutdoorModule::NetatmoOutdoorModule(const QString &name, const QString &macAddress, const QString &connectionId, const QString &baseStation, QObject *parent) : +NetatmoOutdoorModule::NetatmoOutdoorModule(const QString &name, const QString &macAddress, const QString &baseStation, QObject *parent) : QObject(parent), m_name(name), m_macAddress(macAddress), - m_connectionId(connectionId), m_baseStation(baseStation) { } @@ -43,11 +42,6 @@ QString NetatmoOutdoorModule::macAddress() const return m_macAddress; } -QString NetatmoOutdoorModule::connectionId() const -{ - return m_connectionId; -} - QString NetatmoOutdoorModule::baseStation() const { return m_baseStation; diff --git a/netatmo/netatmooutdoormodule.h b/netatmo/netatmooutdoormodule.h index 8ad9a251..7fa6c2df 100644 --- a/netatmo/netatmooutdoormodule.h +++ b/netatmo/netatmooutdoormodule.h @@ -29,12 +29,11 @@ class NetatmoOutdoorModule : public QObject { Q_OBJECT public: - explicit NetatmoOutdoorModule(const QString &name, const QString &macAddress, const QString &connectionId, const QString &baseStation, QObject *parent = 0); + explicit NetatmoOutdoorModule(const QString &name, const QString &macAddress, const QString &baseStation, QObject *parent = 0); // Params QString name() const; QString macAddress() const; - QString connectionId() const; QString baseStation() const; // States @@ -52,7 +51,6 @@ private: // Params QString m_name; QString m_macAddress; - QString m_connectionId; QString m_baseStation; // States