[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
main
Adriaan de Groot 7 years ago
parent 7e2e2cabfe
commit 71e80f680e

@ -169,16 +169,22 @@ PackageTreeItem::setSelected( Qt::CheckState isSelected )
PackageTreeItem* currentItem = parentItem();
while ( currentItem != nullptr )
{
if ( currentItem->childCount() == 0)
{
currentItem = currentItem->parentItem();
continue;
}
int childrenSelected = 0;
bool isChildPartiallySelected = false;
int childrenPartiallySelected = 0;
for ( int i = 0; i < currentItem->childCount(); i++ )
{
if ( currentItem->child( i )->isSelected() == Qt::Checked )
childrenSelected++;
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
isChildPartiallySelected = true;
childrenPartiallySelected++;
}
if ( !childrenSelected && !isChildPartiallySelected )
if ( !childrenSelected && !childrenPartiallySelected)
currentItem->m_data.selected = Qt::Unchecked;
else if ( childrenSelected == currentItem->childCount() )
currentItem->m_data.selected = Qt::Checked;

Loading…
Cancel
Save