Merge pull request #255 from stikonas/master

Port away from most cases of Q_FOREACH to C++11 ranged for loop.
This commit is contained in:
Teo Mrnjavac 2016-09-02 15:14:25 +02:00 committed by GitHub
commit cbb2162ee9
35 changed files with 105 additions and 92 deletions

View File

@ -132,7 +132,8 @@ ProgressTreeModel::setupModelData()
m_rootItem = new ProgressTreeRoot(); m_rootItem = new ProgressTreeRoot();
const Calamares::ViewManager* vm = Calamares::ViewManager::instance(); const Calamares::ViewManager* vm = Calamares::ViewManager::instance();
foreach ( const Calamares::ViewStep* step, vm->viewSteps() ) const auto steps = vm->viewSteps();
for ( const Calamares::ViewStep* step : steps )
{ {
m_rootItem->appendChild( new ViewStepItem( step, m_rootItem ) ); m_rootItem->appendChild( new ViewStepItem( step, m_rootItem ) );
} }

View File

@ -118,7 +118,8 @@ bp::list
GlobalStoragePythonWrapper::keys() const GlobalStoragePythonWrapper::keys() const
{ {
bp::list pyList; bp::list pyList;
foreach( const QString& key, m_gs->keys() ) const auto keys = m_gs->keys();
for ( const QString& key : keys )
pyList.append( key.toStdString() ); pyList.append( key.toStdString() );
return pyList; return pyList;
} }

View File

@ -97,7 +97,7 @@ boost::python::list
variantListToPyList( const QVariantList& variantList ) variantListToPyList( const QVariantList& variantList )
{ {
bp::list pyList; bp::list pyList;
foreach ( const QVariant& variant, variantList ) for ( const QVariant& variant : variantList )
pyList.append( variantToPyObject( variant ) ); pyList.append( variantToPyObject( variant ) );
return pyList; return pyList;
} }

View File

@ -390,7 +390,7 @@ void ProcessInfo::setArguments( const QStringList & arguments )
return; return;
size_t totalsize = MarkerSize; size_t totalsize = MarkerSize;
Q_FOREACH( const QString& arg, arguments ) for ( const QString& arg : arguments )
{ {
const QByteArray utf8 = arg.toUtf8(); const QByteArray utf8 = arg.toUtf8();
totalsize += utf8.size() + MarkerSize; totalsize += utf8.size() + MarkerSize;
@ -406,7 +406,7 @@ void ProcessInfo::setArguments( const QStringList & arguments )
char* const commandline = this->commandline + reinterpret_cast<qptrdiff>(reg->commandLines); char* const commandline = this->commandline + reinterpret_cast<qptrdiff>(reg->commandLines);
int argpos = 0; int argpos = 0;
Q_FOREACH( const QString & arg, arguments ) for ( const QString & arg : arguments )
{ {
const QByteArray utf8 = arg.toUtf8(); const QByteArray utf8 = arg.toUtf8();
const int required = MarkerSize + utf8.size() + MarkerSize ; const int required = MarkerSize + utf8.size() + MarkerSize ;

View File

@ -273,7 +273,7 @@ removeDiacritics( const QString& string )
}; };
QString output; QString output;
foreach ( QChar c, string ) for ( const QChar &c : string )
{ {
int i = diacriticLetters.indexOf( c ); int i = diacriticLetters.indexOf( c );
if ( i < 0 ) if ( i < 0 )

View File

@ -29,7 +29,7 @@ Retranslator::attachRetranslator( QObject* parent,
std::function< void ( void ) > retranslateFunc ) std::function< void ( void ) > retranslateFunc )
{ {
Retranslator* r = nullptr; Retranslator* r = nullptr;
foreach ( QObject* child, parent->children() ) for ( QObject* child : parent->children() )
{ {
r = qobject_cast< Retranslator* >( child ); r = qobject_cast< Retranslator* >( child );
if ( r ) if ( r )

View File

@ -44,7 +44,7 @@ Branding::instance()
} }
QStringList Branding::s_stringEntryStrings = const QStringList Branding::s_stringEntryStrings =
{ {
"productName", "productName",
"version", "version",
@ -60,14 +60,14 @@ QStringList Branding::s_stringEntryStrings =
}; };
QStringList Branding::s_imageEntryStrings = const QStringList Branding::s_imageEntryStrings =
{ {
"productLogo", "productLogo",
"productIcon", "productIcon",
"productWelcome" "productWelcome"
}; };
QStringList Branding::s_styleEntryStrings = const QStringList Branding::s_styleEntryStrings =
{ {
"sidebarBackground", "sidebarBackground",
"sidebarText", "sidebarText",
@ -268,7 +268,7 @@ void
Branding::setGlobals( GlobalStorage* globalStorage ) const Branding::setGlobals( GlobalStorage* globalStorage ) const
{ {
QVariantMap brandingMap; QVariantMap brandingMap;
foreach ( const QString& key, s_stringEntryStrings ) for ( const QString& key : s_stringEntryStrings )
brandingMap.insert( key, m_strings.value( key ) ); brandingMap.insert( key, m_strings.value( key ) );
globalStorage->insert( "branding", brandingMap ); globalStorage->insert( "branding", brandingMap );
} }

View File

@ -91,9 +91,9 @@ public:
private: private:
static Branding* s_instance; static Branding* s_instance;
static QStringList s_stringEntryStrings; static const QStringList s_stringEntryStrings;
static QStringList s_imageEntryStrings; static const QStringList s_imageEntryStrings;
static QStringList s_styleEntryStrings; static const QStringList s_styleEntryStrings;
void bail( const QString& message ); void bail( const QString& message );

View File

@ -98,7 +98,8 @@ Settings::Settings( const QString& settingsFilePath,
= CalamaresUtils::yamlToVariant( config[ "instances" ] ).toList(); = CalamaresUtils::yamlToVariant( config[ "instances" ] ).toList();
if ( instancesV.type() == QVariant::List ) if ( instancesV.type() == QVariant::List )
{ {
foreach ( const QVariant& instancesVListItem, instancesV.toList() ) const auto instances = instancesV.toList();
for ( const QVariant& instancesVListItem : instances )
{ {
if ( instancesVListItem.type() != QVariant::Map ) if ( instancesVListItem.type() != QVariant::Map )
continue; continue;
@ -123,7 +124,8 @@ Settings::Settings( const QString& settingsFilePath,
QVariant sequenceV QVariant sequenceV
= CalamaresUtils::yamlToVariant( config[ "sequence" ] ); = CalamaresUtils::yamlToVariant( config[ "sequence" ] );
Q_ASSERT( sequenceV.type() == QVariant::List ); Q_ASSERT( sequenceV.type() == QVariant::List );
foreach ( const QVariant& sequenceVListItem, sequenceV.toList() ) const auto sequence = sequenceV.toList();
for ( const QVariant& sequenceVListItem : sequence )
{ {
if ( sequenceVListItem.type() != QVariant::Map ) if ( sequenceVListItem.type() != QVariant::Map )
continue; continue;

View File

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

View File

@ -66,7 +66,7 @@ private:
QMap< QString, QVariantMap > m_availableDescriptorsByModuleName; QMap< QString, QVariantMap > m_availableDescriptorsByModuleName;
QMap< QString, QString > m_moduleDirectoriesByModuleName; QMap< QString, QString > m_moduleDirectoriesByModuleName;
QMap< QString, Module* > m_loadedModulesByInstanceKey; QMap< QString, Module* > m_loadedModulesByInstanceKey;
QStringList m_paths; const QStringList m_paths;
static ModuleManager* s_instance; static ModuleManager* s_instance;
}; };

View File

@ -95,10 +95,10 @@ ViewModule::initFrom( const QVariantMap& moduleDescriptor )
// If a load path is not specified, we look for a plugin to load in the directory. // If a load path is not specified, we look for a plugin to load in the directory.
if ( load.isEmpty() || !QLibrary::isLibrary( load ) ) if ( load.isEmpty() || !QLibrary::isLibrary( load ) )
{ {
QStringList ls = directory.entryList( QStringList{ "*.so" } ); const QStringList ls = directory.entryList( QStringList{ "*.so" } );
if ( !ls.isEmpty() ) if ( !ls.isEmpty() )
{ {
foreach ( QString entry, ls ) for ( QString entry : ls )
{ {
entry = directory.absoluteFilePath( entry ); entry = directory.absoluteFilePath( entry );
if ( QLibrary::isLibrary( entry ) ) if ( QLibrary::isLibrary( entry ) )

View File

@ -59,7 +59,7 @@ DebugWindow::DebugWindow()
this, [ this ]( const QList< Calamares::job_ptr >& jobs ) this, [ this ]( const QList< Calamares::job_ptr >& jobs )
{ {
QStringList text; QStringList text;
foreach( auto job, jobs ) for ( const auto &job : jobs )
{ {
text.append( job->prettyName() ); text.append( job->prettyName() );
} }

View File

@ -66,10 +66,10 @@ void PluginFactory::doRegisterPlugin(const QString &keyword, const QMetaObject *
} }
d->createInstanceHash.insert(keyword, PluginFactoryPrivate::Plugin(metaObject, instanceFunction)); d->createInstanceHash.insert(keyword, PluginFactoryPrivate::Plugin(metaObject, instanceFunction));
} else { } else {
QList<PluginFactoryPrivate::Plugin> clashes(d->createInstanceHash.values(keyword)); const QList<PluginFactoryPrivate::Plugin> clashes(d->createInstanceHash.values(keyword));
const QMetaObject *superClass = metaObject->superClass(); const QMetaObject *superClass = metaObject->superClass();
if (superClass) { if (superClass) {
foreach (const PluginFactoryPrivate::Plugin &plugin, clashes) { for (const PluginFactoryPrivate::Plugin &plugin : clashes) {
for (const QMetaObject *otherSuper = plugin.first->superClass(); otherSuper; for (const QMetaObject *otherSuper = plugin.first->superClass(); otherSuper;
otherSuper = otherSuper->superClass()) { otherSuper = otherSuper->superClass()) {
if (superClass == otherSuper) { if (superClass == otherSuper) {
@ -78,7 +78,7 @@ void PluginFactory::doRegisterPlugin(const QString &keyword, const QMetaObject *
} }
} }
} }
foreach (const PluginFactoryPrivate::Plugin &plugin, clashes) { for (const PluginFactoryPrivate::Plugin &plugin : clashes) {
superClass = plugin.first->superClass(); superClass = plugin.first->superClass();
if (superClass) { if (superClass) {
for (const QMetaObject *otherSuper = metaObject->superClass(); otherSuper; for (const QMetaObject *otherSuper = metaObject->superClass(); otherSuper;
@ -102,7 +102,7 @@ QObject *PluginFactory::create(const char *iface, QWidget *parentWidget, QObject
const QList<PluginFactoryPrivate::Plugin> candidates(d->createInstanceHash.values(keyword)); const QList<PluginFactoryPrivate::Plugin> candidates(d->createInstanceHash.values(keyword));
// for !keyword.isEmpty() candidates.count() is 0 or 1 // for !keyword.isEmpty() candidates.count() is 0 or 1
foreach (const PluginFactoryPrivate::Plugin &plugin, candidates) { for (const PluginFactoryPrivate::Plugin &plugin : candidates) {
for (const QMetaObject *current = plugin.first; current; current = current->superClass()) { for (const QMetaObject *current = plugin.first; current; current = current->superClass()) {
if (0 == qstrcmp(iface, current->className())) { if (0 == qstrcmp(iface, current->className())) {
if (obj) { if (obj) {

View File

@ -104,7 +104,8 @@ QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* paren
{ {
//Get all QJsonValue childs //Get all QJsonValue childs
foreach (QString key , value.toObject().keys()){ const auto keys = value.toObject().keys();
for (const QString &key : keys){
QJsonValue v = value.toObject().value(key); QJsonValue v = value.toObject().value(key);
QJsonTreeItem * child = load(v,rootItem); QJsonTreeItem * child = load(v,rootItem);
child->setKey(key); child->setKey(key);
@ -119,7 +120,8 @@ QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* paren
{ {
//Get all QJsonValue childs //Get all QJsonValue childs
int index = 0; int index = 0;
foreach (QJsonValue v , value.toArray()){ const auto valueArray = value.toArray();
for (const QJsonValue &v : valueArray) {
QJsonTreeItem * child = load(v,rootItem); QJsonTreeItem * child = load(v,rootItem);
child->setKey(QString::number(index)); child->setKey(QString::number(index));

View File

@ -92,10 +92,10 @@ KeyboardPage::init()
if ( process.waitForFinished() ) if ( process.waitForFinished() )
{ {
QStringList list = QString( process.readAll() ) const QStringList list = QString( process.readAll() )
.split( "\n", QString::SkipEmptyParts ); .split( "\n", QString::SkipEmptyParts );
foreach( QString line, list ) for ( QString line : list )
{ {
line = line.trimmed(); line = line.trimmed();
if ( !line.startsWith( "xkb_symbols" ) ) if ( !line.startsWith( "xkb_symbols" ) )

View File

@ -122,9 +122,9 @@ bool KeyBoardPreview::loadCodes() {
// Clear codes // Clear codes
codes.clear(); codes.clear();
QStringList list = QString(process.readAll()).split("\n", QString::SkipEmptyParts); const QStringList list = QString(process.readAll()).split("\n", QString::SkipEmptyParts);
foreach(QString line, list) { for (const QString &line : list) {
if (!line.startsWith("keycode") || !line.contains('=')) if (!line.startsWith("keycode") || !line.contains('='))
continue; continue;
@ -253,7 +253,7 @@ void KeyBoardPreview::paintEvent(QPaintEvent* event) {
int rw=usable_width-x; int rw=usable_width-x;
int ii=0; int ii=0;
foreach (int k, kb->keys.at(i)) { for (int k : kb->keys.at(i)) {
QRectF rect = QRectF(x, y, key_w, key_w); QRectF rect = QRectF(x, y, key_w, key_w);
if (ii == kb->keys.at(i).size()-1 && last_end) if (ii == kb->keys.at(i).size()-1 && last_end)

View File

@ -97,7 +97,7 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
CalamaresUtils::clearLayout( ui->licenseEntriesLayout ); CalamaresUtils::clearLayout( ui->licenseEntriesLayout );
bool required = false; bool required = false;
foreach ( const LicenseEntry& entry, entriesList ) for ( const LicenseEntry& entry : entriesList )
{ {
if ( entry.required ) if ( entry.required )
{ {
@ -134,7 +134,7 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
ui->retranslateUi( this ); ui->retranslateUi( this );
) )
foreach ( const LicenseEntry& entry, entriesList ) for ( const LicenseEntry& entry : entriesList )
{ {
QWidget* widget = new QWidget( this ); QWidget* widget = new QWidget( this );
QPalette pal( palette() ); QPalette pal( palette() );

View File

@ -112,7 +112,8 @@ LicenseViewStep::setConfigurationMap( const QVariantMap& configurationMap )
if ( configurationMap.contains( "entries" ) && if ( configurationMap.contains( "entries" ) &&
configurationMap.value( "entries" ).type() == QVariant::List ) configurationMap.value( "entries" ).type() == QVariant::List )
{ {
foreach ( const QVariant& entryV, configurationMap.value( "entries" ).toList() ) const auto entries = configurationMap.value( "entries" ).toList();
for ( const QVariant& entryV : entries )
{ {
if ( entryV.type() != QVariant::Map ) if ( entryV.type() != QVariant::Map )
continue; continue;

View File

@ -43,7 +43,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
QString language = languageLocale.split( '_' ).first(); QString language = languageLocale.split( '_' ).first();
QStringList linesForLanguage; QStringList linesForLanguage;
foreach ( QString line, availableLocales ) for ( const QString &line : availableLocales )
{ {
if ( line.startsWith( language ) ) if ( line.startsWith( language ) )
linesForLanguage.append( line ); linesForLanguage.append( line );
@ -95,7 +95,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
// language locale and pick the first result, if any. // language locale and pick the first result, if any.
if ( lang.isEmpty() ) if ( lang.isEmpty() )
{ {
foreach ( QString line, availableLocales ) for ( const QString &line : availableLocales )
{ {
if ( line.startsWith( languageLocale ) ) if ( line.startsWith( languageLocale ) )
{ {
@ -161,7 +161,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
QString combined = QString( "%1_%2" ).arg( language ) QString combined = QString( "%1_%2" ).arg( language )
.arg( countryCode ); .arg( countryCode );
// We look up if it's a supported locale. // We look up if it's a supported locale.
foreach ( QString line, availableLocales ) for ( const QString &line : availableLocales )
{ {
if ( line.startsWith( combined ) ) if ( line.startsWith( combined ) )
{ {
@ -174,7 +174,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
if ( lc_formats.isEmpty() ) if ( lc_formats.isEmpty() )
{ {
QStringList available; QStringList available;
foreach ( QString line, availableLocales ) for ( const QString &line : availableLocales )
{ {
if ( line.contains( QString( "_%1" ).arg( countryCode ) ) ) if ( line.contains( QString( "_%1" ).arg( countryCode ) ) )
{ {
@ -239,7 +239,7 @@ LocaleConfiguration::fromLanguageAndLocation( const QString& languageLocale,
QString( "%1_%2" ).arg( countryToDefaultLanguage.value( countryCode ) ) QString( "%1_%2" ).arg( countryToDefaultLanguage.value( countryCode ) )
.arg( countryCode ); .arg( countryCode );
foreach ( QString line, availableLocales ) for ( const QString &line : availableLocales )
{ {
if ( line.startsWith( combinedLocale ) ) if ( line.startsWith( combinedLocale ) )
{ {

View File

@ -108,8 +108,8 @@ LocalePage::LocalePage( QWidget* parent )
m_zoneCombo->clear(); m_zoneCombo->clear();
QList< LocaleGlobal::Location > zones = regions.value( m_regionCombo->currentData().toString() ); const QList< LocaleGlobal::Location > zones = regions.value( m_regionCombo->currentData().toString() );
foreach ( const LocaleGlobal::Location& zone, zones ) for ( const LocaleGlobal::Location& zone : zones )
{ {
m_zoneCombo->addItem( LocaleGlobal::Location::pretty( zone.zone ), zone.zone ); m_zoneCombo->addItem( LocaleGlobal::Location::pretty( zone.zone ), zone.zone );
} }
@ -270,7 +270,7 @@ LocalePage::init( const QString& initialRegion,
auto containsLocation = []( const QList< LocaleGlobal::Location >& locations, auto containsLocation = []( const QList< LocaleGlobal::Location >& locations,
const QString& zone ) -> bool const QString& zone ) -> bool
{ {
foreach ( const LocaleGlobal::Location& location, locations ) for ( const LocaleGlobal::Location& location : locations )
{ {
if ( location.zone == zone ) if ( location.zone == zone )
return true; return true;
@ -303,7 +303,8 @@ LocalePage::init( const QString& initialRegion,
ba = supported.readAll(); ba = supported.readAll();
supported.close(); supported.close();
foreach ( QByteArray line, ba.split( '\n' ) ) const auto lines = ba.split( '\n' );
for ( const QByteArray &line : lines )
{ {
m_localeGenLines.append( QString::fromLatin1( line.simplified() ) ); m_localeGenLines.append( QString::fromLatin1( line.simplified() ) );
} }
@ -326,7 +327,8 @@ LocalePage::init( const QString& initialRegion,
localeA.waitForFinished(); localeA.waitForFinished();
ba = localeA.readAllStandardOutput(); ba = localeA.readAllStandardOutput();
} }
foreach ( QByteArray line, ba.split( '\n' ) ) const auto lines = ba.split( '\n' );
for ( const QByteArray &line : lines )
{ {
if ( line.startsWith( "## " ) || if ( line.startsWith( "## " ) ||
line.startsWith( "# " ) || line.startsWith( "# " ) ||

View File

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

View File

@ -480,7 +480,7 @@ PartitionCoreModule::dumpQueue() const
} }
OsproberEntryList const OsproberEntryList
PartitionCoreModule::osproberEntries() const PartitionCoreModule::osproberEntries() const
{ {
return m_osproberLines; return m_osproberLines;

View File

@ -127,7 +127,7 @@ public:
void dumpQueue() const; void dumpQueue() const;
OsproberEntryList osproberEntries() const; const OsproberEntryList osproberEntries() const;
Q_SIGNALS: Q_SIGNALS:
void hasRootMountPointChanged( bool value ); void hasRootMountPointChanged( bool value );

View File

@ -129,7 +129,7 @@ AlongsidePage::init( PartitionCoreModule* core )
string( Calamares::Branding::ProductName ) ) ); string( Calamares::Branding::ProductName ) ) );
} ); } );
foreach ( const OsproberEntry& e, m_core->osproberEntries() ) for ( const OsproberEntry& e : m_core->osproberEntries() )
{ {
if ( e.canBeResized ) if ( e.canBeResized )
m_partitionsComboBox->addItem( e.prettyName + " (" + e.path + ")", e.path ); m_partitionsComboBox->addItem( e.prettyName + " (" + e.path + ")", e.path );

View File

@ -733,7 +733,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
// Find out is the selected partition has a rootfs. If yes, then make the // Find out is the selected partition has a rootfs. If yes, then make the
// m_reuseHomeCheckBox visible and set its text to something meaningful. // m_reuseHomeCheckBox visible and set its text to something meaningful.
homePartitionPath->clear(); homePartitionPath->clear();
foreach ( const OsproberEntry& osproberEntry, m_core->osproberEntries() ) for ( const OsproberEntry& osproberEntry : m_core->osproberEntries() )
if ( osproberEntry.path == partPath ) if ( osproberEntry.path == partPath )
*homePartitionPath = osproberEntry.homePath; *homePartitionPath = osproberEntry.homePath;
if ( homePartitionPath->isEmpty() ) if ( homePartitionPath->isEmpty() )
@ -1329,7 +1329,7 @@ OsproberEntryList
ChoicePage::getOsproberEntriesForDevice( Device* device ) const ChoicePage::getOsproberEntriesForDevice( Device* device ) const
{ {
OsproberEntryList eList; OsproberEntryList eList;
foreach ( const OsproberEntry& entry, m_core->osproberEntries() ) for ( const OsproberEntry& entry : m_core->osproberEntries() )
{ {
if ( entry.path.startsWith( device->deviceNode() ) ) if ( entry.path.startsWith( device->deviceNode() ) )
eList.append( entry ); eList.append( entry );

View File

@ -240,11 +240,11 @@ PartitionLabelsView::drawLabels( QPainter* painter,
if ( !modl ) if ( !modl )
return; return;
QModelIndexList indexesToDraw = getIndexesToDraw( parent ); const QModelIndexList indexesToDraw = getIndexesToDraw( parent );
int label_x = rect.x(); int label_x = rect.x();
int label_y = rect.y(); int label_y = rect.y();
foreach ( const QModelIndex& index, indexesToDraw ) for ( const QModelIndex& index : indexesToDraw )
{ {
QStringList texts = buildTexts( index ); QStringList texts = buildTexts( index );
@ -306,12 +306,12 @@ PartitionLabelsView::sizeForAllLabels( int maxLineWidth ) const
if ( !modl ) if ( !modl )
return QSize(); return QSize();
QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() ); const QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() );
int lineLength = 0; int lineLength = 0;
int numLines = 1; int numLines = 1;
int singleLabelHeight = 0; int singleLabelHeight = 0;
foreach ( const QModelIndex& index, indexesToDraw ) for ( const QModelIndex& index : indexesToDraw )
{ {
QStringList texts = buildTexts( index ); QStringList texts = buildTexts( index );
@ -349,7 +349,7 @@ PartitionLabelsView::sizeForLabel( const QStringList& text ) const
{ {
int vertOffset = 0; int vertOffset = 0;
int width = 0; int width = 0;
foreach ( const QString& textLine, text ) for ( const QString& textLine : text )
{ {
QSize textSize = fontMetrics().size( Qt::TextSingleLine, textLine ); QSize textSize = fontMetrics().size( Qt::TextSingleLine, textLine );
@ -371,7 +371,7 @@ PartitionLabelsView::drawLabel( QPainter* painter,
painter->setPen( Qt::black ); painter->setPen( Qt::black );
int vertOffset = 0; int vertOffset = 0;
int width = 0; int width = 0;
foreach ( const QString& textLine, text ) for ( const QString& textLine : text )
{ {
QSize textSize = painter->fontMetrics().size( Qt::TextSingleLine, textLine ); QSize textSize = painter->fontMetrics().size( Qt::TextSingleLine, textLine );
painter->drawText( pos.x()+LABEL_PARTITION_SQUARE_MARGIN, painter->drawText( pos.x()+LABEL_PARTITION_SQUARE_MARGIN,
@ -402,12 +402,12 @@ PartitionLabelsView::indexAt( const QPoint& point ) const
if ( !modl ) if ( !modl )
return QModelIndex(); return QModelIndex();
QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() ); const QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() );
QRect rect = this->rect(); QRect rect = this->rect();
int label_x = rect.x(); int label_x = rect.x();
int label_y = rect.y(); int label_y = rect.y();
foreach ( const QModelIndex& index, indexesToDraw ) for ( const QModelIndex& index : indexesToDraw )
{ {
QStringList texts = buildTexts( index ); QStringList texts = buildTexts( index );
@ -437,12 +437,12 @@ PartitionLabelsView::visualRect( const QModelIndex& idx ) const
if ( !modl ) if ( !modl )
return QRect(); return QRect();
QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() ); const QModelIndexList indexesToDraw = getIndexesToDraw( QModelIndex() );
QRect rect = this->rect(); QRect rect = this->rect();
int label_x = rect.x(); int label_x = rect.x();
int label_y = rect.y(); int label_y = rect.y();
foreach ( const QModelIndex& index, indexesToDraw ) for ( const QModelIndex& index : indexesToDraw )
{ {
QStringList texts = buildTexts( index ); QStringList texts = buildTexts( index );

View File

@ -105,7 +105,7 @@ PartitionSplitterWidget::setupItems( const QVector<PartitionSplitterItem>& items
m_items.clear(); m_items.clear();
m_items = items; m_items = items;
repaint(); repaint();
foreach ( const PartitionSplitterItem& item, items ) for ( const PartitionSplitterItem& item : items )
cDebug() << "PSI added item" << item.itemPath << "size" << item.size; cDebug() << "PSI added item" << item.itemPath << "size" << item.size;
} }

View File

@ -149,7 +149,7 @@ ReplaceWidget::onPartitionSelected()
PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() ); PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() );
if ( model && ok ) if ( model && ok )
{ {
QStringList osproberLines = Calamares::JobQueue::instance() const QStringList osproberLines = Calamares::JobQueue::instance()
->globalStorage() ->globalStorage()
->value( "osproberLines" ).toStringList(); ->value( "osproberLines" ).toStringList();
@ -197,7 +197,7 @@ ReplaceWidget::onPartitionSelected()
QString prettyName = tr( "Data partition (%1)" ) QString prettyName = tr( "Data partition (%1)" )
.arg( partition->fileSystem().name() ); .arg( partition->fileSystem().name() );
foreach ( const QString& line, osproberLines ) for ( const QString& line : osproberLines )
{ {
QStringList lineColumns = line.split( ':' ); QStringList lineColumns = line.split( ':' );

View File

@ -72,8 +72,8 @@ ClearMountsJob::exec()
process.start(); process.start();
process.waitForFinished(); process.waitForFinished();
QString partitions = process.readAllStandardOutput(); const QString partitions = process.readAllStandardOutput();
QStringList partitionsList = partitions.simplified().split( ' ' ); const QStringList partitionsList = partitions.simplified().split( ' ' );
// Build a list of partitions of type 82 (Linux swap / Solaris). // Build a list of partitions of type 82 (Linux swap / Solaris).
// We then need to clear them just in case they contain something resumable from a // We then need to clear them just in case they contain something resumable from a
@ -100,7 +100,8 @@ ClearMountsJob::exec()
*it = (*it).simplified().split( ' ' ).first(); *it = (*it).simplified().split( ' ' ).first();
} }
foreach ( QString mapperPath, getCryptoDevices() ) const QStringList cryptoDevices = getCryptoDevices();
for ( const QString &mapperPath : cryptoDevices )
{ {
tryUmount( mapperPath ); tryUmount( mapperPath );
QString news = tryCryptoClose( mapperPath ); QString news = tryCryptoClose( mapperPath );
@ -113,8 +114,8 @@ ClearMountsJob::exec()
process.waitForFinished(); process.waitForFinished();
if ( process.exitCode() == 0 ) //means LVM2 tools are installed if ( process.exitCode() == 0 ) //means LVM2 tools are installed
{ {
QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' ); const QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
foreach ( const QString& lvscanLine, lvscanLines ) for ( const QString& lvscanLine : lvscanLines )
{ {
QString lvPath = lvscanLine.simplified().split( ' ' ).value( 1 ); //second column QString lvPath = lvscanLine.simplified().split( ' ' ).value( 1 ); //second column
lvPath = lvPath.replace( '\'', "" ); lvPath = lvPath.replace( '\'', "" );
@ -137,8 +138,8 @@ ClearMountsJob::exec()
{ {
QSet< QString > vgSet; QSet< QString > vgSet;
QStringList pvdisplayLines = pvdisplayOutput.split( '\n' ); const QStringList pvdisplayLines = pvdisplayOutput.split( '\n' );
foreach ( const QString& pvdisplayLine, pvdisplayLines ) for ( const QString& pvdisplayLine : pvdisplayLines )
{ {
QString pvPath = pvdisplayLine.simplified().split( ' ' ).value( 0 ); QString pvPath = pvdisplayLine.simplified().split( ' ' ).value( 0 );
QString vgName = pvdisplayLine.simplified().split( ' ' ).value( 1 ); QString vgName = pvdisplayLine.simplified().split( ' ' ).value( 1 );
@ -160,7 +161,8 @@ ClearMountsJob::exec()
else else
cDebug() << "WARNING: this system does not seem to have LVM2 tools."; cDebug() << "WARNING: this system does not seem to have LVM2 tools.";
foreach ( QString mapperPath, getCryptoDevices() ) const QStringList cryptoDevices2 = getCryptoDevices();
for ( const QString &mapperPath : cryptoDevices2 )
{ {
tryUmount( mapperPath ); tryUmount( mapperPath );
QString news = tryCryptoClose( mapperPath ); QString news = tryCryptoClose( mapperPath );
@ -168,7 +170,7 @@ ClearMountsJob::exec()
goodNews.append( news ); goodNews.append( news );
} }
foreach ( QString p, partitionsList ) for ( const QString &p : partitionsList )
{ {
QString partPath = QString( "/dev/%1" ).arg( p ); QString partPath = QString( "/dev/%1" ).arg( p );
@ -247,13 +249,13 @@ ClearMountsJob::tryCryptoClose( const QString& mapperPath )
QStringList QStringList
ClearMountsJob::getCryptoDevices() ClearMountsJob::getCryptoDevices() const
{ {
QDir mapperDir( "/dev/mapper" ); QDir mapperDir( "/dev/mapper" );
QFileInfoList fiList = mapperDir.entryInfoList( QDir::Files ); const QFileInfoList fiList = mapperDir.entryInfoList( QDir::Files );
QStringList list; QStringList list;
QProcess process; QProcess process;
foreach ( QFileInfo fi, fiList ) for ( const QFileInfo &fi : fiList )
{ {
if ( fi.baseName() == "control" ) if ( fi.baseName() == "control" )
continue; continue;

View File

@ -39,7 +39,7 @@ private:
QString tryUmount( const QString& partPath ); QString tryUmount( const QString& partPath );
QString tryClearSwap( const QString& partPath ); QString tryClearSwap( const QString& partPath );
QString tryCryptoClose( const QString& mapperPath ); QString tryCryptoClose( const QString& mapperPath );
QStringList getCryptoDevices(); QStringList getCryptoDevices() const;
Device* m_device; Device* m_device;
}; };

View File

@ -126,7 +126,8 @@ FillGlobalStorageJob::prettyDescription() const
{ {
QStringList lines; QStringList lines;
foreach ( QVariant partitionItem, createPartitionList().toList() ) const auto partitionList = createPartitionList().toList();
for ( const QVariant &partitionItem : partitionList )
{ {
if ( partitionItem.type() == QVariant::Map ) if ( partitionItem.type() == QVariant::Map )
{ {

View File

@ -63,10 +63,10 @@ SummaryPage::onActivate()
QString text; QString text;
bool first = true; bool first = true;
Calamares::ViewStepList steps = const Calamares::ViewStepList steps =
stepsForSummary( Calamares::ViewManager::instance()->viewSteps() ); stepsForSummary( Calamares::ViewManager::instance()->viewSteps() );
foreach ( Calamares::ViewStep* step, steps ) for ( Calamares::ViewStep* step : steps )
{ {
QString text = step->prettyStatus(); QString text = step->prettyStatus();
QWidget* widget = step->createSummaryWidget(); QWidget* widget = step->createSummaryWidget();
@ -101,7 +101,7 @@ Calamares::ViewStepList
SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps ) const SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
{ {
Calamares::ViewStepList steps; Calamares::ViewStepList steps;
foreach ( Calamares::ViewStep* step, allSteps ) for ( Calamares::ViewStep* step : allSteps )
{ {
// We start from the beginning of the complete steps list. If we encounter any // We start from the beginning of the complete steps list. If we encounter any
// ExecutionViewStep, it means there was an execution phase in the past, and any // ExecutionViewStep, it means there was an execution phase in the past, and any

View File

@ -109,7 +109,8 @@ WelcomePage::initLanguages()
{ {
bool isTranslationAvailable = false; bool isTranslationAvailable = false;
foreach ( const QString& locale, QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') ) const auto locales = QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';');
for ( const QString& locale : locales )
{ {
QLocale thisLocale = QLocale( locale ); QLocale thisLocale = QLocale( locale );
QString lang = QLocale::languageToString( thisLocale.language() ); QString lang = QLocale::languageToString( thisLocale.language() );

View File

@ -264,9 +264,8 @@ RequirementsChecker::checkBatteryExists()
return false; return false;
QDir baseDir( basePath.absoluteFilePath() ); QDir baseDir( basePath.absoluteFilePath() );
foreach ( auto item, baseDir.entryList( QDir::AllDirs | const auto entries = baseDir.entryList( QDir::AllDirs | QDir::Readable | QDir::NoDotAndDotDot );
QDir::Readable | for ( const auto &item : entries )
QDir::NoDotAndDotDot ) )
{ {
QFileInfo typePath( baseDir.absoluteFilePath( QString( "%1/type" ) QFileInfo typePath( baseDir.absoluteFilePath( QString( "%1/type" )
.arg( item ) ) ); .arg( item ) ) );