[netinstall] Only update selectedness of parents with children.
While walking up the tree, only switch the selectedness states of parents with children. This avoids the case where a parent has a first subgroup that is hidden -- in which case the parent ends up with no children, and is unselected even though it is marked as selected in the config file. FIXES #864
This commit is contained in:
parent
7e2e2cabfe
commit
71e80f680e
@ -169,16 +169,22 @@ PackageTreeItem::setSelected( Qt::CheckState isSelected )
|
|||||||
PackageTreeItem* currentItem = parentItem();
|
PackageTreeItem* currentItem = parentItem();
|
||||||
while ( currentItem != nullptr )
|
while ( currentItem != nullptr )
|
||||||
{
|
{
|
||||||
|
if ( currentItem->childCount() == 0)
|
||||||
|
{
|
||||||
|
currentItem = currentItem->parentItem();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int childrenSelected = 0;
|
int childrenSelected = 0;
|
||||||
bool isChildPartiallySelected = false;
|
int childrenPartiallySelected = 0;
|
||||||
for ( int i = 0; i < currentItem->childCount(); i++ )
|
for ( int i = 0; i < currentItem->childCount(); i++ )
|
||||||
{
|
{
|
||||||
if ( currentItem->child( i )->isSelected() == Qt::Checked )
|
if ( currentItem->child( i )->isSelected() == Qt::Checked )
|
||||||
childrenSelected++;
|
childrenSelected++;
|
||||||
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
|
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
|
||||||
isChildPartiallySelected = true;
|
childrenPartiallySelected++;
|
||||||
}
|
}
|
||||||
if ( !childrenSelected && !isChildPartiallySelected )
|
if ( !childrenSelected && !childrenPartiallySelected)
|
||||||
currentItem->m_data.selected = Qt::Unchecked;
|
currentItem->m_data.selected = Qt::Unchecked;
|
||||||
else if ( childrenSelected == currentItem->childCount() )
|
else if ( childrenSelected == currentItem->childCount() )
|
||||||
currentItem->m_data.selected = Qt::Checked;
|
currentItem->m_data.selected = Qt::Checked;
|
||||||
|
Loading…
Reference in New Issue
Block a user