forked from qt-creator/qt-creator
QmlDesigner: Fix FilterComboBox same value submit
* Fix issue when same URL gets submitted twice in a row * Fix selection of model item when submitting a custom URL that aligns with an item in the model Change-Id: Ica8819f72a1f2dc0c239eb2ced25a11a1355d81f Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
e10b3bc98b
commit
5294c3a23b
@@ -185,24 +185,34 @@ Row {
|
|||||||
onEditTextChanged: comboBox.dirty = true
|
onEditTextChanged: comboBox.dirty = true
|
||||||
|
|
||||||
function setCurrentText(text) {
|
function setCurrentText(text) {
|
||||||
var index = comboBox.find(text)
|
comboBox.currentIndex = comboBox.find(text)
|
||||||
if (index === -1)
|
comboBox.setHighlightedIndexItems(comboBox.currentIndex)
|
||||||
comboBox.currentIndex = -1
|
comboBox.autocompleteString = ""
|
||||||
|
|
||||||
comboBox.editText = text
|
comboBox.editText = text
|
||||||
comboBox.dirty = false
|
comboBox.dirty = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes into account applied bindings
|
// Takes into account applied bindings
|
||||||
property string textValue: {
|
function updateTextValue() {
|
||||||
if (root.backendValue.isBound)
|
if (root.backendValue.isBound) {
|
||||||
return root.backendValue.expression
|
comboBox.textValue = root.backendValue.expression
|
||||||
|
} else {
|
||||||
var fullPath = root.backendValue.valueToString
|
var fullPath = root.backendValue.valueToString
|
||||||
return fullPath.substr(fullPath.lastIndexOf('/') + 1)
|
comboBox.textValue = fullPath.substr(fullPath.lastIndexOf('/') + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
onTextValueChanged: comboBox.setCurrentText(comboBox.textValue)
|
comboBox.setCurrentText(comboBox.textValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: root.backendValue
|
||||||
|
|
||||||
|
function onIsBoundChanged() { comboBox.updateTextValue() }
|
||||||
|
function onExpressionChanged() { comboBox.updateTextValue() }
|
||||||
|
function onValueChangedQml() { comboBox.updateTextValue() }
|
||||||
|
}
|
||||||
|
|
||||||
|
property string textValue: ""
|
||||||
|
|
||||||
onModelChanged: {
|
onModelChanged: {
|
||||||
if (!comboBox.isComplete)
|
if (!comboBox.isComplete)
|
||||||
@@ -223,7 +233,6 @@ Row {
|
|||||||
inputValue = comboBox.items.get(index).model.fullPath
|
inputValue = comboBox.items.get(index).model.fullPath
|
||||||
|
|
||||||
root.backendValue.value = inputValue
|
root.backendValue.value = inputValue
|
||||||
|
|
||||||
comboBox.dirty = false
|
comboBox.dirty = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +312,10 @@ Row {
|
|||||||
|
|
||||||
onDefaultItemsChanged: root.createModel()
|
onDefaultItemsChanged: root.createModel()
|
||||||
|
|
||||||
Component.onCompleted: root.createModel()
|
Component.onCompleted: {
|
||||||
|
root.createModel()
|
||||||
|
comboBox.updateTextValue()
|
||||||
|
}
|
||||||
|
|
||||||
function indexOf(model, criteria) {
|
function indexOf(model, criteria) {
|
||||||
for (var i = 0; i < model.count; ++i) {
|
for (var i = 0; i < model.count; ++i) {
|
||||||
|
Reference in New Issue
Block a user