[netinstall] Inherit criticalness in groups

- Groups inherit slightly differently: if a subgroup **explicitly**
  configures criticalness, use that. It would be weird, but possibly,
  to have a non-critical subgroup of a critical group.
This commit is contained in:
Adriaan de Groot 2020-03-27 20:51:52 +01:00
parent 83a89c144c
commit 433ed8384f

View File

@ -22,6 +22,7 @@
#include "utils/Logger.h"
#include "utils/Variant.h"
/** @brief Should a package be selected, given its parent's state? */
static Qt::CheckState
parentCheckState( PackageTreeItem* parent )
{
@ -36,6 +37,20 @@ parentCheckState( PackageTreeItem* parent )
}
}
/** @brief Should a subgroup be marked critical?
*
* If set explicitly, then use that, otherwise use the parent's critical-ness.
*/
static bool
parentCriticality( const QVariantMap& groupData, PackageTreeItem* parent )
{
if ( groupData.contains( "critical" ) )
{
return CalamaresUtils::getBool( groupData, "critical", false );
}
return parent ? parent->isCritical() : false;
}
PackageTreeItem::PackageTreeItem( const QString& packageName, PackageTreeItem* parent )
: m_parentItem( parent )
, m_packageName( packageName )
@ -54,7 +69,7 @@ PackageTreeItem::PackageTreeItem( const QVariantMap& groupData, PackageTreeItem*
, m_preScript( CalamaresUtils::getString( groupData, "pre-install" ) )
, m_postScript( CalamaresUtils::getString( groupData, "post-install" ) )
, m_isGroup( true )
, m_isCritical( CalamaresUtils::getBool( groupData, "critical", false ) )
, m_isCritical( parentCriticality( groupData, parent ) )
, m_isHidden( CalamaresUtils::getBool( groupData, "hidden", false ) )
, m_showReadOnly( CalamaresUtils::getBool( groupData, "immutable", false ) )
, m_startExpanded( CalamaresUtils::getBool( groupData, "expanded", false ) )