add support for allowedValues

This commit is contained in:
Michael Zanetti 2014-07-06 19:01:20 +02:00
parent 16f15a347b
commit f32abc8a2e
4 changed files with 19 additions and 0 deletions

View File

@ -86,6 +86,16 @@ void ParamType::setLimits(const QVariant &min, const QVariant &max)
m_maxValue = max;
}
QList<QVariant> ParamType::allowedValues() const
{
return m_allowedValues;
}
void ParamType::setAllowedValues(const QList<QVariant> allowedValues)
{
m_allowedValues = allowedValues;
}
QDebug operator<<(QDebug dbg, const ParamType &paramType)
{
dbg.nospace() << "ParamType(Name: " << paramType.name()

View File

@ -45,12 +45,16 @@ public:
QPair<QVariant, QVariant> limits() const;
void setLimits(const QVariant &min, const QVariant &max);
QList<QVariant> allowedValues() const;
void setAllowedValues(const QList<QVariant> allowedValues);
private:
QString m_name;
QVariant::Type m_type;
QVariant m_defaultValue;
QVariant m_minValue;
QVariant m_maxValue;
QVariantList m_allowedValues;
};
QDebug operator<<(QDebug dbg, const ParamType &paramType);

View File

@ -322,6 +322,7 @@ QList<DeviceClass> DevicePluginMailNotification::supportedDevices() const
customMailParams.append(portCustomParam);
ParamType authCustomParam("auth", QVariant::String);
authCustomParam.setAllowedValues(QVariantList() << "PLAIN" << "LOGIN");
customMailParams.append(authCustomParam);
deviceClassCustomMail.setActions(mailActions);

View File

@ -69,6 +69,7 @@ void JsonTypes::init()
s_paramType.insert("o:defaultValue", "variant");
s_paramType.insert("o:minValue", "variant");
s_paramType.insert("o:maxValue", "variant");
s_paramType.insert("o:allowedValues", QVariantList() << "variant");
// Param
s_param.insert("name", "string");
@ -332,6 +333,9 @@ QVariantMap JsonTypes::packParamType(const ParamType &paramType)
if (paramType.maxValue().isValid()) {
variantMap.insert("maxValue", paramType.maxValue());
}
if (!paramType.allowedValues().isEmpty()) {
variantMap.insert("allowedValues", paramType.allowedValues());
}
return variantMap;
}