Port away from most cases of Q_FOREACH to C++11 ranged for loop.

In order to avoid deep copies, Qt containers over which we iterate must be const
The remaining unported cases require qAsConst (Qt 5.7) or std::as_const (C++17)
This commit is contained in:
Andrius Štikonas 2016-09-01 13:21:05 +01:00
parent b0122f25e5
commit 9f0ca042fe
35 changed files with 105 additions and 92 deletions

View file

@ -155,10 +155,10 @@ lookForFstabEntries( const QString& partitionPath )
QFile fstabFile( mountsDir.path() + "/etc/fstab" );
if ( fstabFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() )
const QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() )
.split( '\n' );
foreach ( const QString& rawLine, fstabLines )
for ( const QString& rawLine : fstabLines )
{
QString line = rawLine.simplified();
if ( line.startsWith( '#' ) )
@ -194,7 +194,7 @@ findPartitionPathForMountPoint( const FstabEntryList& fstab,
if ( fstab.isEmpty() )
return QString();
foreach ( const FstabEntry& entry, fstab )
for ( const FstabEntry& entry : fstab )
{
if ( entry.mountPoint == mountPoint )
{
@ -283,7 +283,8 @@ runOsprober( PartitionCoreModule* core )
QString osProberReport( "Osprober lines, clean:\n" );
QStringList osproberCleanLines;
OsproberEntryList osproberEntries;
foreach ( const QString& line, osproberOutput.split( '\n' ) )
const auto lines = osproberOutput.split( '\n' );
for ( const QString& line : lines )
{
if ( !line.simplified().isEmpty() )
{