diff --git a/src/modules/summaryq/Config.cpp b/src/modules/summaryq/Config.cpp index e0f855ab5..e404c1f62 100644 --- a/src/modules/summaryq/Config.cpp +++ b/src/modules/summaryq/Config.cpp @@ -48,7 +48,7 @@ SummaryModel::rowCount( const QModelIndex& ) const } void -SummaryModel::setSummary( const Calamares::ViewStepList& steps, bool withWidgets ) +SummaryModel::setSummaryList( const Calamares::ViewStepList& steps, bool withWidgets ) { Q_EMIT beginResetModel(); m_summary.clear(); @@ -105,28 +105,24 @@ Config::componentComplete() void Config::refresh() -{ - m_summary->setSummary( stepsForSummary( Calamares::ViewManager::instance()->viewSteps() ) ); -} - -void -Config::init() -{ - refresh(); -} - -Calamares::ViewStepList -Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const { Calamares::ViewStepList steps; - for ( Calamares::ViewStep* step : allSteps ) + for ( Calamares::ViewStep* step : Calamares::ViewManager::instance()->viewSteps() ) { + // *Assume* that if there's an exec step in the sequence, + // we don't need a summary for steps before it. This works in + // practice if there's a summary step before each exec -- + // and in practice, there's only one of each. if ( qobject_cast< Calamares::ExecutionViewStep* >( step ) ) { steps.clear(); continue; } + // Having reached the parent view-step of the Config object, + // we know we're providing a summary of steps up until this + // view step, so we now have steps since the previous exec, up + // to this summary. if ( m_thisViewStep == step ) { break; @@ -135,5 +131,11 @@ Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const steps.append( step ); } - return steps; + m_summary->setSummaryList( steps ); +} + +void +Config::init() +{ + refresh(); } diff --git a/src/modules/summaryq/Config.h b/src/modules/summaryq/Config.h index ec804321b..08f2c0f16 100644 --- a/src/modules/summaryq/Config.h +++ b/src/modules/summaryq/Config.h @@ -17,6 +17,8 @@ #include #include +class Config; + /** @brief Data for one step * * A step generally has a text description, but **may** have a @@ -33,17 +35,26 @@ struct StepSummary class SummaryModel : public QAbstractListModel { Q_OBJECT + friend class Config; + public: explicit SummaryModel( QObject* parent = nullptr ); int rowCount( const QModelIndex& = QModelIndex() ) const override; QVariant data( const QModelIndex& index, int role ) const override; - void setSummary( const Calamares::ViewStepList& steps, bool withWidgets = false ); - protected: QHash< int, QByteArray > roleNames() const override; private: + /** @brief Sets the model data from @p steps + * + * Replaces the list of summaries with summaries given by + * the jobs and ViewSteps objects in @p steps. If @p withWidgets + * is @c true, then also queries for widget summaries alongside + * the text summaries for each step. + */ + void setSummaryList( const Calamares::ViewStepList& steps, bool withWidgets = false ); + QVector< StepSummary > m_summary; };