fix allowedValues for statetypes

This commit is contained in:
Michael Zanetti 2018-07-13 23:57:52 +02:00
parent b71f65e023
commit 6eb08e7dda
10 changed files with 24 additions and 5 deletions

View File

@ -150,6 +150,7 @@ void DeviceManager::getVendorsResponse(const QVariantMap &params)
void DeviceManager::getSupportedDevicesResponse(const QVariantMap &params)
{
qDebug() << "DeviceClass received:" << qUtf8Printable(QJsonDocument::fromVariant(params).toJson(QJsonDocument::Indented));
if (params.value("params").toMap().keys().contains("deviceClasses")) {
QVariantList deviceClassList = params.value("params").toMap().value("deviceClasses").toList();
foreach (QVariant deviceClassVariant, deviceClassList) {

View File

@ -157,7 +157,9 @@ StateType *JsonTypes::unpackStateType(const QVariantMap &stateTypeMap, QObject *
stateType->setDisplayName(stateTypeMap.value("displayName").toString());
stateType->setIndex(stateTypeMap.value("index").toInt());
stateType->setDefaultValue(stateTypeMap.value("defaultValue"));
stateType->setAllowedValues(stateTypeMap.value("possibleValues").toList());
stateType->setType(stateTypeMap.value("type").toString());
QPair<Types::Unit, QString> unit = stringToUnit(stateTypeMap.value("unit").toString());
stateType->setUnit(unit.first);
stateType->setUnitString(unit.second);

View File

@ -154,7 +154,7 @@ void RuleManager::getRuleDetailsReply(const QVariantMap &params)
qDebug() << "Got rule details for a rule we don't know";
return;
}
qDebug() << "got rule details for rule" << qUtf8Printable(QJsonDocument::fromVariant(ruleMap).toJson());
// qDebug() << "got rule details for rule" << qUtf8Printable(QJsonDocument::fromVariant(ruleMap).toJson());
parseEventDescriptors(ruleMap.value("eventDescriptors").toList(), rule);
parseRuleActions(ruleMap.value("actions").toList(), rule);
parseRuleExitActions(ruleMap.value("exitActions").toList(), rule);

View File

@ -147,7 +147,7 @@ void ParamType::setUnit(const Types::Unit &unit)
m_unit = unit;
}
QList<QVariant> ParamType::allowedValues() const
QVariantList ParamType::allowedValues() const
{
return m_allowedValues;
}

View File

@ -83,7 +83,7 @@ public:
QString unitString() const;
void setUnitString(const QString &unitString);
QList<QVariant> allowedValues() const;
QVariantList allowedValues() const;
void setAllowedValues(const QList<QVariant> allowedValues);
bool readOnly() const;

View File

@ -92,6 +92,16 @@ void StateType::setDefaultValue(const QVariant &defaultValue)
m_defaultValue = defaultValue;
}
QVariantList StateType::allowedValues() const
{
return m_allowedValues;
}
void StateType::setAllowedValues(const QVariantList &allowedValues)
{
m_allowedValues = allowedValues;
}
Types::Unit StateType::unit() const
{
return m_unit;

View File

@ -38,6 +38,7 @@ class StateType : public QObject
Q_PROPERTY(QString type READ type CONSTANT)
Q_PROPERTY(int index READ index CONSTANT)
Q_PROPERTY(QVariant defaultValue READ defaultValue CONSTANT)
Q_PROPERTY(QVariantList allowedValues READ allowedValues WRITE setAllowedValues CONSTANT)
Q_PROPERTY(Types::Unit unit READ unit CONSTANT)
Q_PROPERTY(QString unitString READ unitString CONSTANT)
@ -63,6 +64,9 @@ public:
QVariant defaultValue() const;
void setDefaultValue(const QVariant &defaultValue);
QVariantList allowedValues() const;
void setAllowedValues(const QVariantList &allowedValues);
Types::Unit unit() const;
void setUnit(const Types::Unit &unit);
@ -76,6 +80,7 @@ private:
QString m_type;
int m_index;
QVariant m_defaultValue;
QVariantList m_allowedValues;
Types::Unit m_unit;
QString m_unitString;

View File

@ -62,7 +62,7 @@ ItemDelegate {
Layout.fillWidth: true
sourceComponent: {
print("Datatye is:", paramType.type, paramType.minValue, paramType.maxValue, paramType.allowedValues)
print("Datatye is:", paramType.name, paramType.type, paramType.minValue, paramType.maxValue, paramType.allowedValues)
switch (paramType.type.toLowerCase()) {
case "bool":
return boolComponent;

View File

@ -19,7 +19,7 @@ Page {
header: GuhHeader {
text: {
if (subPage.shownInterfaces.length === 1) {
return qsTr("My %1 things").arg(interfaceToString(subPage.filterInterface))
return qsTr("My %1").arg(interfaceToString(subPage.shownInterfaces[0]))
} else if (subPage.shownInterfaces.length > 1 || subPage.hiddenInterfaces.length > 0) {
return qsTr("My things")
}

View File

@ -40,6 +40,7 @@ SwipeDelegate {
Label {
Layout.fillWidth: true
font.pixelSize: childEvaluatorsRepeater.count > 0 ? app.smallFont : app.mediumFont
wrapMode: Text.WordWrap
property string operatorString: {
if (!root.stateEvaluator) {
return "";