forked from qt-creator/qt-creator
QtSupport: Replace foreach with range-based for loops
Change-Id: Ia941c8dec41a73ca126c91304223d1fe98bc2972 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -875,7 +875,7 @@ QString QtVersion::toHtml(bool verbose) const
|
|||||||
const QHash<ProKey, ProString> vInfo = d->versionInfo();
|
const QHash<ProKey, ProString> vInfo = d->versionInfo();
|
||||||
if (!vInfo.isEmpty()) {
|
if (!vInfo.isEmpty()) {
|
||||||
const QList<ProKey> keys = Utils::sorted(vInfo.keys());
|
const QList<ProKey> keys = Utils::sorted(vInfo.keys());
|
||||||
foreach (const ProKey &key, keys) {
|
for (const ProKey &key : keys) {
|
||||||
const QString &value = vInfo.value(key).toQString();
|
const QString &value = vInfo.value(key).toQString();
|
||||||
QString variableName = key.toQString();
|
QString variableName = key.toQString();
|
||||||
if (variableName != "QMAKE_MKSPECS"
|
if (variableName != "QMAKE_MKSPECS"
|
||||||
@@ -2281,7 +2281,7 @@ QtVersion *QtVersionFactory::createQtVersionFromQMakePath
|
|||||||
setup.platforms = evaluator.values("QMAKE_PLATFORM"); // It's a list in general.
|
setup.platforms = evaluator.values("QMAKE_PLATFORM"); // It's a list in general.
|
||||||
setup.isQnx = !evaluator.value("QNX_CPUDIR").isEmpty();
|
setup.isQnx = !evaluator.value("QNX_CPUDIR").isEmpty();
|
||||||
|
|
||||||
foreach (QtVersionFactory *factory, factories) {
|
for (QtVersionFactory *factory : factories) {
|
||||||
if (!factory->m_restrictionChecker || factory->m_restrictionChecker(setup)) {
|
if (!factory->m_restrictionChecker || factory->m_restrictionChecker(setup)) {
|
||||||
QtVersion *ver = factory->create();
|
QtVersion *ver = factory->create();
|
||||||
QTC_ASSERT(ver, continue);
|
QTC_ASSERT(ver, continue);
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ void ExampleSetModel::recreateModel(const QtVersions &qtVersions)
|
|||||||
extraManifestDirs.insert(set.manifestPath);
|
extraManifestDirs.insert(set.manifestPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (QtVersion *version, qtVersions) {
|
for (QtVersion *version : qtVersions) {
|
||||||
// sanitize away qt versions that have already been added through extra sets
|
// sanitize away qt versions that have already been added through extra sets
|
||||||
if (extraManifestDirs.contains(version->docsPath().toString())) {
|
if (extraManifestDirs.contains(version->docsPath().toString())) {
|
||||||
if (debugExamples()) {
|
if (debugExamples()) {
|
||||||
@@ -446,13 +446,13 @@ void ExamplesListModel::updateExamples()
|
|||||||
QString examplesInstallPath;
|
QString examplesInstallPath;
|
||||||
QString demosInstallPath;
|
QString demosInstallPath;
|
||||||
|
|
||||||
QStringList sources = m_exampleSetModel.exampleSources(&examplesInstallPath, &demosInstallPath);
|
const QStringList sources = m_exampleSetModel.exampleSources(&examplesInstallPath,
|
||||||
|
&demosInstallPath);
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
qDeleteAll(m_items);
|
qDeleteAll(m_items);
|
||||||
m_items.clear();
|
m_items.clear();
|
||||||
|
|
||||||
foreach (const QString &exampleSource, sources) {
|
for (const QString &exampleSource : sources) {
|
||||||
QFile exampleFile(exampleSource);
|
QFile exampleFile(exampleSource);
|
||||||
if (!exampleFile.open(QIODevice::ReadOnly)) {
|
if (!exampleFile.open(QIODevice::ReadOnly)) {
|
||||||
if (debugExamples())
|
if (debugExamples())
|
||||||
@@ -604,8 +604,9 @@ QStringList ExampleSetModel::exampleSources(QString *examplesInstallPath, QStrin
|
|||||||
examplesPath = exampleSet.examplesPath;
|
examplesPath = exampleSet.examplesPath;
|
||||||
demosPath = exampleSet.examplesPath;
|
demosPath = exampleSet.examplesPath;
|
||||||
} else if (currentType == ExampleSetModel::QtExampleSet) {
|
} else if (currentType == ExampleSetModel::QtExampleSet) {
|
||||||
int qtId = getQtId(m_selectedExampleSetIndex);
|
const int qtId = getQtId(m_selectedExampleSetIndex);
|
||||||
foreach (QtVersion *version, QtVersionManager::versions()) {
|
const QtVersions versions = QtVersionManager::versions();
|
||||||
|
for (QtVersion *version : versions) {
|
||||||
if (version->uniqueId() == qtId) {
|
if (version->uniqueId() == qtId) {
|
||||||
manifestScanPath = version->docsPath().toString();
|
manifestScanPath = version->docsPath().toString();
|
||||||
examplesPath = version->examplesPath().toString();
|
examplesPath = version->examplesPath().toString();
|
||||||
@@ -620,11 +621,12 @@ QStringList ExampleSetModel::exampleSources(QString *examplesInstallPath, QStrin
|
|||||||
const QStringList examplesPattern(QLatin1String("examples-manifest.xml"));
|
const QStringList examplesPattern(QLatin1String("examples-manifest.xml"));
|
||||||
const QStringList demosPattern(QLatin1String("demos-manifest.xml"));
|
const QStringList demosPattern(QLatin1String("demos-manifest.xml"));
|
||||||
QFileInfoList fis;
|
QFileInfoList fis;
|
||||||
foreach (QFileInfo subDir, dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
const QFileInfoList subDirs = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
for (QFileInfo subDir : subDirs) {
|
||||||
fis << QDir(subDir.absoluteFilePath()).entryInfoList(examplesPattern);
|
fis << QDir(subDir.absoluteFilePath()).entryInfoList(examplesPattern);
|
||||||
fis << QDir(subDir.absoluteFilePath()).entryInfoList(demosPattern);
|
fis << QDir(subDir.absoluteFilePath()).entryInfoList(demosPattern);
|
||||||
}
|
}
|
||||||
foreach (const QFileInfo &fi, fis)
|
for (const QFileInfo &fi : std::as_const(fis))
|
||||||
sources.append(fi.filePath());
|
sources.append(fi.filePath());
|
||||||
}
|
}
|
||||||
if (examplesInstallPath)
|
if (examplesInstallPath)
|
||||||
|
|||||||
@@ -414,7 +414,6 @@ void QtOptionsPageWidget::cleanUpQtVersions()
|
|||||||
if (toRemove.isEmpty())
|
if (toRemove.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
if (QMessageBox::warning(nullptr, Tr::tr("Remove Invalid Qt Versions"),
|
if (QMessageBox::warning(nullptr, Tr::tr("Remove Invalid Qt Versions"),
|
||||||
Tr::tr("Do you want to remove all invalid Qt Versions?<br>"
|
Tr::tr("Do you want to remove all invalid Qt Versions?<br>"
|
||||||
"<ul><li>%1</li></ul><br>"
|
"<ul><li>%1</li></ul><br>"
|
||||||
@@ -422,7 +421,7 @@ void QtOptionsPageWidget::cleanUpQtVersions()
|
|||||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
|
QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (QtVersionItem *item, toRemove)
|
for (QtVersionItem *item : std::as_const(toRemove))
|
||||||
m_model->destroyItem(item);
|
m_model->destroyItem(item);
|
||||||
|
|
||||||
updateCleanUpButton();
|
updateCleanUpButton();
|
||||||
@@ -531,8 +530,10 @@ QList<ToolChain*> QtOptionsPageWidget::toolChains(const QtVersion *version)
|
|||||||
return toolChains;
|
return toolChains;
|
||||||
|
|
||||||
QSet<QByteArray> ids;
|
QSet<QByteArray> ids;
|
||||||
foreach (const Abi &a, version->qtAbis()) {
|
const Abis abis = version->qtAbis();
|
||||||
foreach (ToolChain *tc, ToolChainManager::findToolChains(a)) {
|
for (const Abi &a : abis) {
|
||||||
|
const Toolchains tcList = ToolChainManager::findToolChains(a);
|
||||||
|
for (ToolChain *tc : tcList) {
|
||||||
if (ids.contains(tc->id()))
|
if (ids.contains(tc->id()))
|
||||||
continue;
|
continue;
|
||||||
ids.insert(tc->id());
|
ids.insert(tc->id());
|
||||||
@@ -591,11 +592,11 @@ void QtOptionsPageWidget::updateQtVersions(const QList<int> &additions, const QL
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Remove changed/removed items:
|
// Remove changed/removed items:
|
||||||
foreach (QtVersionItem *item, toRemove)
|
for (QtVersionItem *item : std::as_const(toRemove))
|
||||||
m_model->destroyItem(item);
|
m_model->destroyItem(item);
|
||||||
|
|
||||||
// Add changed/added items:
|
// Add changed/added items:
|
||||||
foreach (int a, toAdd) {
|
for (int a : std::as_const(toAdd)) {
|
||||||
QtVersion *version = QtVersionManager::version(a)->clone();
|
QtVersion *version = QtVersionManager::version(a)->clone();
|
||||||
auto *item = new QtVersionItem(version);
|
auto *item = new QtVersionItem(version);
|
||||||
|
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ void QtSupportPlugin::testQtProjectImporter_oneProject()
|
|||||||
|
|
||||||
qDeleteAll(testData);
|
qDeleteAll(testData);
|
||||||
|
|
||||||
foreach (Kit *k, toUnregisterLater)
|
for (Kit *k : std::as_const(toUnregisterLater))
|
||||||
KitManager::deregisterKit(k);
|
KitManager::deregisterKit(k);
|
||||||
|
|
||||||
// Delete kit templates:
|
// Delete kit templates:
|
||||||
|
|||||||
Reference in New Issue
Block a user