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

@ -77,13 +77,13 @@ ModuleManager::doInit()
// the module name, and must contain a settings file named module.desc.
// If at any time the module loading procedure finds something unexpected, it
// silently skips to the next module or search path. --Teo 6/2014
foreach ( const QString& path, m_paths )
for ( const QString& path : m_paths )
{
QDir currentDir( path );
if ( currentDir.exists() && currentDir.isReadable() )
{
QStringList subdirs = currentDir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot );
foreach ( const QString& subdir, subdirs )
const QStringList subdirs = currentDir.entryList( QDir::AllDirs | QDir::NoDotAndDotDot );
for ( const QString& subdir : subdirs )
{
currentDir.setPath( path );
bool success = currentDir.cd( subdir );
@ -179,8 +179,8 @@ ModuleManager::loadModules()
QList< QMap< QString, QString > > customInstances =
Settings::instance()->customModuleInstances();
for ( const QPair< ModuleAction, QStringList >& modulePhase :
Settings::instance()->modulesSequence() )
const auto modulesSequence = Settings::instance()->modulesSequence();
for ( const auto &modulePhase : modulesSequence )
{
ModuleAction currentAction = modulePhase.first;