aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-09-08 14:24:06 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-10-07 13:46:47 +0000
commitd9b6b259068a5c6d32db8c32b60ea4903587103b (patch)
tree23823d996e057e4e42bb4ea5f6eca28e9cacdf9a /src/qml/types
parentd83f4aca1ebca26f9025628a42eec5ed19cbf1eb (diff)
Qml types: replace 'foreach' with 'range for'
Not all, just instances with low risk. Change-Id: I30612a1debd83dfa01aa087799658cff254bc9fc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/types')
-rw-r--r--src/qml/types/qqmlconnections.cpp2
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp8
-rw-r--r--src/qml/types/qqmlinstantiator.cpp6
-rw-r--r--src/qml/types/qqmllistmodel.cpp4
-rw-r--r--src/qml/types/qqmlobjectmodel.cpp2
5 files changed, 12 insertions, 10 deletions
diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp
index 84782114ac..1e9e0149dc 100644
--- a/src/qml/types/qqmlconnections.cpp
+++ b/src/qml/types/qqmlconnections.cpp
@@ -204,7 +204,7 @@ void QQmlConnections::setEnabled(bool enabled)
d->enabled = enabled;
- foreach (QQmlBoundSignal *s, d->boundsignals)
+ for (QQmlBoundSignal *s : qAsConst(d->boundsignals))
s->setEnabled(d->enabled);
emit enabledChanged();
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 1ca51ea360..b323de2a9f 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1121,7 +1121,7 @@ void QQmlDelegateModelPrivate::itemsChanged(const QVector<Compositor::Change> &c
QVarLengthArray<QVector<QQmlChangeSet::Change>, Compositor::MaximumGroupCount> translatedChanges(m_groupCount);
- foreach (const Compositor::Change &change, changes) {
+ for (const Compositor::Change &change : changes) {
for (int i = 1; i < m_groupCount; ++i) {
if (change.inGroup(i)) {
translatedChanges[i].append(QQmlChangeSet::Change(change.index[i], change.count));
@@ -1170,7 +1170,7 @@ void QQmlDelegateModelPrivate::itemsInserted(
for (int i = 1; i < m_groupCount; ++i)
inserted[i] = 0;
- foreach (const Compositor::Insert &insert, inserts) {
+ for (const Compositor::Insert &insert : inserts) {
for (; cacheIndex < insert.cacheIndex; ++cacheIndex)
incrementIndexes(m_cache.at(cacheIndex), m_groupCount, inserted);
@@ -1262,7 +1262,7 @@ void QQmlDelegateModelPrivate::itemsRemoved(
for (int i = 1; i < m_groupCount; ++i)
removed[i] = 0;
- foreach (const Compositor::Remove &remove, removes) {
+ for (const Compositor::Remove &remove : removes) {
for (; cacheIndex < remove.cacheIndex; ++cacheIndex)
incrementIndexes(m_cache.at(cacheIndex), m_groupCount, removed);
@@ -1744,7 +1744,7 @@ void QQmlDelegateModelItemMetaType::initializePrototype()
int QQmlDelegateModelItemMetaType::parseGroups(const QStringList &groups) const
{
int groupFlags = 0;
- foreach (const QString &groupName, groups) {
+ for (const QString &groupName : groups) {
int index = groupNames.indexOf(groupName);
if (index != -1)
groupFlags |= 2 << index;
diff --git a/src/qml/types/qqmlinstantiator.cpp b/src/qml/types/qqmlinstantiator.cpp
index 0cec39790d..2de5875deb 100644
--- a/src/qml/types/qqmlinstantiator.cpp
+++ b/src/qml/types/qqmlinstantiator.cpp
@@ -155,7 +155,8 @@ void QQmlInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &changeSet, bo
int difference = 0;
QHash<int, QVector<QPointer<QObject> > > moved;
- foreach (const QQmlChangeSet::Change &remove, changeSet.removes()) {
+ const QVector<QQmlChangeSet::Change> &removes = changeSet.removes();
+ for (const QQmlChangeSet::Change &remove : removes) {
int index = qMin(remove.index, objects.count());
int count = qMin(remove.index + remove.count, objects.count()) - index;
if (remove.isMove()) {
@@ -174,7 +175,8 @@ void QQmlInstantiatorPrivate::_q_modelUpdated(const QQmlChangeSet &changeSet, bo
difference -= remove.count;
}
- foreach (const QQmlChangeSet::Change &insert, changeSet.inserts()) {
+ const QVector<QQmlChangeSet::Change> &inserts = changeSet.inserts();
+ for (const QQmlChangeSet::Change &insert : inserts) {
int index = qMin(insert.index, objects.count());
if (insert.isMove()) {
QVector<QPointer<QObject> > movedObjects = moved.value(insert.moveId);
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 56cc3d4c66..c27c6ac26d 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -2477,7 +2477,7 @@ void QQmlListModelParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit,
{
listElementTypeName = QString(); // unknown
- foreach (const QV4::CompiledData::Binding *binding, bindings) {
+ for (const QV4::CompiledData::Binding *binding : bindings) {
QString propName = qmlUnit->stringAt(binding->propertyNameIndex);
if (!propName.isEmpty()) { // isn't default property
error(binding, QQmlListModel::tr("ListModel: undefined property '%1'").arg(propName));
@@ -2498,7 +2498,7 @@ void QQmlListModelParser::applyBindings(QObject *obj, QV4::CompiledData::Compila
bool setRoles = false;
- foreach (const QV4::CompiledData::Binding *binding, bindings) {
+ for (const QV4::CompiledData::Binding *binding : bindings) {
if (binding->type != QV4::CompiledData::Binding::Type_Object)
continue;
setRoles |= applyProperty(qmlUnit, binding, rv->m_listModel, /*outter element index*/-1);
diff --git a/src/qml/types/qqmlobjectmodel.cpp b/src/qml/types/qqmlobjectmodel.cpp
index 8c8005fb69..695043b592 100644
--- a/src/qml/types/qqmlobjectmodel.cpp
+++ b/src/qml/types/qqmlobjectmodel.cpp
@@ -154,7 +154,7 @@ public:
void clear() {
Q_Q(QQmlObjectModel);
- foreach (const Item &child, children)
+ for (const Item &child : qAsConst(children))
emit q->destroyingItem(child.item);
remove(0, children.count());
}