harbour-seaprint/qml/components/DependentOn.qml

43 lines
1,020 B
QML
Raw Normal View History

import QtQuick 2.6
Item {
property alias target: targetConnection.target
property var values
property var overlap: []
Component.onCompleted:
{
for(var i in values)
{
2021-07-31 13:18:41 +03:00
if(target.actual_choices.indexOf(values[i]) != -1)
{
overlap.push(values[i])
}
}
2021-07-11 13:11:56 +03:00
parent.valid = parent.valid && overlap.length != 0
}
Connections {
id: targetConnection
onChoiceChanged:
{
if(parent.choice != undefined && overlap.indexOf(target.choice) == -1)
{
parent.reset()
parent.highlight()
}
}
}
Connections {
target: parent
onChoiceChanged:
{
2021-07-11 13:11:56 +03:00
if(parent.choice != undefined && overlap.indexOf(targetConnection.target.choice) == -1)
{
targetConnection.target.choice = overlap[0]
targetConnection.target.highlight()
}
}
}
}