From 6b2c5afb27b15fcaaf68942267062bb576214349 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 26 Nov 2017 17:17:16 +0100 Subject: [PATCH] fix notifications view --- guh-control/ui/customviews/NotificationsView.qml | 5 +++-- libguh-common/types/paramtypes.cpp | 10 ++++++++++ libguh-common/types/paramtypes.h | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/guh-control/ui/customviews/NotificationsView.qml b/guh-control/ui/customviews/NotificationsView.qml index 4967168f..ad37e5ef 100644 --- a/guh-control/ui/customviews/NotificationsView.qml +++ b/guh-control/ui/customviews/NotificationsView.qml @@ -10,7 +10,7 @@ CustomViewBase { ColumnLayout { id: grid - anchors { left: parent.left; top: parent.top; right: parent.right } + anchors { left: parent.left; top: parent.top; right: parent.right; margins: app.margins } Label { Layout.fillWidth: true text: "Send a notification now:" @@ -26,7 +26,8 @@ CustomViewBase { var params = [] var param1 = {} - var paramTypeId = root.deviceClass.actionTypes.findByName("notify").paramTypes.getParamType("title").id + print("bla:", root.deviceClass.actionTypes.findByName("notify").paramTypes) + var paramTypeId = root.deviceClass.actionTypes.findByName("notify").paramTypes.findByName("title").id param1.paramTypeId = paramTypeId param1.value = textArea.text params.push(param1) diff --git a/libguh-common/types/paramtypes.cpp b/libguh-common/types/paramtypes.cpp index 5f0f28c0..14feaa00 100644 --- a/libguh-common/types/paramtypes.cpp +++ b/libguh-common/types/paramtypes.cpp @@ -47,6 +47,16 @@ ParamType *ParamTypes::getParamType(const QString &id) const return 0; } +ParamType *ParamTypes::findByName(const QString &name) const +{ + foreach (ParamType *paramType, m_paramTypes) { + if (paramType->name() == name) { + return paramType; + } + } + return 0; +} + int ParamTypes::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) diff --git a/libguh-common/types/paramtypes.h b/libguh-common/types/paramtypes.h index 721b5c5a..7328720c 100644 --- a/libguh-common/types/paramtypes.h +++ b/libguh-common/types/paramtypes.h @@ -50,6 +50,7 @@ public: Q_INVOKABLE ParamType *get(int index) const; Q_INVOKABLE ParamType *getParamType(const QString &id) const; + Q_INVOKABLE ParamType *findByName(const QString &name) const; int rowCount(const QModelIndex & parent = QModelIndex()) const; QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;