Merge PR #279: Fix browserItemActionTypes
This commit is contained in:
commit
00fb1406b8
@ -188,7 +188,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));
|
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) {
|
||||||
|
|||||||
@ -71,7 +71,7 @@ private:
|
|||||||
bool m_showActions = true;
|
bool m_showActions = true;
|
||||||
bool m_showEvents = true;
|
bool m_showEvents = true;
|
||||||
|
|
||||||
QList<QString> m_list;
|
QList<QUuid> m_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEVICEMODEL_H
|
#endif // DEVICEMODEL_H
|
||||||
|
|||||||
@ -27,12 +27,12 @@ ActionType::ActionType(QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ActionType::id() const
|
QUuid ActionType::id() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionType::setId(const QString &id)
|
void ActionType::setId(const QUuid &id)
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
class ActionType : public QObject
|
class ActionType : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString id READ id CONSTANT)
|
Q_PROPERTY(QUuid id READ id CONSTANT)
|
||||||
Q_PROPERTY(QString name READ name CONSTANT)
|
Q_PROPERTY(QString name READ name CONSTANT)
|
||||||
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
||||||
Q_PROPERTY(int index READ index CONSTANT)
|
Q_PROPERTY(int index READ index CONSTANT)
|
||||||
@ -40,8 +40,8 @@ class ActionType : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit ActionType(QObject *parent = nullptr);
|
explicit ActionType(QObject *parent = nullptr);
|
||||||
|
|
||||||
QString id() const;
|
QUuid id() const;
|
||||||
void setId(const QString &id);
|
void setId(const QUuid &id);
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
@ -56,7 +56,7 @@ public:
|
|||||||
void setParamTypes(ParamTypes *paramTypes);
|
void setParamTypes(ParamTypes *paramTypes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_id;
|
QUuid m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
int m_index;
|
int m_index;
|
||||||
|
|||||||
@ -38,7 +38,7 @@ ActionType *ActionTypes::get(int index) const
|
|||||||
return m_actionTypes.at(index);
|
return m_actionTypes.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionType *ActionTypes::getActionType(const QString &actionTypeId) const
|
ActionType *ActionTypes::getActionType(const QUuid &actionTypeId) const
|
||||||
{
|
{
|
||||||
foreach (ActionType *actionType, m_actionTypes) {
|
foreach (ActionType *actionType, m_actionTypes) {
|
||||||
if (actionType->id() == actionTypeId) {
|
if (actionType->id() == actionTypeId) {
|
||||||
|
|||||||
@ -39,12 +39,12 @@ public:
|
|||||||
RoleDisplayName
|
RoleDisplayName
|
||||||
};
|
};
|
||||||
|
|
||||||
ActionTypes(QObject *parent = 0);
|
ActionTypes(QObject *parent = nullptr);
|
||||||
|
|
||||||
QList<ActionType *> actionTypes();
|
QList<ActionType *> actionTypes();
|
||||||
|
|
||||||
Q_INVOKABLE ActionType *get(int index) const;
|
Q_INVOKABLE ActionType *get(int index) const;
|
||||||
Q_INVOKABLE ActionType *getActionType(const QString &actionTypeId) const;
|
Q_INVOKABLE ActionType *getActionType(const QUuid &actionTypeId) const;
|
||||||
|
|
||||||
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||||
|
|||||||
@ -27,12 +27,12 @@ EventType::EventType(QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EventType::id() const
|
QUuid EventType::id() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventType::setId(const QString &id)
|
void EventType::setId(const QUuid &id)
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,17 +31,17 @@
|
|||||||
class EventType : public QObject
|
class EventType : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString id READ id CONSTANT)
|
Q_PROPERTY(QUuid id READ id CONSTANT)
|
||||||
Q_PROPERTY(QString name READ name CONSTANT)
|
Q_PROPERTY(QString name READ name CONSTANT)
|
||||||
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
||||||
Q_PROPERTY(int index READ index CONSTANT)
|
Q_PROPERTY(int index READ index CONSTANT)
|
||||||
Q_PROPERTY(ParamTypes* paramTypes READ paramTypes CONSTANT)
|
Q_PROPERTY(ParamTypes* paramTypes READ paramTypes CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EventType(QObject *parent = 0);
|
explicit EventType(QObject *parent = nullptr);
|
||||||
|
|
||||||
QString id() const;
|
QUuid id() const;
|
||||||
void setId(const QString &id);
|
void setId(const QUuid &id);
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
@ -56,7 +56,7 @@ public:
|
|||||||
void setParamTypes(ParamTypes *paramTypes);
|
void setParamTypes(ParamTypes *paramTypes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_id;
|
QUuid m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
int m_index;
|
int m_index;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ EventType *EventTypes::get(int index) const
|
|||||||
return m_eventTypes.at(index);
|
return m_eventTypes.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventType *EventTypes::getEventType(const QString &eventTypeId) const
|
EventType *EventTypes::getEventType(const QUuid &eventTypeId) const
|
||||||
{
|
{
|
||||||
foreach (EventType *eventType, m_eventTypes) {
|
foreach (EventType *eventType, m_eventTypes) {
|
||||||
if (eventType->id() == eventTypeId) {
|
if (eventType->id() == eventTypeId) {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public:
|
|||||||
QList<EventType *> eventTypes();
|
QList<EventType *> eventTypes();
|
||||||
|
|
||||||
Q_INVOKABLE EventType *get(int index) const;
|
Q_INVOKABLE EventType *get(int index) const;
|
||||||
Q_INVOKABLE EventType *getEventType(const QString &eventTypeId) const;
|
Q_INVOKABLE EventType *getEventType(const QUuid &eventTypeId) const;
|
||||||
|
|
||||||
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||||
|
|||||||
@ -27,12 +27,12 @@ StateType::StateType(QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString StateType::id() const
|
QUuid StateType::id() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StateType::setId(const QString &id)
|
void StateType::setId(const QUuid &id)
|
||||||
{
|
{
|
||||||
m_id = id;
|
m_id = id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
class StateType : public QObject
|
class StateType : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString id READ id CONSTANT)
|
Q_PROPERTY(QUuid id READ id CONSTANT)
|
||||||
Q_PROPERTY(QString name READ name CONSTANT)
|
Q_PROPERTY(QString name READ name CONSTANT)
|
||||||
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
Q_PROPERTY(QString displayName READ displayName CONSTANT)
|
||||||
Q_PROPERTY(QString type READ type CONSTANT)
|
Q_PROPERTY(QString type READ type CONSTANT)
|
||||||
@ -47,8 +47,8 @@ class StateType : public QObject
|
|||||||
public:
|
public:
|
||||||
StateType(QObject *parent = nullptr);
|
StateType(QObject *parent = nullptr);
|
||||||
|
|
||||||
QString id() const;
|
QUuid id() const;
|
||||||
void setId(const QString &id);
|
void setId(const QUuid &id);
|
||||||
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
void setMaxValue(const QVariant &maxValue);
|
void setMaxValue(const QVariant &maxValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_id;
|
QUuid m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
QString m_type;
|
QString m_type;
|
||||||
|
|||||||
@ -42,7 +42,7 @@ StateType *StateTypes::get(int index) const
|
|||||||
return m_stateTypes.at(index);
|
return m_stateTypes.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
StateType *StateTypes::getStateType(const QString &stateTypeId) const
|
StateType *StateTypes::getStateType(const QUuid &stateTypeId) const
|
||||||
{
|
{
|
||||||
foreach (StateType *stateType, m_stateTypes) {
|
foreach (StateType *stateType, m_stateTypes) {
|
||||||
if (stateType->id() == stateTypeId) {
|
if (stateType->id() == stateTypeId) {
|
||||||
|
|||||||
@ -49,7 +49,7 @@ public:
|
|||||||
QList<StateType *> stateTypes();
|
QList<StateType *> stateTypes();
|
||||||
|
|
||||||
Q_INVOKABLE StateType *get(int index) const;
|
Q_INVOKABLE StateType *get(int index) const;
|
||||||
Q_INVOKABLE StateType *getStateType(const QString &stateTypeId) const;
|
Q_INVOKABLE StateType *getStateType(const QUuid &stateTypeId) const;
|
||||||
|
|
||||||
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import "../delegates"
|
|||||||
|
|
||||||
MeaDialog {
|
MeaDialog {
|
||||||
id: root
|
id: root
|
||||||
|
x: (parent.width - width) / 2
|
||||||
|
y: (parent.height - height / 2)
|
||||||
|
|
||||||
property Device device
|
property Device device
|
||||||
property string itemId
|
property string itemId
|
||||||
@ -18,7 +20,7 @@ MeaDialog {
|
|||||||
StackView {
|
StackView {
|
||||||
id: stackView
|
id: stackView
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.minimumHeight: actionListView.implicitHeight
|
Layout.preferredHeight: actionListView.implicitHeight
|
||||||
|
|
||||||
property var actionTypeId
|
property var actionTypeId
|
||||||
|
|
||||||
@ -64,9 +66,11 @@ MeaDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
id: buttonRow
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
id: cancelButton
|
||||||
text: qsTr("Cancel")
|
text: qsTr("Cancel")
|
||||||
onClicked: root.reject()
|
onClicked: root.reject()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,13 @@ NymeaListItemDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var actionDialogComponent = Qt.createComponent(Qt.resolvedUrl("../components/BrowserContextMenu.qml"));
|
var actionDialogComponent = Qt.createComponent(Qt.resolvedUrl("../components/BrowserContextMenu.qml"));
|
||||||
var popup = actionDialogComponent.createObject(root, {device: root.device, title: model.displayName, itemId: model.id, actionTypeIds: model.actionTypeIds});
|
var popup = actionDialogComponent.createObject(root.parent,
|
||||||
|
{
|
||||||
|
device: root.device,
|
||||||
|
title: model.displayName,
|
||||||
|
itemId: model.id,
|
||||||
|
actionTypeIds: model.actionTypeIds
|
||||||
|
});
|
||||||
popup.activated.connect(function(actionTypeId, params) {
|
popup.activated.connect(function(actionTypeId, params) {
|
||||||
root.contextMenuActionTriggered(actionTypeId, params)
|
root.contextMenuActionTriggered(actionTypeId, params)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user