forked from qt-creator/qt-creator
ProjectExplorer: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: I9a7b21643393852d2904ed25abb876998c543172 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -81,7 +81,7 @@ Utils::FileIterator *AllProjectsFind::filesForProjects(const QStringList &nameFi
|
||||
Utils::filterFilesFunction(nameFilters, exclusionFilters);
|
||||
const QMap<QString, QTextCodec *> openEditorEncodings = TextDocument::openedTextDocumentEncodings();
|
||||
QMap<QString, QTextCodec *> encodings;
|
||||
foreach (const Project *project, projects) {
|
||||
for (const Project *project : projects) {
|
||||
const EditorConfiguration *config = project->editorConfiguration();
|
||||
QTextCodec *projectCodec = config->useGlobalSettings()
|
||||
? Core::EditorManager::defaultTextCodec()
|
||||
|
@@ -283,8 +283,8 @@ void BuildConfiguration::addConfigWidgets(const std::function<void(NamedWidget *
|
||||
adder(new Internal::BuildStepListWidget(buildSteps()));
|
||||
adder(new Internal::BuildStepListWidget(cleanSteps()));
|
||||
|
||||
QList<NamedWidget *> subConfigWidgets = createSubConfigWidgets();
|
||||
foreach (NamedWidget *subConfigWidget, subConfigWidgets)
|
||||
const QList<NamedWidget *> subConfigWidgets = createSubConfigWidgets();
|
||||
for (NamedWidget *subConfigWidget : subConfigWidgets)
|
||||
adder(subConfigWidget);
|
||||
}
|
||||
|
||||
|
@@ -156,7 +156,7 @@ static int queue(const QList<Project *> &projects, const QList<Id> &stepIds,
|
||||
}
|
||||
|
||||
if (stopThem) {
|
||||
foreach (RunControl *rc, toStop)
|
||||
for (RunControl *rc : toStop)
|
||||
rc->initiateStop();
|
||||
|
||||
WaitForStopDialog dialog(toStop);
|
||||
@@ -171,18 +171,18 @@ static int queue(const QList<Project *> &projects, const QList<Id> &stepIds,
|
||||
QList<BuildStepList *> stepLists;
|
||||
QStringList preambleMessage;
|
||||
|
||||
foreach (Project *pro, projects) {
|
||||
for (const Project *pro : projects) {
|
||||
if (pro && pro->needsConfiguration()) {
|
||||
preambleMessage.append(
|
||||
BuildManager::tr("The project %1 is not configured, skipping it.")
|
||||
.arg(pro->displayName()) + QLatin1Char('\n'));
|
||||
}
|
||||
}
|
||||
foreach (Id id, stepIds) {
|
||||
for (const Id id : stepIds) {
|
||||
const bool isBuild = id == Constants::BUILDSTEPS_BUILD;
|
||||
const bool isClean = id == Constants::BUILDSTEPS_CLEAN;
|
||||
const bool isDeploy = id == Constants::BUILDSTEPS_DEPLOY;
|
||||
foreach (Project *pro, projects) {
|
||||
for (const Project *pro : projects) {
|
||||
if (!pro || pro->needsConfiguration())
|
||||
continue;
|
||||
BuildStepList *bsl = nullptr;
|
||||
|
@@ -171,7 +171,8 @@ BaseFileWizard *CustomWizard::create(QWidget *parent, const WizardDialogParamete
|
||||
wizard->setPage(parameters()->firstPageId, customPage);
|
||||
else
|
||||
wizard->addPage(customPage);
|
||||
foreach (QWizardPage *ep, wizard->extensionPages())
|
||||
const QList<QWizardPage *> pages = wizard->extensionPages();
|
||||
for (QWizardPage *ep : pages)
|
||||
wizard->addPage(ep);
|
||||
if (CustomWizardPrivate::verbose)
|
||||
qDebug() << "initWizardDialog" << wizard << wizard->pageIds();
|
||||
@@ -228,7 +229,8 @@ static bool createFile(CustomWizardFile cwFile,
|
||||
template <class WizardPage>
|
||||
WizardPage *findWizardPage(const QWizard *w)
|
||||
{
|
||||
foreach (int pageId, w->pageIds())
|
||||
const QList<int> ids = w->pageIds();
|
||||
for (const int pageId : ids)
|
||||
if (auto wp = qobject_cast<WizardPage *>(w->page(pageId)))
|
||||
return wp;
|
||||
return nullptr;
|
||||
|
@@ -96,7 +96,7 @@ CustomWizardFieldPage::CustomWizardFieldPage(const QSharedPointer<CustomWizardCo
|
||||
m_formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO << parameters->fields.size();
|
||||
foreach (const CustomWizardField &f, parameters->fields)
|
||||
for (const CustomWizardField &f : qAsConst(parameters->fields))
|
||||
addField(f);
|
||||
vLayout->addLayout(m_formLayout);
|
||||
m_errorLabel->setVisible(false);
|
||||
@@ -371,7 +371,7 @@ bool CustomWizardFieldPage::validatePage()
|
||||
{
|
||||
clearError();
|
||||
// Check line edits with validators
|
||||
foreach (const LineEditData &led, m_lineEdits) {
|
||||
for (const LineEditData &led : qAsConst(m_lineEdits)) {
|
||||
if (const QValidator *val = led.lineEdit->validator()) {
|
||||
int pos = 0;
|
||||
QString text = led.lineEdit->text();
|
||||
@@ -399,7 +399,7 @@ QMap<QString, QString> CustomWizardFieldPage::replacementMap(const QWizard *w,
|
||||
const FieldList &f)
|
||||
{
|
||||
QMap<QString, QString> fieldReplacementMap = ctx->baseReplacements;
|
||||
foreach (const Internal::CustomWizardField &field, f) {
|
||||
for (const Internal::CustomWizardField &field : f) {
|
||||
const QString value = w->field(field.name).toString();
|
||||
fieldReplacementMap.insert(field.name, value);
|
||||
}
|
||||
|
@@ -176,7 +176,7 @@ bool CustomWizardValidationRule::validateRules(const QList<CustomWizardValidatio
|
||||
if (rules.isEmpty())
|
||||
return true;
|
||||
QJSEngine engine;
|
||||
foreach (const CustomWizardValidationRule &rule, rules)
|
||||
for (const CustomWizardValidationRule &rule : rules)
|
||||
if (!rule.validate(engine, replacementMap)) {
|
||||
*errorMessage = rule.message;
|
||||
CustomWizardContext::replaceFields(replacementMap, errorMessage);
|
||||
@@ -302,7 +302,7 @@ static bool parseCustomProjectElement(QXmlStreamReader &reader,
|
||||
static inline QMap<QString, QString> attributesToStringMap(const QXmlStreamAttributes &attributes)
|
||||
{
|
||||
QMap<QString, QString> rc;
|
||||
foreach (const QXmlStreamAttribute &attribute, attributes)
|
||||
for (const QXmlStreamAttribute &attribute : attributes)
|
||||
rc.insert(attribute.name().toString(), attribute.value().toString());
|
||||
return rc;
|
||||
}
|
||||
@@ -452,9 +452,9 @@ static inline IWizardFactory::WizardKind kindAttribute(const QXmlStreamReader &r
|
||||
static inline QSet<Id> readRequiredFeatures(const QXmlStreamReader &reader)
|
||||
{
|
||||
QString value = reader.attributes().value(QLatin1String(featuresRequiredC)).toString();
|
||||
QStringList stringList = value.split(QLatin1Char(','), Qt::SkipEmptyParts);
|
||||
const QStringList stringList = value.split(QLatin1Char(','), Qt::SkipEmptyParts);
|
||||
QSet<Id> features;
|
||||
foreach (const QString &string, stringList)
|
||||
for (const QString &string : stringList)
|
||||
features |= Id::fromString(string);
|
||||
return features;
|
||||
}
|
||||
@@ -708,7 +708,7 @@ static inline QString passThrough(const QString &in) { return in; }
|
||||
static inline QString headerGuard(const QString &in)
|
||||
{
|
||||
QString result;
|
||||
foreach (const QChar c, in) {
|
||||
for (const QChar c : in) {
|
||||
if (c.isLetterOrNumber())
|
||||
result.append(c.toUpper());
|
||||
else
|
||||
@@ -721,7 +721,7 @@ static inline QString structName(const QString &in)
|
||||
{
|
||||
bool capNeeded = true;
|
||||
QString result;
|
||||
foreach (const QChar c, in) {
|
||||
for (const QChar c : in) {
|
||||
if (c.isLetterOrNumber()) {
|
||||
if (capNeeded) {
|
||||
result.append(c.toUpper());
|
||||
|
@@ -99,7 +99,7 @@ static bool
|
||||
// Arguments: Prepend 'dryrun'. Do field replacement to actual
|
||||
// argument value to expand via temporary file if specified
|
||||
CustomWizardContext::TemporaryFilePtrList temporaryFiles;
|
||||
foreach (const GeneratorScriptArgument &argument, argumentsIn) {
|
||||
for (const GeneratorScriptArgument &argument : argumentsIn) {
|
||||
QString value = argument.value;
|
||||
const bool nonEmptyReplacements
|
||||
= argument.flags & GeneratorScriptArgument::WriteFile ?
|
||||
@@ -155,7 +155,8 @@ Core::GeneratedFiles
|
||||
Core::GeneratedFiles files;
|
||||
// Parse the output consisting of lines with ',' separated tokens.
|
||||
// (file name + attributes matching those of the <file> element)
|
||||
foreach (const QString &line, stdOut.split(QLatin1Char('\n'))) {
|
||||
const QStringList lines = stdOut.split(QLatin1Char('\n'));
|
||||
for (const QString &line : lines) {
|
||||
const QString trimmed = line.trimmed();
|
||||
if (!trimmed.isEmpty()) {
|
||||
Core::GeneratedFile file;
|
||||
@@ -187,7 +188,7 @@ Core::GeneratedFiles
|
||||
if (CustomWizard::verbose()) {
|
||||
QDebug nospace = qDebug().nospace();
|
||||
nospace << script << " generated:\n";
|
||||
foreach (const Core::GeneratedFile &f, files)
|
||||
for (const Core::GeneratedFile &f : qAsConst(files))
|
||||
nospace << ' ' << f.path() << f.attributes() << '\n';
|
||||
}
|
||||
return files;
|
||||
|
@@ -282,7 +282,8 @@ void EditorConfiguration::setUseGlobalSettings(bool use)
|
||||
{
|
||||
d->m_useGlobal = use;
|
||||
d->m_defaultCodeStyle->setCurrentDelegate(use ? TextEditorSettings::codeStyle() : nullptr);
|
||||
foreach (Core::IEditor *editor, Core::DocumentModel::editorsForOpenedDocuments()) {
|
||||
const QList<Core::IEditor *> editors = Core::DocumentModel::editorsForOpenedDocuments();
|
||||
for (Core::IEditor *editor : editors) {
|
||||
if (auto widget = TextEditorWidget::fromEditor(editor)) {
|
||||
Project *project = SessionManager::projectForFile(editor->document()->filePath());
|
||||
if (project && project->editorConfiguration() == this)
|
||||
@@ -403,7 +404,7 @@ void EditorConfiguration::slotAboutToRemoveProject(Project *project)
|
||||
if (project->editorConfiguration() != this)
|
||||
return;
|
||||
|
||||
foreach (BaseTextEditor *editor, d->m_editors)
|
||||
for (BaseTextEditor *editor : qAsConst(d->m_editors))
|
||||
deconfigureEditor(editor);
|
||||
}
|
||||
|
||||
|
@@ -395,7 +395,7 @@ void EnvironmentWidget::updateSummaryText()
|
||||
Utils::EnvironmentItem::sort(&list);
|
||||
|
||||
QString text;
|
||||
foreach (const Utils::EnvironmentItem &item, list) {
|
||||
for (const Utils::EnvironmentItem &item : qAsConst(list)) {
|
||||
if (item.name != Utils::EnvironmentModel::tr("<VARIABLE>")) {
|
||||
if (!d->m_baseEnvironmentText.isEmpty() || !text.isEmpty())
|
||||
text.append(QLatin1String("<br>"));
|
||||
|
@@ -526,7 +526,7 @@ Utils::LanguageExtensions GccToolChain::languageExtensions(const QStringList &cx
|
||||
LanguageExtensions extensions = defaultLanguageExtensions();
|
||||
|
||||
const QStringList allCxxflags = m_platformCodeGenFlags + cxxflags; // add only cxxflags is empty?
|
||||
foreach (const QString &flag, allCxxflags) {
|
||||
for (const QString &flag : allCxxflags) {
|
||||
if (flag.startsWith("-std=")) {
|
||||
const QByteArray std = flag.mid(5).toLatin1();
|
||||
if (std.startsWith("gnu"))
|
||||
@@ -553,7 +553,8 @@ WarningFlags GccToolChain::warningFlags(const QStringList &cflags) const
|
||||
| WarningFlags::SignedComparison | WarningFlags::UninitializedVars);
|
||||
WarningFlags groupWextra(WarningFlags::Extra | WarningFlags::IgnoredQualifiers | WarningFlags::UnusedParams);
|
||||
|
||||
foreach (const QString &flag, cflags) {
|
||||
for (int end = cflags.size(), i = 0; i != end; ++i) {
|
||||
const QString &flag = cflags[i];
|
||||
if (flag == "--all-warnings")
|
||||
flags |= groupWall;
|
||||
else if (flag == "--extra-warnings")
|
||||
@@ -1606,7 +1607,8 @@ LanguageExtensions ClangToolChain::languageExtensions(const QStringList &cxxflag
|
||||
WarningFlags ClangToolChain::warningFlags(const QStringList &cflags) const
|
||||
{
|
||||
WarningFlags flags = GccToolChain::warningFlags(cflags);
|
||||
foreach (const QString &flag, cflags) {
|
||||
for (int end = cflags.size(), i = 0; i != end; ++i) {
|
||||
const QString &flag = cflags[i];
|
||||
if (flag == "-Wdocumentation")
|
||||
flags |= WarningFlags::Documentation;
|
||||
if (flag == "-Wno-documentation")
|
||||
|
@@ -370,7 +370,7 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing()
|
||||
FilePaths searchDirs = childParser->searchDirectories();
|
||||
|
||||
// add extra directories:
|
||||
foreach (const QString &dir, extraSearchDirs)
|
||||
for (const QString &dir : qAsConst(extraSearchDirs))
|
||||
testbench.addSearchDir(FilePath::fromString(dir));
|
||||
|
||||
testbench.testParsing(input, inputChannel,
|
||||
@@ -379,13 +379,13 @@ void ProjectExplorerPlugin::testGnuMakeParserParsing()
|
||||
|
||||
// make sure we still have all the original dirs
|
||||
FilePaths newSearchDirs = tester->directories;
|
||||
foreach (const FilePath &dir, searchDirs) {
|
||||
for (const FilePath &dir : qAsConst(searchDirs)) {
|
||||
QVERIFY(newSearchDirs.contains(dir));
|
||||
newSearchDirs.removeOne(dir);
|
||||
}
|
||||
|
||||
// make sure we have all additional dirs:
|
||||
foreach (const QString &dir, additionalSearchDirs) {
|
||||
for (const QString &dir : qAsConst(additionalSearchDirs)) {
|
||||
const FilePath fp = FilePath::fromString(dir);
|
||||
QVERIFY(newSearchDirs.contains(fp));
|
||||
newSearchDirs.removeOne(fp);
|
||||
|
@@ -212,7 +212,7 @@ void JournaldWatcher::handleEntry()
|
||||
if (logEntry.isEmpty())
|
||||
break;
|
||||
|
||||
foreach (const JournaldWatcherPrivate::SubscriberInformation &info, d->m_subscriptions)
|
||||
for (const JournaldWatcherPrivate::SubscriberInformation &info: qAsConst(d->m_subscriptions))
|
||||
info.subscription(logEntry);
|
||||
}
|
||||
}
|
||||
|
@@ -1383,8 +1383,8 @@ void JsonFieldPage::registerFieldFactory(const QString &id, const JsonFieldPage:
|
||||
bool JsonFieldPage::setup(const QVariant &data)
|
||||
{
|
||||
QString errorMessage;
|
||||
QList<QVariant> fieldList = JsonWizardFactory::objectOrList(data, &errorMessage);
|
||||
foreach (const QVariant &field, fieldList) {
|
||||
const QList<QVariant> fieldList = JsonWizardFactory::objectOrList(data, &errorMessage);
|
||||
for (const QVariant &field : fieldList) {
|
||||
Field *f = JsonFieldPage::Field::parse(field, &errorMessage);
|
||||
if (!f)
|
||||
continue;
|
||||
@@ -1407,7 +1407,7 @@ bool JsonFieldPage::isComplete() const
|
||||
|
||||
bool result = true;
|
||||
bool hasErrorMessage = false;
|
||||
foreach (Field *f, m_fields) {
|
||||
for (Field *f : qAsConst(m_fields)) {
|
||||
f->adjustState(m_expander);
|
||||
if (!f->validate(m_expander, &message)) {
|
||||
if (!message.isEmpty()) {
|
||||
@@ -1427,13 +1427,13 @@ bool JsonFieldPage::isComplete() const
|
||||
|
||||
void JsonFieldPage::initializePage()
|
||||
{
|
||||
foreach (Field *f, m_fields)
|
||||
for (Field *f : qAsConst(m_fields))
|
||||
f->initialize(m_expander);
|
||||
}
|
||||
|
||||
void JsonFieldPage::cleanupPage()
|
||||
{
|
||||
foreach (Field *f, m_fields)
|
||||
for (Field *f : qAsConst(m_fields))
|
||||
f->cleanup(m_expander);
|
||||
}
|
||||
|
||||
|
@@ -132,7 +132,7 @@ QSet<Id> JsonKitsPage::evaluate(const QVector<JsonKitsPage::ConditionalFeature>
|
||||
return Id::fromStringList(defaultSet.toStringList());
|
||||
|
||||
QSet<Id> features;
|
||||
foreach (const ConditionalFeature &f, list) {
|
||||
for (const ConditionalFeature &f : list) {
|
||||
if (JsonWizard::boolFromVariant(f.condition, wiz->expander()))
|
||||
features.insert(Id::fromString(wiz->expander()->expand(f.feature)));
|
||||
}
|
||||
@@ -154,7 +154,8 @@ QVector<JsonKitsPage::ConditionalFeature> JsonKitsPage::parseFeatures(const QVar
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (const QVariant &element, data.toList()) {
|
||||
const QList<QVariant> elements = data.toList();
|
||||
for (const QVariant &element : elements) {
|
||||
if (element.type() == QVariant::String) {
|
||||
result.append({ element.toString(), QVariant(true) });
|
||||
} else if (element.type() == QVariant::Map) {
|
||||
|
@@ -195,7 +195,7 @@ JsonWizard::GeneratorFiles JsonWizard::generateFileList()
|
||||
|
||||
if (m_files.isEmpty() && errorMessage.isEmpty()) {
|
||||
emit preGenerateFiles();
|
||||
foreach (JsonWizardGenerator *gen, m_generators) {
|
||||
for (JsonWizardGenerator *gen : qAsConst(m_generators)) {
|
||||
Core::GeneratedFiles tmp = gen->fileList(&m_expander, stringValue(QStringLiteral("WizardDir")),
|
||||
targetPath, &errorMessage);
|
||||
if (!errorMessage.isEmpty())
|
||||
@@ -261,7 +261,7 @@ QList<JsonWizard::OptionDefinition> JsonWizard::parseOptions(const QVariant &v,
|
||||
QList<JsonWizard::OptionDefinition> result;
|
||||
if (!v.isNull()) {
|
||||
const QVariantList optList = JsonWizardFactory::objectOrList(v, errorMessage);
|
||||
foreach (const QVariant &o, optList) {
|
||||
for (const QVariant &o : optList) {
|
||||
QVariantMap optionObject = o.toMap();
|
||||
JsonWizard::OptionDefinition odef;
|
||||
odef.m_key = optionObject.value(QLatin1String("key")).toString();
|
||||
@@ -331,7 +331,8 @@ void JsonWizard::removeAttributeFromAllFiles(Core::GeneratedFile::Attribute a)
|
||||
QHash<QString, QVariant> JsonWizard::variables() const
|
||||
{
|
||||
QHash<QString, QVariant> result = Wizard::variables();
|
||||
foreach (const QByteArray &p, dynamicPropertyNames()) {
|
||||
const QList<QByteArray> properties = dynamicPropertyNames();
|
||||
for (const QByteArray &p : properties) {
|
||||
QString key = QString::fromUtf8(p);
|
||||
result.insert(key, value(key));
|
||||
}
|
||||
@@ -442,7 +443,7 @@ void JsonWizard::openFiles(const JsonWizard::GeneratorFiles &files)
|
||||
{
|
||||
QString errorMessage;
|
||||
bool openedSomething = false;
|
||||
foreach (const JsonWizard::GeneratorFile &f, files) {
|
||||
for (const JsonWizard::GeneratorFile &f : files) {
|
||||
const Core::GeneratedFile &file = f.file;
|
||||
if (!QFileInfo::exists(file.path())) {
|
||||
errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
|
||||
|
@@ -112,7 +112,8 @@ static QString supportedTypeIds(const QList<T *> &factories)
|
||||
{
|
||||
QStringList tmp;
|
||||
for (const T *f : factories) {
|
||||
foreach (Id i, f->supportedIds())
|
||||
const QList<Id> ids = f->supportedIds();
|
||||
for (const Id i : ids)
|
||||
tmp.append(i.toString());
|
||||
}
|
||||
return tmp.join(QLatin1String("', '"));
|
||||
@@ -166,7 +167,8 @@ QVariantMap JsonWizardFactory::loadDefaultValues(const QString &fileName)
|
||||
}
|
||||
|
||||
QList <Core::IWizardFactory *> result;
|
||||
foreach (const Utils::FilePath &path, searchPaths()) {
|
||||
const Utils::FilePaths paths = searchPaths();
|
||||
for (const Utils::FilePath &path : paths) {
|
||||
if (path.isEmpty())
|
||||
continue;
|
||||
|
||||
@@ -402,7 +404,8 @@ QList<Core::IWizardFactory *> JsonWizardFactory::createWizardFactories()
|
||||
const QString wizardFileName = QLatin1String(WIZARD_FILE);
|
||||
|
||||
QList <Core::IWizardFactory *> result;
|
||||
foreach (const FilePath &path, searchPaths()) {
|
||||
const Utils::FilePaths paths = searchPaths();
|
||||
for (const Utils::FilePath &path : paths) {
|
||||
if (path.isEmpty())
|
||||
continue;
|
||||
|
||||
|
@@ -49,11 +49,11 @@ bool JsonWizardFileGenerator::setup(const QVariant &data, QString *errorMessage)
|
||||
{
|
||||
QTC_ASSERT(errorMessage && errorMessage->isEmpty(), return false);
|
||||
|
||||
QVariantList list = JsonWizardFactory::objectOrList(data, errorMessage);
|
||||
const QVariantList list = JsonWizardFactory::objectOrList(data, errorMessage);
|
||||
if (list.isEmpty())
|
||||
return false;
|
||||
|
||||
foreach (const QVariant &d, list) {
|
||||
for (const QVariant &d : list) {
|
||||
if (d.type() != QVariant::Map) {
|
||||
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonFieldPage",
|
||||
"Files data list entry is not an object.");
|
||||
@@ -117,7 +117,7 @@ Core::GeneratedFile JsonWizardFileGenerator::generateFile(const File &file,
|
||||
|
||||
// evaluate file options once:
|
||||
QHash<QString, QString> options;
|
||||
foreach (const JsonWizard::OptionDefinition &od, file.options) {
|
||||
for (const JsonWizard::OptionDefinition &od : qAsConst(file.options)) {
|
||||
if (od.condition(*expander))
|
||||
options.insert(od.key(), od.value(*expander));
|
||||
}
|
||||
@@ -195,7 +195,7 @@ Core::GeneratedFiles JsonWizardFileGenerator::fileList(Utils::MacroExpander *exp
|
||||
|
||||
const QSet<QString> knownFiles = Utils::transform<QSet>(fileList, &File::target);
|
||||
|
||||
foreach (const File &dir, dirList) {
|
||||
for (const File &dir : qAsConst(dirList)) {
|
||||
QDir sourceDir(dir.source);
|
||||
QDirIterator it(dir.source, QDir::NoDotAndDotDot | QDir::Files| QDir::Hidden,
|
||||
QDirIterator::Subdirectories);
|
||||
|
@@ -161,7 +161,7 @@ JsonWizardGenerator::OverwriteResult JsonWizardGenerator::promptForOverwrite(Jso
|
||||
QStringList existingFiles;
|
||||
bool oddStuffFound = false;
|
||||
|
||||
foreach (const JsonWizard::GeneratorFile &f, *files) {
|
||||
for (const JsonWizard::GeneratorFile &f : qAsConst(*files)) {
|
||||
const QFileInfo fi(f.file.path());
|
||||
if (fi.exists()
|
||||
&& !(f.file.attributes() & GeneratedFile::ForceOverwrite)
|
||||
@@ -176,7 +176,7 @@ JsonWizardGenerator::OverwriteResult JsonWizardGenerator::promptForOverwrite(Jso
|
||||
// Format a file list message as ( "<file1> [readonly], <file2> [folder]").
|
||||
const QString commonExistingPath = Utils::commonPath(existingFiles);
|
||||
QString fileNamesMsgPart;
|
||||
foreach (const QString &fileName, existingFiles) {
|
||||
for (const QString &fileName : qAsConst(existingFiles)) {
|
||||
const QFileInfo fi(fileName);
|
||||
if (fi.exists()) {
|
||||
if (!fileNamesMsgPart.isEmpty())
|
||||
@@ -210,7 +210,7 @@ JsonWizardGenerator::OverwriteResult JsonWizardGenerator::promptForOverwrite(Jso
|
||||
|
||||
// Scripts cannot handle overwrite
|
||||
overwriteDialog.setFiles(existingFiles);
|
||||
foreach (const JsonWizard::GeneratorFile &file, *files)
|
||||
for (const JsonWizard::GeneratorFile &file : qAsConst(*files))
|
||||
if (!file.generator->canKeepExistingFiles())
|
||||
overwriteDialog.setFileEnabled(file.file.path(), false);
|
||||
if (overwriteDialog.exec() != QDialog::Accepted)
|
||||
|
@@ -80,7 +80,7 @@ bool FieldPageFactory::validateData(Utils::Id typeId, const QVariant &data, QStr
|
||||
{
|
||||
QTC_ASSERT(canCreate(typeId), return false);
|
||||
|
||||
QList<QVariant> list = JsonWizardFactory::objectOrList(data, errorMessage);
|
||||
const QList<QVariant> list = JsonWizardFactory::objectOrList(data, errorMessage);
|
||||
if (list.isEmpty()) {
|
||||
*errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
|
||||
"When parsing fields of page \"%1\": %2")
|
||||
@@ -88,7 +88,7 @@ bool FieldPageFactory::validateData(Utils::Id typeId, const QVariant &data, QStr
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (const QVariant &v, list) {
|
||||
for (const QVariant &v : list) {
|
||||
JsonFieldPage::Field *field = JsonFieldPage::Field::parse(v, errorMessage);
|
||||
if (!field)
|
||||
return false;
|
||||
|
@@ -61,8 +61,8 @@ bool JsonWizardScannerGenerator::setup(const QVariant &data, QString *errorMessa
|
||||
QVariantMap gen = data.toMap();
|
||||
|
||||
m_binaryPattern = gen.value(QLatin1String("binaryPattern")).toString();
|
||||
QStringList patterns = gen.value(QLatin1String("subdirectoryPatterns")).toStringList();
|
||||
foreach (const QString pattern, patterns) {
|
||||
const QStringList patterns = gen.value(QLatin1String("subdirectoryPatterns")).toStringList();
|
||||
for (const QString &pattern : patterns) {
|
||||
QRegularExpression regexp(pattern);
|
||||
if (!regexp.isValid()) {
|
||||
*errorMessage = QCoreApplication::translate("ProjectExplorer::Internal::JsonWizard",
|
||||
@@ -126,7 +126,7 @@ Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander *
|
||||
|
||||
bool JsonWizardScannerGenerator::matchesSubdirectoryPattern(const QString &path)
|
||||
{
|
||||
foreach (const QRegularExpression ®exp, m_subDirectoryExpressions) {
|
||||
for (const QRegularExpression ®exp : qAsConst(m_subDirectoryExpressions)) {
|
||||
if (regexp.match(path).hasMatch())
|
||||
return true;
|
||||
}
|
||||
@@ -141,9 +141,9 @@ Core::GeneratedFiles JsonWizardScannerGenerator::scan(const QString &dir, const
|
||||
if (!directory.exists())
|
||||
return result;
|
||||
|
||||
QFileInfoList entries = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot,
|
||||
QDir::DirsLast | QDir::Name);
|
||||
foreach (const QFileInfo &fi, entries) {
|
||||
const QFileInfoList entries = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot,
|
||||
QDir::DirsLast | QDir::Name);
|
||||
for (const QFileInfo &fi : entries) {
|
||||
const QString relativePath = base.relativeFilePath(fi.absoluteFilePath());
|
||||
if (fi.isDir() && matchesSubdirectoryPattern(relativePath)) {
|
||||
result += scan(fi.absoluteFilePath(), base);
|
||||
|
Reference in New Issue
Block a user