add actions to json
This commit is contained in:
parent
e30a533391
commit
9598362988
@ -42,6 +42,16 @@ void DeviceClass::setTriggers(const QList<TriggerType> &triggers)
|
||||
m_triggers = triggers;
|
||||
}
|
||||
|
||||
QList<ActionType> DeviceClass::actions() const
|
||||
{
|
||||
return m_actions;
|
||||
}
|
||||
|
||||
void DeviceClass::setActions(const QList<ActionType> &actions)
|
||||
{
|
||||
m_actions = actions;
|
||||
}
|
||||
|
||||
QVariantList DeviceClass::params() const
|
||||
{
|
||||
return m_params;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define DEVICECLASS_H
|
||||
|
||||
#include "triggertype.h"
|
||||
#include "actiontype.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QUuid>
|
||||
@ -21,6 +22,9 @@ public:
|
||||
QList<TriggerType> triggers() const;
|
||||
void setTriggers(const QList<TriggerType> &triggers);
|
||||
|
||||
QList<ActionType> actions() const;
|
||||
void setActions(const QList<ActionType> &actions);
|
||||
|
||||
QVariantList params() const;
|
||||
void setParams(const QVariantList ¶ms);
|
||||
|
||||
@ -31,6 +35,7 @@ private:
|
||||
QUuid m_pluginId;
|
||||
QString m_name;
|
||||
QList<TriggerType> m_triggers;
|
||||
QList<ActionType> m_actions;
|
||||
QVariantList m_params;
|
||||
};
|
||||
|
||||
|
||||
@ -139,8 +139,18 @@ QVariantMap JsonRPCServer::packDeviceClass(const DeviceClass &deviceClass)
|
||||
|
||||
triggerTypes.append(triggerMap);
|
||||
}
|
||||
QVariantList actionTypes;
|
||||
foreach (const ActionType &actionType, deviceClass.actions()) {
|
||||
QVariantMap actionMap;
|
||||
actionMap.insert("id", actionType.id().toString());
|
||||
actionMap.insert("name", actionType.name());
|
||||
actionMap.insert("params", actionType.parameters());
|
||||
|
||||
actionTypes.append(actionMap);
|
||||
}
|
||||
variant.insert("params", deviceClass.params());
|
||||
variant.insert("triggers", triggerTypes);
|
||||
variant.insert("actions", actionTypes);
|
||||
return variant;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user