forked from qt-creator/qt-creator
QMLPlugins: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: Ie3e3ec9fdaea856943e5325cabd21e52bf290e70 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -99,7 +99,7 @@ TextEditor::IndentationForBlock Indenter::indentationForBlocks(
|
||||
codeFormatter.updateStateUntil(blocks.last());
|
||||
|
||||
TextEditor::IndentationForBlock ret;
|
||||
foreach (QTextBlock block, blocks)
|
||||
for (QTextBlock block : blocks)
|
||||
ret.insert(block.blockNumber(), codeFormatter.indentFor(block));
|
||||
return ret;
|
||||
}
|
||||
|
@@ -252,7 +252,7 @@ void LocatorData::onDocumentUpdated(const Document::Ptr &doc)
|
||||
void LocatorData::onAboutToRemoveFiles(const QStringList &files)
|
||||
{
|
||||
QMutexLocker l(&m_mutex);
|
||||
foreach (const QString &file, files) {
|
||||
for (const QString &file : files) {
|
||||
m_entries.remove(file);
|
||||
}
|
||||
}
|
||||
|
@@ -92,10 +92,11 @@ static void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &proje
|
||||
|
||||
if (projectInfo.project) {
|
||||
QSet<Kit *> currentKits;
|
||||
foreach (const Target *t, projectInfo.project->targets())
|
||||
const QList<Target *> targets = projectInfo.project->targets();
|
||||
for (const Target *t : targets)
|
||||
currentKits.insert(t->kit());
|
||||
currentKits.remove(activeKit);
|
||||
foreach (Kit *kit, currentKits) {
|
||||
for (Kit *kit : qAsConst(currentKits)) {
|
||||
for (IBundleProvider *bp : IBundleProvider::allBundleProviders())
|
||||
bp->mergeBundlesForKit(kit, projectInfo.extendedBundle, replacements);
|
||||
}
|
||||
@@ -214,22 +215,28 @@ QHash<QString,Dialect> ModelManager::initLanguageForSuffix() const
|
||||
|
||||
if (ICore::instance()) {
|
||||
MimeType jsSourceTy = Utils::mimeTypeForName(Constants::JS_MIMETYPE);
|
||||
foreach (const QString &suffix, jsSourceTy.suffixes())
|
||||
const QStringList jsSuffixes = jsSourceTy.suffixes();
|
||||
for (const QString &suffix : jsSuffixes)
|
||||
res[suffix] = Dialect::JavaScript;
|
||||
MimeType qmlSourceTy = Utils::mimeTypeForName(Constants::QML_MIMETYPE);
|
||||
foreach (const QString &suffix, qmlSourceTy.suffixes())
|
||||
const QStringList qmlSuffixes = qmlSourceTy.suffixes();
|
||||
for (const QString &suffix : qmlSuffixes)
|
||||
res[suffix] = Dialect::Qml;
|
||||
MimeType qbsSourceTy = Utils::mimeTypeForName(Constants::QBS_MIMETYPE);
|
||||
foreach (const QString &suffix, qbsSourceTy.suffixes())
|
||||
const QStringList qbsSuffixes = qbsSourceTy.suffixes();
|
||||
for (const QString &suffix : qbsSuffixes)
|
||||
res[suffix] = Dialect::QmlQbs;
|
||||
MimeType qmlProjectSourceTy = Utils::mimeTypeForName(Constants::QMLPROJECT_MIMETYPE);
|
||||
foreach (const QString &suffix, qmlProjectSourceTy.suffixes())
|
||||
const QStringList qmlProjSuffixes = qmlProjectSourceTy.suffixes();
|
||||
for (const QString &suffix : qmlProjSuffixes)
|
||||
res[suffix] = Dialect::QmlProject;
|
||||
MimeType qmlUiSourceTy = Utils::mimeTypeForName(Constants::QMLUI_MIMETYPE);
|
||||
foreach (const QString &suffix, qmlUiSourceTy.suffixes())
|
||||
const QStringList qmlUiSuffixes = qmlUiSourceTy.suffixes();
|
||||
for (const QString &suffix : qmlUiSuffixes)
|
||||
res[suffix] = Dialect::QmlQtQuick2Ui;
|
||||
MimeType jsonSourceTy = Utils::mimeTypeForName(Constants::JSON_MIMETYPE);
|
||||
foreach (const QString &suffix, jsonSourceTy.suffixes())
|
||||
const QStringList jsonSuffixes = jsonSourceTy.suffixes();
|
||||
for (const QString &suffix : jsonSuffixes)
|
||||
res[suffix] = Dialect::Json;
|
||||
}
|
||||
return res;
|
||||
@@ -288,7 +295,8 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const
|
||||
if (!Core::ICore::instance())
|
||||
return workingCopy;
|
||||
|
||||
foreach (IDocument *document, DocumentModel::openedDocuments()) {
|
||||
const QList<IDocument *> documents = DocumentModel::openedDocuments();
|
||||
for (IDocument *document : documents) {
|
||||
const QString key = document->filePath().toString();
|
||||
if (auto textDocument = qobject_cast<const TextEditor::TextDocument *>(document)) {
|
||||
// TODO the language should be a property on the document, not the editor
|
||||
|
@@ -191,7 +191,7 @@ QList<AST::Node *> SemanticInfo::rangePath(int cursorPosition) const
|
||||
{
|
||||
QList<AST::Node *> path;
|
||||
|
||||
foreach (const Range &range, ranges) {
|
||||
for (const Range &range : qAsConst(ranges)) {
|
||||
if (range.begin.isNull() || range.end.isNull())
|
||||
continue;
|
||||
else if (cursorPosition >= range.begin.position() && cursorPosition <= range.end.position())
|
||||
|
@@ -200,7 +200,8 @@ QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const
|
||||
if (!m_typeIdsWithNotes.contains(stats.typeIndex))
|
||||
return ret;
|
||||
Timeline::TimelineNotesModel *notes = m_modelManager->notesModel();
|
||||
foreach (const QVariant &item, notes->byTypeId(stats.typeIndex)) {
|
||||
const QList<QVariant> items = notes->byTypeId(stats.typeIndex);
|
||||
for (const QVariant &item : items) {
|
||||
if (ret.isEmpty())
|
||||
ret = notes->text(item.toInt());
|
||||
else
|
||||
|
@@ -432,7 +432,7 @@ QString PixmapCacheModel::fileName(int index) const
|
||||
|
||||
void PixmapCacheModel::computeMaxCacheSize()
|
||||
{
|
||||
foreach (const PixmapCacheModel::Item &event, m_data) {
|
||||
for (const PixmapCacheModel::Item &event : qAsConst(m_data)) {
|
||||
if (event.pixmapEventType == PixmapCacheModel::PixmapCacheCountChanged) {
|
||||
if (event.cacheSize > m_maxCacheSize)
|
||||
m_maxCacheSize = event.cacheSize;
|
||||
|
@@ -41,7 +41,8 @@ int QmlProfilerNotesModel::addQmlNote(int typeId, int collapsedRow, qint64 start
|
||||
int foundTypeId = -1;
|
||||
int timelineModel = -1;
|
||||
int timelineIndex = -1;
|
||||
foreach (const Timeline::TimelineModel *model, timelineModels()) {
|
||||
const QList<const Timeline::TimelineModel *> models = timelineModels();
|
||||
for (const Timeline::TimelineModel *model : models) {
|
||||
if (model->handlesTypeId(typeId)) {
|
||||
for (int i = model->firstIndex(start); i <= model->lastIndex(start + duration); ++i) {
|
||||
if (i < 0)
|
||||
|
@@ -137,8 +137,8 @@ void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev)
|
||||
|
||||
QPoint position = ev->globalPos();
|
||||
|
||||
QList <QAction *> commonActions = QmlProfilerTool::profilerContextMenuActions();
|
||||
foreach (QAction *act, commonActions)
|
||||
const QList <QAction *> commonActions = QmlProfilerTool::profilerContextMenuActions();
|
||||
for (QAction *act : commonActions)
|
||||
menu.addAction(act);
|
||||
|
||||
if (mouseOnTable(position)) {
|
||||
|
@@ -503,7 +503,8 @@ void QmlProfilerTool::setButtonsEnabled(bool enable)
|
||||
void QmlProfilerTool::createInitialTextMarks()
|
||||
{
|
||||
QmlProfilerTextMarkModel *model = d->m_profilerModelManager->textMarkModel();
|
||||
foreach (IDocument *document, DocumentModel::openedDocuments())
|
||||
const QList<IDocument *> documents = DocumentModel::openedDocuments();
|
||||
for (IDocument *document : documents)
|
||||
model->createMarks(d->m_viewContainer, document->filePath().toString());
|
||||
}
|
||||
|
||||
@@ -736,7 +737,8 @@ void QmlProfilerTool::setAvailableFeatures(quint64 features)
|
||||
|
||||
void QmlProfilerTool::setRecordedFeatures(quint64 features)
|
||||
{
|
||||
foreach (QAction *action, d->m_displayFeaturesMenu->actions())
|
||||
const QList<QAction *> actions = d->m_displayFeaturesMenu->actions();
|
||||
for (QAction *action : actions)
|
||||
action->setEnabled(features & (1ULL << action->data().toUInt()));
|
||||
}
|
||||
|
||||
|
@@ -142,7 +142,8 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fi
|
||||
if (debug)
|
||||
qDebug() << "importPath:" << importPathsProperty.value << "mainFile:" << mainFileProperty.value;
|
||||
|
||||
foreach (const QmlJS::SimpleReaderNode::Ptr &childNode, rootNode->children()) {
|
||||
const QList<QmlJS::SimpleReaderNode::Ptr> childNodes = rootNode->children();
|
||||
for (const QmlJS::SimpleReaderNode::Ptr &childNode : childNodes) {
|
||||
if (debug)
|
||||
qDebug() << "reading type:" << childNode->name();
|
||||
|
||||
|
@@ -319,7 +319,8 @@ void QmlBuildSystem::refresh(RefreshOptions options)
|
||||
|
||||
QmlJS::ModelManagerInterface::ProjectInfo projectInfo =
|
||||
modelManager->defaultProjectInfoForProject(project());
|
||||
foreach (const QString &searchPath, makeAbsolute(canonicalProjectDir(), customImportPaths()))
|
||||
const QStringList searchPaths = makeAbsolute(canonicalProjectDir(), customImportPaths());
|
||||
for (const QString &searchPath : searchPaths)
|
||||
projectInfo.importPaths.maybeInsert(Utils::FilePath::fromString(searchPath),
|
||||
QmlJS::Dialect::Qml);
|
||||
|
||||
|
@@ -212,8 +212,9 @@ QString QmlProjectRunConfiguration::commandLineArguments() const
|
||||
|
||||
// arguments from .qmlproject file
|
||||
const QmlBuildSystem *bs = qobject_cast<QmlBuildSystem *>(target()->buildSystem());
|
||||
foreach (const QString &importPath,
|
||||
QmlBuildSystem::makeAbsolute(bs->targetDirectory(), bs->customImportPaths())) {
|
||||
const QStringList importPaths = QmlBuildSystem::makeAbsolute(bs->targetDirectory(),
|
||||
bs->customImportPaths());
|
||||
for (const QString &importPath : importPaths) {
|
||||
ProcessArgs::addArg(&args, "-I", osType);
|
||||
ProcessArgs::addArg(&args, importPath, osType);
|
||||
}
|
||||
|
Reference in New Issue
Block a user