diff --git a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp index 0de06fc3608..c2df77b16bc 100644 --- a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp @@ -181,9 +181,9 @@ QPointF MoveManipulator::findSnappingOffset(const QHash QMap verticalOffsetMap; QMap horizontalOffsetMap; - QHashIterator hashIterator(boundingRectHash); - while (hashIterator.hasNext()) { - hashIterator.next(); + for (auto hashIterator = boundingRectHash.cbegin(), end = boundingRectHash.cend(); + hashIterator != end; + ++hashIterator) { FormEditorItem *formEditorItem = hashIterator.key(); QRectF boundingRect = hashIterator.value(); @@ -230,10 +230,10 @@ QHash MoveManipulator::tanslatedBoundingRects(const QHa { QHash translatedBoundingRectHash; - QHashIterator hashIterator(boundingRectHash); - while (hashIterator.hasNext()) { + for (auto hashIterator = boundingRectHash.cbegin(), end = boundingRectHash.cend(); + hashIterator != end; + ++hashIterator) { QPointF alignedOffset(offsetVector); - hashIterator.next(); FormEditorItem *formEditorItem = hashIterator.key(); QRectF boundingRect = transform.mapRect(hashIterator.value()); diff --git a/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp b/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp index 55f80798d78..bc4c95232c0 100644 --- a/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp +++ b/src/plugins/qmldesigner/components/formeditor/resizeindicator.cpp @@ -42,19 +42,14 @@ ResizeIndicator::~ResizeIndicator() void ResizeIndicator::show() { - QHashIterator itemControllerIterator(m_itemControllerHash); - while (itemControllerIterator.hasNext()) { - ResizeController controller = itemControllerIterator.next().value(); + for (ResizeController controller : m_itemControllerHash) controller.show(); - } } + void ResizeIndicator::hide() { - QHashIterator itemControllerIterator(m_itemControllerHash); - while (itemControllerIterator.hasNext()) { - ResizeController controller = itemControllerIterator.next().value(); + for (ResizeController controller : m_itemControllerHash) controller.hide(); - } } void ResizeIndicator::clear() diff --git a/src/plugins/qmldesigner/components/formeditor/snapper.cpp b/src/plugins/qmldesigner/components/formeditor/snapper.cpp index eec5c3ab1ef..361a8a46b42 100644 --- a/src/plugins/qmldesigner/components/formeditor/snapper.cpp +++ b/src/plugins/qmldesigner/components/formeditor/snapper.cpp @@ -311,9 +311,9 @@ QList Snapper::findSnappingLines(const SnapLineMap &snappingLineMap, { QList lineList; - SnapLineMapIterator snappingLineIterator(snappingLineMap); - while (snappingLineIterator.hasNext()) { - snappingLineIterator.next(); + for (auto snappingLineIterator = snappingLineMap.cbegin(), end = snappingLineMap.cend(); + snappingLineIterator != end; + ++snappingLineIterator) { if (compareLines(snapLine, snappingLineIterator.key())) { // near distance snapping lines lineList += createSnapLine(orientation, @@ -339,9 +339,9 @@ QList Snapper::findSnappingOffsetLines(const SnapLineMap &snappingOffset { QList lineList; - SnapLineMapIterator snappingOffsetIterator(snappingOffsetMap); - while (snappingOffsetIterator.hasNext()) { - snappingOffsetIterator.next(); + for (auto snappingOffsetIterator = snappingOffsetMap.cbegin(), end = snappingOffsetMap.cend(); + snappingOffsetIterator != end; + ++snappingOffsetIterator) { const QRectF &formEditorItemRect(snappingOffsetIterator.value().first); double formEditorItemRectLowerLimit; @@ -377,9 +377,9 @@ double Snapper::snappedOffsetForLines(const SnapLineMap &snappingLineMap, { QMultiMap minimumSnappingLineMap; - SnapLineMapIterator snappingLineIterator(snappingLineMap); - while (snappingLineIterator.hasNext()) { - snappingLineIterator.next(); + for (auto snappingLineIterator = snappingLineMap.cbegin(), end = snappingLineMap.cend(); + snappingLineIterator != end; + ++snappingLineIterator) { double snapLine = snappingLineIterator.key(); double offset = value - snapLine; double distance = qAbs(offset); @@ -403,9 +403,9 @@ double Snapper::snappedOffsetForOffsetLines(const SnapLineMap &snappingOffsetMap { QMultiMap minimumSnappingLineMap; - SnapLineMapIterator snappingOffsetIterator(snappingOffsetMap); - while (snappingOffsetIterator.hasNext()) { - snappingOffsetIterator.next(); + for (auto snappingOffsetIterator = snappingOffsetMap.cbegin(), end = snappingOffsetMap.cend(); + snappingOffsetIterator != end; + ++snappingOffsetIterator) { double snapLine = snappingOffsetIterator.key(); const QRectF &formEditorItemRect(snappingOffsetIterator.value().first); double formEditorItemRectLowerLimit; @@ -492,13 +492,12 @@ static QList mergedHorizontalLines(const QList &lineList) }); QList lineWithTheSameY; - QListIterator sortedLineListIterator(sortedLineList); - while (sortedLineListIterator.hasNext()) { - QLineF line = sortedLineListIterator.next(); + for (int i = 0, n = sortedLineList.size(); i < n; ++i) { + QLineF line = sortedLineList.at(i); lineWithTheSameY.append(line); - if (sortedLineListIterator.hasNext()) { - QLineF nextLine = sortedLineListIterator.peekNext(); + if (i + 1 < n) { + QLineF nextLine = sortedLineList.at(i + 1); if (!qFuzzyCompare(line.y1(), nextLine.y1())) { mergedLineList.append(mergedHorizontalLine(lineWithTheSameY)); lineWithTheSameY.clear(); @@ -521,13 +520,12 @@ static QList mergedVerticalLines(const QList &lineList) }); QList lineWithTheSameX; - QListIterator sortedLineListIterator(sortedLineList); - while (sortedLineListIterator.hasNext()) { - QLineF line = sortedLineListIterator.next(); + for (int i = 0, n = sortedLineList.size(); i < n; ++i) { + QLineF line = sortedLineList.at(i); lineWithTheSameX.append(line); - if (sortedLineListIterator.hasNext()) { - QLineF nextLine = sortedLineListIterator.peekNext(); + if (i + 1 < n) { + QLineF nextLine = sortedLineList.at(i + 1); if (!qFuzzyCompare(line.x1(), nextLine.x1())) { mergedLineList.append(mergedVerticalLine(lineWithTheSameX)); lineWithTheSameX.clear(); @@ -565,9 +563,9 @@ static QmlItemNode findItemOnSnappingLine(const QmlItemNode &sourceQmlItemNode, else compareAnchorLineType = AnchorLineLeft; - SnapLineMapIterator snapLineIterator(snappingLines); - while (snapLineIterator.hasNext()) { - snapLineIterator.next(); + for (auto snapLineIterator = snappingLines.cbegin(), end = snappingLines.cend(); + snapLineIterator != end; + ++snapLineIterator) { double snapLine = snapLineIterator.key(); if (qAbs(snapLine - anchorLine ) < 1.0) { diff --git a/src/plugins/qmldesigner/components/formeditor/snappinglinecreator.h b/src/plugins/qmldesigner/components/formeditor/snappinglinecreator.h index aba0a52444d..032426629b0 100644 --- a/src/plugins/qmldesigner/components/formeditor/snappinglinecreator.h +++ b/src/plugins/qmldesigner/components/formeditor/snappinglinecreator.h @@ -32,7 +32,6 @@ namespace QmlDesigner { class FormEditorItem; using SnapLineMap = QMultiMap >; -using SnapLineMapIterator = QMapIterator >; class FormEditorItem; diff --git a/src/plugins/qmldesigner/components/pathtool/pathitem.cpp b/src/plugins/qmldesigner/components/pathtool/pathitem.cpp index f8e3b5549c3..602666e8951 100644 --- a/src/plugins/qmldesigner/components/pathtool/pathitem.cpp +++ b/src/plugins/qmldesigner/components/pathtool/pathitem.cpp @@ -104,9 +104,9 @@ void PathItem::writeCubicPath(const ModelNode &pathNode, const CubicSegment &cub void PathItem::writePathAttributes(const ModelNode &pathNode, const QMap &attributes) { - QMapIterator attributesIterator(attributes); - while (attributesIterator.hasNext()) { - attributesIterator.next(); + for (auto attributesIterator = attributes.cbegin(), end = attributes.cend(); + attributesIterator != end; + ++attributesIterator) { QList > propertyList; propertyList.append(PropertyPair("name", attributesIterator.key())); propertyList.append(PropertyPair("value", attributesIterator.value())); diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index c48bfedce1b..f316200dcc5 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -204,8 +204,8 @@ void NodeInstanceView::modelAboutToBeDetached(Model * model) void NodeInstanceView::handleCrash() { - int elaspsedTimeSinceLastCrash = m_lastCrashTime.restart(); - int forceRestartTime = 2000; + qint64 elaspsedTimeSinceLastCrash = m_lastCrashTime.restart(); + qint64 forceRestartTime = 2000; #ifdef QT_DEBUG forceRestartTime = 4000; #endif @@ -816,9 +816,10 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand() bindingPropertyList.append(node.bindingProperties()); if (node.isValid() && hasInstanceForModelNode(node)) { NodeInstance instance = instanceForModelNode(node); - QHashIterator auxiliaryIterator(node.auxiliaryData()); - while (auxiliaryIterator.hasNext()) { - auxiliaryIterator.next(); + const QHash aux = node.auxiliaryData(); + for (auto auxiliaryIterator = aux.cbegin(), end = aux.cend(); + auxiliaryIterator != end; + ++auxiliaryIterator) { PropertyValueContainer container(instance.instanceId(), auxiliaryIterator.key(), auxiliaryIterator.value(), TypeName()); auxiliaryContainerVector.append(container); } diff --git a/src/plugins/qmldesigner/designercore/model/model.cpp b/src/plugins/qmldesigner/designercore/model/model.cpp index 981524b3095..960ad32aed3 100644 --- a/src/plugins/qmldesigner/designercore/model/model.cpp +++ b/src/plugins/qmldesigner/designercore/model/model.cpp @@ -502,11 +502,8 @@ QMultiHash convertModelNodeInformationHash(const QMu { QMultiHash convertedModelNodeInformationHash; - QHashIterator hashIterator(informationChangeHash); - while (hashIterator.hasNext()) { - hashIterator.next(); - convertedModelNodeInformationHash.insert(ModelNode(hashIterator.key(), view), hashIterator.value()); - } + for (auto it = informationChangeHash.cbegin(), end = informationChangeHash.cend(); it != end; ++it) + convertedModelNodeInformationHash.insert(ModelNode(it.key(), view), it.value()); return convertedModelNodeInformationHash; } diff --git a/src/plugins/qmldesigner/designercore/model/modelnodepositionstorage.cpp b/src/plugins/qmldesigner/designercore/model/modelnodepositionstorage.cpp index 69a3849062b..0c7615c7d4c 100644 --- a/src/plugins/qmldesigner/designercore/model/modelnodepositionstorage.cpp +++ b/src/plugins/qmldesigner/designercore/model/modelnodepositionstorage.cpp @@ -37,9 +37,7 @@ void ModelNodePositionStorage::cleanupInvalidOffsets() { QHash validModelNodes; - QHashIterator iter(m_rewriterData); - while (iter.hasNext()) { - iter.next(); + for (auto iter = m_rewriterData.cbegin(), end = m_rewriterData.cend(); iter != end; ++iter) { const ModelNode modelNode = iter.key(); if (modelNode.isValid()) validModelNodes.insert(modelNode, iter.value()); diff --git a/src/plugins/qmldesigner/designercore/model/rewriteactioncompressor.cpp b/src/plugins/qmldesigner/designercore/model/rewriteactioncompressor.cpp index 3c111471a61..d84b088db85 100644 --- a/src/plugins/qmldesigner/designercore/model/rewriteactioncompressor.cpp +++ b/src/plugins/qmldesigner/designercore/model/rewriteactioncompressor.cpp @@ -67,10 +67,8 @@ void RewriteActionCompressor::compressImports(QList &actions) c QHash addedImports; QHash removedImports; - QMutableListIterator iter(actions); - iter.toBack(); - while (iter.hasPrevious()) { - RewriteAction *action = iter.previous(); + for (int i = actions.size(); --i >= 0; ) { + RewriteAction *action = actions.at(i); if (RemoveImportRewriteAction *removeImportAction = action->asRemoveImportRewriteAction()) { const Import import = removeImportAction->import(); @@ -113,10 +111,8 @@ void RewriteActionCompressor::compressRereparentActions(QList & QList actionsToRemove; QHash reparentedNodes; - QMutableListIterator iter(actions); - iter.toBack(); - while (iter.hasPrevious()) { - RewriteAction *action = iter.previous(); + for (int i = actions.size(); --i >= 0; ) { + RewriteAction *action = actions.at(i); if (ReparentNodeRewriteAction *reparentAction = action->asReparentNodeRewriteAction()) { const ModelNode reparentedNode = reparentAction->reparentedNode(); @@ -139,10 +135,9 @@ void RewriteActionCompressor::compressRereparentActions(QList & void RewriteActionCompressor::compressReparentIntoSamePropertyActions(QList &actions) const { QList actionsToRemove; - QMutableListIterator iter(actions); - iter.toBack(); - while (iter.hasPrevious()) { - RewriteAction *action = iter.previous(); + + for (int i = actions.size(); --i >= 0; ) { + RewriteAction *action = actions.at(i); if (ReparentNodeRewriteAction *reparentAction = action->asReparentNodeRewriteAction()) { if (reparentAction->targetProperty() == reparentAction->oldParentProperty()) @@ -161,10 +156,8 @@ void RewriteActionCompressor::compressAddEditRemoveNodeActions(QList actionsToRemove; QHash removedNodes; - QMutableListIterator iter(actions); - iter.toBack(); - while (iter.hasPrevious()) { - RewriteAction *action = iter.previous(); + for (int i = actions.size(); --i >= 0; ) { + RewriteAction *action = actions.at(i); if (RemoveNodeRewriteAction *removeNodeAction = action->asRemoveNodeRewriteAction()) { const ModelNode modelNode = removeNodeAction->node(); @@ -220,10 +213,8 @@ void RewriteActionCompressor::compressPropertyActions(QList &ac QHash changedProperties; QHash addedProperties; - QMutableListIterator iter(actions); - iter.toBack(); - while (iter.hasPrevious()) { - RewriteAction *action = iter.previous(); + for (int i = actions.size(); --i >= 0; ) { + RewriteAction *action = actions.at(i); if (RemovePropertyRewriteAction *removeAction = action->asRemovePropertyRewriteAction()) { const AbstractProperty property = removeAction->property(); @@ -271,10 +262,7 @@ void RewriteActionCompressor::compressAddEditActions(QList &act QSet addedNodes; QSet dirtyActions; - QMutableListIterator iter(actions); - while (iter.hasNext()) { - RewriteAction *action = iter.next(); - + for (RewriteAction *action : qAsConst(actions)) { if (action->asAddPropertyRewriteAction() || action->asChangePropertyRewriteAction()) { AbstractProperty property; ModelNode containedNode; @@ -343,10 +331,8 @@ void RewriteActionCompressor::compressAddReparentActions(QList QList actionsToRemove; QMap addedNodes; - QMutableListIterator iter(actions); - while (iter.hasNext()) { - RewriteAction *action = iter.next(); - + for (int i = 0, n = actions.size(); i < n; ++i) { + RewriteAction *action = actions.at(i); if (action->asAddPropertyRewriteAction() || action->asChangePropertyRewriteAction()) { ModelNode containedNode; @@ -377,7 +363,7 @@ void RewriteActionCompressor::compressAddReparentActions(QList changeAction->containedModelNode()); } - iter.setValue(replacementAction); + actions[i] = replacementAction; delete action; } } diff --git a/src/plugins/qmldesigner/documentmanager.cpp b/src/plugins/qmldesigner/documentmanager.cpp index d264f286cce..45fd4957590 100644 --- a/src/plugins/qmldesigner/documentmanager.cpp +++ b/src/plugins/qmldesigner/documentmanager.cpp @@ -96,9 +96,9 @@ static inline void applyProperties(ModelNode &node, const QHash propertyIterator(propertyHash); - while (propertyIterator.hasNext()) { - propertyIterator.next(); + for (auto propertyIterator = propertyHash.cbegin(), end = propertyHash.cend(); + propertyIterator != end; + ++propertyIterator) { const PropertyName propertyName = propertyIterator.key(); if (propertyName == "width" || propertyName == "height") { node.setAuxiliaryData(propertyIterator.key(), propertyIterator.value());