From 71e80f680ee2cb814a5141a34789788dbeeee364 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 21 Nov 2017 05:36:30 -0500 Subject: [PATCH] [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 --- src/modules/netinstall/PackageTreeItem.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/modules/netinstall/PackageTreeItem.cpp b/src/modules/netinstall/PackageTreeItem.cpp index 77ca07a9c..8e0d3f43b 100644 --- a/src/modules/netinstall/PackageTreeItem.cpp +++ b/src/modules/netinstall/PackageTreeItem.cpp @@ -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;