forked from qt-creator/qt-creator
qmleditor: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: Ic6d667d97a9708963f7c3e21aa9598ffe0f9c7b7 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -352,7 +352,8 @@ bool Semantic::visit(FunctionCallExpressionAST *ast)
|
||||
_expr.type = funTy->returnType();
|
||||
} else if (const OverloadSet *overloads = id.type->asOverloadSetType()) {
|
||||
QVector<Function *> candidates;
|
||||
foreach (Function *f, overloads->functions()) {
|
||||
const QVector<Function *> functions = overloads->functions();
|
||||
for (Function *f : functions) {
|
||||
if (f->argumentCount() == actuals.size()) {
|
||||
int argc = 0;
|
||||
for (; argc < actuals.size(); ++argc) {
|
||||
|
@@ -308,7 +308,7 @@ bool ArrayType::isLessThan(const Type *other) const
|
||||
QList<Symbol *> Struct::members() const
|
||||
{
|
||||
QList<Symbol *> m;
|
||||
foreach (Symbol *s, _members) {
|
||||
for (Symbol *s : std::as_const(_members)) {
|
||||
if (! s->name().isEmpty())
|
||||
m.append(s);
|
||||
}
|
||||
@@ -322,7 +322,7 @@ void Struct::add(Symbol *member)
|
||||
|
||||
Symbol *Struct::find(const QString &name) const
|
||||
{
|
||||
foreach (Symbol *s, _members) {
|
||||
for (Symbol *s : std::as_const(_members)) {
|
||||
if (s->name() == name)
|
||||
return s;
|
||||
}
|
||||
@@ -411,7 +411,7 @@ bool Function::isLessThan(const Type *other) const
|
||||
QList<Symbol *> Function::members() const
|
||||
{
|
||||
QList<Symbol *> m;
|
||||
foreach (Argument *arg, _arguments) {
|
||||
for (Argument *arg : std::as_const(_arguments)) {
|
||||
if (! arg->name().isEmpty())
|
||||
m.append(arg);
|
||||
}
|
||||
@@ -420,7 +420,7 @@ QList<Symbol *> Function::members() const
|
||||
|
||||
Symbol *Function::find(const QString &name) const
|
||||
{
|
||||
foreach (Argument *arg, _arguments) {
|
||||
for (Argument *arg : std::as_const(_arguments)) {
|
||||
if (arg->name() == name)
|
||||
return arg;
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ void FakeMetaEnum::addToHash(QCryptographicHash &hash) const
|
||||
hash.addData(reinterpret_cast<const char *>(m_name.constData()), len * sizeof(QChar));
|
||||
len = m_keys.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const QString &key, m_keys) {
|
||||
for (const QString &key : std::as_const(m_keys)) {
|
||||
len = key.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(key.constData()), len * sizeof(QChar));
|
||||
@@ -129,14 +129,14 @@ void FakeMetaMethod::addToHash(QCryptographicHash &hash) const
|
||||
hash.addData(reinterpret_cast<const char *>(&m_revision), sizeof(m_revision));
|
||||
len = m_paramNames.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const QString &pName, m_paramNames) {
|
||||
for (const QString &pName : std::as_const(m_paramNames)) {
|
||||
len = pName.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(pName.constData()), len * sizeof(QChar));
|
||||
}
|
||||
len = m_paramTypes.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const QString &pType, m_paramTypes) {
|
||||
for (const QString &pType : std::as_const(m_paramTypes)) {
|
||||
len = pType.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(pType.constData()), len * sizeof(QChar));
|
||||
@@ -158,7 +158,7 @@ QString FakeMetaMethod::describe(int baseIndent) const
|
||||
res += QString::number(methodType());
|
||||
res += newLine;
|
||||
res += QLatin1String(" parameterNames:[");
|
||||
foreach (const QString &pName, parameterNames()) {
|
||||
for (const QString &pName : parameterNames()) {
|
||||
res += newLine;
|
||||
res += QLatin1String(" ");
|
||||
res += pName;
|
||||
@@ -166,7 +166,7 @@ QString FakeMetaMethod::describe(int baseIndent) const
|
||||
res += QLatin1Char(']');
|
||||
res += newLine;
|
||||
res += QLatin1String(" parameterTypes:[");
|
||||
foreach (const QString &pType, parameterTypes()) {
|
||||
for (const QString &pType : parameterTypes()) {
|
||||
res += newLine;
|
||||
res += QLatin1String(" ");
|
||||
res += pType;
|
||||
@@ -287,7 +287,7 @@ QList<FakeMetaObject::Export> FakeMetaObject::exports() const
|
||||
{ return m_exports; }
|
||||
FakeMetaObject::Export FakeMetaObject::exportInPackage(const QString &package) const
|
||||
{
|
||||
foreach (const Export &exp, m_exports) {
|
||||
for (const Export &exp : std::as_const(m_exports)) {
|
||||
if (exp.package == package)
|
||||
return exp;
|
||||
}
|
||||
@@ -369,7 +369,7 @@ QByteArray FakeMetaObject::calculateFingerprint() const
|
||||
{
|
||||
QStringList keys(m_enumNameToIndex.keys());
|
||||
keys.sort();
|
||||
foreach (const QString &key, keys) {
|
||||
for (const QString &key : std::as_const(keys)) {
|
||||
len = key.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(key.constData()), len * sizeof(QChar));
|
||||
@@ -380,16 +380,16 @@ QByteArray FakeMetaObject::calculateFingerprint() const
|
||||
}
|
||||
len = m_exports.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const Export &e, m_exports)
|
||||
for (const Export &e : std::as_const(m_exports))
|
||||
e.addToHash(hash); // normalize order?
|
||||
len = m_exports.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const FakeMetaMethod &m, m_methods)
|
||||
for (const FakeMetaMethod &m : std::as_const(m_methods))
|
||||
m.addToHash(hash); // normalize order?
|
||||
{
|
||||
QStringList keys(m_propNameToIdx.keys());
|
||||
keys.sort();
|
||||
foreach (const QString &key, keys) {
|
||||
for (const QString &key : std::as_const(keys)) {
|
||||
len = key.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(key.constData()), len * sizeof(QChar));
|
||||
@@ -488,7 +488,7 @@ QString FakeMetaObject::describe(bool printDetails, int baseIndent) const
|
||||
|
||||
res += newLine;
|
||||
res += QLatin1String("exports:[");
|
||||
foreach (const Export &e, exports()) {
|
||||
for (const Export &e : exports()) {
|
||||
res += newLine;
|
||||
res += QLatin1String(" ");
|
||||
res += e.describe(baseIndent + 2);
|
||||
|
@@ -21,7 +21,8 @@ void BaseToolsClient::recurseObjectIdList(const ObjectReference &ref,
|
||||
{
|
||||
debugIds << ref.debugId();
|
||||
objectIds << ref.idString();
|
||||
foreach (const ObjectReference &child, ref.children())
|
||||
const QList<ObjectReference> children = ref.children();
|
||||
for (const ObjectReference &child : children)
|
||||
recurseObjectIdList(child, debugIds, objectIds);
|
||||
}
|
||||
|
||||
|
@@ -56,7 +56,7 @@ void QmlToolsClient::messageReceived(const QByteArray &message)
|
||||
debugIds.removeAll(-1);
|
||||
|
||||
QStringList debugIdStrings;
|
||||
foreach (int debugId, debugIds) {
|
||||
for (int debugId : std::as_const(debugIds)) {
|
||||
debugIdStrings << QString::number(debugId);
|
||||
}
|
||||
log(LogReceive, type + ':' + event,
|
||||
|
@@ -189,7 +189,8 @@ ContextPaneWidget::~ContextPaneWidget()
|
||||
void ContextPaneWidget::activate(const QPoint &pos, const QPoint &alternative, const QPoint &alternative2, bool pinned)
|
||||
{
|
||||
//uncheck all color buttons
|
||||
foreach (ColorButton *colorButton, findChildren<ColorButton*>()) {
|
||||
const QList<ColorButton *> children = findChildren<ColorButton*>();
|
||||
for (ColorButton *colorButton : children) {
|
||||
colorButton->setChecked(false);
|
||||
}
|
||||
show();
|
||||
|
@@ -896,7 +896,9 @@ PreviewDialog::PreviewDialog(QWidget *parent) : DragWidget(parent)
|
||||
|
||||
connect(m_slider, &QSlider::valueChanged, this, &PreviewDialog::onSliderMoved);
|
||||
|
||||
foreach (QWidget *childWidget, findChildren<QWidget*>()) {
|
||||
|
||||
const QList<QWidget *> children = findChildren<QWidget*>();
|
||||
for (QWidget *childWidget : children) {
|
||||
childWidget->installEventFilter(wheelFilter);
|
||||
}
|
||||
}
|
||||
|
@@ -241,7 +241,8 @@ void ContextPaneWidgetRectangle::timerEvent(QTimerEvent *event)
|
||||
|
||||
QLinearGradient gradient = ui->gradientLine->gradient();
|
||||
QString str = QLatin1String("Gradient {\n");
|
||||
foreach (const QGradientStop &stop, gradient.stops()) {
|
||||
const QGradientStops stops = gradient.stops();
|
||||
for (const QGradientStop &stop : stops) {
|
||||
str += QLatin1String("GradientStop {\n");
|
||||
str += QLatin1String("position: ") + QString::number(stop.first, 'f', 2) + QLatin1String(";\n");
|
||||
str += QLatin1String("color: ") + QLatin1String("\"") + stop.second.name() + QLatin1String("\";\n");
|
||||
|
@@ -77,7 +77,8 @@ void GradientLine::readGradient()
|
||||
if (m_useGradient) {
|
||||
m_colorList.clear();
|
||||
m_stops.clear();
|
||||
foreach (const QGradientStop &stop, m_gradient.stops()) {
|
||||
const QGradientStops stops = m_gradient.stops();
|
||||
for (const QGradientStop &stop : stops) {
|
||||
m_stops << stop.first;
|
||||
m_colorList << stop.second;
|
||||
}
|
||||
|
Reference in New Issue
Block a user