Rectangle{
id: header
width: 620
height: 70
y: 150
color: "#E8E8E8"
anchors{left: parent.left;leftMargin: 110;top:separator.bottom}
CheckBox {
id: headerCombo
text: qsTr("Select All")
checked: false
anchors{left: parent.left;leftMargin: 38;top:parent.top;topMargin: 20}
onCheckedChanged: {
if(headerCombo.pressed)
{
console.log("checjed chaneging")
for(var i=0;i<checkBoxModel.count;i++)
{
checkBoxModel.set(i,{"selected": headerCombo.checked})
}
}
}
}
}
ListModel {
id: checkBoxModel
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
ListElement { selected: false; }
}
ListView{
id: listt
model: checkBoxModel
clip:true
width: 620
anchors{left: parent.left;leftMargin: 110;top: header.bottom;topMargin: 10;bottom: bottomBar.top}
delegate: listDelegate
}
Component {
id: listDelegate
Warnings{ //consider this item as checkbox
id: warningsList
width: 620
color: "#EFF0F0"
childChkBox: selected //this is checked property
onChildChanged: {
if(!headerCombo.pressed && childChkBox===true){
console.log(" changed by child true")
checkBoxModel.set(index,{"selected": true})
checkSelection()
}
else if(!headerCombo.pressed && childChkBox===false){
console.log(" changed by child false")
checkBoxModel.set(index,{"selected": false})
checkSelection()
}
else
{
console.log(" changed by Parent")
for(var i=0;i<checkBoxModel.count;i++)
{
checkBoxModel.set(index,{"selected": headerCombo.checked})
}
}
// function checkSelection1()
// {
// for(var i=0;i<checkBoxModel.count;i++)
// {
// if(checkBoxModel.get(i).selected===true){
// headerValue=true
// }
// else
// headerValue=false
// }
// }
function checkSelection()
{
if(checkBoxModel.get(0).selected===true)
{
if(checkBoxModel.get(1).selected===true)
{
if(checkBoxModel.get(2).selected===true)
{
if(checkBoxModel.get(3).selected===true)
{
if(checkBoxModel.get(4).selected===true)
{
if(checkBoxModel.get(5).selected===true)
{
headerValue=true
}
else
{
headerValue=false
}
}
else
{
headerValue=false
}
}
else
{
headerValue=false
}
}
else
{
headerValue=false
}
}
else
{
headerValue=false
}
}
else
{
headerValue=false
}
}
}
}
}
Bookmarks