fix some param handling issues

This commit is contained in:
Michael Zanetti 2014-07-06 21:11:55 +02:00
parent 944adda293
commit 913f08edd8
4 changed files with 22 additions and 24 deletions

View File

@ -98,9 +98,3 @@ void ParamList::setParamValue(const QString &paramName, const QVariant &value)
}
}
}
ParamList ParamList::operator<<(const Param &param)
{
this->append(param);
return *this;
}

View File

@ -53,4 +53,12 @@ public:
};
QDebug operator<<(QDebug dbg, const ParamList &params);
class ParamList: public QList<Param>
{
public:
bool hasParam(const QString &paramName) const;
QVariant paramValue(const QString &paramName) const;
void setParamValue(const QString &paramName, const QVariant &value);
};
#endif // PARAM_H

View File

@ -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);

View File

@ -425,24 +425,22 @@ QList<DeviceClass> DevicePluginOpenweathermap::supportedDevices() const
QPair<DeviceManager::DeviceError, QString> DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const ParamList &params)
{
if(deviceClassId == openweathermapDeviceClassId){
QString location;
foreach (const Param &param, params) {
if (param.name() == "location") {
location = param.value().toString();
}
qDebug() << "should discover devices with params:" << params;
QString location;
foreach (const Param &param, 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)