fix some param handling issues
This commit is contained in:
parent
944adda293
commit
913f08edd8
@ -98,9 +98,3 @@ void ParamList::setParamValue(const QString ¶mName, const QVariant &value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParamList ParamList::operator<<(const Param ¶m)
|
|
||||||
{
|
|
||||||
this->append(param);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|||||||
@ -53,4 +53,12 @@ public:
|
|||||||
};
|
};
|
||||||
QDebug operator<<(QDebug dbg, const ParamList ¶ms);
|
QDebug operator<<(QDebug dbg, const ParamList ¶ms);
|
||||||
|
|
||||||
|
class ParamList: public QList<Param>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool hasParam(const QString ¶mName) const;
|
||||||
|
QVariant paramValue(const QString ¶mName) const;
|
||||||
|
void setParamValue(const QString ¶mName, const QVariant &value);
|
||||||
|
};
|
||||||
|
|
||||||
#endif // PARAM_H
|
#endif // PARAM_H
|
||||||
|
|||||||
@ -274,9 +274,7 @@ void DevicePluginMock::startMonitoringAutoDevices()
|
|||||||
DeviceDescriptor mockDescriptor(mockDeviceAutoClassId, "Mock Device (Auto created)");
|
DeviceDescriptor mockDescriptor(mockDeviceAutoClassId, "Mock Device (Auto created)");
|
||||||
|
|
||||||
ParamList params;
|
ParamList params;
|
||||||
qsrand(QDateTime::currentMSecsSinceEpoch());
|
Param param("httpport", 4242);
|
||||||
int port = 4242 + (qrand() % 1000);
|
|
||||||
Param param("httpport", port);
|
|
||||||
params.append(param);
|
params.append(param);
|
||||||
mockDescriptor.setParams(params);
|
mockDescriptor.setParams(params);
|
||||||
|
|
||||||
|
|||||||
@ -425,24 +425,22 @@ QList<DeviceClass> DevicePluginOpenweathermap::supportedDevices() const
|
|||||||
|
|
||||||
QPair<DeviceManager::DeviceError, QString> DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
QPair<DeviceManager::DeviceError, QString> DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||||
{
|
{
|
||||||
if(deviceClassId == openweathermapDeviceClassId){
|
|
||||||
|
|
||||||
QString location;
|
qDebug() << "should discover devices with params:" << params;
|
||||||
foreach (const Param ¶m, params) {
|
QString location;
|
||||||
if (param.name() == "location") {
|
foreach (const Param ¶m, params) {
|
||||||
location = param.value().toString();
|
qDebug() << "### got param:" << param;
|
||||||
}
|
if (param.name() == "location") {
|
||||||
|
location = param.value().toString();
|
||||||
}
|
}
|
||||||
qDebug() << "Searching for... " << location;
|
|
||||||
if (location.isEmpty()){
|
|
||||||
m_openweaher->searchAutodetect();
|
|
||||||
}else{
|
|
||||||
m_openweaher->search(location);
|
|
||||||
}
|
|
||||||
return DeviceManager::DeviceErrorAsync;
|
|
||||||
}else{
|
|
||||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (location.isEmpty()){
|
||||||
|
m_openweaher->searchAutodetect();
|
||||||
|
return report(DeviceManager::DeviceErrorAsync);
|
||||||
|
}
|
||||||
|
m_openweaher->search(location);
|
||||||
|
return report(DeviceManager::DeviceErrorAsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginOpenweathermap::setupDevice(Device *device)
|
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginOpenweathermap::setupDevice(Device *device)
|
||||||
|
|||||||
Reference in New Issue
Block a user