fix allowedValues for statetypes
This commit is contained in:
parent
b71f65e023
commit
6eb08e7dda
@ -150,6 +150,7 @@ void DeviceManager::getVendorsResponse(const QVariantMap ¶ms)
|
|||||||
|
|
||||||
void DeviceManager::getSupportedDevicesResponse(const QVariantMap ¶ms)
|
void DeviceManager::getSupportedDevicesResponse(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
|
qDebug() << "DeviceClass received:" << qUtf8Printable(QJsonDocument::fromVariant(params).toJson(QJsonDocument::Indented));
|
||||||
if (params.value("params").toMap().keys().contains("deviceClasses")) {
|
if (params.value("params").toMap().keys().contains("deviceClasses")) {
|
||||||
QVariantList deviceClassList = params.value("params").toMap().value("deviceClasses").toList();
|
QVariantList deviceClassList = params.value("params").toMap().value("deviceClasses").toList();
|
||||||
foreach (QVariant deviceClassVariant, deviceClassList) {
|
foreach (QVariant deviceClassVariant, deviceClassList) {
|
||||||
|
|||||||
@ -157,7 +157,9 @@ StateType *JsonTypes::unpackStateType(const QVariantMap &stateTypeMap, QObject *
|
|||||||
stateType->setDisplayName(stateTypeMap.value("displayName").toString());
|
stateType->setDisplayName(stateTypeMap.value("displayName").toString());
|
||||||
stateType->setIndex(stateTypeMap.value("index").toInt());
|
stateType->setIndex(stateTypeMap.value("index").toInt());
|
||||||
stateType->setDefaultValue(stateTypeMap.value("defaultValue"));
|
stateType->setDefaultValue(stateTypeMap.value("defaultValue"));
|
||||||
|
stateType->setAllowedValues(stateTypeMap.value("possibleValues").toList());
|
||||||
stateType->setType(stateTypeMap.value("type").toString());
|
stateType->setType(stateTypeMap.value("type").toString());
|
||||||
|
|
||||||
QPair<Types::Unit, QString> unit = stringToUnit(stateTypeMap.value("unit").toString());
|
QPair<Types::Unit, QString> unit = stringToUnit(stateTypeMap.value("unit").toString());
|
||||||
stateType->setUnit(unit.first);
|
stateType->setUnit(unit.first);
|
||||||
stateType->setUnitString(unit.second);
|
stateType->setUnitString(unit.second);
|
||||||
|
|||||||
@ -154,7 +154,7 @@ void RuleManager::getRuleDetailsReply(const QVariantMap ¶ms)
|
|||||||
qDebug() << "Got rule details for a rule we don't know";
|
qDebug() << "Got rule details for a rule we don't know";
|
||||||
return;
|
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);
|
parseEventDescriptors(ruleMap.value("eventDescriptors").toList(), rule);
|
||||||
parseRuleActions(ruleMap.value("actions").toList(), rule);
|
parseRuleActions(ruleMap.value("actions").toList(), rule);
|
||||||
parseRuleExitActions(ruleMap.value("exitActions").toList(), rule);
|
parseRuleExitActions(ruleMap.value("exitActions").toList(), rule);
|
||||||
|
|||||||
@ -147,7 +147,7 @@ void ParamType::setUnit(const Types::Unit &unit)
|
|||||||
m_unit = unit;
|
m_unit = unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QVariant> ParamType::allowedValues() const
|
QVariantList ParamType::allowedValues() const
|
||||||
{
|
{
|
||||||
return m_allowedValues;
|
return m_allowedValues;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,7 +83,7 @@ public:
|
|||||||
QString unitString() const;
|
QString unitString() const;
|
||||||
void setUnitString(const QString &unitString);
|
void setUnitString(const QString &unitString);
|
||||||
|
|
||||||
QList<QVariant> allowedValues() const;
|
QVariantList allowedValues() const;
|
||||||
void setAllowedValues(const QList<QVariant> allowedValues);
|
void setAllowedValues(const QList<QVariant> allowedValues);
|
||||||
|
|
||||||
bool readOnly() const;
|
bool readOnly() const;
|
||||||
|
|||||||
@ -92,6 +92,16 @@ void StateType::setDefaultValue(const QVariant &defaultValue)
|
|||||||
m_defaultValue = 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
|
Types::Unit StateType::unit() const
|
||||||
{
|
{
|
||||||
return m_unit;
|
return m_unit;
|
||||||
|
|||||||
@ -38,6 +38,7 @@ class StateType : public QObject
|
|||||||
Q_PROPERTY(QString type READ type CONSTANT)
|
Q_PROPERTY(QString type READ type CONSTANT)
|
||||||
Q_PROPERTY(int index READ index CONSTANT)
|
Q_PROPERTY(int index READ index CONSTANT)
|
||||||
Q_PROPERTY(QVariant defaultValue READ defaultValue 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(Types::Unit unit READ unit CONSTANT)
|
||||||
Q_PROPERTY(QString unitString READ unitString CONSTANT)
|
Q_PROPERTY(QString unitString READ unitString CONSTANT)
|
||||||
|
|
||||||
@ -63,6 +64,9 @@ public:
|
|||||||
QVariant defaultValue() const;
|
QVariant defaultValue() const;
|
||||||
void setDefaultValue(const QVariant &defaultValue);
|
void setDefaultValue(const QVariant &defaultValue);
|
||||||
|
|
||||||
|
QVariantList allowedValues() const;
|
||||||
|
void setAllowedValues(const QVariantList &allowedValues);
|
||||||
|
|
||||||
Types::Unit unit() const;
|
Types::Unit unit() const;
|
||||||
void setUnit(const Types::Unit &unit);
|
void setUnit(const Types::Unit &unit);
|
||||||
|
|
||||||
@ -76,6 +80,7 @@ private:
|
|||||||
QString m_type;
|
QString m_type;
|
||||||
int m_index;
|
int m_index;
|
||||||
QVariant m_defaultValue;
|
QVariant m_defaultValue;
|
||||||
|
QVariantList m_allowedValues;
|
||||||
Types::Unit m_unit;
|
Types::Unit m_unit;
|
||||||
QString m_unitString;
|
QString m_unitString;
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ ItemDelegate {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
sourceComponent: {
|
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()) {
|
switch (paramType.type.toLowerCase()) {
|
||||||
case "bool":
|
case "bool":
|
||||||
return boolComponent;
|
return boolComponent;
|
||||||
|
|||||||
@ -19,7 +19,7 @@ Page {
|
|||||||
header: GuhHeader {
|
header: GuhHeader {
|
||||||
text: {
|
text: {
|
||||||
if (subPage.shownInterfaces.length === 1) {
|
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) {
|
} else if (subPage.shownInterfaces.length > 1 || subPage.hiddenInterfaces.length > 0) {
|
||||||
return qsTr("My things")
|
return qsTr("My things")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,7 @@ SwipeDelegate {
|
|||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
font.pixelSize: childEvaluatorsRepeater.count > 0 ? app.smallFont : app.mediumFont
|
font.pixelSize: childEvaluatorsRepeater.count > 0 ? app.smallFont : app.mediumFont
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
property string operatorString: {
|
property string operatorString: {
|
||||||
if (!root.stateEvaluator) {
|
if (!root.stateEvaluator) {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
Reference in New Issue
Block a user