CmakeProjectManager: Remove foreach / Q_FOREACH usage

Task-number: QTCREATORBUG-27464
Change-Id: Iabe3a621efa56282bf1511f540c98fdf5d8da270
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Artem Sokolovskii
2022-05-18 12:28:04 +02:00
parent 7173bd6190
commit c23aa1c656
6 changed files with 18 additions and 13 deletions

View File

@@ -1197,7 +1197,8 @@ void CMakeBuildSystem::updateQmlJSCodeModel(const QStringList &extraHeaderPaths,
projectInfo.importPaths.clear();
auto addImports = [&projectInfo](const QString &imports) {
foreach (const QString &import, CMakeConfigItem::cmakeSplitValue(imports))
const QStringList importList = CMakeConfigItem::cmakeSplitValue(imports);
for (const QString &import : importList)
projectInfo.importPaths.maybeInsert(FilePath::fromString(import), QmlJS::Dialect::Qml);
};

View File

@@ -99,7 +99,8 @@ public:
m_comboBox->setEnabled(false);
m_comboBox->setToolTip(ki->description());
foreach (CMakeTool *tool, CMakeToolManager::cmakeTools())
const QList<CMakeTool *> tools = CMakeToolManager::cmakeTools();
for (const CMakeTool *tool : tools)
cmakeToolAdded(tool->id());
updateComboBox();

View File

@@ -80,7 +80,8 @@ static QStringList scanDirectory(const FilePath &path, const QString &prefix)
QStringList result;
qCDebug(cmInputLog) << "Scanning for directories matching" << prefix << "in" << path;
foreach (const FilePath &entry, path.dirEntries({{prefix + "*"}, QDir::Dirs | QDir::NoDotAndDotDot})) {
const QList<FilePath> entries = path.dirEntries({{prefix + "*"}, QDir::Dirs | QDir::NoDotAndDotDot});
for (const FilePath &entry : entries) {
QTC_ASSERT(entry.isDir(), continue);
result.append(entry.toString());
}
@@ -119,7 +120,8 @@ QStringList CMakeProjectImporter::importCandidates()
candidates << scanDirectory(projectFilePath().absolutePath(), "build");
foreach (Kit *k, KitManager::kits()) {
const QList<Kit *> kits = KitManager::kits();
for (const Kit *k : kits) {
FilePath shadowBuildDirectory
= CMakeBuildConfiguration::shadowBuildDirectory(projectFilePath(),
k,
@@ -533,7 +535,7 @@ void CMakeProjectPlugin::testCMakeProjectImporterQt()
QFETCH(QString, expectedQmake);
CMakeConfig config;
foreach (const QString &c, cache) {
for (const QString &c : qAsConst(cache)) {
const int pos = c.indexOf('=');
Q_ASSERT(pos > 0);
const QString key = c.left(pos);
@@ -590,7 +592,7 @@ void CMakeProjectPlugin::testCMakeProjectImporterToolChain()
QCOMPARE(expectedLanguages.count(), expectedToolChains.count());
CMakeConfig config;
foreach (const QString &c, cache) {
for (const QString &c : qAsConst(cache)) {
const int pos = c.indexOf('=');
Q_ASSERT(pos > 0);
const QString key = c.left(pos);

View File

@@ -243,7 +243,8 @@ CMakeToolItemModel::CMakeToolItemModel()
{ProjectExplorer::Constants::msgAutoDetectedToolTip()}));
rootItem()->appendChild(new StaticTreeItem(tr("Manual")));
foreach (const CMakeTool *item, CMakeToolManager::cmakeTools())
const QList<CMakeTool *> items = CMakeToolManager::cmakeTools();
for (const CMakeTool *item : items)
addCMakeTool(item, false);
CMakeTool *defTool = CMakeToolManager::defaultCMakeTool();
@@ -355,7 +356,7 @@ void CMakeToolItemModel::removeCMakeTool(const Utils::Id &id)
void CMakeToolItemModel::apply()
{
foreach (const Utils::Id &id, m_removedItems)
for (const Utils::Id &id : qAsConst(m_removedItems))
CMakeToolManager::deregisterCMakeTool(id);
QList<CMakeToolTreeItem *> toRegister;
@@ -372,7 +373,7 @@ void CMakeToolItemModel::apply()
}
});
foreach (CMakeToolTreeItem *item, toRegister) {
for (CMakeToolTreeItem *item : qAsConst(toRegister)) {
CMakeTool::Detection detection = item->m_autodetected ? CMakeTool::AutoDetection
: CMakeTool::ManualDetection;
auto cmake = std::make_unique<CMakeTool>(detection, item->m_id);

View File

@@ -432,7 +432,7 @@ static QStringList parseDefinition(const QString &definition)
bool ignoreWord = false;
QVector<QChar> braceStack;
foreach (const QChar &c, definition) {
for (const QChar &c : definition) {
if (c == '[' || c == '<' || c == '(') {
braceStack.append(c);
ignoreWord = false;
@@ -498,7 +498,7 @@ QStringList CMakeTool::parseVariableOutput(const QString &output)
{
const QStringList variableList = output.split('\n');
QStringList result;
foreach (const QString &v, variableList) {
for (const QString &v : variableList) {
if (v.startsWith("CMAKE_COMPILER_IS_GNU<LANG>")) { // This key takes a compiler name :-/
result << "CMAKE_COMPILER_IS_GNUCC"
<< "CMAKE_COMPILER_IS_GNUCXX";

View File

@@ -93,7 +93,7 @@ static std::vector<std::unique_ptr<CMakeTool>> autoDetectCMakeTools()
const QStringList execs = env.appendExeExtensions(QLatin1String("cmake"));
FilePaths suspects;
foreach (const FilePath &base, path) {
for (const FilePath &base : qAsConst(path)) {
if (base.isEmpty())
continue;
@@ -106,7 +106,7 @@ static std::vector<std::unique_ptr<CMakeTool>> autoDetectCMakeTools()
}
std::vector<std::unique_ptr<CMakeTool>> found;
foreach (const FilePath &command, suspects) {
for (const FilePath &command : qAsConst(suspects)) {
auto item = std::make_unique<CMakeTool>(CMakeTool::AutoDetection, CMakeTool::createId());
item->setFilePath(command);
item->setDisplayName(CMakeToolManager::tr("System CMake at %1").arg(command.toUserOutput()));