Skip to content

Commit 7d52038

Browse files
Small changes
1 parent 2ef30b9 commit 7d52038

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

app/qml/filters/MMFiltersPanel.qml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ MMComponents.MMDrawer {
7575
currentValueTo: f.currentValueTo !== undefined ? f.currentValueTo : null,
7676
hasTime: !!f.hasTime,
7777
multiSelect: !!f.multiSelect,
78-
currentValueTexts: f.currentValueTexts || []
78+
currentValueTexts: f.currentValueTexts || [],
79+
boolTrueLabel: f.boolTrueLabel || "",
80+
boolFalseLabel: f.boolFalseLabel || "",
81+
boolCheckedValue: f.boolCheckedValue !== undefined ? f.boolCheckedValue : null,
82+
boolUncheckedValue: f.boolUncheckedValue !== undefined ? f.boolUncheckedValue : null
7983
})
8084
}
8185
}
@@ -172,7 +176,12 @@ MMComponents.MMDrawer {
172176
}))
173177
break
174178
case "bool":
175-
setSource( "components/MMFilterBoolInput.qml", base )
179+
setSource( "components/MMFilterBoolInput.qml", Object.assign( {}, base, {
180+
boolTrueLabel: modelData.boolTrueLabel,
181+
boolFalseLabel: modelData.boolFalseLabel,
182+
boolCheckedValue: modelData.boolCheckedValue,
183+
boolUncheckedValue: modelData.boolUncheckedValue
184+
}))
176185
break
177186
case "dropdown":
178187
setSource( "components/MMFilterDropdownEditor.qml", Object.assign( {}, base, {

app/qml/filters/components/MMFilterBoolInput.qml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ Column {
2222
required property string fieldLayerId
2323
required property string fieldName
2424

25+
property string boolTrueLabel: ""
26+
property string boolFalseLabel: ""
27+
property var boolCheckedValue: null
28+
property var boolUncheckedValue: null
29+
2530
property bool _initialized: false
2631
Component.onCompleted: _initialized = true
2732

@@ -39,10 +44,14 @@ Column {
3944
width: parent.width
4045
backgroundColor: __style.lightGreenColor
4146

47+
trueText: root.boolTrueLabel !== "" ? root.boolTrueLabel : qsTr( "True" )
48+
falseText: root.boolFalseLabel !== "" ? root.boolFalseLabel : qsTr( "False" )
49+
4250
selectedIndex: {
4351
let val = root.currentValue
4452
if ( val === null || val === undefined ) return MMSegmentControl.Options.All
45-
return ( val === true || val === 1 ) ? MMSegmentControl.Options.True : MMSegmentControl.Options.False
53+
let checkedVal = root.boolCheckedValue !== null ? root.boolCheckedValue : true
54+
return ( val == checkedVal ) ? MMSegmentControl.Options.True : MMSegmentControl.Options.False
4655
}
4756

4857
onSelectedIndexChanged: {
@@ -52,10 +61,12 @@ Column {
5261
__activeProject.filterController.removeFieldFilter( root.fieldLayerId, root.fieldName )
5362
break
5463
case MMSegmentControl.Options.True:
55-
__activeProject.filterController.setFieldFilter( root.fieldLayerId, root.fieldName, "bool", true )
64+
__activeProject.filterController.setFieldFilter( root.fieldLayerId, root.fieldName, "bool",
65+
root.boolCheckedValue !== null ? root.boolCheckedValue : true )
5666
break
5767
case MMSegmentControl.Options.False:
58-
__activeProject.filterController.setFieldFilter( root.fieldLayerId, root.fieldName, "bool", false )
68+
__activeProject.filterController.setFieldFilter( root.fieldLayerId, root.fieldName, "bool",
69+
root.boolUncheckedValue !== null ? root.boolUncheckedValue : false )
5970
break
6071
}
6172
}

0 commit comments

Comments
 (0)