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