diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index 8a4e3b5b4..387aa274a 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -18,10 +18,12 @@ #include "SummaryPage.h" -#include "ViewManager.h" -#include "viewpages/ViewStep.h" +#include "SummaryViewStep.h" + +#include "ExecutionViewStep.h" #include "utils/Retranslator.h" #include "utils/CalamaresUtilsGui.h" +#include "ViewManager.h" #include #include @@ -29,11 +31,13 @@ static const int SECTION_SPACING = 12; -SummaryPage::SummaryPage( QWidget* parent ) +SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent ) : QWidget() + , m_thisViewStep( thisViewStep ) , m_scrollArea( new QScrollArea( this ) ) , m_contentWidget( nullptr ) { + Q_ASSERT( m_thisViewStep ); QVBoxLayout* layout = new QVBoxLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); @@ -59,8 +63,10 @@ SummaryPage::onActivate() QString text; bool first = true; - foreach ( Calamares::ViewStep* step, - Calamares::ViewManager::instance()->prepareSteps() ) + Calamares::ViewStepList steps = + stepsForSummary( Calamares::ViewManager::instance()->viewSteps() ); + + foreach ( Calamares::ViewStep* step, steps ) { QString text = step->prettyStatus(); QWidget* widget = step->createSummaryWidget(); @@ -90,6 +96,35 @@ SummaryPage::onActivate() m_layout->addStretch(); } + +Calamares::ViewStepList +SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps ) const +{ + Calamares::ViewStepList steps; + foreach ( Calamares::ViewStep* step, allSteps ) + { + // We start from the beginning of the complete steps list. If we encounter any + // ExecutionViewStep, it means there was an execution phase in the past, and any + // jobs from before that phase were already executed, so we can safely clear the + // list of steps to summarize and start collecting from scratch. + if ( qobject_cast< Calamares::ExecutionViewStep* >( step ) ) + { + steps.clear(); + continue; + } + + // If we reach the parent step of this page, we're done collecting the list of + // steps to summarize. + if ( m_thisViewStep == step ) + break; + + steps.append( step ); + } + + return steps; +} + + void SummaryPage::createContentWidget() { diff --git a/src/modules/summary/SummaryPage.h b/src/modules/summary/SummaryPage.h index 837c694ce..21d2e2ede 100644 --- a/src/modules/summary/SummaryPage.h +++ b/src/modules/summary/SummaryPage.h @@ -19,21 +19,28 @@ #ifndef SUMMARYPAGE_H #define SUMMARYPAGE_H +#include "Typedefs.h" + #include class QLabel; class QScrollArea; class QVBoxLayout; +class SummaryViewStep; class SummaryPage : public QWidget { Q_OBJECT public: - explicit SummaryPage( QWidget* parent = nullptr ); + explicit SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent = nullptr ); void onActivate(); private: + Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const; + + const SummaryViewStep* m_thisViewStep; + QVBoxLayout* m_layout = nullptr; QWidget* m_contentWidget = nullptr;