forked from qt-creator/qt-creator
ios: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: If29d2960692c42456967025d60e6d6d7ddd09928 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -120,10 +120,10 @@ void CreateSimulatorDialog::populateDeviceTypes(const QList<DeviceTypeInfo> &dev
|
|||||||
m_ui->deviceTypeCombo->insertSeparator(1);
|
m_ui->deviceTypeCombo->insertSeparator(1);
|
||||||
|
|
||||||
auto addItems = [this, deviceTypes](const QString &filter) {
|
auto addItems = [this, deviceTypes](const QString &filter) {
|
||||||
auto filteredTypes = Utils::filtered(deviceTypes, [filter](const DeviceTypeInfo &type){
|
const auto filteredTypes = Utils::filtered(deviceTypes, [filter](const DeviceTypeInfo &type){
|
||||||
return type.name.contains(filter, Qt::CaseInsensitive);
|
return type.name.contains(filter, Qt::CaseInsensitive);
|
||||||
});
|
});
|
||||||
foreach (auto type, filteredTypes) {
|
for (auto type : filteredTypes) {
|
||||||
m_ui->deviceTypeCombo->addItem(type.name, QVariant::fromValue<DeviceTypeInfo>(type));
|
m_ui->deviceTypeCombo->addItem(type.name, QVariant::fromValue<DeviceTypeInfo>(type));
|
||||||
}
|
}
|
||||||
return filteredTypes.count();
|
return filteredTypes.count();
|
||||||
@@ -156,10 +156,10 @@ void CreateSimulatorDialog::populateRuntimes(const DeviceTypeInfo &deviceType)
|
|||||||
m_ui->runtimeCombo->insertSeparator(1);
|
m_ui->runtimeCombo->insertSeparator(1);
|
||||||
|
|
||||||
auto addItems = [this](const QString &filter) {
|
auto addItems = [this](const QString &filter) {
|
||||||
auto filteredTypes = Utils::filtered(m_runtimes, [filter](const RuntimeInfo &runtime){
|
const auto filteredTypes = Utils::filtered(m_runtimes, [filter](const RuntimeInfo &runtime){
|
||||||
return runtime.name.contains(filter, Qt::CaseInsensitive);
|
return runtime.name.contains(filter, Qt::CaseInsensitive);
|
||||||
});
|
});
|
||||||
foreach (auto runtime, filteredTypes) {
|
for (auto runtime : filteredTypes) {
|
||||||
m_ui->runtimeCombo->addItem(runtime.name, QVariant::fromValue<RuntimeInfo>(runtime));
|
m_ui->runtimeCombo->addItem(runtime.name, QVariant::fromValue<RuntimeInfo>(runtime));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -271,7 +271,8 @@ void IosSigningSettingsWidget::populateDevelopmentTeams()
|
|||||||
// Populate Team id's
|
// Populate Team id's
|
||||||
m_signEntityCombo->clear();
|
m_signEntityCombo->clear();
|
||||||
m_signEntityCombo->addItem(IosQmakeBuildConfiguration::tr("Default"));
|
m_signEntityCombo->addItem(IosQmakeBuildConfiguration::tr("Default"));
|
||||||
foreach (auto team, IosConfigurations::developmentTeams()) {
|
const auto teams = IosConfigurations::developmentTeams();
|
||||||
|
for (auto team : teams) {
|
||||||
m_signEntityCombo->addItem(team->displayName());
|
m_signEntityCombo->addItem(team->displayName());
|
||||||
const int index = m_signEntityCombo->count() - 1;
|
const int index = m_signEntityCombo->count() - 1;
|
||||||
m_signEntityCombo->setItemData(index, team->identifier(), IdentifierRole);
|
m_signEntityCombo->setItemData(index, team->identifier(), IdentifierRole);
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ static QSet<Kit *> existingAutoDetectedIosKits()
|
|||||||
|
|
||||||
static void printKits(const QSet<Kit *> &kits)
|
static void printKits(const QSet<Kit *> &kits)
|
||||||
{
|
{
|
||||||
foreach (const Kit *kit, kits)
|
for (const Kit *kit : kits)
|
||||||
qCDebug(kitSetupLog) << " -" << kit->displayName();
|
qCDebug(kitSetupLog) << " -" << kit->displayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ void IosConfigurations::updateAutomaticKitList()
|
|||||||
existingKits.subtract(resultingKits);
|
existingKits.subtract(resultingKits);
|
||||||
qCDebug(kitSetupLog) << "Removing unused kits:";
|
qCDebug(kitSetupLog) << "Removing unused kits:";
|
||||||
printKits(existingKits);
|
printKits(existingKits);
|
||||||
foreach (Kit *kit, existingKits)
|
for (Kit *kit : qAsConst(existingKits))
|
||||||
KitManager::deregisterKit(kit);
|
KitManager::deregisterKit(kit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,7 +496,7 @@ void IosConfigurations::loadProvisioningData(bool notify)
|
|||||||
return teamInfo1.value(freeTeamTag).toInt() < teamInfo2.value(freeTeamTag).toInt();
|
return teamInfo1.value(freeTeamTag).toInt() < teamInfo2.value(freeTeamTag).toInt();
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (auto teamInfo, teams) {
|
for (auto teamInfo : qAsConst(teams)) {
|
||||||
auto team = std::make_shared<DevelopmentTeam>();
|
auto team = std::make_shared<DevelopmentTeam>();
|
||||||
team->m_name = teamInfo.value(teamNameTag).toString();
|
team->m_name = teamInfo.value(teamNameTag).toString();
|
||||||
team->m_email = teamInfo.value(emailTag).toString();
|
team->m_email = teamInfo.value(emailTag).toString();
|
||||||
@@ -507,7 +507,10 @@ void IosConfigurations::loadProvisioningData(bool notify)
|
|||||||
|
|
||||||
const QDir provisioningProflesDir(provisioningProfileDirPath);
|
const QDir provisioningProflesDir(provisioningProfileDirPath);
|
||||||
const QStringList filters = {"*.mobileprovision"};
|
const QStringList filters = {"*.mobileprovision"};
|
||||||
foreach (QFileInfo fileInfo, provisioningProflesDir.entryInfoList(filters, QDir::NoDotAndDotDot | QDir::Files)) {
|
const QList<QFileInfo> fileInfos = provisioningProflesDir.entryInfoList(filters,
|
||||||
|
QDir::NoDotAndDotDot
|
||||||
|
| QDir::Files);
|
||||||
|
for (const QFileInfo fileInfo : fileInfos) {
|
||||||
QDomDocument provisioningDoc;
|
QDomDocument provisioningDoc;
|
||||||
auto profile = std::make_shared<ProvisioningProfile>();
|
auto profile = std::make_shared<ProvisioningProfile>();
|
||||||
QString teamID;
|
QString teamID;
|
||||||
@@ -643,7 +646,7 @@ QDebug &operator<<(QDebug &stream, DevelopmentTeamPtr team)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(team, return stream);
|
QTC_ASSERT(team, return stream);
|
||||||
stream << team->displayName() << team->identifier() << team->isFreeProfile();
|
stream << team->displayName() << team->identifier() << team->isFreeProfile();
|
||||||
foreach (auto profile, team->m_profiles)
|
for (const auto profile : qAsConst(team->m_profiles))
|
||||||
stream << "Profile:" << profile;
|
stream << "Profile:" << profile;
|
||||||
return stream;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -532,7 +532,7 @@ IosDeviceManager::IosDeviceManager(QObject *parent) :
|
|||||||
|
|
||||||
void IosDeviceManager::updateUserModeDevices()
|
void IosDeviceManager::updateUserModeDevices()
|
||||||
{
|
{
|
||||||
foreach (const QString &uid, m_userModeDeviceIds)
|
for (const QString &uid : qAsConst(m_userModeDeviceIds))
|
||||||
updateInfo(uid);
|
updateInfo(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,7 +544,7 @@ IosDeviceManager *IosDeviceManager::instance()
|
|||||||
|
|
||||||
void IosDeviceManager::updateAvailableDevices(const QStringList &devices)
|
void IosDeviceManager::updateAvailableDevices(const QStringList &devices)
|
||||||
{
|
{
|
||||||
foreach (const QString &uid, devices)
|
for (const QString &uid : devices)
|
||||||
deviceConnected(uid);
|
deviceConnected(uid);
|
||||||
|
|
||||||
DeviceManager *devManager = DeviceManager::instance();
|
DeviceManager *devManager = DeviceManager::instance();
|
||||||
|
|||||||
@@ -375,7 +375,8 @@ void IosDeviceTypeAspect::updateValues()
|
|||||||
m_deviceTypeLabel->setVisible(showDeviceSelector);
|
m_deviceTypeLabel->setVisible(showDeviceSelector);
|
||||||
m_deviceTypeComboBox->setVisible(showDeviceSelector);
|
m_deviceTypeComboBox->setVisible(showDeviceSelector);
|
||||||
if (showDeviceSelector && m_deviceTypeModel.rowCount() == 0) {
|
if (showDeviceSelector && m_deviceTypeModel.rowCount() == 0) {
|
||||||
foreach (const SimulatorInfo &device, SimulatorControl::availableSimulators()) {
|
const QList<SimulatorInfo> devices = SimulatorControl::availableSimulators();
|
||||||
|
for (const SimulatorInfo &device : devices) {
|
||||||
QStandardItem *item = new QStandardItem(Internal::displayName(device));
|
QStandardItem *item = new QStandardItem(Internal::displayName(device));
|
||||||
QVariant v;
|
QVariant v;
|
||||||
v.setValue(device);
|
v.setValue(device);
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ void IosSettingsWidget::onStart()
|
|||||||
Utils::NormalMessageFormat);
|
Utils::NormalMessageFormat);
|
||||||
|
|
||||||
QList<QFuture<void>> futureList;
|
QList<QFuture<void>> futureList;
|
||||||
foreach (const SimulatorInfo &info, simulatorInfoList) {
|
for (const SimulatorInfo &info : simulatorInfoList) {
|
||||||
if (!info.isShutdown()) {
|
if (!info.isShutdown()) {
|
||||||
statusDialog->addMessage(tr("Cannot start simulator (%1, %2) in current state: %3")
|
statusDialog->addMessage(tr("Cannot start simulator (%1, %2) in current state: %3")
|
||||||
.arg(info.name).arg(info.runtimeName).arg(info.state),
|
.arg(info.name).arg(info.runtimeName).arg(info.state),
|
||||||
@@ -198,7 +198,7 @@ void IosSettingsWidget::onReset()
|
|||||||
statusDialog->addMessage(tr("Resetting contents and settings..."), Utils::NormalMessageFormat);
|
statusDialog->addMessage(tr("Resetting contents and settings..."), Utils::NormalMessageFormat);
|
||||||
|
|
||||||
QList<QFuture<void>> futureList;
|
QList<QFuture<void>> futureList;
|
||||||
foreach (const SimulatorInfo &info, simulatorInfoList) {
|
for (const SimulatorInfo &info : simulatorInfoList) {
|
||||||
futureList << QFuture<void>(Utils::onResultReady(
|
futureList << QFuture<void>(Utils::onResultReady(
|
||||||
SimulatorControl::resetSimulator(info.identifier),
|
SimulatorControl::resetSimulator(info.identifier),
|
||||||
std::bind(onSimOperation, info, statusDialog, tr("simulator reset"), _1)));
|
std::bind(onSimOperation, info, statusDialog, tr("simulator reset"), _1)));
|
||||||
@@ -255,7 +255,7 @@ void IosSettingsWidget::onDelete()
|
|||||||
statusDialog->addMessage(tr("Deleting %n simulator device(s)...", "", simulatorInfoList.count()),
|
statusDialog->addMessage(tr("Deleting %n simulator device(s)...", "", simulatorInfoList.count()),
|
||||||
Utils::NormalMessageFormat);
|
Utils::NormalMessageFormat);
|
||||||
QList<QFuture<void>> futureList;
|
QList<QFuture<void>> futureList;
|
||||||
foreach (const SimulatorInfo &info, simulatorInfoList) {
|
for (const SimulatorInfo &info : simulatorInfoList) {
|
||||||
futureList << QFuture<void>(Utils::onResultReady(
|
futureList << QFuture<void>(Utils::onResultReady(
|
||||||
SimulatorControl::deleteSimulator(info.identifier),
|
SimulatorControl::deleteSimulator(info.identifier),
|
||||||
std::bind(onSimOperation, info, statusDialog, tr("simulator delete"), _1)));
|
std::bind(onSimOperation, info, statusDialog, tr("simulator delete"), _1)));
|
||||||
@@ -286,7 +286,7 @@ void IosSettingsWidget::onScreenshot()
|
|||||||
statusDialog->addMessage(tr("Capturing screenshots from %n device(s)...", "",
|
statusDialog->addMessage(tr("Capturing screenshots from %n device(s)...", "",
|
||||||
simulatorInfoList.count()), Utils::NormalMessageFormat);
|
simulatorInfoList.count()), Utils::NormalMessageFormat);
|
||||||
QList<QFuture<void>> futureList;
|
QList<QFuture<void>> futureList;
|
||||||
foreach (const SimulatorInfo &info, simulatorInfoList) {
|
for (const SimulatorInfo &info : simulatorInfoList) {
|
||||||
futureList << QFuture<void>(Utils::onResultReady(
|
futureList << QFuture<void>(Utils::onResultReady(
|
||||||
SimulatorControl::takeSceenshot(info.identifier, generatePath(info)),
|
SimulatorControl::takeSceenshot(info.identifier, generatePath(info)),
|
||||||
std::bind(onSimOperation, info, statusDialog, tr("simulator screenshot"), _1)));
|
std::bind(onSimOperation, info, statusDialog, tr("simulator screenshot"), _1)));
|
||||||
|
|||||||
@@ -654,7 +654,8 @@ IosDeviceToolHandlerPrivate::IosDeviceToolHandlerPrivate(const IosDeviceType &de
|
|||||||
|
|
||||||
// Prepare & set process Environment.
|
// Prepare & set process Environment.
|
||||||
QProcessEnvironment env(QProcessEnvironment::systemEnvironment());
|
QProcessEnvironment env(QProcessEnvironment::systemEnvironment());
|
||||||
foreach (const QString &k, env.keys())
|
const QStringList keys = env.keys();
|
||||||
|
for (const QString &k : keys)
|
||||||
if (k.startsWith(QLatin1String("DYLD_")))
|
if (k.startsWith(QLatin1String("DYLD_")))
|
||||||
env.remove(k);
|
env.remove(k);
|
||||||
QStringList frameworkPaths;
|
QStringList frameworkPaths;
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ static QList<DeviceTypeInfo> getAvailableDeviceTypes()
|
|||||||
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
||||||
if (!doc.isNull()) {
|
if (!doc.isNull()) {
|
||||||
const QJsonArray runtimesArray = doc.object().value(deviceTypeTag).toArray();
|
const QJsonArray runtimesArray = doc.object().value(deviceTypeTag).toArray();
|
||||||
foreach (const QJsonValue deviceTypeValue, runtimesArray) {
|
for (const QJsonValue deviceTypeValue : runtimesArray) {
|
||||||
QJsonObject deviceTypeObject = deviceTypeValue.toObject();
|
QJsonObject deviceTypeObject = deviceTypeValue.toObject();
|
||||||
if (isAvailable(deviceTypeObject)) {
|
if (isAvailable(deviceTypeObject)) {
|
||||||
DeviceTypeInfo deviceType;
|
DeviceTypeInfo deviceType;
|
||||||
@@ -159,7 +159,7 @@ static QList<RuntimeInfo> getAvailableRuntimes()
|
|||||||
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
||||||
if (!doc.isNull()) {
|
if (!doc.isNull()) {
|
||||||
const QJsonArray runtimesArray = doc.object().value(runtimesTag).toArray();
|
const QJsonArray runtimesArray = doc.object().value(runtimesTag).toArray();
|
||||||
foreach (const QJsonValue runtimeValue, runtimesArray) {
|
for (const QJsonValue runtimeValue : runtimesArray) {
|
||||||
QJsonObject runtimeObject = runtimeValue.toObject();
|
QJsonObject runtimeObject = runtimeValue.toObject();
|
||||||
if (isAvailable(runtimeObject)) {
|
if (isAvailable(runtimeObject)) {
|
||||||
RuntimeInfo runtime;
|
RuntimeInfo runtime;
|
||||||
@@ -225,9 +225,10 @@ static QList<SimulatorInfo> getAllSimulatorDevices()
|
|||||||
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
QJsonDocument doc = QJsonDocument::fromJson(output.toUtf8());
|
||||||
if (!doc.isNull()) {
|
if (!doc.isNull()) {
|
||||||
const QJsonObject runtimeObject = doc.object().value(devicesTag).toObject();
|
const QJsonObject runtimeObject = doc.object().value(devicesTag).toObject();
|
||||||
foreach (const QString &runtime, runtimeObject.keys()) {
|
const QStringList keys = runtimeObject.keys();
|
||||||
|
for (const QString &runtime : keys) {
|
||||||
const QJsonArray devices = runtimeObject.value(runtime).toArray();
|
const QJsonArray devices = runtimeObject.value(runtime).toArray();
|
||||||
foreach (const QJsonValue deviceValue, devices) {
|
for (const QJsonValue deviceValue : devices) {
|
||||||
QJsonObject deviceObject = deviceValue.toObject();
|
QJsonObject deviceObject = deviceValue.toObject();
|
||||||
SimulatorInfo device;
|
SimulatorInfo device;
|
||||||
device.identifier = deviceObject.value(udidTag).toString();
|
device.identifier = deviceObject.value(udidTag).toString();
|
||||||
@@ -503,7 +504,7 @@ void launchApp(QFutureInterface<SimulatorControl::ResponseData> &fi,
|
|||||||
if (waitForDebugger)
|
if (waitForDebugger)
|
||||||
args.insert(1, "-w");
|
args.insert(1, "-w");
|
||||||
|
|
||||||
foreach (const QString extraArgument, extraArgs) {
|
for (const QString extraArgument : extraArgs) {
|
||||||
if (!extraArgument.trimmed().isEmpty())
|
if (!extraArgument.trimmed().isEmpty())
|
||||||
args << extraArgument;
|
args << extraArgument;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,13 +54,14 @@ SimulatorOperationDialog::SimulatorOperationDialog(QWidget *parent) :
|
|||||||
SimulatorOperationDialog::~SimulatorOperationDialog()
|
SimulatorOperationDialog::~SimulatorOperationDialog()
|
||||||
{
|
{
|
||||||
// Cancel all pending futures.
|
// Cancel all pending futures.
|
||||||
foreach (auto watcher, m_futureWatchList) {
|
const auto futureWatchList = m_futureWatchList;
|
||||||
|
for (auto watcher : futureWatchList) {
|
||||||
if (!watcher->isFinished())
|
if (!watcher->isFinished())
|
||||||
watcher->cancel();
|
watcher->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for futures to finish
|
// wait for futures to finish
|
||||||
foreach (auto watcher, m_futureWatchList) {
|
for (auto watcher : futureWatchList) {
|
||||||
if (!watcher->isFinished())
|
if (!watcher->isFinished())
|
||||||
watcher->waitForFinished();
|
watcher->waitForFinished();
|
||||||
delete watcher;
|
delete watcher;
|
||||||
@@ -72,7 +73,7 @@ SimulatorOperationDialog::~SimulatorOperationDialog()
|
|||||||
|
|
||||||
void SimulatorOperationDialog::addFutures(const QList<QFuture<void> > &futureList)
|
void SimulatorOperationDialog::addFutures(const QList<QFuture<void> > &futureList)
|
||||||
{
|
{
|
||||||
foreach (auto future, futureList) {
|
for (auto future : futureList) {
|
||||||
if (!future.isFinished() || !future.isCanceled()) {
|
if (!future.isFinished() || !future.isCanceled()) {
|
||||||
auto watcher = new QFutureWatcher<void>;
|
auto watcher = new QFutureWatcher<void>;
|
||||||
connect(watcher, &QFutureWatcher<void>::finished,
|
connect(watcher, &QFutureWatcher<void>::finished,
|
||||||
|
|||||||
Reference in New Issue
Block a user