An attempt to make it configurable
This commit is contained in:
parent
59140f7bd4
commit
56448543df
@ -383,6 +383,24 @@ State Thing::state(const StateTypeId &stateTypeId) const
|
|||||||
return State(StateTypeId(), ThingId());
|
return State(StateTypeId(), ThingId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Thing::setStateLogged(const StateTypeId &stateTypeId, bool logged)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_states.count(); i++) {
|
||||||
|
if (m_states.at(i).stateTypeId() == stateTypeId) {
|
||||||
|
m_states[i].setLogged(logged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Thing::setStateFilter(const StateTypeId &stateTypeId, Types::StateValueFilter filter)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_states.count(); i++) {
|
||||||
|
if (m_states.at(i).stateTypeId() == stateTypeId) {
|
||||||
|
m_states[i].setFilter(filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns the \l{ThingId} of the parent of this thing. If the parentId
|
/*! Returns the \l{ThingId} of the parent of this thing. If the parentId
|
||||||
is not set, this thing does not have a parent.
|
is not set, this thing does not have a parent.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -133,6 +133,9 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE State state(const StateTypeId &stateTypeId) const;
|
Q_INVOKABLE State state(const StateTypeId &stateTypeId) const;
|
||||||
|
|
||||||
|
void setStateLogged(const StateTypeId &stateTypeId, bool logged);
|
||||||
|
void setStateFilter(const StateTypeId &stateTypeId, Types::StateValueFilter filter);
|
||||||
|
|
||||||
ThingId parentId() const;
|
ThingId parentId() const;
|
||||||
void setParentId(const ThingId &parentId);
|
void setParentId(const ThingId &parentId);
|
||||||
|
|
||||||
|
|||||||
@ -80,6 +80,26 @@ void State::setValue(const QVariant &value)
|
|||||||
m_value = value;
|
m_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Types::StateValueFilter State::filter() const
|
||||||
|
{
|
||||||
|
return m_filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void State::setFilter(Types::StateValueFilter filter)
|
||||||
|
{
|
||||||
|
m_filter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool State::logged() const
|
||||||
|
{
|
||||||
|
return m_logged;
|
||||||
|
}
|
||||||
|
|
||||||
|
void State::setLogged(bool logged)
|
||||||
|
{
|
||||||
|
m_logged = logged;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Writes the stateTypeId, the deviceId and the value of the given \a state to \a dbg. */
|
/*! Writes the stateTypeId, the deviceId and the value of the given \a state to \a dbg. */
|
||||||
QDebug operator<<(QDebug dbg, const State &state)
|
QDebug operator<<(QDebug dbg, const State &state)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -42,6 +42,8 @@ class LIBNYMEA_EXPORT State
|
|||||||
Q_GADGET
|
Q_GADGET
|
||||||
Q_PROPERTY(QUuid stateTypeId READ stateTypeId)
|
Q_PROPERTY(QUuid stateTypeId READ stateTypeId)
|
||||||
Q_PROPERTY(QVariant value READ value)
|
Q_PROPERTY(QVariant value READ value)
|
||||||
|
Q_PROPERTY(Types::StateValueFilter filter READ filter)
|
||||||
|
Q_PROPERTY(bool logged READ logged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
State();
|
State();
|
||||||
@ -53,10 +55,18 @@ public:
|
|||||||
QVariant value() const;
|
QVariant value() const;
|
||||||
void setValue(const QVariant &value);
|
void setValue(const QVariant &value);
|
||||||
|
|
||||||
|
Types::StateValueFilter filter() const;
|
||||||
|
void setFilter(Types::StateValueFilter filter);
|
||||||
|
|
||||||
|
bool logged() const;
|
||||||
|
void setLogged(bool logged);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StateTypeId m_stateTypeId;
|
StateTypeId m_stateTypeId;
|
||||||
ThingId m_thingId;
|
ThingId m_thingId;
|
||||||
QVariant m_value;
|
QVariant m_value;
|
||||||
|
Types::StateValueFilter m_filter;
|
||||||
|
bool m_logged = false;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(State)
|
Q_DECLARE_METATYPE(State)
|
||||||
|
|
||||||
|
|||||||
@ -208,6 +208,16 @@ void StateType::setCached(bool cached)
|
|||||||
m_cached = cached;
|
m_cached = cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Types::StateValueFilter StateType::filter() const
|
||||||
|
{
|
||||||
|
return m_filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateType::setFilter(Types::StateValueFilter filter)
|
||||||
|
{
|
||||||
|
m_filter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns a list of all valid properties a DeviceClass definition can have. */
|
/*! Returns a list of all valid properties a DeviceClass definition can have. */
|
||||||
QStringList StateType::typeProperties()
|
QStringList StateType::typeProperties()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -93,6 +93,12 @@ public:
|
|||||||
bool cached() const;
|
bool cached() const;
|
||||||
void setCached(bool cached);
|
void setCached(bool cached);
|
||||||
|
|
||||||
|
bool logged() const;
|
||||||
|
void setLogged(bool logged);
|
||||||
|
|
||||||
|
Types::StateValueFilter filter() const;
|
||||||
|
void setFilter(Types::StateValueFilter filter);
|
||||||
|
|
||||||
static QStringList typeProperties();
|
static QStringList typeProperties();
|
||||||
static QStringList mandatoryTypeProperties();
|
static QStringList mandatoryTypeProperties();
|
||||||
|
|
||||||
@ -112,6 +118,8 @@ private:
|
|||||||
Types::IOType m_ioType = Types::IOTypeNone;
|
Types::IOType m_ioType = Types::IOTypeNone;
|
||||||
bool m_writable = false;
|
bool m_writable = false;
|
||||||
bool m_cached = true;
|
bool m_cached = true;
|
||||||
|
bool m_logged = false;
|
||||||
|
Types::StateValueFilter m_filter = Types::StateValueFilterNone;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(StateType)
|
Q_DECLARE_METATYPE(StateType)
|
||||||
|
|
||||||
|
|||||||
@ -173,6 +173,12 @@ public:
|
|||||||
IOTypeAnalogOutput
|
IOTypeAnalogOutput
|
||||||
};
|
};
|
||||||
Q_ENUM(IOType)
|
Q_ENUM(IOType)
|
||||||
|
|
||||||
|
enum StateValueFilter {
|
||||||
|
StateValueFilterNone,
|
||||||
|
StateValueFilterAdaptive
|
||||||
|
};
|
||||||
|
Q_ENUM(StateValueFilter)
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Types::InputType)
|
Q_DECLARE_METATYPE(Types::InputType)
|
||||||
|
|||||||
Reference in New Issue
Block a user