[packagechooser] Introduce a Config object
Rip out most of the ViewStep that deals with configuration, move it to a Config object (not one that supports QML yet, though), and massage the model a little.
This commit is contained in:
parent
59ea88f1ad
commit
dd52e10839
@ -45,6 +45,7 @@ calamares_add_plugin( packagechooser
|
|||||||
TYPE viewmodule
|
TYPE viewmodule
|
||||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||||
SOURCES
|
SOURCES
|
||||||
|
Config.cpp
|
||||||
PackageChooserPage.cpp
|
PackageChooserPage.cpp
|
||||||
PackageChooserViewStep.cpp
|
PackageChooserViewStep.cpp
|
||||||
PackageModel.cpp
|
PackageModel.cpp
|
||||||
|
170
src/modules/packagechooser/Config.cpp
Normal file
170
src/modules/packagechooser/Config.cpp
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||||
|
*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* Calamares is Free Software: see the License-Identifier above.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_XML
|
||||||
|
#include "ItemAppData.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
|
|
||||||
|
Config::Config( const QString& defaultId, QObject* parent )
|
||||||
|
: Calamares::ModuleSystem::Config( parent )
|
||||||
|
, m_model( new PackageListModel( this ) )
|
||||||
|
, m_mode( PackageChooserMode::Required )
|
||||||
|
, m_defaultId( defaultId )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Config::~Config() {}
|
||||||
|
|
||||||
|
const PackageItem&
|
||||||
|
Config::introductionPackage() const
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < m_model->packageCount(); ++i )
|
||||||
|
{
|
||||||
|
const auto& package = m_model->packageData( i );
|
||||||
|
if ( package.isNonePackage() )
|
||||||
|
{
|
||||||
|
return package;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static PackageItem* defaultIntroduction = nullptr;
|
||||||
|
if ( !defaultIntroduction )
|
||||||
|
{
|
||||||
|
defaultIntroduction = new PackageItem(
|
||||||
|
QString(),
|
||||||
|
QT_TR_NOOP( "Package Selection" ),
|
||||||
|
QT_TR_NOOP( "Please pick a product from the list. The selected product will be installed." ) );
|
||||||
|
defaultIntroduction->screenshot = QPixmap( QStringLiteral( ":/images/no-selection.png" ) );
|
||||||
|
// TODO: enable better translation
|
||||||
|
// defaultIntroduction->name.setContext( metaObject()->className() );
|
||||||
|
// defaultIntroduction->description.setContext( metaObject()->className() );
|
||||||
|
}
|
||||||
|
return *defaultIntroduction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Config::updateGlobalStorage( const QStringList& selected ) const
|
||||||
|
{
|
||||||
|
QString key = QStringLiteral( "packagechooser_%1" ).arg( m_id );
|
||||||
|
QString value = selected.join( ',' );
|
||||||
|
Calamares::JobQueue::instance()->globalStorage()->insert( key, value );
|
||||||
|
|
||||||
|
cDebug() << "PackageChooser" << key << "selected" << value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
fillModel( PackageListModel* model, const QVariantList& items )
|
||||||
|
{
|
||||||
|
if ( items.isEmpty() )
|
||||||
|
{
|
||||||
|
cWarning() << "No *items* for PackageChooser module.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_APPSTREAM
|
||||||
|
std::unique_ptr< AppStream::Pool > pool;
|
||||||
|
bool poolOk = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cDebug() << "Loading PackageChooser model items from config";
|
||||||
|
int item_index = 0;
|
||||||
|
for ( const auto& item_it : items )
|
||||||
|
{
|
||||||
|
++item_index;
|
||||||
|
QVariantMap item_map = item_it.toMap();
|
||||||
|
if ( item_map.isEmpty() )
|
||||||
|
{
|
||||||
|
cWarning() << "PackageChooser entry" << item_index << "is not valid.";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( item_map.contains( "appdata" ) )
|
||||||
|
{
|
||||||
|
#ifdef HAVE_XML
|
||||||
|
model->addPackage( fromAppData( item_map ) );
|
||||||
|
#else
|
||||||
|
cWarning() << "Loading AppData XML is not supported.";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if ( item_map.contains( "appstream" ) )
|
||||||
|
{
|
||||||
|
#ifdef HAVE_APPSTREAM
|
||||||
|
if ( !pool )
|
||||||
|
{
|
||||||
|
pool = std::make_unique< AppStream::Pool >();
|
||||||
|
pool->setLocale( QStringLiteral( "ALL" ) );
|
||||||
|
poolOk = pool->load();
|
||||||
|
}
|
||||||
|
if ( pool && poolOk )
|
||||||
|
{
|
||||||
|
model->addPackage( fromAppStream( *pool, item_map ) );
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
cWarning() << "Loading AppStream data is not supported.";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model->addPackage( PackageItem( item_map ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
|
{
|
||||||
|
QString mode = CalamaresUtils::getString( configurationMap, "mode" );
|
||||||
|
bool mode_ok = false;
|
||||||
|
if ( !mode.isEmpty() )
|
||||||
|
{
|
||||||
|
m_mode = packageChooserModeNames().find( mode, mode_ok );
|
||||||
|
}
|
||||||
|
if ( !mode_ok )
|
||||||
|
{
|
||||||
|
m_mode = PackageChooserMode::Required;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_id = CalamaresUtils::getString( configurationMap, "id" );
|
||||||
|
if ( m_id.isEmpty() )
|
||||||
|
{
|
||||||
|
m_id = m_defaultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_defaultModelIndex = QModelIndex();
|
||||||
|
if ( configurationMap.contains( "items" ) )
|
||||||
|
{
|
||||||
|
fillModel( m_model, configurationMap.value( "items" ).toList() );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString default_item_id = CalamaresUtils::getString( configurationMap, "default" );
|
||||||
|
// find default item
|
||||||
|
if ( !default_item_id.isEmpty() )
|
||||||
|
{
|
||||||
|
for ( int item_n = 0; item_n < m_model->packageCount(); ++item_n )
|
||||||
|
{
|
||||||
|
QModelIndex item_idx = m_model->index( item_n, 0 );
|
||||||
|
QVariant item_id = m_model->data( item_idx, PackageListModel::IdRole );
|
||||||
|
|
||||||
|
if ( item_id.toString() == default_item_id )
|
||||||
|
{
|
||||||
|
m_defaultModelIndex = item_idx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
61
src/modules/packagechooser/Config.h
Normal file
61
src/modules/packagechooser/Config.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||||
|
*
|
||||||
|
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* Calamares is Free Software: see the License-Identifier above.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PACKAGECHOOSER_CONFIG_H
|
||||||
|
#define PACKAGECHOOSER_CONFIG_H
|
||||||
|
|
||||||
|
#include "PackageModel.h"
|
||||||
|
|
||||||
|
#include "modulesystem/Config.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class Config : public Calamares::ModuleSystem::Config
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Config( const QString& defaultId, QObject* parent = nullptr );
|
||||||
|
~Config() override;
|
||||||
|
|
||||||
|
void setConfigurationMap( const QVariantMap& ) override;
|
||||||
|
|
||||||
|
PackageChooserMode mode() const { return m_mode; }
|
||||||
|
PackageListModel* model() const { return m_model; }
|
||||||
|
QModelIndex defaultSelectionIndex() const { return m_defaultModelIndex; }
|
||||||
|
|
||||||
|
/** @brief Returns an "introductory package" which describes packagechooser
|
||||||
|
*
|
||||||
|
* If the model contains a "none" package, returns that one on
|
||||||
|
* the assumption that it is one to describe the whole; otherwise
|
||||||
|
* returns a totally generic description.
|
||||||
|
*/
|
||||||
|
const PackageItem& introductionPackage() const;
|
||||||
|
|
||||||
|
/** @brief Write selection to global storage
|
||||||
|
*
|
||||||
|
* Updates the GS keys for this packagechooser, marking all
|
||||||
|
* (and only) the packages in @p selected as selected.
|
||||||
|
*/
|
||||||
|
void updateGlobalStorage( const QStringList& selected ) const;
|
||||||
|
/// As updateGlobalStorage() with an empty selection list
|
||||||
|
void updateGlobalStorage() const { updateGlobalStorage( QStringList() ); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
PackageListModel* m_model = nullptr;
|
||||||
|
QModelIndex m_defaultModelIndex;
|
||||||
|
|
||||||
|
// Configuration
|
||||||
|
PackageChooserMode m_mode = PackageChooserMode::Optional;
|
||||||
|
QString m_id;
|
||||||
|
QString m_defaultId;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -9,20 +9,22 @@
|
|||||||
|
|
||||||
#include "PackageChooserViewStep.h"
|
#include "PackageChooserViewStep.h"
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
#include "PackageChooserPage.h"
|
||||||
|
#include "PackageModel.h"
|
||||||
|
|
||||||
#ifdef HAVE_XML
|
#ifdef HAVE_XML
|
||||||
#include "ItemAppData.h"
|
#include "ItemAppData.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_APPSTREAM
|
#ifdef HAVE_APPSTREAM
|
||||||
#include "ItemAppStream.h"
|
#include "ItemAppStream.h"
|
||||||
#include <AppStreamQt/pool.h>
|
#include <AppStreamQt/pool.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#endif
|
#endif
|
||||||
#include "PackageChooserPage.h"
|
|
||||||
#include "PackageModel.h"
|
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
|
||||||
#include "locale/TranslatableConfiguration.h"
|
#include "locale/TranslatableConfiguration.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
@ -35,9 +37,8 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( PackageChooserViewStepFactory, registerPlug
|
|||||||
|
|
||||||
PackageChooserViewStep::PackageChooserViewStep( QObject* parent )
|
PackageChooserViewStep::PackageChooserViewStep( QObject* parent )
|
||||||
: Calamares::ViewStep( parent )
|
: Calamares::ViewStep( parent )
|
||||||
|
, m_config( new Config( moduleInstanceKey().id(), this ) )
|
||||||
, m_widget( nullptr )
|
, m_widget( nullptr )
|
||||||
, m_model( nullptr )
|
|
||||||
, m_mode( PackageChooserMode::Required )
|
|
||||||
, m_stepName( nullptr )
|
, m_stepName( nullptr )
|
||||||
{
|
{
|
||||||
emit nextStatusChanged( false );
|
emit nextStatusChanged( false );
|
||||||
@ -50,7 +51,6 @@ PackageChooserViewStep::~PackageChooserViewStep()
|
|||||||
{
|
{
|
||||||
m_widget->deleteLater();
|
m_widget->deleteLater();
|
||||||
}
|
}
|
||||||
delete m_model;
|
|
||||||
delete m_stepName;
|
delete m_stepName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,19 +67,10 @@ PackageChooserViewStep::widget()
|
|||||||
{
|
{
|
||||||
if ( !m_widget )
|
if ( !m_widget )
|
||||||
{
|
{
|
||||||
m_widget = new PackageChooserPage( m_mode, nullptr );
|
m_widget = new PackageChooserPage( m_config->mode(), nullptr );
|
||||||
connect( m_widget, &PackageChooserPage::selectionChanged, [=]() {
|
connect( m_widget, &PackageChooserPage::selectionChanged, [=]() {
|
||||||
emit nextStatusChanged( this->isNextEnabled() );
|
emit nextStatusChanged( this->isNextEnabled() );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
if ( m_model )
|
|
||||||
{
|
|
||||||
hookupModel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cWarning() << "PackageChooser Widget created before model.";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return m_widget;
|
return m_widget;
|
||||||
}
|
}
|
||||||
@ -88,18 +79,13 @@ PackageChooserViewStep::widget()
|
|||||||
bool
|
bool
|
||||||
PackageChooserViewStep::isNextEnabled() const
|
PackageChooserViewStep::isNextEnabled() const
|
||||||
{
|
{
|
||||||
if ( !m_model )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !m_widget )
|
if ( !m_widget )
|
||||||
{
|
{
|
||||||
// No way to have changed anything
|
// No way to have changed anything
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( m_mode )
|
switch ( m_config->mode() )
|
||||||
{
|
{
|
||||||
case PackageChooserMode::Optional:
|
case PackageChooserMode::Optional:
|
||||||
case PackageChooserMode::OptionalMultiple:
|
case PackageChooserMode::OptionalMultiple:
|
||||||
@ -139,22 +125,14 @@ PackageChooserViewStep::onActivate()
|
|||||||
{
|
{
|
||||||
if ( !m_widget->hasSelection() )
|
if ( !m_widget->hasSelection() )
|
||||||
{
|
{
|
||||||
m_widget->setSelection( m_defaultIdx );
|
m_widget->setSelection( m_config->defaultSelectionIndex() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageChooserViewStep::onLeave()
|
PackageChooserViewStep::onLeave()
|
||||||
{
|
{
|
||||||
QString key = QStringLiteral( "packagechooser_%1" ).arg( m_id );
|
m_config->updateGlobalStorage( m_widget->selectedPackageIds() );
|
||||||
QString value;
|
|
||||||
if ( m_widget->hasSelection() )
|
|
||||||
{
|
|
||||||
value = m_widget->selectedPackageIds().join( ',' );
|
|
||||||
}
|
|
||||||
Calamares::JobQueue::instance()->globalStorage()->insert( key, value );
|
|
||||||
|
|
||||||
cDebug() << "PackageChooser" << key << "selected" << value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobList
|
Calamares::JobList
|
||||||
@ -167,23 +145,7 @@ PackageChooserViewStep::jobs() const
|
|||||||
void
|
void
|
||||||
PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
QString mode = CalamaresUtils::getString( configurationMap, "mode" );
|
m_config->setConfigurationMap( configurationMap );
|
||||||
bool mode_ok = false;
|
|
||||||
if ( !mode.isEmpty() )
|
|
||||||
{
|
|
||||||
m_mode = roleNames().find( mode, mode_ok );
|
|
||||||
}
|
|
||||||
if ( !mode_ok )
|
|
||||||
{
|
|
||||||
m_mode = PackageChooserMode::Required;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_id = CalamaresUtils::getString( configurationMap, "id" );
|
|
||||||
if ( m_id.isEmpty() )
|
|
||||||
{
|
|
||||||
// Not set, so use the instance id
|
|
||||||
m_id = moduleInstanceKey().id();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool labels_ok = false;
|
bool labels_ok = false;
|
||||||
auto labels = CalamaresUtils::getSubMap( configurationMap, "labels", labels_ok );
|
auto labels = CalamaresUtils::getSubMap( configurationMap, "labels", labels_ok );
|
||||||
@ -195,117 +157,22 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString default_item_id = CalamaresUtils::getString( configurationMap, "default" );
|
if ( m_widget )
|
||||||
m_defaultIdx = QModelIndex();
|
|
||||||
|
|
||||||
bool first_time = !m_model;
|
|
||||||
if ( configurationMap.contains( "items" ) )
|
|
||||||
{
|
|
||||||
fillModel( configurationMap.value( "items" ).toList() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( first_time && m_widget && m_model )
|
|
||||||
{
|
{
|
||||||
hookupModel();
|
hookupModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// find default item
|
|
||||||
if ( first_time && m_model && !default_item_id.isEmpty() )
|
|
||||||
{
|
|
||||||
for ( int item_n = 0; item_n < m_model->packageCount(); ++item_n )
|
|
||||||
{
|
|
||||||
QModelIndex item_idx = m_model->index( item_n, 0 );
|
|
||||||
QVariant item_id = m_model->data( item_idx, PackageListModel::IdRole );
|
|
||||||
|
|
||||||
if ( item_id.toString() == default_item_id )
|
|
||||||
{
|
|
||||||
m_defaultIdx = item_idx;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
PackageChooserViewStep::fillModel( const QVariantList& items )
|
|
||||||
{
|
|
||||||
if ( !m_model )
|
|
||||||
{
|
|
||||||
m_model = new PackageListModel( nullptr );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( items.isEmpty() )
|
|
||||||
{
|
|
||||||
cWarning() << "No *items* for PackageChooser module.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_APPSTREAM
|
|
||||||
std::unique_ptr< AppStream::Pool > pool;
|
|
||||||
bool poolOk = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cDebug() << "Loading PackageChooser model items from config";
|
|
||||||
int item_index = 0;
|
|
||||||
for ( const auto& item_it : items )
|
|
||||||
{
|
|
||||||
++item_index;
|
|
||||||
QVariantMap item_map = item_it.toMap();
|
|
||||||
if ( item_map.isEmpty() )
|
|
||||||
{
|
|
||||||
cWarning() << "PackageChooser entry" << item_index << "is not valid.";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( item_map.contains( "appdata" ) )
|
|
||||||
{
|
|
||||||
#ifdef HAVE_XML
|
|
||||||
m_model->addPackage( fromAppData( item_map ) );
|
|
||||||
#else
|
|
||||||
cWarning() << "Loading AppData XML is not supported.";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if ( item_map.contains( "appstream" ) )
|
|
||||||
{
|
|
||||||
#ifdef HAVE_APPSTREAM
|
|
||||||
if ( !pool )
|
|
||||||
{
|
|
||||||
pool = std::make_unique< AppStream::Pool >();
|
|
||||||
pool->setLocale( QStringLiteral( "ALL" ) );
|
|
||||||
poolOk = pool->load();
|
|
||||||
}
|
|
||||||
if ( pool && poolOk )
|
|
||||||
{
|
|
||||||
m_model->addPackage( fromAppStream( *pool, item_map ) );
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
cWarning() << "Loading AppStream data is not supported.";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_model->addPackage( PackageItem( item_map ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageChooserViewStep::hookupModel()
|
PackageChooserViewStep::hookupModel()
|
||||||
{
|
{
|
||||||
if ( !m_model || !m_widget )
|
if ( !m_config->model() || !m_widget )
|
||||||
{
|
{
|
||||||
cError() << "Can't hook up model until widget and model both exist.";
|
cError() << "Can't hook up model until widget and model both exist.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_widget->setModel( m_model );
|
m_widget->setModel( m_config->model() );
|
||||||
for ( int i = 0; i < m_model->packageCount(); ++i )
|
m_widget->setIntroduction( m_config->introductionPackage() );
|
||||||
{
|
|
||||||
const auto& package = m_model->packageData( i );
|
|
||||||
if ( package.id.isEmpty() )
|
|
||||||
{
|
|
||||||
m_widget->setIntroduction( package );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,9 @@
|
|||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
#include "viewpages/ViewStep.h"
|
#include "viewpages/ViewStep.h"
|
||||||
|
|
||||||
#include "PackageModel.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
class Config;
|
||||||
class PackageChooserPage;
|
class PackageChooserPage;
|
||||||
|
|
||||||
class PLUGINDLLEXPORT PackageChooserViewStep : public Calamares::ViewStep
|
class PLUGINDLLEXPORT PackageChooserViewStep : public Calamares::ViewStep
|
||||||
@ -49,17 +46,11 @@ public:
|
|||||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fillModel( const QVariantList& items );
|
|
||||||
void hookupModel();
|
void hookupModel();
|
||||||
|
|
||||||
|
Config* m_config;
|
||||||
PackageChooserPage* m_widget;
|
PackageChooserPage* m_widget;
|
||||||
PackageListModel* m_model;
|
|
||||||
|
|
||||||
// Configuration
|
|
||||||
PackageChooserMode m_mode;
|
|
||||||
QString m_id;
|
|
||||||
CalamaresUtils::Locale::TranslatedString* m_stepName; // As it appears in the sidebar
|
CalamaresUtils::Locale::TranslatedString* m_stepName; // As it appears in the sidebar
|
||||||
QModelIndex m_defaultIdx;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory )
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
const NamedEnumTable< PackageChooserMode >&
|
const NamedEnumTable< PackageChooserMode >&
|
||||||
roleNames()
|
packageChooserModeNames()
|
||||||
{
|
{
|
||||||
static const NamedEnumTable< PackageChooserMode > names {
|
static const NamedEnumTable< PackageChooserMode > names {
|
||||||
{ "optional", PackageChooserMode::Optional },
|
{ "optional", PackageChooserMode::Optional },
|
||||||
|
@ -26,7 +26,7 @@ enum class PackageChooserMode
|
|||||||
RequiredMultiple // one or more
|
RequiredMultiple // one or more
|
||||||
};
|
};
|
||||||
|
|
||||||
const NamedEnumTable< PackageChooserMode >& roleNames();
|
const NamedEnumTable< PackageChooserMode >& packageChooserModeNames();
|
||||||
|
|
||||||
struct PackageItem
|
struct PackageItem
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user