//connect(ui->treeWidget,&QTreeWidget::itemClicked,this,&PushSelectUser::treeItemChanged);
void PushSelectUser::treeItemChanged(QTreeWidgetItem *item, int column)
{
updateParentItem(item);
// 设置子对象的勾选状态
for( int i=0;i<item->childCount();++i ){
if(item->checkState(0) == Qt::PartiallyChecked)
continue;
item->child(i)->setCheckState(0,item->checkState(0));
updateChildItem(item->child(i));
}
Qt::CheckState status = item->checkState(0);
sigSlectStatusChanged(item->text(0),status);
getSelectUsers();
}
void PushSelectUser::updateParentItem(QTreeWidgetItem *item)
{
// 更新父对象的勾选状态
QTreeWidgetItem* p = item->parent();
if( p!=0 ){
p->setCheckState(0,item->checkState(0));
for( int i=0;i<p->childCount();++i )
if( p->child(i)->checkState(0)!=item->checkState(0) || p->child(i)->checkState(0) == Qt::PartiallyChecked){
p->setCheckState(0,Qt::PartiallyChecked);
break;
}
updateParentItem(p);
}
}
void PushSelectUser::updateChildItem(QTreeWidgetItem *item)
{
// 更新zi对象的勾选状态
if( item!=0 ){
for( int i=0;i<item->childCount();++i ){
item->child(i)->setCheckState(0,item->checkState(0));
updateChildItem(item->child(i));
}
}
}
void PushSelectUser::treeItemChanged(QTreeWidgetItem *item, int column)
{
updateParentItem(item);
// 设置子对象的勾选状态
for( int i=0;i<item->childCount();++i ){
if(item->checkState(0) == Qt::PartiallyChecked)
continue;
item->child(i)->setCheckState(0,item->checkState(0));
updateChildItem(item->child(i));
}
Qt::CheckState status = item->checkState(0);
sigSlectStatusChanged(item->text(0),status);
getSelectUsers();
}
void PushSelectUser::updateParentItem(QTreeWidgetItem *item)
{
// 更新父对象的勾选状态
QTreeWidgetItem* p = item->parent();
if( p!=0 ){
p->setCheckState(0,item->checkState(0));
for( int i=0;i<p->childCount();++i )
if( p->child(i)->checkState(0)!=item->checkState(0) || p->child(i)->checkState(0) == Qt::PartiallyChecked){
p->setCheckState(0,Qt::PartiallyChecked);
break;
}
updateParentItem(p);
}
}
void PushSelectUser::updateChildItem(QTreeWidgetItem *item)
{
// 更新zi对象的勾选状态
if( item!=0 ){
for( int i=0;i<item->childCount();++i ){
item->child(i)->setCheckState(0,item->checkState(0));
updateChildItem(item->child(i));
}
}
}