[netinstall] Move package-listing wrangling to the Config object

Now all the business logic is in Config, the door is open to
building a QML-ified netinstall module. I'm not sure that
would be worth it: packagechooser offers more space for a
nice UI and should be QML'ed first.
This commit is contained in:
Adriaan de Groot 2021-03-16 14:47:12 +01:00
parent 9acd2fe458
commit 603a7106b3
3 changed files with 39 additions and 29 deletions

View File

@ -15,6 +15,7 @@
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "network/Manager.h"
#include "packages/Globals.h"
#include "utils/Logger.h"
#include "utils/RAII.h"
#include "utils/Retranslator.h"
@ -25,12 +26,13 @@
Config::Config( QObject* parent )
: QObject( parent )
, m_model( new PackageModel( this ) ) { CALAMARES_RETRANSLATE_SLOT( &Config::retranslate ) }
Config::~Config()
, m_model( new PackageModel( this ) )
{
CALAMARES_RETRANSLATE_SLOT( &Config::retranslate );
}
Config::~Config() {}
void
Config::retranslate()
{
@ -238,3 +240,29 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
}
}
}
void
Config::finalizeGlobalStorage( const Calamares::ModuleSystem::InstanceKey& key )
{
auto packages = model()->getPackages();
// This netinstall module may add two sub-steps to the packageOperations,
// one for installing and one for try-installing.
QVariantList installPackages;
QVariantList tryInstallPackages;
for ( const auto& package : packages )
{
if ( package->isCritical() )
{
installPackages.append( package->toOperation() );
}
else
{
tryInstallPackages.append( package->toOperation() );
}
}
CalamaresUtils::Packages::setGSPackageAdditions(
Calamares::JobQueue::instance()->globalStorage(), key, installPackages, tryInstallPackages );
}

View File

@ -15,6 +15,7 @@
#include "PackageModel.h"
#include "locale/TranslatableConfiguration.h"
#include "modulesystem/InstanceKey.h"
#include <QObject>
#include <QQueue>
@ -74,6 +75,12 @@ public:
*/
void loadGroupList( const QVariantList& groupData );
/** @brief Write the selected package lists to global storage
*
* Since the config doesn't know what module it is for,
* pass in an instance key.
*/
void finalizeGlobalStorage( const Calamares::ModuleSystem::InstanceKey& key );
signals:
void statusChanged( QString status ); ///< Something changed

View File

@ -11,11 +11,6 @@
#include "NetInstallViewStep.h"
#include "JobQueue.h"
#include "packages/Globals.h"
#include "utils/Logger.h"
#include "utils/Variant.h"
#include "NetInstallPage.h"
CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin< NetInstallViewStep >(); )
@ -125,27 +120,7 @@ NetInstallViewStep::onActivate()
void
NetInstallViewStep::onLeave()
{
auto packages = m_config.model()->getPackages();
// This netinstall module may add two sub-steps to the packageOperations,
// one for installing and one for try-installing.
QVariantList installPackages;
QVariantList tryInstallPackages;
for ( const auto& package : packages )
{
if ( package->isCritical() )
{
installPackages.append( package->toOperation() );
}
else
{
tryInstallPackages.append( package->toOperation() );
}
}
CalamaresUtils::Packages::setGSPackageAdditions(
Calamares::JobQueue::instance()->globalStorage(), moduleInstanceKey(), installPackages, tryInstallPackages );
m_config.finalizeGlobalStorage( moduleInstanceKey() );
}
void