From 603a7106b3db9c78f7b0e7da79a606b4ecc4160b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 16 Mar 2021 14:47:12 +0100 Subject: [PATCH] [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. --- src/modules/netinstall/Config.cpp | 34 +++++++++++++++++-- src/modules/netinstall/Config.h | 7 ++++ src/modules/netinstall/NetInstallViewStep.cpp | 27 +-------------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/modules/netinstall/Config.cpp b/src/modules/netinstall/Config.cpp index 017164c86..927eb8330 100644 --- a/src/modules/netinstall/Config.cpp +++ b/src/modules/netinstall/Config.cpp @@ -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 ); +} diff --git a/src/modules/netinstall/Config.h b/src/modules/netinstall/Config.h index de96ccee4..e748449a3 100644 --- a/src/modules/netinstall/Config.h +++ b/src/modules/netinstall/Config.h @@ -15,6 +15,7 @@ #include "PackageModel.h" #include "locale/TranslatableConfiguration.h" +#include "modulesystem/InstanceKey.h" #include #include @@ -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 diff --git a/src/modules/netinstall/NetInstallViewStep.cpp b/src/modules/netinstall/NetInstallViewStep.cpp index ae8d2f95f..2ac0e73c9 100644 --- a/src/modules/netinstall/NetInstallViewStep.cpp +++ b/src/modules/netinstall/NetInstallViewStep.cpp @@ -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