forked from qt-creator/qt-creator
QmlDesigner: Remove isArray() hacks
The text role data can be retrieved with model[textRole] in all cases these days. The delegate components should be bound and the model and index properties should be required. Task-number: QDS-13577 Change-Id: I219c509128d4ca9ea09a4d214e96105b7c134078 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
d8a3b1daed
commit
d9ad1dbac0
@@ -131,23 +131,23 @@ T.ComboBox {
|
||||
delegate: ItemDelegate {
|
||||
id: itemDelegate
|
||||
|
||||
required property var model
|
||||
required property int index
|
||||
|
||||
width: comboBoxPopup.width - comboBoxPopup.leftPadding - comboBoxPopup.rightPadding
|
||||
height: control.style.controlSize.height - 2 * control.style.borderWidth
|
||||
padding: 0
|
||||
enabled: model.enabled === undefined ? true : model.enabled
|
||||
enabled: itemDelegate.model["enabled"] === undefined ? true : itemDelegate.model["enabled"]
|
||||
|
||||
contentItem: Text {
|
||||
leftPadding: 8
|
||||
rightPadding: verticalScrollBar.style.scrollBarThicknessHover
|
||||
text: control.textRole ? (Array.isArray(control.model)
|
||||
? modelData[control.textRole]
|
||||
: model[control.textRole])
|
||||
: modelData
|
||||
text: itemDelegate.model[control.textRole]
|
||||
color: {
|
||||
if (!itemDelegate.enabled)
|
||||
return control.style.text.disabled
|
||||
|
||||
if (control.currentIndex === index)
|
||||
if (control.currentIndex === itemDelegate.index)
|
||||
return control.style.text.selectedText
|
||||
|
||||
return control.style.text.idle
|
||||
@@ -158,10 +158,7 @@ T.ComboBox {
|
||||
|
||||
ToolTipArea {
|
||||
anchors.fill: parent
|
||||
text: control.tooltipRole ? (Array.isArray(control.model)
|
||||
? modelData[control.tooltipRole]
|
||||
: model[control.tooltipRole])
|
||||
: ""
|
||||
text: control.tooltipRole ? itemDelegate.model[control.tooltipRole] : ""
|
||||
enabled: text
|
||||
onClicked: itemDelegate.clicked()
|
||||
onDoubleClicked: itemDelegate.doubleClicked()
|
||||
|
@@ -156,6 +156,9 @@ T.ComboBox {
|
||||
delegate: ItemDelegate {
|
||||
id: itemDelegate
|
||||
|
||||
required property var model
|
||||
required property int index
|
||||
|
||||
onClicked: {
|
||||
// Necessary to keep the transient parent open otherwise it will change the focus
|
||||
// to the main window "Utils::AppMainWindowClassWindow" and closes the transient
|
||||
@@ -169,15 +172,12 @@ T.ComboBox {
|
||||
width: control.width
|
||||
height: control.style.controlSize.height
|
||||
padding: 0
|
||||
enabled: model.enabled === undefined ? true : model.enabled
|
||||
enabled: itemDelegate.model["enabled"] === undefined ? true : itemDelegate.model["enabled"]
|
||||
|
||||
contentItem: Text {
|
||||
leftPadding: 8
|
||||
rightPadding: verticalScrollBar.style.scrollBarThicknessHover
|
||||
text: control.textRole ? (Array.isArray(control.model)
|
||||
? modelData[control.textRole]
|
||||
: model[control.textRole])
|
||||
: modelData
|
||||
text: itemDelegate.model[control.textRole]
|
||||
color: {
|
||||
if (!itemDelegate.enabled)
|
||||
return control.style.text.disabled
|
||||
|
Reference in New Issue
Block a user