Fix working in rules param condition selectors

This commit is contained in:
Michael Zanetti 2023-02-13 14:58:45 +01:00
parent efa13f8483
commit 65fff5fde2
2 changed files with 46 additions and 28 deletions

View File

@ -59,6 +59,7 @@ ItemDelegate {
FontMetrics { FontMetrics {
id: fm id: fm
} }
textRole: "text"
Layout.fillWidth: true Layout.fillWidth: true
Layout.minimumWidth: { Layout.minimumWidth: {
@ -86,31 +87,28 @@ ItemDelegate {
} }
model: isNumeric ? model: isNumeric ?
[qsTr("is"), qsTr("is not"), qsTr("is greater"), qsTr("is smaller"), qsTr("is greater or equal"), qsTr("is smaller or equal")] numericModel
: [qsTr("is"), qsTr("is not")]; : nonNumericModel
onCurrentTextChanged: { ListModel {
switch (currentText) { id: numericModel
case qsTr("is"): ListElement { text: qsTr("is equal to"); value: ParamDescriptor.ValueOperatorEquals }
root.operatorType = ParamDescriptor.ValueOperatorEquals; ListElement { text: qsTr("is not equal to"); value: ParamDescriptor.ValueOperatorNotEquals }
break; ListElement { text: qsTr("is greater than"); value: ParamDescriptor.ValueOperatorGreater }
case qsTr("is not"): ListElement { text: qsTr("is less than"); value: ParamDescriptor.ValueOperatorLess }
root.operatorType = ParamDescriptor.ValueOperatorNotEquals; ListElement { text: qsTr("is greater than or equal to"); value: ParamDescriptor.ValueOperatorGreaterOrEqual }
break; ListElement { text: qsTr("is less than or equal to"); value: ParamDescriptor.ValueOperatorLessOrEqual }
case qsTr("is greater"): }
root.operatorType = ParamDescriptor.ValueOperatorGreater;
break; ListModel {
case qsTr("is smaller"): id: nonNumericModel
root.operatorType = ParamDescriptor.ValueOperatorLess; ListElement { text: qsTr("is"); value: ParamDescriptor.ValueOperatorEquals }
break; ListElement { text: qsTr("is not "); value: ParamDescriptor.ValueOperatorNotEquals }
case qsTr("is greater or equal"): }
root.operatorType = ParamDescriptor.ValueOperatorGreaterOrEqual;
break; onCurrentIndexChanged: {
case qsTr("is smaller or equal"): root.operatorType = model.get(currentIndex).value
root.operatorType = ParamDescriptor.ValueOperatorLessOrEqual; print("set operator to", root.operatorType, currentText, currentIndex, model, model.get(currentIndex))
break;
}
print("set operator to", root.operatorType, currentText)
} }
} }
@ -218,7 +216,7 @@ ItemDelegate {
} }
Component.onCompleted: { Component.onCompleted: {
if (root.value == null || root.v^alue == undefined) { if (root.value == null || root.value == undefined) {
root.value = from; root.value = from;
} }
} }

View File

@ -89,8 +89,27 @@ Page {
} }
model: isNumeric ? model: isNumeric ?
[qsTr("is equal to"), qsTr("is not equal to"), qsTr("is smaller than"), qsTr("is greater than"), qsTr("is smaller or equal than"), qsTr("is greater or equal than")] numericModel
: [qsTr("is"), qsTr("is not")]; : nonNumericModel
textRole: "text"
ListModel {
id: numericModel
ListElement { text: qsTr("is equal to"); value: ParamDescriptor.ValueOperatorEquals }
ListElement { text: qsTr("is not equal to"); value: ParamDescriptor.ValueOperatorNotEquals }
ListElement { text: qsTr("is greater than"); value: ParamDescriptor.ValueOperatorGreater }
ListElement { text: qsTr("is less than"); value: ParamDescriptor.ValueOperatorLess }
ListElement { text: qsTr("is greater than or equal to"); value: ParamDescriptor.ValueOperatorGreaterOrEqual }
ListElement { text: qsTr("is less than or equal to"); value: ParamDescriptor.ValueOperatorLessOrEqual }
}
ListModel {
id: nonNumericModel
ListElement { text: qsTr("is"); value: ParamDescriptor.ValueOperatorEquals }
ListElement { text: qsTr("is not "); value: ParamDescriptor.ValueOperatorNotEquals }
}
} }
GroupBox { GroupBox {
@ -168,7 +187,8 @@ Page {
Layout.margins: app.margins Layout.margins: app.margins
onClicked: { onClicked: {
print("saving") print("saving")
root.stateDescriptor.valueOperator = operatorComboBox.currentIndex root.stateDescriptor.valueOperator = operatorComboBox.model.get(operatorComboBox.currentIndex).value
print("operator:", root.stateDescriptor.valueOperator)
if (staticValueRadioButton.checked) { if (staticValueRadioButton.checked) {
print("static value:", staticValueParamDelegate.value) print("static value:", staticValueParamDelegate.value)
root.stateDescriptor.value = staticValueParamDelegate.value root.stateDescriptor.value = staticValueParamDelegate.value