ExtensionSystem: Some modernization

Mostly 'foreach'.

Change-Id: I5390d03bb5cc37c3674b61cea6f5d22bae554ed2
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2020-02-14 08:51:08 +01:00
parent 092ee20418
commit d3d294cd81
9 changed files with 59 additions and 59 deletions

View File

@@ -170,7 +170,7 @@ bool OptionsParser::checkForLoadOption()
return false; return false;
if (nextToken(RequiredToken)) { if (nextToken(RequiredToken)) {
if (m_currentArg == QLatin1String("all")) { if (m_currentArg == QLatin1String("all")) {
foreach (PluginSpec *spec, m_pmPrivate->pluginSpecs) for (PluginSpec *spec : qAsConst(m_pmPrivate->pluginSpecs))
spec->d->setForceEnabled(true); spec->d->setForceEnabled(true);
m_isDependencyRefreshNeeded = true; m_isDependencyRefreshNeeded = true;
} else { } else {
@@ -197,7 +197,7 @@ bool OptionsParser::checkForNoLoadOption()
return false; return false;
if (nextToken(RequiredToken)) { if (nextToken(RequiredToken)) {
if (m_currentArg == QLatin1String("all")) { if (m_currentArg == QLatin1String("all")) {
foreach (PluginSpec *spec, m_pmPrivate->pluginSpecs) for (PluginSpec *spec : qAsConst(m_pmPrivate->pluginSpecs))
spec->d->setForceDisabled(true); spec->d->setForceDisabled(true);
m_isDependencyRefreshNeeded = true; m_isDependencyRefreshNeeded = true;
} else { } else {
@@ -210,7 +210,7 @@ bool OptionsParser::checkForNoLoadOption()
} else { } else {
spec->d->setForceDisabled(true); spec->d->setForceDisabled(true);
// recursively disable all plugins that require this plugin // recursively disable all plugins that require this plugin
foreach (PluginSpec *dependantSpec, PluginManager::pluginsRequiringPlugin(spec)) for (PluginSpec *dependantSpec : PluginManager::pluginsRequiringPlugin(spec))
dependantSpec->d->setForceDisabled(true); dependantSpec->d->setForceDisabled(true);
m_isDependencyRefreshNeeded = true; m_isDependencyRefreshNeeded = true;
} }

View File

@@ -46,7 +46,7 @@ PluginErrorOverview::PluginErrorOverview(QWidget *parent) :
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->buttonBox->addButton(tr("Continue"), QDialogButtonBox::AcceptRole); m_ui->buttonBox->addButton(tr("Continue"), QDialogButtonBox::AcceptRole);
foreach (PluginSpec *spec, PluginManager::plugins()) { for (PluginSpec *spec : PluginManager::plugins()) {
// only show errors on startup if plugin is enabled. // only show errors on startup if plugin is enabled.
if (spec->hasError() && spec->isEffectivelyEnabled()) { if (spec->hasError() && spec->isEffectivelyEnabled()) {
QListWidgetItem *item = new QListWidgetItem(spec->name()); QListWidgetItem *item = new QListWidgetItem(spec->name());

View File

@@ -359,11 +359,11 @@ const QStringList PluginManager::allErrors()
/*! /*!
Returns all plugins that require \a spec to be loaded. Recurses into dependencies. Returns all plugins that require \a spec to be loaded. Recurses into dependencies.
*/ */
QSet<PluginSpec *> PluginManager::pluginsRequiringPlugin(PluginSpec *spec) const QSet<PluginSpec *> PluginManager::pluginsRequiringPlugin(PluginSpec *spec)
{ {
QSet<PluginSpec *> dependingPlugins({spec}); QSet<PluginSpec *> dependingPlugins({spec});
// recursively add plugins that depend on plugins that.... that depend on spec // recursively add plugins that depend on plugins that.... that depend on spec
foreach (PluginSpec *spec, d->loadQueue()) { for (PluginSpec *spec : d->loadQueue()) {
if (spec->requiresAny(dependingPlugins)) if (spec->requiresAny(dependingPlugins))
dependingPlugins.insert(spec); dependingPlugins.insert(spec);
} }
@@ -374,7 +374,7 @@ QSet<PluginSpec *> PluginManager::pluginsRequiringPlugin(PluginSpec *spec)
/*! /*!
Returns all plugins that \a spec requires to be loaded. Recurses into dependencies. Returns all plugins that \a spec requires to be loaded. Recurses into dependencies.
*/ */
QSet<PluginSpec *> PluginManager::pluginsRequiredByPlugin(PluginSpec *spec) const QSet<PluginSpec *> PluginManager::pluginsRequiredByPlugin(PluginSpec *spec)
{ {
QSet<PluginSpec *> recursiveDependencies; QSet<PluginSpec *> recursiveDependencies;
recursiveDependencies.insert(spec); recursiveDependencies.insert(spec);
@@ -576,7 +576,7 @@ QString PluginManager::serializedArguments()
{ {
const QChar separator = QLatin1Char('|'); const QChar separator = QLatin1Char('|');
QString rc; QString rc;
foreach (const PluginSpec *ps, plugins()) { for (const PluginSpec *ps : plugins()) {
if (!ps->arguments().isEmpty()) { if (!ps->arguments().isEmpty()) {
if (!rc.isEmpty()) if (!rc.isEmpty())
rc += separator; rc += separator;
@@ -593,7 +593,7 @@ QString PluginManager::serializedArguments()
if (!rc.isEmpty()) if (!rc.isEmpty())
rc += separator; rc += separator;
rc += QLatin1String(argumentKeywordC); rc += QLatin1String(argumentKeywordC);
foreach (const QString &argument, d->arguments) for (const QString &argument : qAsConst(d->arguments))
rc += separator + argument; rc += separator + argument;
} }
return rc; return rc;
@@ -633,7 +633,7 @@ void PluginManager::remoteArguments(const QString &serializedArgument, QObject *
const QStringList pwdValue = subList(serializedArguments, QLatin1String(pwdKeywordC)); const QStringList pwdValue = subList(serializedArguments, QLatin1String(pwdKeywordC));
const QString workingDirectory = pwdValue.isEmpty() ? QString() : pwdValue.first(); const QString workingDirectory = pwdValue.isEmpty() ? QString() : pwdValue.first();
const QStringList arguments = subList(serializedArguments, QLatin1String(argumentKeywordC)); const QStringList arguments = subList(serializedArguments, QLatin1String(argumentKeywordC));
foreach (const PluginSpec *ps, plugins()) { for (const PluginSpec *ps : plugins()) {
if (ps->state() == PluginSpec::Running) { if (ps->state() == PluginSpec::Running) {
const QStringList pluginOptions = subList(serializedArguments, QLatin1Char(':') + ps->name()); const QStringList pluginOptions = subList(serializedArguments, QLatin1Char(':') + ps->name());
QObject *socketParent = ps->plugin()->remoteCommand(pluginOptions, workingDirectory, QObject *socketParent = ps->plugin()->remoteCommand(pluginOptions, workingDirectory,
@@ -747,11 +747,11 @@ void PluginManager::formatOptions(QTextStream &str, int optionIndentation, int d
void PluginManager::formatPluginOptions(QTextStream &str, int optionIndentation, int descriptionIndentation) void PluginManager::formatPluginOptions(QTextStream &str, int optionIndentation, int descriptionIndentation)
{ {
// Check plugins for options // Check plugins for options
foreach (PluginSpec *ps, d->pluginSpecs) { for (PluginSpec *ps : qAsConst(d->pluginSpecs)) {
const PluginSpec::PluginArgumentDescriptions pargs = ps->argumentDescriptions(); const PluginSpec::PluginArgumentDescriptions pargs = ps->argumentDescriptions();
if (!pargs.empty()) { if (!pargs.empty()) {
str << "\nPlugin: " << ps->name() << '\n'; str << "\nPlugin: " << ps->name() << '\n';
foreach (PluginArgumentDescription pad, pargs) for (const PluginArgumentDescription &pad : pargs)
formatOption(str, pad.name, pad.parameter, pad.description, optionIndentation, descriptionIndentation); formatOption(str, pad.name, pad.parameter, pad.description, optionIndentation, descriptionIndentation);
} }
} }
@@ -762,7 +762,7 @@ void PluginManager::formatPluginOptions(QTextStream &str, int optionIndentation,
*/ */
void PluginManager::formatPluginVersions(QTextStream &str) void PluginManager::formatPluginVersions(QTextStream &str)
{ {
foreach (PluginSpec *ps, d->pluginSpecs) for (PluginSpec *ps : qAsConst(d->pluginSpecs))
str << " " << ps->name() << ' ' << ps->version() << ' ' << ps->description() << '\n'; str << " " << ps->name() << ' ' << ps->version() << ' ' << ps->description() << '\n';
} }
@@ -887,7 +887,7 @@ void PluginManagerPrivate::writeSettings()
return; return;
QStringList tempDisabledPlugins; QStringList tempDisabledPlugins;
QStringList tempForceEnabledPlugins; QStringList tempForceEnabledPlugins;
foreach (PluginSpec *spec, pluginSpecs) { for (PluginSpec *spec : qAsConst(pluginSpecs)) {
if (spec->isEnabledByDefault() && !spec->isEnabledBySettings()) if (spec->isEnabledByDefault() && !spec->isEnabledBySettings())
tempDisabledPlugins.append(spec->name()); tempDisabledPlugins.append(spec->name());
if (!spec->isEnabledByDefault() && spec->isEnabledBySettings()) if (!spec->isEnabledByDefault() && spec->isEnabledBySettings())
@@ -923,11 +923,11 @@ void PluginManagerPrivate::stopAll()
delete delayedInitializeTimer; delete delayedInitializeTimer;
delayedInitializeTimer = nullptr; delayedInitializeTimer = nullptr;
} }
QVector<PluginSpec *> queue = loadQueue();
foreach (PluginSpec *spec, queue) { const QVector<PluginSpec *> queue = loadQueue();
for (PluginSpec *spec : queue)
loadPlugin(spec, PluginSpec::Stopped); loadPlugin(spec, PluginSpec::Stopped);
} }
}
/*! /*!
\internal \internal
@@ -1001,7 +1001,7 @@ static QStringList matchingTestFunctions(const QStringList &testFunctions,
const QRegExp regExp(testFunctionName, Qt::CaseSensitive, QRegExp::Wildcard); const QRegExp regExp(testFunctionName, Qt::CaseSensitive, QRegExp::Wildcard);
QStringList matchingFunctions; QStringList matchingFunctions;
foreach (const QString &testFunction, testFunctions) { for (const QString &testFunction : testFunctions) {
if (regExp.exactMatch(testFunction)) { if (regExp.exactMatch(testFunction)) {
// If the specified test data is invalid, the QTest framework will // If the specified test data is invalid, the QTest framework will
// print a reasonable error message for us. // print a reasonable error message for us.
@@ -1058,7 +1058,7 @@ static TestPlan generateCompleteTestPlan(IPlugin *plugin, const QVector<QObject
TestPlan testPlan; TestPlan testPlan;
testPlan.insert(plugin, testFunctions(plugin->metaObject())); testPlan.insert(plugin, testFunctions(plugin->metaObject()));
foreach (QObject *testObject, testObjects) { for (QObject *testObject : testObjects) {
const QStringList allFunctions = testFunctions(testObject->metaObject()); const QStringList allFunctions = testFunctions(testObject->metaObject());
testPlan.insert(testObject, allFunctions); testPlan.insert(testObject, allFunctions);
} }
@@ -1096,7 +1096,7 @@ static TestPlan generateCustomTestPlan(IPlugin *plugin,
} else { } else {
// Add all matching test functions of all remaining test objects // Add all matching test functions of all remaining test objects
foreach (QObject *testObject, remainingTestObjectsOfPlugin) { for (QObject *testObject : qAsConst(remainingTestObjectsOfPlugin)) {
const QStringList allFunctions = testFunctions(testObject->metaObject()); const QStringList allFunctions = testFunctions(testObject->metaObject());
const QStringList matchingFunctions = matchingTestFunctions(allFunctions, const QStringList matchingFunctions = matchingTestFunctions(allFunctions,
matchText); matchText);
@@ -1119,7 +1119,7 @@ static TestPlan generateCustomTestPlan(IPlugin *plugin,
out << "No test function or class matches \"" << matchText out << "No test function or class matches \"" << matchText
<< "\" in plugin \"" << plugin->metaObject()->className() << "\" in plugin \"" << plugin->metaObject()->className()
<< "\".\nAvailable functions:\n"; << "\".\nAvailable functions:\n";
foreach (const QString &f, testFunctionsOfPluginObject) for (const QString &f : testFunctionsOfPluginObject)
out << " " << f << '\n'; out << " " << f << '\n';
out << endl; out << endl;
} }
@@ -1143,7 +1143,7 @@ void PluginManagerPrivate::startTests()
} }
int failedTests = 0; int failedTests = 0;
foreach (const PluginManagerPrivate::TestSpec &testSpec, testSpecs) { for (const TestSpec &testSpec : qAsConst(testSpecs)) {
IPlugin *plugin = testSpec.pluginSpec->plugin(); IPlugin *plugin = testSpec.pluginSpec->plugin();
if (!plugin) if (!plugin)
continue; // plugin not loaded continue; // plugin not loaded
@@ -1227,15 +1227,15 @@ void PluginManagerPrivate::removeObject(QObject *obj)
*/ */
void PluginManagerPrivate::loadPlugins() void PluginManagerPrivate::loadPlugins()
{ {
QVector<PluginSpec *> queue = loadQueue(); const QVector<PluginSpec *> queue = loadQueue();
Utils::setMimeStartupPhase(MimeStartupPhase::PluginsLoading); Utils::setMimeStartupPhase(MimeStartupPhase::PluginsLoading);
foreach (PluginSpec *spec, queue) { for (PluginSpec *spec : queue)
loadPlugin(spec, PluginSpec::Loaded); loadPlugin(spec, PluginSpec::Loaded);
}
Utils::setMimeStartupPhase(MimeStartupPhase::PluginsInitializing); Utils::setMimeStartupPhase(MimeStartupPhase::PluginsInitializing);
foreach (PluginSpec *spec, queue) { for (PluginSpec *spec : queue)
loadPlugin(spec, PluginSpec::Initialized); loadPlugin(spec, PluginSpec::Initialized);
}
Utils::setMimeStartupPhase(MimeStartupPhase::PluginsDelayedInitializing); Utils::setMimeStartupPhase(MimeStartupPhase::PluginsDelayedInitializing);
Utils::reverseForeach(queue, [this](PluginSpec *spec) { Utils::reverseForeach(queue, [this](PluginSpec *spec) {
loadPlugin(spec, PluginSpec::Running); loadPlugin(spec, PluginSpec::Running);
@@ -1291,10 +1291,10 @@ void PluginManagerPrivate::asyncShutdownFinished()
/*! /*!
\internal \internal
*/ */
QVector<PluginSpec *> PluginManagerPrivate::loadQueue() const QVector<PluginSpec *> PluginManagerPrivate::loadQueue()
{ {
QVector<PluginSpec *> queue; QVector<PluginSpec *> queue;
foreach (PluginSpec *spec, pluginSpecs) { for (PluginSpec *spec : qAsConst(pluginSpecs)) {
QVector<PluginSpec *> circularityCheckQueue; QVector<PluginSpec *> circularityCheckQueue;
loadQueue(spec, queue, circularityCheckQueue); loadQueue(spec, queue, circularityCheckQueue);
} }
@@ -1526,7 +1526,7 @@ void PluginManagerPrivate::setPluginPaths(const QStringList &paths)
readPluginPaths(); readPluginPaths();
} }
static QStringList pluginFiles(const QStringList &pluginPaths) static const QStringList pluginFiles(const QStringList &pluginPaths)
{ {
QStringList pluginFiles; QStringList pluginFiles;
QStringList searchPaths = pluginPaths; QStringList searchPaths = pluginPaths;
@@ -1553,7 +1553,7 @@ void PluginManagerPrivate::readPluginPaths()
// default // default
pluginCategories.insert(QString(), QVector<PluginSpec *>()); pluginCategories.insert(QString(), QVector<PluginSpec *>());
foreach (const QString &pluginFile, pluginFiles(pluginPaths)) { for (const QString &pluginFile : pluginFiles(pluginPaths)) {
auto *spec = new PluginSpec; auto *spec = new PluginSpec;
if (!spec->d->read(pluginFile)) { // not a Qt Creator plugin if (!spec->d->read(pluginFile)) { // not a Qt Creator plugin
delete spec; delete spec;
@@ -1586,13 +1586,13 @@ void PluginManagerPrivate::readPluginPaths()
void PluginManagerPrivate::resolveDependencies() void PluginManagerPrivate::resolveDependencies()
{ {
foreach (PluginSpec *spec, pluginSpecs) for (PluginSpec *spec : qAsConst(pluginSpecs))
spec->d->resolveDependencies(pluginSpecs); spec->d->resolveDependencies(pluginSpecs);
} }
void PluginManagerPrivate::enableDependenciesIndirectly() void PluginManagerPrivate::enableDependenciesIndirectly()
{ {
foreach (PluginSpec *spec, pluginSpecs) for (PluginSpec *spec : qAsConst(pluginSpecs))
spec->d->enabledIndirectly = false; spec->d->enabledIndirectly = false;
// cannot use reverse loadQueue here, because test dependencies can introduce circles // cannot use reverse loadQueue here, because test dependencies can introduce circles
QVector<PluginSpec *> queue = Utils::filtered(pluginSpecs, &PluginSpec::isEffectivelyEnabled); QVector<PluginSpec *> queue = Utils::filtered(pluginSpecs, &PluginSpec::isEffectivelyEnabled);
@@ -1607,7 +1607,7 @@ PluginSpec *PluginManagerPrivate::pluginForOption(const QString &option, bool *r
{ {
// Look in the plugins for an option // Look in the plugins for an option
*requiresArgument = false; *requiresArgument = false;
foreach (PluginSpec *spec, pluginSpecs) { for (PluginSpec *spec : qAsConst(pluginSpecs)) {
PluginArgumentDescription match = Utils::findOrDefault(spec->argumentDescriptions(), PluginArgumentDescription match = Utils::findOrDefault(spec->argumentDescriptions(),
[option](PluginArgumentDescription pad) { [option](PluginArgumentDescription pad) {
return pad.name == option; return pad.name == option;

View File

@@ -62,8 +62,8 @@ public:
template <typename T> static T *getObject() template <typename T> static T *getObject()
{ {
QReadLocker lock(listLock()); QReadLocker lock(listLock());
QVector<QObject *> all = allObjects(); const QVector<QObject *> all = allObjects();
foreach (QObject *obj, all) { for (QObject *obj : all) {
if (T *result = qobject_cast<T *>(obj)) if (T *result = qobject_cast<T *>(obj))
return result; return result;
} }
@@ -72,8 +72,8 @@ public:
template <typename T, typename Predicate> static T *getObject(Predicate predicate) template <typename T, typename Predicate> static T *getObject(Predicate predicate)
{ {
QReadLocker lock(listLock()); QReadLocker lock(listLock());
QVector<QObject *> all = allObjects(); const QVector<QObject *> all = allObjects();
foreach (QObject *obj, all) { for (QObject *obj : all) {
if (T *result = qobject_cast<T *>(obj)) if (T *result = qobject_cast<T *>(obj))
if (predicate(result)) if (predicate(result))
return result; return result;
@@ -94,8 +94,8 @@ public:
static QHash<QString, QVector<PluginSpec *>> pluginCollections(); static QHash<QString, QVector<PluginSpec *>> pluginCollections();
static bool hasError(); static bool hasError();
static const QStringList allErrors(); static const QStringList allErrors();
static QSet<PluginSpec *> pluginsRequiringPlugin(PluginSpec *spec); static const QSet<PluginSpec *> pluginsRequiringPlugin(PluginSpec *spec);
static QSet<PluginSpec *> pluginsRequiredByPlugin(PluginSpec *spec); static const QSet<PluginSpec *> pluginsRequiredByPlugin(PluginSpec *spec);
static void checkForProblematicPlugins(); static void checkForProblematicPlugins();
// Settings // Settings

View File

@@ -69,7 +69,7 @@ public:
void loadPlugins(); void loadPlugins();
void shutdown(); void shutdown();
void setPluginPaths(const QStringList &paths); void setPluginPaths(const QStringList &paths);
QVector<ExtensionSystem::PluginSpec *> loadQueue(); const QVector<ExtensionSystem::PluginSpec *> loadQueue();
void loadPlugin(PluginSpec *spec, PluginSpec::State destState); void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
void resolveDependencies(); void resolveDependencies();
void enableDependenciesIndirectly(); void enableDependenciesIndirectly();

View File

@@ -803,8 +803,8 @@ bool PluginSpecPrivate::readMetaData(const QJsonObject &pluginMetaData)
if (!value.isUndefined() && !value.isArray()) if (!value.isUndefined() && !value.isArray())
return reportError(msgValueIsNotAObjectArray(DEPENDENCIES)); return reportError(msgValueIsNotAObjectArray(DEPENDENCIES));
if (!value.isUndefined()) { if (!value.isUndefined()) {
QJsonArray array = value.toArray(); const QJsonArray array = value.toArray();
foreach (const QJsonValue &v, array) { for (const QJsonValue &v : array) {
if (!v.isObject()) if (!v.isObject())
return reportError(msgValueIsNotAObjectArray(DEPENDENCIES)); return reportError(msgValueIsNotAObjectArray(DEPENDENCIES));
QJsonObject dependencyObject = v.toObject(); QJsonObject dependencyObject = v.toObject();
@@ -850,8 +850,8 @@ bool PluginSpecPrivate::readMetaData(const QJsonObject &pluginMetaData)
if (!value.isUndefined() && !value.isArray()) if (!value.isUndefined() && !value.isArray())
return reportError(msgValueIsNotAObjectArray(ARGUMENTS)); return reportError(msgValueIsNotAObjectArray(ARGUMENTS));
if (!value.isUndefined()) { if (!value.isUndefined()) {
QJsonArray array = value.toArray(); const QJsonArray array = value.toArray();
foreach (const QJsonValue &v, array) { for (const QJsonValue &v : array) {
if (!v.isObject()) if (!v.isObject())
return reportError(msgValueIsNotAObjectArray(ARGUMENTS)); return reportError(msgValueIsNotAObjectArray(ARGUMENTS));
QJsonObject argumentObject = v.toObject(); QJsonObject argumentObject = v.toObject();
@@ -946,7 +946,7 @@ bool PluginSpecPrivate::resolveDependencies(const QVector<PluginSpec *> &specs)
return false; return false;
} }
QHash<PluginDependency, PluginSpec *> resolvedDependencies; QHash<PluginDependency, PluginSpec *> resolvedDependencies;
foreach (const PluginDependency &dependency, dependencies) { for (const PluginDependency &dependency : qAsConst(dependencies)) {
PluginSpec * const found = Utils::findOrDefault(specs, [&dependency](PluginSpec *spec) { PluginSpec * const found = Utils::findOrDefault(specs, [&dependency](PluginSpec *spec) {
return spec->provides(dependency.name, dependency.version); return spec->provides(dependency.name, dependency.version);
}); });

View File

@@ -218,12 +218,12 @@ public:
class CollectionItem : public TreeItem class CollectionItem : public TreeItem
{ {
public: public:
CollectionItem(const QString &name, QVector<PluginSpec *> plugins, PluginView *view) CollectionItem(const QString &name, const QVector<PluginSpec *> &plugins, PluginView *view)
: m_name(name) : m_name(name)
, m_plugins(plugins) , m_plugins(plugins)
, m_view(view) , m_view(view)
{ {
foreach (PluginSpec *spec, plugins) for (PluginSpec *spec : plugins)
appendChild(new PluginItem(spec, view)); appendChild(new PluginItem(spec, view));
} }
@@ -243,7 +243,7 @@ public:
return PluginView::tr("Load on Startup"); return PluginView::tr("Load on Startup");
if (role == Qt::CheckStateRole || role == SortRole) { if (role == Qt::CheckStateRole || role == SortRole) {
int checkedCount = 0; int checkedCount = 0;
foreach (PluginSpec *spec, m_plugins) { for (PluginSpec *spec : m_plugins) {
if (spec->isEnabledBySettings()) if (spec->isEnabledBySettings())
++checkedCount; ++checkedCount;
} }
@@ -284,7 +284,7 @@ public:
public: public:
QString m_name; QString m_name;
QVector<PluginSpec *> m_plugins; const QVector<PluginSpec *> m_plugins;
PluginView *m_view; // Not owned. PluginView *m_view; // Not owned.
}; };
@@ -437,7 +437,7 @@ void PluginView::updatePlugins()
} }
Utils::sort(collections, &CollectionItem::m_name); Utils::sort(collections, &CollectionItem::m_name);
foreach (CollectionItem *collection, collections) for (CollectionItem *collection : qAsConst(collections))
m_model->rootItem()->appendChild(collection); m_model->rootItem()->appendChild(collection);
emit m_model->layoutChanged(); emit m_model->layoutChanged();
@@ -455,8 +455,8 @@ bool PluginView::setPluginsEnabled(const QSet<PluginSpec *> &plugins, bool enabl
{ {
QSet<PluginSpec *> additionalPlugins; QSet<PluginSpec *> additionalPlugins;
if (enable) { if (enable) {
foreach (PluginSpec *spec, plugins) { for (PluginSpec *spec : plugins) {
foreach (PluginSpec *other, PluginManager::pluginsRequiredByPlugin(spec)) { for (PluginSpec *other : PluginManager::pluginsRequiredByPlugin(spec)) {
if (!other->isEnabledBySettings()) if (!other->isEnabledBySettings())
additionalPlugins.insert(other); additionalPlugins.insert(other);
} }
@@ -472,8 +472,8 @@ bool PluginView::setPluginsEnabled(const QSet<PluginSpec *> &plugins, bool enabl
return false; return false;
} }
} else { } else {
foreach (PluginSpec *spec, plugins) { for (PluginSpec *spec : plugins) {
foreach (PluginSpec *other, PluginManager::pluginsRequiringPlugin(spec)) { for (PluginSpec *other : PluginManager::pluginsRequiringPlugin(spec)) {
if (other->isEnabledBySettings()) if (other->isEnabledBySettings())
additionalPlugins.insert(other); additionalPlugins.insert(other);
} }
@@ -490,8 +490,8 @@ bool PluginView::setPluginsEnabled(const QSet<PluginSpec *> &plugins, bool enabl
} }
} }
QSet<PluginSpec *> affectedPlugins = plugins + additionalPlugins; const QSet<PluginSpec *> affectedPlugins = plugins + additionalPlugins;
foreach (PluginSpec *spec, affectedPlugins) { for (PluginSpec *spec : affectedPlugins) {
PluginItem *item = m_model->findItemAtLevel<2>([spec](PluginItem *item) { PluginItem *item = m_model->findItemAtLevel<2>([spec](PluginItem *item) {
return item->m_spec == spec; return item->m_spec == spec;
}); });

View File

@@ -44,7 +44,7 @@ bool MyPlugin1::initialize(const QStringList & /*arguments*/, QString *errorStri
bool found2 = false; bool found2 = false;
bool found3 = false; bool found3 = false;
foreach (QObject *object, ExtensionSystem::PluginManager::allObjects()) { for (QObject *object : ExtensionSystem::PluginManager::allObjects()) {
if (object->objectName() == QLatin1String("MyPlugin2")) if (object->objectName() == QLatin1String("MyPlugin2"))
found2 = true; found2 = true;
else if (object->objectName() == QLatin1String("MyPlugin3")) else if (object->objectName() == QLatin1String("MyPlugin3"))

View File

@@ -43,7 +43,7 @@ bool MyPlugin3::initialize(const QStringList & /*arguments*/, QString *errorStri
ExtensionSystem::PluginManager::addObject(object1); ExtensionSystem::PluginManager::addObject(object1);
bool found2 = false; bool found2 = false;
foreach (QObject *object, ExtensionSystem::PluginManager::allObjects()) { for (QObject *object : ExtensionSystem::PluginManager::allObjects()) {
if (object->objectName() == QLatin1String("MyPlugin2")) if (object->objectName() == QLatin1String("MyPlugin2"))
found2 = true; found2 = true;
} }