mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 10:18:42 +02:00
Filter text reset when attribute reset
This commit is contained in:
parent
c439c5a06e
commit
57a02fc50c
2 changed files with 32 additions and 9 deletions
|
@ -6,25 +6,25 @@ import Utils 1.0
|
||||||
* ComboBox with filter text area
|
* ComboBox with filter text area
|
||||||
*
|
*
|
||||||
* @param inputModel - model to filter
|
* @param inputModel - model to filter
|
||||||
|
* @param editingFinished - signal emitted when editing is finished
|
||||||
|
* @alias filterText - text to filter the model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
|
id: combo
|
||||||
|
|
||||||
property var inputModel
|
property var inputModel
|
||||||
|
signal editingFinished(var value)
|
||||||
|
|
||||||
|
property alias filterText: filterTextArea
|
||||||
|
|
||||||
id: combo
|
|
||||||
enabled: root.editable
|
enabled: root.editable
|
||||||
model: {
|
model: {
|
||||||
var filteredData = inputModel.filter(condition => {
|
var filteredData = inputModel.filter(condition => {
|
||||||
if (filterTextArea.text.length > 0) return condition.toString().includes(filterTextArea.text)
|
if (filterTextArea.text.length > 0) return condition.toString().includes(filterTextArea.text)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
if (filteredData.length > 0) {
|
||||||
if (filteredData.length == 0 || filterTextArea.length == 0) {
|
|
||||||
filteredData = inputModel
|
|
||||||
|
|
||||||
filterTextArea.background.color = Colors.red
|
|
||||||
} else {
|
|
||||||
filterTextArea.background.color = Qt.lighter(palette.base, 2)
|
filterTextArea.background.color = Qt.lighter(palette.base, 2)
|
||||||
|
|
||||||
// order filtered data by relevance (results that start with the filter text come first)
|
// order filtered data by relevance (results that start with the filter text come first)
|
||||||
|
@ -37,9 +37,15 @@ ComboBox {
|
||||||
if (!nameA.startsWith(filterText) && nameB.startsWith(filterText))
|
if (!nameA.startsWith(filterText) && nameB.startsWith(filterText))
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
});
|
})
|
||||||
|
} else {
|
||||||
|
filterTextArea.background.color = Colors.red
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filteredData.length == 0 || filterTextArea.length == 0) {
|
||||||
|
filteredData = inputModel
|
||||||
|
}
|
||||||
|
|
||||||
return filteredData
|
return filteredData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,10 +74,11 @@ ComboBox {
|
||||||
|
|
||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
combo.popup.close()
|
combo.popup.close()
|
||||||
|
combo.editingFinished(currentText)
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: {
|
||||||
editingFinished();
|
editingFinished()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,6 +346,22 @@ RowLayout {
|
||||||
|
|
||||||
FilterComboBox {
|
FilterComboBox {
|
||||||
inputModel: attribute.desc.values
|
inputModel: attribute.desc.values
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
currentIndex = find(attribute.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
onEditingFinished: function(value) {
|
||||||
|
_reconstruction.setAttribute(attribute, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: attribute
|
||||||
|
onValueChanged: {
|
||||||
|
filterText.clear()
|
||||||
|
currentIndex = find(attribute.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue