Commit e7546560 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

use a role of the model to also choose the correct delegate for metadata

BUG: 429039
parent 7f5e5436
Pipeline #41350 passed with stage
in 25 seconds
......@@ -101,40 +101,52 @@ Window {
model: realModel
Component {
id: metaDataDelegate
delegate: Item {
id: topLevel
MetaDataDelegate {
width: trackData.width
property bool isReadOnlyDelegate: (dialogStates.state !== 'readWrite' && dialogStates.state !== 'readWriteAndDirty' &&
dialogStates.state !== 'create' && dialogStates.state !== 'createAndDirty') || realModel.isReadOnly || model.isReadOnly
index: model.index
name: model.name
display: model.display
type: model.type
height: delegateChooser.height
Loader {
id: delegateChooser
sourceComponent: isReadOnlyDelegate ? metaDataDelegate : editableMetaDataDelegate
}
}
Component {
id: editableMetaDataDelegate
Component {
id: metaDataDelegate
MetaDataDelegate {
width: trackData.width
EditableMetaDataDelegate {
width: trackData.width
index: model.index
name: model.name
display: model.display
type: model.type
}
}
Component {
id: editableMetaDataDelegate
index: model.index
name: model.name
display: model.display
type: model.type
isRemovable: model.isRemovable
EditableMetaDataDelegate {
width: trackData.width
onEdited: model.display = display
index: model.index
name: model.name
display: model.display
type: model.type
isRemovable: model.isRemovable
onDeleteField: realModel.removeData(model.index)
onEdited: model.display = display
onDeleteField: realModel.removeData(model.index)
}
}
}
delegate: ((dialogStates.state === 'readWrite' || dialogStates.state === 'readWriteAndDirty' ||
dialogStates.state === 'create' || dialogStates.state === 'createAndDirty') && !realModel.isReadOnly) ? editableMetaDataDelegate: metaDataDelegate
footer: RowLayout {
width: trackData.width
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment