diff --git a/src/modules/netinstall/Config.cpp b/src/modules/netinstall/Config.cpp index 2327a732c..6b1daaa07 100644 --- a/src/modules/netinstall/Config.cpp +++ b/src/modules/netinstall/Config.cpp @@ -170,6 +170,19 @@ Config::receivedGroupData() } } +Config::SourceItem Config::SourceItem::makeSourceItem(const QVariantMap& configurationMap, const QString& groupsUrl) +{ + if ( groupsUrl == QStringLiteral( "local" ) ) + { + return SourceItem{ QUrl(), configurationMap.value( "groups" ).toList() }; + } + else + { + return SourceItem{ QUrl{ groupsUrl }, QVariantList() }; + } +} + + void Config::setConfigurationMap( const QVariantMap& configurationMap ) { @@ -193,6 +206,20 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) } // Lastly, load the groups data + const QString key = QStringLiteral( "groupsUrl" ); + const auto& groupsUrlVariant = configurationMap.value( key ); + if ( groupsUrlVariant.type() == QVariant::String ) + { + m_urls.append( SourceItem::makeSourceItem( configurationMap, groupsUrlVariant.toString() ) ); + } + else if ( groupsUrlVariant.type() == QVariant::StringList ) + { + for ( const auto& s : groupsUrlVariant.toStringList() ) + { + m_urls.append( SourceItem::makeSourceItem( configurationMap, s ) ); + } + } + QString groupsUrl = CalamaresUtils::getString( configurationMap, "groupsUrl" ); if ( !groupsUrl.isEmpty() ) { diff --git a/src/modules/netinstall/Config.h b/src/modules/netinstall/Config.h index f5f76f35f..554b4ce7d 100644 --- a/src/modules/netinstall/Config.h +++ b/src/modules/netinstall/Config.h @@ -18,6 +18,7 @@ #include #include +#include #include class QNetworkReply; @@ -85,6 +86,23 @@ private slots: void retranslate(); private: + /** @brief Data about an entry in *groupsUrl* + * + * This can be a specific URL, or "local" which uses data stored + * in the configuration file itself. + */ + struct SourceItem + { + QUrl url; + QVariantList data; + + bool isUrl() const { return url.isValid(); } + bool isLocal() const { return !data.isEmpty(); } + bool isValid() const { return isUrl() || isLocal(); } + static SourceItem makeSourceItem( const QVariantMap& configurationMap, const QString& groupsUrl); + }; + + QQueue< SourceItem > m_urls; CalamaresUtils::Locale::TranslatedString* m_sidebarLabel = nullptr; // As it appears in the sidebar CalamaresUtils::Locale::TranslatedString* m_titleLabel = nullptr; PackageModel* m_model = nullptr;