mirror of https://github.com/nymea/nymea.git
Add more methods to get to states by name instead of id
parent
67b097f2fe
commit
15faf72785
|
|
@ -266,6 +266,12 @@ QVariant Thing::setting(const ParamTypeId ¶mTypeId) const
|
|||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant Thing::setting(const QString ¶mName) const
|
||||
{
|
||||
ParamTypeId paramTypeId = m_thingClass.settingsTypes().findByName(paramName).id();
|
||||
return setting(paramTypeId);
|
||||
}
|
||||
|
||||
void Thing::setSettingValue(const ParamTypeId ¶mTypeId, const QVariant &value)
|
||||
{
|
||||
ParamList settings;
|
||||
|
|
@ -291,6 +297,12 @@ void Thing::setSettingValue(const ParamTypeId ¶mTypeId, const QVariant &valu
|
|||
}
|
||||
}
|
||||
|
||||
void Thing::setSettingValue(const QString ¶mName, const QVariant &value)
|
||||
{
|
||||
ParamTypeId paramTypeId = m_thingClass.settingsTypes().findByName(paramName).id();
|
||||
setSettingValue(paramTypeId, value);
|
||||
}
|
||||
|
||||
/*! Returns the states of this thing. It must match the \l{StateType} description in the associated \l{ThingClass}. */
|
||||
States Thing::states() const
|
||||
{
|
||||
|
|
@ -386,6 +398,12 @@ void Thing::setStateValue(const StateTypeId &stateTypeId, const QVariant &value)
|
|||
qCWarning(dcThing).nospace() << m_name << ": Failed setting state " << stateType.name() << "to" << value;
|
||||
}
|
||||
|
||||
void Thing::setStateValue(const QString &stateName, const QVariant &value)
|
||||
{
|
||||
StateTypeId stateTypeId = m_thingClass.stateTypes().findByName(stateName).id();
|
||||
setStateValue(stateTypeId, value);
|
||||
}
|
||||
|
||||
/*! Returns the \l{State} with the given \a stateTypeId of this thing. */
|
||||
State Thing::state(const StateTypeId &stateTypeId) const
|
||||
{
|
||||
|
|
@ -397,6 +415,13 @@ State Thing::state(const StateTypeId &stateTypeId) const
|
|||
return State(StateTypeId(), ThingId());
|
||||
}
|
||||
|
||||
/*! Returns the \l{State} with the given name of this thing. */
|
||||
State Thing::state(const QString &stateName) const
|
||||
{
|
||||
StateTypeId stateTypeId = m_thingClass.stateTypes().findByName(stateName).id();
|
||||
return state(stateTypeId);
|
||||
}
|
||||
|
||||
QList<EventTypeId> Thing::loggedEventTypeIds() const
|
||||
{
|
||||
return m_loggedEventTypeIds;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,9 @@ public:
|
|||
Q_INVOKABLE void setSettings(const ParamList &settings);
|
||||
|
||||
Q_INVOKABLE QVariant setting(const ParamTypeId ¶mTypeId) const;
|
||||
Q_INVOKABLE QVariant setting(const QString ¶mName) const;
|
||||
Q_INVOKABLE void setSettingValue(const ParamTypeId ¶mTypeId, const QVariant &value);
|
||||
Q_INVOKABLE void setSettingValue(const QString ¶mName, const QVariant &value);
|
||||
|
||||
States states() const;
|
||||
bool hasState(const StateTypeId &stateTypeId) const;
|
||||
|
|
@ -135,8 +137,10 @@ public:
|
|||
Q_INVOKABLE QVariant stateValue(const StateTypeId &stateTypeId) const;
|
||||
Q_INVOKABLE QVariant stateValue(const QString &stateName) const;
|
||||
Q_INVOKABLE void setStateValue(const StateTypeId &stateTypeId, const QVariant &value);
|
||||
Q_INVOKABLE void setStateValue(const QString &stateName, const QVariant &value);
|
||||
|
||||
Q_INVOKABLE State state(const StateTypeId &stateTypeId) const;
|
||||
Q_INVOKABLE State state(const QString &stateName) const;
|
||||
|
||||
QList<EventTypeId> loggedEventTypeIds() const;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue