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);
|
||||
|
||||
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
|
||||
|
||||
@ -274,9 +274,7 @@ void DevicePluginMock::startMonitoringAutoDevices()
|
||||
DeviceDescriptor mockDescriptor(mockDeviceAutoClassId, "Mock Device (Auto created)");
|
||||
|
||||
ParamList params;
|
||||
qsrand(QDateTime::currentMSecsSinceEpoch());
|
||||
int port = 4242 + (qrand() % 1000);
|
||||
Param param("httpport", port);
|
||||
Param param("httpport", 4242);
|
||||
params.append(param);
|
||||
mockDescriptor.setParams(params);
|
||||
|
||||
|
||||
@ -425,24 +425,22 @@ QList<DeviceClass> DevicePluginOpenweathermap::supportedDevices() const
|
||||
|
||||
QPair<DeviceManager::DeviceError, QString> DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
{
|
||||
if(deviceClassId == openweathermapDeviceClassId){
|
||||
|
||||
QString location;
|
||||
foreach (const Param ¶m, params) {
|
||||
if (param.name() == "location") {
|
||||
location = param.value().toString();
|
||||
}
|
||||
qDebug() << "should discover devices with params:" << params;
|
||||
QString location;
|
||||
foreach (const Param ¶m, params) {
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user