[partition] Factor out gather job-descriptions

Since prettyStatus() and the summaryWidget share a lot of
strings and code, start factoring that out.
This commit is contained in:
Adriaan de Groot 2021-07-12 15:02:24 +02:00
parent 7094c7bf39
commit 535f81ba8a

View File

@ -109,6 +109,19 @@ PartitionViewStep::prettyName() const
return tr( "Partitions" ); return tr( "Partitions" );
} }
static QStringList jobDescriptions( const Calamares::JobList& jobs )
{
QStringList jobsLines;
for( const Calamares::job_ptr& job : qAsConst( jobs ) )
{
if ( !job->prettyDescription().isEmpty() )
{
jobsLines.append( job->prettyDescription() );
}
}
return jobsLines;
}
QString QString
PartitionViewStep::prettyStatus() const PartitionViewStep::prettyStatus() const
{ {
@ -182,14 +195,7 @@ PartitionViewStep::prettyStatus() const
} }
} }
QStringList jobsLines; const QStringList jobsLines = jobDescriptions( jobs() );
foreach ( const Calamares::job_ptr& job, jobs() )
{
if ( !job->prettyDescription().isEmpty() )
{
jobsLines.append( job->prettyDescription() );
}
}
if ( !jobsLines.isEmpty() ) if ( !jobsLines.isEmpty() )
{ {
jobsLabel = jobsLines.join( "<br/>" ); jobsLabel = jobsLines.join( "<br/>" );
@ -324,14 +330,7 @@ PartitionViewStep::createSummaryWidget() const
field->addWidget( previewLabels ); field->addWidget( previewLabels );
formLayout->addRow( tr( "After:" ), field ); formLayout->addRow( tr( "After:" ), field );
} }
QStringList jobsLines; const QStringList jobsLines = jobDescriptions( jobs() );
foreach ( const Calamares::job_ptr& job, jobs() )
{
if ( !job->prettyDescription().isEmpty() )
{
jobsLines.append( job->prettyDescription() );
}
}
if ( !jobsLines.isEmpty() ) if ( !jobsLines.isEmpty() )
{ {
QLabel* jobsLabel = new QLabel( widget ); QLabel* jobsLabel = new QLabel( widget );