some small fixes

This commit is contained in:
Michael Zanetti 2018-11-29 14:29:54 +01:00
parent dcb648addb
commit 75ae223f54
5 changed files with 78 additions and 18 deletions

View File

@ -8,11 +8,13 @@ import "../components"
ItemDelegate {
id: root
property var actionType: null
property ActionType actionType: null
property var actionState: null
signal executeAction(var params)
readonly property bool multiParam: actionType.paramTypes.count > 1
contentItem: ColumnLayout {
RowLayout {
Label {
@ -25,7 +27,7 @@ ItemDelegate {
id: loader
Layout.fillWidth: sourceComponent == textFieldComponent || sourceComponent == buttonComponent
sourceComponent: {
if (root.actionType.paramTypes.count !== 1) {
if (root.multiParam || root.actionType.paramTypes.count === 0) {
return buttonComponent
}
@ -68,16 +70,21 @@ ItemDelegate {
}
Repeater {
id: paramRepeater
model: root.actionType.paramTypes
delegate: Loader {
id: bottomLoader
property var paramType: root.actionType.paramTypes.get(index)
Layout.fillWidth: true
sourceComponent: {
switch (paramType.type.toLowerCase()) {
case "int":
case "double":
if (paramType.minValue !== undefined && paramType.maxValue !== undefined) {
if (root.multiParam) {
return labelledSpinnerComponent;
}
return sliderComponent
}
return textFieldComponent;
@ -87,7 +94,7 @@ ItemDelegate {
return paramType.allowedValues.length === 0 ? textFieldComponent :
root.actionType.paramTypes.count === 1 ? null : comboBoxComponent
case "bool":
if (root.actionType.paramTypes.count > 1) {
if (root.multiParam) {
return labeledBoolComponent;
}
return null
@ -104,9 +111,9 @@ ItemDelegate {
}
Binding {
target: bottomLoader.item
when: bottomLoader.item && root.actionState
when: bottomLoader.item
property: "value"
value: root.actionState
value: (root.actionState && index == 0) ? root.actionState : root.actionType.paramTypes.get(index).defaultValue
}
}
}
@ -147,8 +154,10 @@ ItemDelegate {
id: switchRow
property var paramType: null
property var value
Label {
text: paramType.displayName
Layout.fillWidth: true
}
Switch {
checked: paramType.defaultValue
@ -196,7 +205,28 @@ ItemDelegate {
text: sliderRow.paramType.maxValue
}
}
}
Component {
id: labelledSpinnerComponent
RowLayout {
id: sliderRow
property var paramType: null
property var value: null
Label {
text: sliderRow.paramType.displayName
Layout.fillWidth: true
}
SpinBox {
from: sliderRow.paramType.minValue
to: sliderRow.paramType.maxValue
value: sliderRow.value
editable: true
onValueModified: {
sliderRow.value = value
}
}
}
}
Component {

View File

@ -8,7 +8,7 @@ import "../components"
ItemDelegate {
id: root
property var paramType: null
property ParamType paramType: null
property alias value: d.value
property var param: Param {
id: d
@ -39,10 +39,7 @@ ItemDelegate {
case "bool":
return boolComponent;
case "int":
if (root.paramType.minimumValue !== undefined && root.paramType.maximumValue !== undefined) {
return sliderComponent;
}
return textFieldComponent;
return spinnerComponent;
case "string":
case "qstring":
if (root.paramType.allowedValues.length > 0) {
@ -61,12 +58,12 @@ ItemDelegate {
Layout.fillWidth: true
sourceComponent: {
switch (root.paramType.type.toLowerCase()) {
case "int":
case "double":
if (root.paramType.minValue !== undefined && root.paramType.maxValue !== undefined) {
return sliderComponent
}
break;
// case "int":
// case "double":
// if (root.paramType.minValue !== undefined && root.paramType.maxValue !== undefined) {
// return sliderComponent
// }
// break;
case "color":
return colorPickerComponent
}
@ -143,6 +140,20 @@ ItemDelegate {
}
Component {
id: spinnerComponent
SpinBox {
value: root.param.value
from: root.paramType.minValue
to: root.paramType.maxValue
editable: true
onValueModified: root.param.value = value
textFromValue: function(value) {
return value
}
}
}
Component {
id: textFieldComponent
TextField {

View File

@ -22,7 +22,8 @@ Page {
function enterPage(index, replace) {
var device = devicesProxy.get(index);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var page = app.interfaceListToDevicePage(deviceClass.interfaces);
var page = app.interfaceListToDevicePage(root.shownInterfaces);
// var page = "GenericDevicePage.qml";
if (replace) {
pageStack.replace(Qt.resolvedUrl("../devicepages/" + page), {device: devicesProxy.get(index)})
} else {

View File

@ -9,6 +9,7 @@ DevicePageBase {
id: root
GenericTypeLogView {
id: logView
anchors.fill: parent
logsModel: engine.jsonRpcClient.ensureServerVersion("1.10") ? logsModelNg : logsModel
@ -28,6 +29,22 @@ DevicePageBase {
typeIds: [root.deviceClass.eventTypes.findByName("triggered").id];
}
// delegate: MeaListItemDelegate {
// width: parent.width
// iconName: app.interfaceToIcon("inputtrigger")
// text: model.value.trim()
// subText: Qt.formatDateTime(model.timestamp)
// progressive: false
// onClicked: {
// print("a", model.value.trim())
// var parts = model.value.trim().split(', ')
// print("b", parts)
// var popup = detailsPopup.createObject(root, {timestamp: model.timestamp, notificationTitle: parts[1], notificationBody: parts[0]});
// popup.open();
// }
// }
onAddRuleClicked: {
var value = logView.logsModel.get(index).value
var typeId = logView.logsModel.get(index).typeId

View File

@ -88,6 +88,7 @@ DevicePageBase {
id: logsModelNg
deviceId: root.device.id
engine: _engine
live: true
typeIds: [root.deviceClass.actionTypes.findByName("notify").id];
}
@ -102,7 +103,7 @@ DevicePageBase {
delegate: MeaListItemDelegate {
width: parent.width
iconName: "../images/notification.svg"
iconName: app.interfaceToIcon("notifications")
text: model.value.trim()
subText: Qt.formatDateTime(model.timestamp)
progressive: false