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 {
|
delegate: ItemDelegate {
|
||||||
id: itemDelegate
|
id: itemDelegate
|
||||||
|
|
||||||
|
required property var model
|
||||||
|
required property int index
|
||||||
|
|
||||||
width: comboBoxPopup.width - comboBoxPopup.leftPadding - comboBoxPopup.rightPadding
|
width: comboBoxPopup.width - comboBoxPopup.leftPadding - comboBoxPopup.rightPadding
|
||||||
height: control.style.controlSize.height - 2 * control.style.borderWidth
|
height: control.style.controlSize.height - 2 * control.style.borderWidth
|
||||||
padding: 0
|
padding: 0
|
||||||
enabled: model.enabled === undefined ? true : model.enabled
|
enabled: itemDelegate.model["enabled"] === undefined ? true : itemDelegate.model["enabled"]
|
||||||
|
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
leftPadding: 8
|
leftPadding: 8
|
||||||
rightPadding: verticalScrollBar.style.scrollBarThicknessHover
|
rightPadding: verticalScrollBar.style.scrollBarThicknessHover
|
||||||
text: control.textRole ? (Array.isArray(control.model)
|
text: itemDelegate.model[control.textRole]
|
||||||
? modelData[control.textRole]
|
|
||||||
: model[control.textRole])
|
|
||||||
: modelData
|
|
||||||
color: {
|
color: {
|
||||||
if (!itemDelegate.enabled)
|
if (!itemDelegate.enabled)
|
||||||
return control.style.text.disabled
|
return control.style.text.disabled
|
||||||
|
|
||||||
if (control.currentIndex === index)
|
if (control.currentIndex === itemDelegate.index)
|
||||||
return control.style.text.selectedText
|
return control.style.text.selectedText
|
||||||
|
|
||||||
return control.style.text.idle
|
return control.style.text.idle
|
||||||
@@ -158,10 +158,7 @@ T.ComboBox {
|
|||||||
|
|
||||||
ToolTipArea {
|
ToolTipArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
text: control.tooltipRole ? (Array.isArray(control.model)
|
text: control.tooltipRole ? itemDelegate.model[control.tooltipRole] : ""
|
||||||
? modelData[control.tooltipRole]
|
|
||||||
: model[control.tooltipRole])
|
|
||||||
: ""
|
|
||||||
enabled: text
|
enabled: text
|
||||||
onClicked: itemDelegate.clicked()
|
onClicked: itemDelegate.clicked()
|
||||||
onDoubleClicked: itemDelegate.doubleClicked()
|
onDoubleClicked: itemDelegate.doubleClicked()
|
||||||
|
@@ -156,6 +156,9 @@ T.ComboBox {
|
|||||||
delegate: ItemDelegate {
|
delegate: ItemDelegate {
|
||||||
id: itemDelegate
|
id: itemDelegate
|
||||||
|
|
||||||
|
required property var model
|
||||||
|
required property int index
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
// Necessary to keep the transient parent open otherwise it will change the focus
|
// Necessary to keep the transient parent open otherwise it will change the focus
|
||||||
// to the main window "Utils::AppMainWindowClassWindow" and closes the transient
|
// to the main window "Utils::AppMainWindowClassWindow" and closes the transient
|
||||||
@@ -169,15 +172,12 @@ T.ComboBox {
|
|||||||
width: control.width
|
width: control.width
|
||||||
height: control.style.controlSize.height
|
height: control.style.controlSize.height
|
||||||
padding: 0
|
padding: 0
|
||||||
enabled: model.enabled === undefined ? true : model.enabled
|
enabled: itemDelegate.model["enabled"] === undefined ? true : itemDelegate.model["enabled"]
|
||||||
|
|
||||||
contentItem: Text {
|
contentItem: Text {
|
||||||
leftPadding: 8
|
leftPadding: 8
|
||||||
rightPadding: verticalScrollBar.style.scrollBarThicknessHover
|
rightPadding: verticalScrollBar.style.scrollBarThicknessHover
|
||||||
text: control.textRole ? (Array.isArray(control.model)
|
text: itemDelegate.model[control.textRole]
|
||||||
? modelData[control.textRole]
|
|
||||||
: model[control.textRole])
|
|
||||||
: modelData
|
|
||||||
color: {
|
color: {
|
||||||
if (!itemDelegate.enabled)
|
if (!itemDelegate.enabled)
|
||||||
return control.style.text.disabled
|
return control.style.text.disabled
|
||||||
|
Reference in New Issue
Block a user