Commit 16d54aa7 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

custom-definesandincludes: port foreach -> range-based for

parent 123b2024
...@@ -188,7 +188,8 @@ Path::List GccLikeCompiler::includes(Utils::LanguageType type, const QString& ar ...@@ -188,7 +188,8 @@ Path::List GccLikeCompiler::includes(Utils::LanguageType type, const QString& ar
Status mode = Initial; Status mode = Initial;
const auto output = QString::fromLocal8Bit( proc.readAllStandardOutput() ); const auto output = QString::fromLocal8Bit( proc.readAllStandardOutput() );
foreach (const auto& line, output.splitRef(QLatin1Char('\n'))) { const auto lines = output.splitRef(QLatin1Char('\n'));
for (const auto& line : lines) {
switch ( mode ) { switch ( mode ) {
case Initial: case Initial:
if ( line.indexOf( QLatin1String("#include \"...\"") ) != -1 ) { if ( line.indexOf( QLatin1String("#include \"...\"") ) != -1 ) {
......
...@@ -272,7 +272,8 @@ QVector<ConfigEntry> convertedPaths( KConfig* cfg ) ...@@ -272,7 +272,8 @@ QVector<ConfigEntry> convertedPaths( KConfig* cfg )
return {}; return {};
QVector<ConfigEntry> paths; QVector<ConfigEntry> paths;
foreach( const QString &grpName, sorted(group.groupList()) ) { const auto sortedGroupNames = sorted(group.groupList());
for (const QString& grpName : sortedGroupNames) {
KConfigGroup subgroup = group.group( grpName ); KConfigGroup subgroup = group.group( grpName );
if ( !subgroup.isValid() ) if ( !subgroup.isValid() )
continue; continue;
......
...@@ -52,7 +52,8 @@ CompilersWidget::CompilersWidget(QWidget* parent) ...@@ -52,7 +52,8 @@ CompilersWidget::CompilersWidget(QWidget* parent)
auto settings = SettingsManager::globalInstance(); auto settings = SettingsManager::globalInstance();
auto provider = settings->provider(); auto provider = settings->provider();
foreach (const auto& factory, provider->compilerFactories()) { const auto compilerFactories = provider->compilerFactories();
for (const auto& factory : compilerFactories) {
auto* action = new QAction(m_addMenu); auto* action = new QAction(m_addMenu);
const QString fname = factory->name(); const QString fname = factory->name();
action->setText(fname); action->setText(fname);
...@@ -99,7 +100,8 @@ void CompilersWidget::deleteCompiler() ...@@ -99,7 +100,8 @@ void CompilersWidget::deleteCompiler()
{ {
qCDebug(DEFINESANDINCLUDES) << "Deleting compiler"; qCDebug(DEFINESANDINCLUDES) << "Deleting compiler";
auto selectionModel = m_ui->compilers->selectionModel(); auto selectionModel = m_ui->compilers->selectionModel();
foreach (const QModelIndex& row, selectionModel->selectedIndexes()) { const auto selectedRowsBefore = selectionModel->selectedIndexes();
for (const QModelIndex& row : selectedRowsBefore) {
if (row.column() == 1) { if (row.column() == 1) {
//Don't remove the same compiler twice //Don't remove the same compiler twice
continue; continue;
...@@ -118,7 +120,8 @@ void CompilersWidget::addCompiler(const QString& factoryName) ...@@ -118,7 +120,8 @@ void CompilersWidget::addCompiler(const QString& factoryName)
{ {
auto settings = SettingsManager::globalInstance(); auto settings = SettingsManager::globalInstance();
auto provider = settings->provider(); auto provider = settings->provider();
foreach (const auto& factory, provider->compilerFactories()) { const auto compilerFactories = provider->compilerFactories();
for (const auto& factory : compilerFactories) {
if (factoryName == factory->name()) { if (factoryName == factory->name()) {
//add compiler without any information, the user will fill the data in later //add compiler without any information, the user will fill the data in later
auto compilerIndex = m_compilersModel->addCompiler(factory->createCompiler(QString(), QString())); auto compilerIndex = m_compilersModel->addCompiler(factory->createCompiler(QString(), QString()));
......
...@@ -84,7 +84,7 @@ bool ProjectPathsModel::setData( const QModelIndex& index, const QVariant& value ...@@ -84,7 +84,7 @@ bool ProjectPathsModel::setData( const QModelIndex& index, const QVariant& value
QString addedPath = sanitizePath( value.toString(), false ); QString addedPath = sanitizePath( value.toString(), false );
// Do not allow duplicates // Do not allow duplicates
foreach( const ConfigEntry& existingConfig, projectPaths ) { for (const ConfigEntry& existingConfig : qAsConst(projectPaths)) {
if( addedPath == existingConfig.path ) { if( addedPath == existingConfig.path ) {
return false; return false;
} }
...@@ -191,7 +191,7 @@ void ProjectPathsModel::addPathInternal( const ConfigEntry& config, bool prepend ...@@ -191,7 +191,7 @@ void ProjectPathsModel::addPathInternal( const ConfigEntry& config, bool prepend
Q_ASSERT(!config.parserArguments.isAnyEmpty()); Q_ASSERT(!config.parserArguments.isAnyEmpty());
// Do not allow duplicates // Do not allow duplicates
foreach( const ConfigEntry& existingConfig, projectPaths ) { for (const ConfigEntry& existingConfig : qAsConst(projectPaths)) {
if( config.path == existingConfig.path ) { if( config.path == existingConfig.path ) {
return; return;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment