C++: prefer std::as_const over Qt solution
In Qt 6.6, qAsConst is deprecated; since Calamares is C++17 we have had a standard solution always.
This commit is contained in:
parent
ba96a39ca0
commit
196f85fa2c
@ -309,7 +309,7 @@ load_module( const ModuleConfig& moduleConfig )
|
|||||||
QVariantMap descriptor;
|
QVariantMap descriptor;
|
||||||
|
|
||||||
QStringList moduleDirectories { "./", "src/modules/", "modules/", CMAKE_INSTALL_FULL_LIBDIR "/calamares/modules/" };
|
QStringList moduleDirectories { "./", "src/modules/", "modules/", CMAKE_INSTALL_FULL_LIBDIR "/calamares/modules/" };
|
||||||
for ( const QString& prefix : qAsConst( moduleDirectories ) )
|
for ( const QString& prefix : std::as_const( moduleDirectories ) )
|
||||||
{
|
{
|
||||||
// Could be a complete path, eg. src/modules/dummycpp/module.desc
|
// Could be a complete path, eg. src/modules/dummycpp/module.desc
|
||||||
fi = QFileInfo( prefix + moduleName );
|
fi = QFileInfo( prefix + moduleName );
|
||||||
|
@ -275,7 +275,7 @@ bool
|
|||||||
Settings::isModuleEnabled( const QString& module ) const
|
Settings::isModuleEnabled( const QString& module ) const
|
||||||
{
|
{
|
||||||
// Iterate over the list of modules searching for a match
|
// Iterate over the list of modules searching for a match
|
||||||
for ( const auto& moduleInstance : qAsConst( m_moduleInstances ) )
|
for ( const auto& moduleInstance : std::as_const( m_moduleInstances ) )
|
||||||
{
|
{
|
||||||
if ( moduleInstance.key().module() == module )
|
if ( moduleInstance.key().module() == module )
|
||||||
{
|
{
|
||||||
|
@ -96,7 +96,7 @@ PackagesTests::testAdd()
|
|||||||
QVERIFY( action.contains( "install" ) );
|
QVERIFY( action.contains( "install" ) );
|
||||||
auto op = action[ "install" ].toList();
|
auto op = action[ "install" ].toList();
|
||||||
QCOMPARE( op.length(), packages.length() );
|
QCOMPARE( op.length(), packages.length() );
|
||||||
for ( const auto& s : qAsConst( packages ) )
|
for ( const auto& s : std::as_const( packages ) )
|
||||||
{
|
{
|
||||||
QVERIFY( op.contains( s ) );
|
QVERIFY( op.contains( s ) );
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ PackagesTests::testAdd()
|
|||||||
QVERIFY( gs.contains( topKey ) );
|
QVERIFY( gs.contains( topKey ) );
|
||||||
auto actionList = gs.value( topKey ).toList();
|
auto actionList = gs.value( topKey ).toList();
|
||||||
QCOMPARE( actionList.length(), 2 ); // One for each instance key!
|
QCOMPARE( actionList.length(), 2 ); // One for each instance key!
|
||||||
for ( const auto& actionVariant : qAsConst( actionList ) )
|
for ( const auto& actionVariant : std::as_const( actionList ) )
|
||||||
{
|
{
|
||||||
auto action = actionVariant.toMap();
|
auto action = actionVariant.toMap();
|
||||||
QVERIFY( action.contains( "install" ) );
|
QVERIFY( action.contains( "install" ) );
|
||||||
@ -130,7 +130,7 @@ PackagesTests::testAdd()
|
|||||||
{
|
{
|
||||||
auto op = action[ "install" ].toList();
|
auto op = action[ "install" ].toList();
|
||||||
QCOMPARE( op.length(), packages.length() ); // changed from original length, though
|
QCOMPARE( op.length(), packages.length() ); // changed from original length, though
|
||||||
for ( const auto& s : qAsConst( packages ) )
|
for ( const auto& s : std::as_const( packages ) )
|
||||||
{
|
{
|
||||||
QVERIFY( op.contains( s ) );
|
QVERIFY( op.contains( s ) );
|
||||||
}
|
}
|
||||||
@ -212,7 +212,7 @@ PackagesTests::testAddMixed()
|
|||||||
auto actionList = gs.value( topKey ).toList();
|
auto actionList = gs.value( topKey ).toList();
|
||||||
QCOMPARE( actionList.length(), 2 );
|
QCOMPARE( actionList.length(), 2 );
|
||||||
|
|
||||||
for ( const auto& actionVariant : qAsConst( actionList ) )
|
for ( const auto& actionVariant : std::as_const( actionList ) )
|
||||||
{
|
{
|
||||||
auto action = actionVariant.toMap();
|
auto action = actionVariant.toMap();
|
||||||
QVERIFY( action.contains( "install" ) );
|
QVERIFY( action.contains( "install" ) );
|
||||||
|
@ -233,7 +233,7 @@ SetKeyboardLayoutJob::writeVConsoleData( const QString& vconsoleConfPath, const
|
|||||||
}
|
}
|
||||||
QTextStream stream( &file );
|
QTextStream stream( &file );
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for ( const QString& existingLine : qAsConst( existingLines ) )
|
for ( const QString& existingLine : std::as_const( existingLines ) )
|
||||||
{
|
{
|
||||||
if ( existingLine.trimmed().startsWith( "KEYMAP=" ) )
|
if ( existingLine.trimmed().startsWith( "KEYMAP=" ) )
|
||||||
{
|
{
|
||||||
|
@ -378,7 +378,7 @@ PackageModel::appendModelData( const QVariantList& groupList )
|
|||||||
removeList.insert( 0, i );
|
removeList.insert( 0, i );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ( const int& item : qAsConst( removeList ) )
|
for ( const int& item : std::as_const( removeList ) )
|
||||||
{
|
{
|
||||||
m_rootItem->removeChild( item );
|
m_rootItem->removeChild( item );
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ PackageListModel::addPackage( PackageItem&& p )
|
|||||||
QStringList
|
QStringList
|
||||||
PackageListModel::getInstallPackagesForName( const QString& id ) const
|
PackageListModel::getInstallPackagesForName( const QString& id ) const
|
||||||
{
|
{
|
||||||
for ( const auto& p : qAsConst( m_packages ) )
|
for ( const auto& p : std::as_const( m_packages ) )
|
||||||
{
|
{
|
||||||
if ( p.id == id )
|
if ( p.id == id )
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ QStringList
|
|||||||
PackageListModel::getInstallPackagesForNames( const QStringList& ids ) const
|
PackageListModel::getInstallPackagesForNames( const QStringList& ids ) const
|
||||||
{
|
{
|
||||||
QStringList l;
|
QStringList l;
|
||||||
for ( const auto& p : qAsConst( m_packages ) )
|
for ( const auto& p : std::as_const( m_packages ) )
|
||||||
{
|
{
|
||||||
if ( ids.contains( p.id ) )
|
if ( ids.contains( p.id ) )
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,7 @@ static QStringList
|
|||||||
jobDescriptions( const Calamares::JobList& jobs )
|
jobDescriptions( const Calamares::JobList& jobs )
|
||||||
{
|
{
|
||||||
QStringList jobsLines;
|
QStringList jobsLines;
|
||||||
for ( const Calamares::job_ptr& job : qAsConst( jobs ) )
|
for ( const Calamares::job_ptr& job : std::as_const( jobs ) )
|
||||||
{
|
{
|
||||||
const auto description = job->prettyDescription();
|
const auto description = job->prettyDescription();
|
||||||
if ( !description.isEmpty() )
|
if ( !description.isEmpty() )
|
||||||
@ -478,7 +478,7 @@ shouldWarnForGPTOnBIOS( const PartitionCoreModule* core )
|
|||||||
if ( table && table->type() == PartitionTable::TableType::gpt )
|
if ( table && table->type() == PartitionTable::TableType::gpt )
|
||||||
{
|
{
|
||||||
// So this is a BIOS system, and the bootloader will be installed on a GPT system
|
// So this is a BIOS system, and the bootloader will be installed on a GPT system
|
||||||
for ( const auto& partition : qAsConst( table->children() ) )
|
for ( const auto& partition : std::as_const( table->children() ) )
|
||||||
{
|
{
|
||||||
using Calamares::Units::operator""_MiB;
|
using Calamares::Units::operator""_MiB;
|
||||||
if ( ( partition->activeFlags() & KPM_PARTITION_FLAG( BiosGrub ) )
|
if ( ( partition->activeFlags() & KPM_PARTITION_FLAG( BiosGrub ) )
|
||||||
|
@ -619,7 +619,7 @@ findEssentialLVs( const QList< PartitionCoreModule::DeviceInfo* >& infos )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( const auto& j : qAsConst( info->jobs() ) )
|
for ( const auto& j : std::as_const( info->jobs() ) )
|
||||||
{
|
{
|
||||||
FormatPartitionJob* format = dynamic_cast< FormatPartitionJob* >( j.data() );
|
FormatPartitionJob* format = dynamic_cast< FormatPartitionJob* >( j.data() );
|
||||||
if ( format )
|
if ( format )
|
||||||
|
@ -221,7 +221,7 @@ PartitionLayout::createPartitions( Device* dev,
|
|||||||
|
|
||||||
// Let's check if we have enough space for each partitions, using the size
|
// Let's check if we have enough space for each partitions, using the size
|
||||||
// propery or the min-size property if unit is in percentage.
|
// propery or the min-size property if unit is in percentage.
|
||||||
for ( const auto& entry : qAsConst( m_partLayout ) )
|
for ( const auto& entry : std::as_const( m_partLayout ) )
|
||||||
{
|
{
|
||||||
if ( !entry.partSize.isValid() )
|
if ( !entry.partSize.isValid() )
|
||||||
{
|
{
|
||||||
@ -250,7 +250,7 @@ PartitionLayout::createPartitions( Device* dev,
|
|||||||
if ( availableSectors < 0 )
|
if ( availableSectors < 0 )
|
||||||
{
|
{
|
||||||
availableSectors = totalSectors;
|
availableSectors = totalSectors;
|
||||||
for ( const auto& entry : qAsConst( m_partLayout ) )
|
for ( const auto& entry : std::as_const( m_partLayout ) )
|
||||||
{
|
{
|
||||||
qint64 sectors = partSectorsMap.value( &entry );
|
qint64 sectors = partSectorsMap.value( &entry );
|
||||||
if ( entry.partMinSize.isValid() )
|
if ( entry.partMinSize.isValid() )
|
||||||
@ -263,7 +263,7 @@ PartitionLayout::createPartitions( Device* dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assign sectors for percentage-defined partitions.
|
// Assign sectors for percentage-defined partitions.
|
||||||
for ( const auto& entry : qAsConst( m_partLayout ) )
|
for ( const auto& entry : std::as_const( m_partLayout ) )
|
||||||
{
|
{
|
||||||
if ( entry.partSize.unit() == Calamares::Partition::SizeUnit::Percent )
|
if ( entry.partSize.unit() == Calamares::Partition::SizeUnit::Percent )
|
||||||
{
|
{
|
||||||
@ -286,7 +286,7 @@ PartitionLayout::createPartitions( Device* dev,
|
|||||||
// Create the partitions.
|
// Create the partitions.
|
||||||
currentSector = firstSector;
|
currentSector = firstSector;
|
||||||
availableSectors = totalSectors;
|
availableSectors = totalSectors;
|
||||||
for ( const auto& entry : qAsConst( m_partLayout ) )
|
for ( const auto& entry : std::as_const( m_partLayout ) )
|
||||||
{
|
{
|
||||||
// Adjust partition size based on available space.
|
// Adjust partition size based on available space.
|
||||||
qint64 sectors = partSectorsMap.value( &entry );
|
qint64 sectors = partSectorsMap.value( &entry );
|
||||||
|
@ -333,7 +333,7 @@ template < typename F >
|
|||||||
void
|
void
|
||||||
apply( const QStringList& paths, F f, QList< MessageAndPath >& news )
|
apply( const QStringList& paths, F f, QList< MessageAndPath >& news )
|
||||||
{
|
{
|
||||||
for ( const QString& p : qAsConst( paths ) )
|
for ( const QString& p : std::as_const( paths ) )
|
||||||
{
|
{
|
||||||
auto n = f( p );
|
auto n = f( p );
|
||||||
if ( !n.isEmpty() )
|
if ( !n.isEmpty() )
|
||||||
@ -347,7 +347,7 @@ STATICTEST QStringList
|
|||||||
stringify( const QList< MessageAndPath >& news )
|
stringify( const QList< MessageAndPath >& news )
|
||||||
{
|
{
|
||||||
QStringList l;
|
QStringList l;
|
||||||
for ( const auto& m : qAsConst( news ) )
|
for ( const auto& m : std::as_const( news ) )
|
||||||
{
|
{
|
||||||
l << QString( m );
|
l << QString( m );
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ ClearTempMountsJob::exec()
|
|||||||
std::sort( targetMounts.begin(), targetMounts.end(), MtabInfo::mountPointOrder );
|
std::sort( targetMounts.begin(), targetMounts.end(), MtabInfo::mountPointOrder );
|
||||||
|
|
||||||
QStringList goodNews;
|
QStringList goodNews;
|
||||||
for ( const auto& m : qAsConst( targetMounts ) )
|
for ( const auto& m : std::as_const( targetMounts ) )
|
||||||
{
|
{
|
||||||
cDebug() << o << "Will try to umount path" << m.mountPoint;
|
cDebug() << o << "Will try to umount path" << m.mountPoint;
|
||||||
if ( Calamares::Partition::unmount( m.mountPoint, { "-lv" } ) == 0 )
|
if ( Calamares::Partition::unmount( m.mountPoint, { "-lv" } ) == 0 )
|
||||||
|
@ -65,7 +65,7 @@ PreserveFiles::exec()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for ( const auto& it : qAsConst( m_items ) )
|
for ( const auto& it : std::as_const( m_items ) )
|
||||||
{
|
{
|
||||||
if ( !it )
|
if ( !it )
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ unmountTargetMounts( const QString& rootMountPoint )
|
|||||||
std::sort( targetMounts.begin(), targetMounts.end(), MtabInfo::mountPointOrder );
|
std::sort( targetMounts.begin(), targetMounts.end(), MtabInfo::mountPointOrder );
|
||||||
|
|
||||||
cDebug() << "Read" << targetMounts.count() << "entries from" << targetMountPath;
|
cDebug() << "Read" << targetMounts.count() << "entries from" << targetMountPath;
|
||||||
for ( const auto& m : qAsConst( targetMounts ) )
|
for ( const auto& m : std::as_const( targetMounts ) )
|
||||||
{
|
{
|
||||||
// Returns the program's exit code, so 0 is success and non-0
|
// Returns the program's exit code, so 0 is success and non-0
|
||||||
// (truthy) is a failure.
|
// (truthy) is a failure.
|
||||||
|
@ -288,7 +288,7 @@ getCheckInternetUrls( const QVariantMap& configurationMap )
|
|||||||
if ( !checkInternetSetting.isEmpty() )
|
if ( !checkInternetSetting.isEmpty() )
|
||||||
{
|
{
|
||||||
QVector< QUrl > urls;
|
QVector< QUrl > urls;
|
||||||
for ( const auto& urlString : qAsConst( checkInternetSetting ) )
|
for ( const auto& urlString : std::as_const( checkInternetSetting ) )
|
||||||
{
|
{
|
||||||
QUrl url( urlString.trimmed() );
|
QUrl url( urlString.trimmed() );
|
||||||
if ( url.isValid() )
|
if ( url.isValid() )
|
||||||
|
@ -193,7 +193,7 @@ ZfsJob::exec()
|
|||||||
}
|
}
|
||||||
QVariantList zfsInfoList = gs->value( "zfsInfo" ).toList();
|
QVariantList zfsInfoList = gs->value( "zfsInfo" ).toList();
|
||||||
|
|
||||||
for ( auto& partition : qAsConst( partitions ) )
|
for ( auto& partition : std::as_const( partitions ) )
|
||||||
{
|
{
|
||||||
QVariantMap pMap;
|
QVariantMap pMap;
|
||||||
if ( partition.canConvert< QVariantMap >() )
|
if ( partition.canConvert< QVariantMap >() )
|
||||||
@ -231,7 +231,7 @@ ZfsJob::exec()
|
|||||||
// Look in the zfs info list to see if this partition should be encrypted
|
// Look in the zfs info list to see if this partition should be encrypted
|
||||||
bool encrypt = false;
|
bool encrypt = false;
|
||||||
QString passphrase;
|
QString passphrase;
|
||||||
for ( const QVariant& zfsInfo : qAsConst( zfsInfoList ) )
|
for ( const QVariant& zfsInfo : std::as_const( zfsInfoList ) )
|
||||||
{
|
{
|
||||||
if ( zfsInfo.canConvert< QVariantMap >() && zfsInfo.toMap().value( "encrypted" ).toBool()
|
if ( zfsInfo.canConvert< QVariantMap >() && zfsInfo.toMap().value( "encrypted" ).toBool()
|
||||||
&& mountpoint == zfsInfo.toMap().value( "mountpoint" ) )
|
&& mountpoint == zfsInfo.toMap().value( "mountpoint" ) )
|
||||||
@ -276,7 +276,7 @@ ZfsJob::exec()
|
|||||||
{
|
{
|
||||||
collectMountpoints( partitions );
|
collectMountpoints( partitions );
|
||||||
QVariantList datasetList;
|
QVariantList datasetList;
|
||||||
for ( const auto& dataset : qAsConst( m_datasets ) )
|
for ( const auto& dataset : std::as_const( m_datasets ) )
|
||||||
{
|
{
|
||||||
QVariantMap datasetMap = dataset.toMap();
|
QVariantMap datasetMap = dataset.toMap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user