diff --git a/libnymea/types/browseritem.cpp b/libnymea/types/browseritem.cpp index 77af9ae7..da914a22 100644 --- a/libnymea/types/browseritem.cpp +++ b/libnymea/types/browseritem.cpp @@ -97,6 +97,16 @@ void BrowserItem::setThumbnail(const QString &thumbnail) m_thumbnail = thumbnail; } +QList BrowserItem::actionTypeIds() const +{ + return m_actionTypeIds; +} + +void BrowserItem::setActionTypeIs(const QList &actionTypeIds) +{ + m_actionTypeIds = actionTypeIds; +} + BrowserItem::ExtendedPropertiesFlags BrowserItem::extendedPropertiesFlags() const { return m_extendedPropertiesFlags; diff --git a/libnymea/types/browseritem.h b/libnymea/types/browseritem.h index 7bbd14cb..260a64ad 100644 --- a/libnymea/types/browseritem.h +++ b/libnymea/types/browseritem.h @@ -79,6 +79,9 @@ public: QString thumbnail() const; void setThumbnail(const QString &thumbnail); + QList actionTypeIds() const; + void setActionTypeIs(const QList &actionTypeIds); + ExtendedPropertiesFlags extendedPropertiesFlags() const; QVariant extendedProperty(const QString &propertyName) const; @@ -94,6 +97,7 @@ private: protected: ExtendedPropertiesFlags m_extendedPropertiesFlags = ExtendedPropertiesNone; QHash m_extendedProperties; + QList m_actionTypeIds; }; Q_DECLARE_OPERATORS_FOR_FLAGS(BrowserItem::ExtendedPropertiesFlags) diff --git a/libnymea/types/deviceclass.cpp b/libnymea/types/deviceclass.cpp index 08dbb71f..6ddb7ab0 100644 --- a/libnymea/types/deviceclass.cpp +++ b/libnymea/types/deviceclass.cpp @@ -147,7 +147,7 @@ StateType DeviceClass::getStateType(const StateTypeId &stateTypeId) /*! Set the \a stateTypes of this DeviceClass. \{Device}{Devices} created from this \l{DeviceClass} must have their states matching to this template. */ -void DeviceClass::setStateTypes(const QList &stateTypes) +void DeviceClass::setStateTypes(const StateTypes &stateTypes) { m_stateTypes = stateTypes; } @@ -172,7 +172,7 @@ EventTypes DeviceClass::eventTypes() const /*! Set the \a eventTypes of this DeviceClass. \{Device}{Devices} created from this \l{DeviceClass} must have their events matching to this template. */ -void DeviceClass::setEventTypes(const QList &eventTypes) +void DeviceClass::setEventTypes(const EventTypes &eventTypes) { m_eventTypes = eventTypes; } @@ -197,7 +197,7 @@ ActionTypes DeviceClass::actionTypes() const /*! Set the \a actionTypes of this DeviceClass. \{Device}{Devices} created from this \l{DeviceClass} must have their actions matching to this template. */ -void DeviceClass::setActionTypes(const QList &actionTypes) +void DeviceClass::setActionTypes(const ActionTypes &actionTypes) { m_actionTypes = actionTypes; } @@ -213,6 +213,31 @@ bool DeviceClass::hasActionType(const ActionTypeId &actionTypeId) return false; } +/*! Returns the browserActionTypes of this DeviceClass. \{Device}{Devices} created + from this \l{DeviceClass} may set those actions to their browser items. */ +ActionTypes DeviceClass::browserActionTypes() const +{ + return m_browserActionTypes; +} + +/*! Set the \a browserActionTypes of this DeviceClass. \{Device}{Devices} created + from this \l{DeviceClass} may set those actions to their browser items. */ +void DeviceClass::setBrowserActionTypes(const ActionTypes &browserActionTypes) +{ + m_browserActionTypes = browserActionTypes; +} + +/*! Returns true if this DeviceClass has a \l{ActionType} with the given \a actionTypeId. */ +bool DeviceClass::hasBrowserActionType(const ActionTypeId &actionTypeId) +{ + foreach (const ActionType &actionType, m_actionTypes) { + if (actionType.id() == actionTypeId) { + return true; + } + } + return false; +} + /*! Returns the params description of this DeviceClass. \{Device}{Devices} created from this \l{DeviceClass} must have their params matching to this template. */ ParamTypes DeviceClass::paramTypes() const diff --git a/libnymea/types/deviceclass.h b/libnymea/types/deviceclass.h index cd89f81a..d40b5324 100644 --- a/libnymea/types/deviceclass.h +++ b/libnymea/types/deviceclass.h @@ -71,17 +71,21 @@ public: StateTypes stateTypes() const; StateType getStateType(const StateTypeId &stateTypeId); - void setStateTypes(const QList &stateTypes); + void setStateTypes(const StateTypes &stateTypes); bool hasStateType(const StateTypeId &stateTypeId); EventTypes eventTypes() const; - void setEventTypes(const QList &eventTypes); + void setEventTypes(const EventTypes &eventTypes); bool hasEventType(const EventTypeId &eventTypeId); ActionTypes actionTypes() const; - void setActionTypes(const QList &actionTypes); + void setActionTypes(const ActionTypes &actionTypes); bool hasActionType(const ActionTypeId &actionTypeId); + ActionTypes browserActionTypes() const; + void setBrowserActionTypes(const ActionTypes &browserActionTypes); + bool hasBrowserActionType(const ActionTypeId &actionTypeId); + ParamTypes paramTypes() const; void setParamTypes(const ParamTypes ¶mTypes); @@ -118,6 +122,7 @@ private: StateTypes m_stateTypes; EventTypes m_eventTypes; ActionTypes m_actionTypes; + ActionTypes m_browserActionTypes; ParamTypes m_paramTypes; ParamTypes m_settingsTypes; ParamTypes m_discoveryParamTypes; diff --git a/libnymea/types/ruleaction.cpp b/libnymea/types/ruleaction.cpp index 556ba2c1..1e7580e2 100644 --- a/libnymea/types/ruleaction.cpp +++ b/libnymea/types/ruleaction.cpp @@ -169,6 +169,12 @@ ActionTypeId RuleAction::actionTypeId() const return m_actionTypeId; } +/*! Returns the browserItemId of this RuleAction. */ +QString RuleAction::browserItemId() const +{ + return m_browserItemId; +} + /*! Returns the deviceId of this RuleAction. */ DeviceId RuleAction::deviceId() const { diff --git a/plugins/mock/devicepluginmock.json b/plugins/mock/devicepluginmock.json index 168f14ce..205b654e 100644 --- a/plugins/mock/devicepluginmock.json +++ b/plugins/mock/devicepluginmock.json @@ -194,6 +194,13 @@ "name": "asyncFailing", "displayName": "Mock Action 5 (async, broken)" } + ], + "brwserItemActionTypes": [ + { + "id": "00b8f0a8-99ca-4aa4-833d-59eb8d4d6de3", + "name": "addToFolder", + "displayName": "Add to Favorites" + } ] }, {