mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-04 01:08:26 +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
|
||||
*
|
||||
* @param inputModel - model to filter
|
||||
* @param editingFinished - signal emitted when editing is finished
|
||||
* @alias filterText - text to filter the model
|
||||
*/
|
||||
|
||||
ComboBox {
|
||||
id: combo
|
||||
|
||||
property var inputModel
|
||||
signal editingFinished(var value)
|
||||
|
||||
property alias filterText: filterTextArea
|
||||
|
||||
id: combo
|
||||
enabled: root.editable
|
||||
model: {
|
||||
var filteredData = inputModel.filter(condition => {
|
||||
if (filterTextArea.text.length > 0) return condition.toString().includes(filterTextArea.text)
|
||||
return true
|
||||
})
|
||||
|
||||
if (filteredData.length == 0 || filterTextArea.length == 0) {
|
||||
filteredData = inputModel
|
||||
|
||||
filterTextArea.background.color = Colors.red
|
||||
} else {
|
||||
if (filteredData.length > 0) {
|
||||
filterTextArea.background.color = Qt.lighter(palette.base, 2)
|
||||
|
||||
// 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))
|
||||
return 1
|
||||
return 0
|
||||
});
|
||||
})
|
||||
} else {
|
||||
filterTextArea.background.color = Colors.red
|
||||
}
|
||||
|
||||
if (filteredData.length == 0 || filterTextArea.length == 0) {
|
||||
filteredData = inputModel
|
||||
}
|
||||
|
||||
return filteredData
|
||||
}
|
||||
|
||||
|
@ -68,10 +74,11 @@ ComboBox {
|
|||
|
||||
onEditingFinished: {
|
||||
combo.popup.close()
|
||||
combo.editingFinished(currentText)
|
||||
}
|
||||
|
||||
Keys.onReturnPressed: {
|
||||
editingFinished();
|
||||
editingFinished()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -346,6 +346,22 @@ RowLayout {
|
|||
|
||||
FilterComboBox {
|
||||
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