[summary] Start using the model

This commit is contained in:
Adriaan de Groot 2021-10-04 14:44:14 +02:00
parent 3bc90e6c06
commit 6b38985a5f

View File

@ -140,26 +140,27 @@ SummaryPage::buildWidgets( Config* config, SummaryViewStep* viewstep )
QPalette bodyPalette( palette() ); QPalette bodyPalette( palette() );
bodyPalette.setColor( WindowBackground, palette().window().color().lighter( 108 ) ); bodyPalette.setColor( WindowBackground, palette().window().color().lighter( 108 ) );
bool first = true; const auto* model = config->summaryModel();
const Calamares::ViewStepList steps = Config::stepsForSummary( viewstep ); const auto rowCount = model->rowCount();
for ( Calamares::ViewStep* step : steps ) for ( int row = 0; row < rowCount; row++ )
{ {
QString text = step->prettyStatus(); const auto rowIndex = model->index( row );
QWidget* widget = step->createSummaryWidget(); QString title = model->data( rowIndex, SummaryModel::TitleRole ).toString();
QString text = model->data( rowIndex, SummaryModel::MessageRole ).toString();
QWidget* widget = model->data( rowIndex, SummaryModel::WidgetRole ).value< QWidget* >();
if ( text.isEmpty() && !widget ) if ( text.isEmpty() && !widget )
{ {
continue; continue;
} }
if ( !first ) if ( row > 0 )
{ {
m_layout->addSpacing( SECTION_SPACING ); m_layout->addSpacing( SECTION_SPACING );
} }
first = false;
m_layout->addWidget( createTitleLabel( step->prettyName(), titleFont ) ); m_layout->addWidget( createTitleLabel( title, titleFont ) );
m_layout->addWidget( createStepWidget( text, widget, bodyPalette ) ); m_layout->addWidget( createStepWidget( text, widget, bodyPalette ) );
} }
m_layout->addStretch(); m_layout->addStretch();