mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-27 09:25:36 -04:00
[license] Use standard algorithms, simplify code
- Introduce isRequired() for readability later - Use std::any_of instead of rolling own loop
This commit is contained in:
parent
937f332441
commit
c245238b89
2 changed files with 4 additions and 9 deletions
|
@ -41,6 +41,8 @@
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
const NamedEnumTable< LicenseEntry::Type >&
|
const NamedEnumTable< LicenseEntry::Type >&
|
||||||
LicenseEntry::typeNames()
|
LicenseEntry::typeNames()
|
||||||
{
|
{
|
||||||
|
@ -134,15 +136,7 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
|
||||||
{
|
{
|
||||||
CalamaresUtils::clearLayout( ui->licenseEntriesLayout );
|
CalamaresUtils::clearLayout( ui->licenseEntriesLayout );
|
||||||
|
|
||||||
bool required = false;
|
const bool required = std::any_of( entriesList.cbegin(), entriesList.cend(), []( const LicenseEntry& e ){ return e.m_required; });
|
||||||
for ( const LicenseEntry& entry : entriesList )
|
|
||||||
{
|
|
||||||
if ( entry.m_required )
|
|
||||||
{
|
|
||||||
required = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_isNextEnabled = !required;
|
m_isNextEnabled = !required;
|
||||||
nextStatusChanged( m_isNextEnabled );
|
nextStatusChanged( m_isNextEnabled );
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct LicenseEntry
|
||||||
LicenseEntry( const LicenseEntry& ) = default;
|
LicenseEntry( const LicenseEntry& ) = default;
|
||||||
|
|
||||||
bool isValid() const { return !m_id.isEmpty(); }
|
bool isValid() const { return !m_id.isEmpty(); }
|
||||||
|
bool isRequired() const { return m_required; }
|
||||||
|
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QString m_prettyName;
|
QString m_prettyName;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue