QmlDesigner: Remove foreach / Q_FOREACH usage in designercore

Task-number: QTCREATORBUG-27464
Change-Id: Ib1e693df7e3690b7cf3e6dc42e1d18a05a8f46d6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Artem Sokolovskii
2022-05-06 15:35:09 +02:00
parent 427c26d900
commit 40d2c283c2
13 changed files with 131 additions and 97 deletions

View File

@@ -40,7 +40,8 @@ FirstDefinitionFinder::FirstDefinitionFinder(const QString &text):
if (!ok) { if (!ok) {
qDebug() << text; qDebug() << text;
foreach (const QmlJS::DiagnosticMessage &message, m_doc->diagnosticMessages()) const QList<QmlJS::DiagnosticMessage> messages = m_doc->diagnosticMessages();
for (const QmlJS::DiagnosticMessage &message : messages)
qDebug() << message.message; qDebug() << message.message;
} }

View File

@@ -92,14 +92,14 @@ template <class ViewType>
void ForwardView<ViewType>::modelAttached(Model *model) void ForwardView<ViewType>::modelAttached(Model *model)
{ {
AbstractView::modelAttached(model); AbstractView::modelAttached(model);
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->modelAttached(model); view->modelAttached(model);
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::modelAboutToBeDetached(Model *model) void ForwardView<ViewType>::modelAboutToBeDetached(Model *model)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->modelAboutToBeDetached(model); view->modelAboutToBeDetached(model);
AbstractView::modelAboutToBeDetached(model); AbstractView::modelAboutToBeDetached(model);
@@ -108,35 +108,35 @@ void ForwardView<ViewType>::modelAboutToBeDetached(Model *model)
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::nodeCreated(const ModelNode &createdNode) void ForwardView<ViewType>::nodeCreated(const ModelNode &createdNode)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->nodeCreated(ModelNode(createdNode, view.data())); view->nodeCreated(ModelNode(createdNode, view.data()));
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::nodeAboutToBeRemoved(const ModelNode &removedNode) void ForwardView<ViewType>::nodeAboutToBeRemoved(const ModelNode &removedNode)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->nodeAboutToBeRemoved(ModelNode(removedNode, view.data())); view->nodeAboutToBeRemoved(ModelNode(removedNode, view.data()));
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange) void ForwardView<ViewType>::nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->nodeRemoved(ModelNode(removedNode, view.data()), NodeAbstractProperty(parentProperty, view.data()), propertyChange); view->nodeRemoved(ModelNode(removedNode, view.data()), NodeAbstractProperty(parentProperty, view.data()), propertyChange);
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, PropertyChangeFlags propertyChange) void ForwardView<ViewType>::nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, PropertyChangeFlags propertyChange)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->nodeReparented(ModelNode(node, view.data()), NodeAbstractProperty(newPropertyParent, view.data()), NodeAbstractProperty(oldPropertyParent, view.data()), propertyChange); view->nodeReparented(ModelNode(node, view.data()), NodeAbstractProperty(newPropertyParent, view.data()), NodeAbstractProperty(oldPropertyParent, view.data()), propertyChange);
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId) void ForwardView<ViewType>::nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->nodeIdChanged(ModelNode(node, view.data()), newId, oldId); view->nodeIdChanged(ModelNode(node, view.data()), newId, oldId);
} }
@@ -145,7 +145,7 @@ static QList<T> adjustedList(const QList<T>& oldList, AbstractView *view)
{ {
QList<T> newList; QList<T> newList;
foreach (const T &item, oldList) for (const T &item : oldList)
{ {
newList.append(T(item, view)); newList.append(T(item, view));
} }
@@ -156,41 +156,41 @@ static QList<T> adjustedList(const QList<T>& oldList, AbstractView *view)
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList) void ForwardView<ViewType>::propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->propertiesAboutToBeRemoved(adjustedList(propertyList, view.data())); view->propertiesAboutToBeRemoved(adjustedList(propertyList, view.data()));
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::propertiesRemoved(const QList<AbstractProperty>& propertyList) void ForwardView<ViewType>::propertiesRemoved(const QList<AbstractProperty>& propertyList)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->propertiesRemoved(adjustedList(propertyList, view.data())); view->propertiesRemoved(adjustedList(propertyList, view.data()));
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange) void ForwardView<ViewType>::variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags propertyChange)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->variantPropertiesChanged(adjustedList(propertyList, view.data()), propertyChange); view->variantPropertiesChanged(adjustedList(propertyList, view.data()), propertyChange);
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange) void ForwardView<ViewType>::bindingPropertiesChanged(const QList<BindingProperty>& propertyList, PropertyChangeFlags propertyChange)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->bindingPropertiesChanged(adjustedList(propertyList, view.data()), propertyChange); view->bindingPropertiesChanged(adjustedList(propertyList, view.data()), propertyChange);
} }
void ForwardView::signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &propertyList, AbstractView::PropertyChangeFlags propertyChange) void ForwardView::signalHandlerPropertiesChanged(const QVector<SignalHandlerProperty> &propertyList, AbstractView::PropertyChangeFlags propertyChange)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->signalHandlerPropertiesChanged(adjustedList(propertyList, view.data()), propertyChange); view->signalHandlerPropertiesChanged(adjustedList(propertyList, view.data()), propertyChange);
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) void ForwardView<ViewType>::rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->rootNodeTypeChanged(type, majorVersion, minorVersion); view->rootNodeTypeChanged(type, majorVersion, minorVersion);
} }
@@ -198,7 +198,7 @@ template <class ViewType>
void ForwardView<ViewType>::selectedNodesChanged(const QList<ModelNode> &selectedNodeList, void ForwardView<ViewType>::selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList) const QList<ModelNode> &lastSelectedNodeList)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->selectedNodesChanged(adjustedList(selectedNodeList, view.data()), adjustedList(lastSelectedNodeList, view.data())); view->selectedNodesChanged(adjustedList(selectedNodeList, view.data()), adjustedList(lastSelectedNodeList, view.data()));
} }
@@ -207,21 +207,21 @@ void ForwardView<ViewType>::fileUrlChanged(const QUrl &oldUrl, const QUrl &newUr
{ {
AbstractView::fileUrlChanged(oldUrl, newUrl); AbstractView::fileUrlChanged(oldUrl, newUrl);
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->fileUrlChanged(oldUrl, newUrl); view->fileUrlChanged(oldUrl, newUrl);
} }
template<class ViewType> template<class ViewType>
void ForwardView<ViewType>::nodeOrderChanged(const NodeListProperty &listProperty) void ForwardView<ViewType>::nodeOrderChanged(const NodeListProperty &listProperty)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->nodeOrderChanged(NodeListProperty(listProperty, view.data())); view->nodeOrderChanged(NodeListProperty(listProperty, view.data()));
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::importChanged(const QList<Import> &addedImports, const QList<Import> &removedImports) void ForwardView<ViewType>::importChanged(const QList<Import> &addedImports, const QList<Import> &removedImports)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->importChanged(addedImport, removedImport); view->importChanged(addedImport, removedImport);
} }
@@ -230,7 +230,7 @@ void ForwardView<ViewType>::importRemoved(const Import &import)
{ {
AbstractView::importRemoved(import); AbstractView::importRemoved(import);
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->importRemoved(import); view->importRemoved(import);
} }
@@ -239,14 +239,14 @@ void ForwardView<ViewType>::auxiliaryDataChanged(const ModelNode &node, const Pr
{ {
AbstractView::auxiliaryDataChanged(node, name, data); AbstractView::auxiliaryDataChanged(node, name, data);
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->auxiliaryDataChanged(ModelNode(node, view.data()), name, data); view->auxiliaryDataChanged(ModelNode(node, view.data()), name, data);
} }
template <class ViewType> template <class ViewType>
void ForwardView<ViewType>::scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList) void ForwardView<ViewType>::scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList)
{ {
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
view->scriptFunctionsChanged(node, scriptFunctionList); view->scriptFunctionsChanged(node, scriptFunctionList);
} }
@@ -267,7 +267,7 @@ QList<ViewType*> ForwardView<ViewType>::viewList() const
{ {
QList<ViewType*> newList; QList<ViewType*> newList;
foreach (const ViewTypePointer &view, m_targetViewList) for (const ViewTypePointer &view : qAsConst(m_targetViewList))
newList.append(view.data()); newList.append(view.data());
return newList; return newList;

View File

@@ -174,7 +174,8 @@ QString NodeInstanceServerProxy::qrcMappingString() const
using StringPair = QPair<QString, QString>; using StringPair = QPair<QString, QString>;
foreach (const StringPair &pair, rewriterView->qrcMapping()) { const QSet<QPair<QString, QString>> &pairs = rewriterView->qrcMapping();
for (const StringPair &pair : pairs) {
if (!mappingString.isEmpty()) if (!mappingString.isEmpty())
mappingString.append(QLatin1String(";")); mappingString.append(QLatin1String(";"));
mappingString.append(pair.first); mappingString.append(pair.first);

View File

@@ -482,7 +482,7 @@ void NodeInstanceView::propertiesAboutToBeRemoved(const QList<AbstractProperty>&
QList<ModelNode> nodeList; QList<ModelNode> nodeList;
QList<AbstractProperty> nonNodePropertyList; QList<AbstractProperty> nonNodePropertyList;
foreach (const AbstractProperty &property, propertyList) { for (const AbstractProperty &property : propertyList) {
if (property.isNodeAbstractProperty()) if (property.isNodeAbstractProperty())
nodeList.append(property.toNodeAbstractProperty().allSubNodes()); nodeList.append(property.toNodeAbstractProperty().allSubNodes());
else else
@@ -497,7 +497,7 @@ void NodeInstanceView::propertiesAboutToBeRemoved(const QList<AbstractProperty>&
m_nodeInstanceServer->removeSharedMemory(createRemoveSharedMemoryCommand("Image", nodeList)); m_nodeInstanceServer->removeSharedMemory(createRemoveSharedMemoryCommand("Image", nodeList));
m_nodeInstanceServer->removeProperties(createRemovePropertiesCommand(nonNodePropertyList)); m_nodeInstanceServer->removeProperties(createRemovePropertiesCommand(nonNodePropertyList));
foreach (const AbstractProperty &property, propertyList) { for (const AbstractProperty &property : propertyList) {
const PropertyName &name = property.name(); const PropertyName &name = property.name();
if (name == "anchors.fill") { if (name == "anchors.fill") {
resetHorizontalAnchors(property.parentModelNode()); resetHorizontalAnchors(property.parentModelNode());
@@ -525,13 +525,14 @@ void NodeInstanceView::propertiesAboutToBeRemoved(const QList<AbstractProperty>&
} }
} }
foreach (const ModelNode &node, nodeList) for (const ModelNode &node : qAsConst(nodeList))
removeInstanceNodeRelationship(node); removeInstanceNodeRelationship(node);
} }
void NodeInstanceView::removeInstanceAndSubInstances(const ModelNode &node) void NodeInstanceView::removeInstanceAndSubInstances(const ModelNode &node)
{ {
foreach (const ModelNode &subNode, node.allSubModelNodes()) { const QList<ModelNode> subNodes = node.allSubModelNodes();
for (const ModelNode &subNode : subNodes) {
if (hasInstanceForModelNode(subNode)) if (hasInstanceForModelNode(subNode))
removeInstanceNodeRelationship(subNode); removeInstanceNodeRelationship(subNode);
} }
@@ -636,7 +637,8 @@ void NodeInstanceView::nodeOrderChanged(const NodeListProperty &listProperty)
if (hasInstanceForModelNode(containerNode)) if (hasInstanceForModelNode(containerNode))
containerInstanceId = instanceForModelNode(containerNode).instanceId(); containerInstanceId = instanceForModelNode(containerNode).instanceId();
foreach (const ModelNode &node, listProperty.toModelNodeList()) { const QList<ModelNode> nodes = listProperty.toModelNodeList();
for (const ModelNode &node : nodes) {
qint32 instanceId = -1; qint32 instanceId = -1;
if (hasInstanceForModelNode(node)) { if (hasInstanceForModelNode(node)) {
instanceId = instanceForModelNode(node).instanceId(); instanceId = instanceForModelNode(node).instanceId();
@@ -848,11 +850,11 @@ NodeInstance NodeInstanceView::activeStateInstance() const
void NodeInstanceView::updateChildren(const NodeAbstractProperty &newPropertyParent) void NodeInstanceView::updateChildren(const NodeAbstractProperty &newPropertyParent)
{ {
QVector<ModelNode> childNodeVector = newPropertyParent.directSubNodes().toVector(); const QVector<ModelNode> childNodeVector = newPropertyParent.directSubNodes().toVector();
qint32 parentInstanceId = newPropertyParent.parentModelNode().internalId(); qint32 parentInstanceId = newPropertyParent.parentModelNode().internalId();
foreach (const ModelNode &childNode, childNodeVector) { for (const ModelNode &childNode : childNodeVector) {
qint32 instanceId = childNode.internalId(); qint32 instanceId = childNode.internalId();
if (hasInstanceForId(instanceId)) { if (hasInstanceForId(instanceId)) {
NodeInstance instance = instanceForId(instanceId); NodeInstance instance = instanceForId(instanceId);
@@ -882,7 +884,7 @@ void NodeInstanceView::updatePosition(const QList<VariantProperty> &propertyList
{ {
QMultiHash<ModelNode, InformationName> informationChangeHash; QMultiHash<ModelNode, InformationName> informationChangeHash;
foreach (const VariantProperty &variantProperty, propertyList) { for (const VariantProperty &variantProperty : propertyList) {
if (variantProperty.name() == "x") { if (variantProperty.name() == "x") {
const ModelNode modelNode = variantProperty.parentModelNode(); const ModelNode modelNode = variantProperty.parentModelNode();
if (!currentState().isBaseState() && QmlPropertyChanges::isValidQmlPropertyChanges(modelNode)) { if (!currentState().isBaseState() && QmlPropertyChanges::isValidQmlPropertyChanges(modelNode)) {
@@ -957,7 +959,8 @@ void NodeInstanceView::removeRecursiveChildRelationship(const ModelNode &removed
// instanceForNode(removedNode).setId(QString()); // instanceForNode(removedNode).setId(QString());
// } // }
foreach (const ModelNode &childNode, removedNode.directSubModelNodes()) const QList<ModelNode> nodes = removedNode.directSubModelNodes();
for (const ModelNode &childNode : nodes)
removeRecursiveChildRelationship(childNode); removeRecursiveChildRelationship(childNode);
removeInstanceNodeRelationship(removedNode); removeInstanceNodeRelationship(removedNode);
@@ -974,7 +977,7 @@ QRectF NodeInstanceView::sceneRect() const
QList<ModelNode> filterNodesForSkipItems(const QList<ModelNode> &nodeList) QList<ModelNode> filterNodesForSkipItems(const QList<ModelNode> &nodeList)
{ {
QList<ModelNode> filteredNodeList; QList<ModelNode> filteredNodeList;
foreach (const ModelNode &node, nodeList) { for (const ModelNode &node : nodeList) {
if (isSkippedNode(node)) if (isSkippedNode(node))
continue; continue;
@@ -1169,7 +1172,7 @@ ClearSceneCommand NodeInstanceView::createClearSceneCommand() const
CompleteComponentCommand NodeInstanceView::createComponentCompleteCommand(const QList<NodeInstance> &instanceList) const CompleteComponentCommand NodeInstanceView::createComponentCompleteCommand(const QList<NodeInstance> &instanceList) const
{ {
QVector<qint32> containerList; QVector<qint32> containerList;
foreach (const NodeInstance &instance, instanceList) { for (const NodeInstance &instance : instanceList) {
if (instance.instanceId() >= 0) if (instance.instanceId() >= 0)
containerList.append(instance.instanceId()); containerList.append(instance.instanceId());
} }
@@ -1180,7 +1183,7 @@ CompleteComponentCommand NodeInstanceView::createComponentCompleteCommand(const
ComponentCompletedCommand NodeInstanceView::createComponentCompletedCommand(const QList<NodeInstance> &instanceList) const ComponentCompletedCommand NodeInstanceView::createComponentCompletedCommand(const QList<NodeInstance> &instanceList) const
{ {
QVector<qint32> containerList; QVector<qint32> containerList;
foreach (const NodeInstance &instance, instanceList) { for (const NodeInstance &instance : instanceList) {
if (instance.instanceId() >= 0) if (instance.instanceId() >= 0)
containerList.append(instance.instanceId()); containerList.append(instance.instanceId());
} }
@@ -1191,7 +1194,7 @@ ComponentCompletedCommand NodeInstanceView::createComponentCompletedCommand(cons
CreateInstancesCommand NodeInstanceView::createCreateInstancesCommand(const QList<NodeInstance> &instanceList) const CreateInstancesCommand NodeInstanceView::createCreateInstancesCommand(const QList<NodeInstance> &instanceList) const
{ {
QVector<InstanceContainer> containerList; QVector<InstanceContainer> containerList;
foreach (const NodeInstance &instance, instanceList) { for (const NodeInstance &instance : instanceList) {
InstanceContainer::NodeSourceType nodeSourceType = static_cast<InstanceContainer::NodeSourceType>(instance.modelNode().nodeSourceType()); InstanceContainer::NodeSourceType nodeSourceType = static_cast<InstanceContainer::NodeSourceType>(instance.modelNode().nodeSourceType());
InstanceContainer::NodeMetaType nodeMetaType = InstanceContainer::ObjectMetaType; InstanceContainer::NodeMetaType nodeMetaType = InstanceContainer::ObjectMetaType;
@@ -1221,7 +1224,7 @@ CreateInstancesCommand NodeInstanceView::createCreateInstancesCommand(const QLis
ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const QList<NodeInstance> &instanceList) const ReparentInstancesCommand NodeInstanceView::createReparentInstancesCommand(const QList<NodeInstance> &instanceList) const
{ {
QVector<ReparentContainer> containerList; QVector<ReparentContainer> containerList;
foreach (const NodeInstance &instance, instanceList) { for (const NodeInstance &instance : instanceList) {
if (instance.modelNode().hasParentProperty()) { if (instance.modelNode().hasParentProperty()) {
NodeAbstractProperty parentProperty = instance.modelNode().parentProperty(); NodeAbstractProperty parentProperty = instance.modelNode().parentProperty();
ReparentContainer container(instance.instanceId(), -1, PropertyName(), instanceForModelNode(parentProperty.parentModelNode()).instanceId(), parentProperty.name()); ReparentContainer container(instance.instanceId(), -1, PropertyName(), instanceForModelNode(parentProperty.parentModelNode()).instanceId(), parentProperty.name());
@@ -1265,7 +1268,7 @@ ChangeValuesCommand NodeInstanceView::createChangeValueCommand(const QList<Varia
const bool reflectionFlag = m_puppetTransaction.isValid() && (!currentTimeline().isValid() || !currentTimeline().isRecording()); const bool reflectionFlag = m_puppetTransaction.isValid() && (!currentTimeline().isValid() || !currentTimeline().isRecording());
foreach (const VariantProperty &property, propertyList) { for (const VariantProperty &property : propertyList) {
ModelNode node = property.parentModelNode(); ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForModelNode(node)) { if (node.isValid() && hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node); NodeInstance instance = instanceForModelNode(node);
@@ -1315,7 +1318,7 @@ ChangeIdsCommand NodeInstanceView::createChangeIdsCommand(const QList<NodeInstan
RemoveInstancesCommand NodeInstanceView::createRemoveInstancesCommand(const QList<ModelNode> &nodeList) const RemoveInstancesCommand NodeInstanceView::createRemoveInstancesCommand(const QList<ModelNode> &nodeList) const
{ {
QVector<qint32> idList; QVector<qint32> idList;
foreach (const ModelNode &node, nodeList) { for (const ModelNode &node : nodeList) {
if (node.isValid() && hasInstanceForModelNode(node)) { if (node.isValid() && hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node); NodeInstance instance = instanceForModelNode(node);
@@ -1330,7 +1333,7 @@ RemoveInstancesCommand NodeInstanceView::createRemoveInstancesCommand(const QLis
ChangeSelectionCommand NodeInstanceView::createChangeSelectionCommand(const QList<ModelNode> &nodeList) const ChangeSelectionCommand NodeInstanceView::createChangeSelectionCommand(const QList<ModelNode> &nodeList) const
{ {
QVector<qint32> idList; QVector<qint32> idList;
foreach (const ModelNode &node, nodeList) { for (const ModelNode &node : nodeList) {
if (node.isValid() && hasInstanceForModelNode(node)) { if (node.isValid() && hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node); NodeInstance instance = instanceForModelNode(node);
@@ -1356,7 +1359,7 @@ RemovePropertiesCommand NodeInstanceView::createRemovePropertiesCommand(const QL
{ {
QVector<PropertyAbstractContainer> containerList; QVector<PropertyAbstractContainer> containerList;
foreach (const AbstractProperty &property, propertyList) { for (const AbstractProperty &property : propertyList) {
ModelNode node = property.parentModelNode(); ModelNode node = property.parentModelNode();
if (node.isValid() && hasInstanceForModelNode(node)) { if (node.isValid() && hasInstanceForModelNode(node)) {
NodeInstance instance = instanceForModelNode(node); NodeInstance instance = instanceForModelNode(node);
@@ -1378,7 +1381,7 @@ RemoveSharedMemoryCommand NodeInstanceView::createRemoveSharedMemoryCommand(cons
{ {
QVector<qint32> keyNumberVector; QVector<qint32> keyNumberVector;
foreach (const ModelNode &modelNode, nodeList) for (const ModelNode &modelNode : nodeList)
keyNumberVector.append(modelNode.internalId()); keyNumberVector.append(modelNode.internalId());
return RemoveSharedMemoryCommand(sharedMemoryTypeName, keyNumberVector); return RemoveSharedMemoryCommand(sharedMemoryTypeName, keyNumberVector);
@@ -1391,7 +1394,8 @@ void NodeInstanceView::valuesChanged(const ValuesChangedCommand &command)
QList<QPair<ModelNode, PropertyName> > valuePropertyChangeList; QList<QPair<ModelNode, PropertyName> > valuePropertyChangeList;
foreach (const PropertyValueContainer &container, command.valueChanges()) { const QVector<PropertyValueContainer> containers = command.valueChanges();
for (const PropertyValueContainer &container : containers) {
if (hasInstanceForId(container.instanceId())) { if (hasInstanceForId(container.instanceId())) {
NodeInstance instance = instanceForId(container.instanceId()); NodeInstance instance = instanceForId(container.instanceId());
if (instance.isValid()) { if (instance.isValid()) {
@@ -1439,7 +1443,8 @@ void NodeInstanceView::pixmapChanged(const PixmapChangedCommand &command)
QSet<ModelNode> renderImageChangeSet; QSet<ModelNode> renderImageChangeSet;
foreach (const ImageContainer &container, command.images()) { const QVector<ImageContainer> containers = command.images();
for (const ImageContainer &container : containers) {
if (hasInstanceForId(container.instanceId())) { if (hasInstanceForId(container.instanceId())) {
NodeInstance instance = instanceForId(container.instanceId()); NodeInstance instance = instanceForId(container.instanceId());
if (instance.isValid()) { if (instance.isValid()) {
@@ -1459,7 +1464,7 @@ QMultiHash<ModelNode, InformationName> NodeInstanceView::informationChanged(cons
{ {
QMultiHash<ModelNode, InformationName> informationChangeHash; QMultiHash<ModelNode, InformationName> informationChangeHash;
foreach (const InformationContainer &container, containerVector) { for (const InformationContainer &container : containerVector) {
if (hasInstanceForId(container.instanceId())) { if (hasInstanceForId(container.instanceId())) {
NodeInstance instance = instanceForId(container.instanceId()); NodeInstance instance = instanceForId(container.instanceId());
if (instance.isValid()) { if (instance.isValid()) {
@@ -1517,7 +1522,8 @@ void NodeInstanceView::statePreviewImagesChanged(const StatePreviewImageChangedC
QVector<ModelNode> previewImageChangeVector; QVector<ModelNode> previewImageChangeVector;
foreach (const ImageContainer &container, command.previews()) { const QVector<ImageContainer> containers = command.previews();
for (const ImageContainer &container : containers) {
if (container.keyNumber() == -1) { if (container.keyNumber() == -1) {
m_baseStatePreviewImage = container.image(); m_baseStatePreviewImage = container.image();
if (!container.image().isNull()) if (!container.image().isNull())
@@ -1541,7 +1547,8 @@ void NodeInstanceView::componentCompleted(const ComponentCompletedCommand &comma
QVector<ModelNode> nodeVector; QVector<ModelNode> nodeVector;
foreach (const qint32 &instanceId, command.instances()) { const QVector<qint32> instances = command.instances();
for (const qint32 &instanceId : instances) {
if (hasModelNodeForInternalId(instanceId)) if (hasModelNodeForInternalId(instanceId))
nodeVector.append(modelNodeForInternalId(instanceId)); nodeVector.append(modelNodeForInternalId(instanceId));
} }
@@ -1559,7 +1566,8 @@ void NodeInstanceView::childrenChanged(const ChildrenChangedCommand &command)
QVector<ModelNode> childNodeVector; QVector<ModelNode> childNodeVector;
foreach (qint32 instanceId, command.childrenInstances()) { const QVector<qint32> instances = command.childrenInstances();
for (const qint32 &instanceId : instances) {
if (hasInstanceForId(instanceId)) { if (hasInstanceForId(instanceId)) {
NodeInstance instance = instanceForId(instanceId); NodeInstance instance = instanceForId(instanceId);
if (instance.parentId() == -1 || !instance.directUpdates()) if (instance.parentId() == -1 || !instance.directUpdates())
@@ -1584,7 +1592,8 @@ void NodeInstanceView::token(const TokenCommand &command)
QVector<ModelNode> nodeVector; QVector<ModelNode> nodeVector;
foreach (const qint32 &instanceId, command.instances()) { const QVector<qint32> instances = command.instances();
for (const qint32 &instanceId : instances) {
if (hasModelNodeForInternalId(instanceId)) if (hasModelNodeForInternalId(instanceId))
nodeVector.append(modelNodeForInternalId(instanceId)); nodeVector.append(modelNodeForInternalId(instanceId));
} }
@@ -1599,7 +1608,8 @@ void NodeInstanceView::debugOutput(const DebugOutputCommand & command)
emitDocumentMessage(command.text()); emitDocumentMessage(command.text());
} else { } else {
QVector<qint32> instanceIdsWithChangedErrors; QVector<qint32> instanceIdsWithChangedErrors;
foreach (qint32 instanceId, command.instanceIds()) { const QVector<qint32> instanceIds = command.instanceIds();
for (const qint32 &instanceId : instanceIds) {
NodeInstance instance = instanceForId(instanceId); NodeInstance instance = instanceForId(instanceId);
if (instance.isValid()) { if (instance.isValid()) {
if (instance.setError(command.text())) if (instance.setError(command.text()))
@@ -1615,7 +1625,7 @@ void NodeInstanceView::debugOutput(const DebugOutputCommand & command)
void NodeInstanceView::sendToken(const QString &token, int number, const QVector<ModelNode> &nodeVector) void NodeInstanceView::sendToken(const QString &token, int number, const QVector<ModelNode> &nodeVector)
{ {
QVector<qint32> instanceIdVector; QVector<qint32> instanceIdVector;
foreach (const ModelNode &node, nodeVector) for (const ModelNode &node : nodeVector)
instanceIdVector.append(node.internalId()); instanceIdVector.append(node.internalId());
m_nodeInstanceServer->token(TokenCommand(token, number, instanceIdVector)); m_nodeInstanceServer->token(TokenCommand(token, number, instanceIdVector));
@@ -1624,7 +1634,8 @@ void NodeInstanceView::sendToken(const QString &token, int number, const QVector
void NodeInstanceView::selectionChanged(const ChangeSelectionCommand &command) void NodeInstanceView::selectionChanged(const ChangeSelectionCommand &command)
{ {
clearSelectedModelNodes(); clearSelectedModelNodes();
foreach (const qint32 &instanceId, command.instanceIds()) { const QVector<qint32> instanceIds = command.instanceIds();
for (const qint32 &instanceId : instanceIds) {
if (hasModelNodeForInternalId(instanceId)) if (hasModelNodeForInternalId(instanceId))
selectModelNode(modelNodeForInternalId(instanceId)); selectModelNode(modelNodeForInternalId(instanceId));
} }

View File

@@ -132,8 +132,9 @@ QDateTime PuppetCreator::puppetSourceLastModified() const
}; };
QDateTime lastModified; QDateTime lastModified;
foreach (const QString directoryPath, sourceDirectoryPaths) { for (const QString &directoryPath : sourceDirectoryPaths) {
foreach (const QFileInfo fileEntry, QDir(directoryPath).entryInfoList()) { const QFileInfoList fileEntrys = QDir(directoryPath).entryInfoList();
for (const QFileInfo &fileEntry : fileEntrys) {
const QDateTime filePathLastModified = fileEntry.lastModified(); const QDateTime filePathLastModified = fileEntry.lastModified();
if (lastModified < filePathLastModified) if (lastModified < filePathLastModified)
lastModified = filePathLastModified; lastModified = filePathLastModified;

View File

@@ -289,7 +289,7 @@ QList<ItemLibraryEntry> ItemLibraryInfo::entriesForType(const QByteArray &typeNa
{ {
QList<ItemLibraryEntry> entries; QList<ItemLibraryEntry> entries;
foreach (const ItemLibraryEntry &entry, m_nameToEntryHash) { for (const ItemLibraryEntry &entry : qAsConst(m_nameToEntryHash)) {
if (entry.typeName() == typeName) if (entry.typeName() == typeName)
entries += entry; entries += entry;
} }
@@ -315,7 +315,7 @@ static inline QString keyForEntry(const ItemLibraryEntry &entry)
void ItemLibraryInfo::addEntries(const QList<ItemLibraryEntry> &entries, bool overwriteDuplicate) void ItemLibraryInfo::addEntries(const QList<ItemLibraryEntry> &entries, bool overwriteDuplicate)
{ {
foreach (const ItemLibraryEntry &entry, entries) { for (const ItemLibraryEntry &entry : entries) {
const QString key = keyForEntry(entry); const QString key = keyForEntry(entry);
if (!overwriteDuplicate && m_nameToEntryHash.contains(key)) if (!overwriteDuplicate && m_nameToEntryHash.contains(key))
throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__); throw InvalidMetaInfoException(__LINE__, __FUNCTION__, __FILE__);

View File

@@ -115,10 +115,10 @@ void MetaInfoPrivate::parseItemLibraryDescriptions()
{ {
#ifndef QMLDESIGNER_TEST #ifndef QMLDESIGNER_TEST
Internal::WidgetPluginManager pluginManager; Internal::WidgetPluginManager pluginManager;
foreach (const QString &pluginDir, m_q->s_pluginDirs) for (const QString &pluginDir : qAsConst(m_q->s_pluginDirs))
pluginManager.addPath(pluginDir); pluginManager.addPath(pluginDir);
QList<IWidgetPlugin *> widgetPluginList = pluginManager.instances(); const QList<IWidgetPlugin *> widgetPluginList = pluginManager.instances();
foreach (IWidgetPlugin *plugin, widgetPluginList) { for (IWidgetPlugin *plugin : widgetPluginList) {
Internal::MetaInfoReader reader(*m_q); Internal::MetaInfoReader reader(*m_q);
try { try {
reader.readMetaInfoFile(plugin->metaInfo()); reader.readMetaInfoFile(plugin->metaInfo());

View File

@@ -140,7 +140,8 @@ static QString qualifiedTypeNameForContext(const ObjectValue *objectValue,
QStringList packages; QStringList packages;
if (const CppComponentValue *cppComponent = value_cast<CppComponentValue>(objectValue)) { if (const CppComponentValue *cppComponent = value_cast<CppComponentValue>(objectValue)) {
QString className = cppComponent->className(); QString className = cppComponent->className();
foreach (const LanguageUtils::FakeMetaObject::Export &e, cppComponent->metaObject()->exports()) { const QList<LanguageUtils::FakeMetaObject::Export> &exports = cppComponent->metaObject()->exports();
for (const LanguageUtils::FakeMetaObject::Export &e : exports) {
if (e.type == className) if (e.type == className)
packages << e.package; packages << e.package;
if (e.package == CppQmlTypes::cppPackage) if (e.package == CppQmlTypes::cppPackage)
@@ -160,7 +161,7 @@ static QString qualifiedTypeNameForContext(const ObjectValue *objectValue,
CoreImport cImport = dep.coreImport(objectValue->originId()); CoreImport cImport = dep.coreImport(objectValue->originId());
if (!cImport.valid()) if (!cImport.valid())
break; break;
foreach (const Export &e, cImport.possibleExports) { for (const Export &e : qAsConst(cImport.possibleExports)) {
if (e.pathRequired.isEmpty() || vContext.paths.contains(e.pathRequired)) { if (e.pathRequired.isEmpty() || vContext.paths.contains(e.pathRequired)) {
switch (e.exportName.type) { switch (e.exportName.type) {
case ImportType::Library: case ImportType::Library:
@@ -185,7 +186,7 @@ static QString qualifiedTypeNameForContext(const ObjectValue *objectValue,
// remove the search path prefix. // remove the search path prefix.
// this means that the same relative path wrt. different import paths will clash // this means that the same relative path wrt. different import paths will clash
QString filePath = e.exportName.path(); QString filePath = e.exportName.path();
foreach (const QString &path, vContext.paths) { for (const QString &path : qAsConst(vContext.paths)) {
if (filePath.startsWith(path) && filePath.size() > path.size() if (filePath.startsWith(path) && filePath.size() > path.size()
&& filePath.at(path.size()) == QLatin1Char('/')) && filePath.at(path.size()) == QLatin1Char('/'))
{ {
@@ -260,7 +261,7 @@ static QString qualifiedTypeNameForContext(const ObjectValue *objectValue,
}; };
if (!possibleLibraries.isEmpty()) { if (!possibleLibraries.isEmpty()) {
if (hasQtQuick) { if (hasQtQuick) {
foreach (const QString &libImport, possibleLibraries) for (const QString &libImport : qAsConst(possibleLibraries))
if (!libImport.startsWith(QLatin1String("QtQuick"))) if (!libImport.startsWith(QLatin1String("QtQuick")))
possibleLibraries.removeAll(libImport); possibleLibraries.removeAll(libImport);
} }
@@ -456,8 +457,8 @@ QVector<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Co
//dot property //dot property
const CppComponentValue * qmlValue = value_cast<CppComponentValue>(objectValue->lookupMember(nameAsString, context)); const CppComponentValue * qmlValue = value_cast<CppComponentValue>(objectValue->lookupMember(nameAsString, context));
if (qmlValue) { if (qmlValue) {
QVector<PropertyInfo> dotProperties = getQmlTypes(qmlValue, context, false, rec + 1); const QVector<PropertyInfo> dotProperties = getQmlTypes(qmlValue, context, false, rec + 1);
foreach (const PropertyInfo &propertyInfo, dotProperties) { for (const PropertyInfo &propertyInfo : dotProperties) {
const PropertyName dotName = name + '.' + propertyInfo.first; const PropertyName dotName = name + '.' + propertyInfo.first;
const TypeName type = propertyInfo.second; const TypeName type = propertyInfo.second;
propertyList.append({dotName, type}); propertyList.append({dotName, type});
@@ -467,8 +468,8 @@ QVector<PropertyInfo> getQmlTypes(const CppComponentValue *objectValue, const Co
if (isValueType(objectValue->propertyType(nameAsString))) { if (isValueType(objectValue->propertyType(nameAsString))) {
const ObjectValue *dotObjectValue = value_cast<ObjectValue>(objectValue->lookupMember(nameAsString, context)); const ObjectValue *dotObjectValue = value_cast<ObjectValue>(objectValue->lookupMember(nameAsString, context));
if (dotObjectValue) { if (dotObjectValue) {
QVector<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1); const QVector<PropertyInfo> dotProperties = getObjectTypes(dotObjectValue, context, false, rec + 1);
foreach (const PropertyInfo &propertyInfo, dotProperties) { for (const PropertyInfo &propertyInfo : dotProperties) {
const PropertyName dotName = name + '.' + propertyInfo.first; const PropertyName dotName = name + '.' + propertyInfo.first;
const TypeName type = propertyInfo.second; const TypeName type = propertyInfo.second;
propertyList.append({dotName, type}); propertyList.append({dotName, type});
@@ -825,7 +826,7 @@ const CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() const
const QmlJS::Imports *importsPtr = context()->imports(document()); const QmlJS::Imports *importsPtr = context()->imports(document());
if (importsPtr) { if (importsPtr) {
const QList<QmlJS::Import> &imports = importsPtr->all(); const QList<QmlJS::Import> &imports = importsPtr->all();
foreach (const QmlJS::Import &import, imports) { for (const QmlJS::Import &import : imports) {
if (import.info.path() != QString::fromUtf8(module)) if (import.info.path() != QString::fromUtf8(module))
continue; continue;
const Value *lookupResult = import.object->lookupMember(QString::fromUtf8(type), context()); const Value *lookupResult = import.object->lookupMember(QString::fromUtf8(type), context());
@@ -846,9 +847,11 @@ const CppComponentValue *NodeMetaInfoPrivate::getCppComponentValue() const
const CppComponentValue *cppValue = context()->valueOwner()->cppQmlTypes().objectByCppName(QString::fromUtf8(type)); const CppComponentValue *cppValue = context()->valueOwner()->cppQmlTypes().objectByCppName(QString::fromUtf8(type));
if (cppValue) { if (cppValue) {
foreach (const LanguageUtils::FakeMetaObject::Export &exportValue, cppValue->metaObject()->exports()) { const QList<LanguageUtils::FakeMetaObject::Export> exports = cppValue->metaObject()->exports();
for (const LanguageUtils::FakeMetaObject::Export &exportValue : exports) {
if (exportValue.package.toUtf8() != "<cpp>") { if (exportValue.package.toUtf8() != "<cpp>") {
foreach (const QmlJS::Import &import, context()->imports(document())->all()) { const QList<QmlJS::Import> imports = context()->imports(document())->all();
for (const QmlJS::Import &import : imports) {
if (import.info.path() != exportValue.package) if (import.info.path() != exportValue.package)
continue; continue;
const Value *lookupResult = import.object->lookupMember(exportValue.type, context()); const Value *lookupResult = import.object->lookupMember(exportValue.type, context());
@@ -884,14 +887,14 @@ const Document *NodeMetaInfoPrivate::document() const
void NodeMetaInfoPrivate::setupLocalPropertyInfo(const QVector<PropertyInfo> &localPropertyInfos) void NodeMetaInfoPrivate::setupLocalPropertyInfo(const QVector<PropertyInfo> &localPropertyInfos)
{ {
foreach (const PropertyInfo &propertyInfo, localPropertyInfos) { for (const PropertyInfo &propertyInfo : localPropertyInfos) {
m_localProperties.append(propertyInfo.first); m_localProperties.append(propertyInfo.first);
} }
} }
void NodeMetaInfoPrivate::setupPropertyInfo(const QVector<PropertyInfo> &propertyInfos) void NodeMetaInfoPrivate::setupPropertyInfo(const QVector<PropertyInfo> &propertyInfos)
{ {
foreach (const PropertyInfo &propertyInfo, propertyInfos) { for (const PropertyInfo &propertyInfo : propertyInfos) {
if (!m_properties.contains(propertyInfo.first)) { if (!m_properties.contains(propertyInfo.first)) {
m_properties.append(propertyInfo.first); m_properties.append(propertyInfo.first);
m_propertyTypes.append(propertyInfo.second); m_propertyTypes.append(propertyInfo.second);
@@ -1197,7 +1200,8 @@ QString NodeMetaInfoPrivate::importDirectoryPath() const
return importInfo.path(); return importInfo.path();
} else if (importInfo.type() == ImportType::Library) { } else if (importInfo.type() == ImportType::Library) {
if (modelManager) { if (modelManager) {
foreach (const QString &importPath, model()->importPaths()) { const QStringList importPaths = model()->importPaths();
for (const QString &importPath : importPaths) {
const QString targetPath = QDir(importPath).filePath(importInfo.path()); const QString targetPath = QDir(importPath).filePath(importInfo.path());
if (QDir(targetPath).exists()) if (QDir(targetPath).exists())
return targetPath; return targetPath;
@@ -1271,7 +1275,7 @@ void NodeMetaInfoPrivate::setupPrototypes()
return; return;
} }
foreach (const ObjectValue *ov, objects) { for (const ObjectValue *ov : qAsConst(objects)) {
TypeDescription description; TypeDescription description;
description.className = ov->className(); description.className = ov->className();
description.minorVersion = -1; description.minorVersion = -1;
@@ -1301,7 +1305,8 @@ void NodeMetaInfoPrivate::setupPrototypes()
} else { } else {
bool found = false; bool found = false;
if (cppExport.isValid()) { if (cppExport.isValid()) {
foreach (const LanguageUtils::FakeMetaObject::Export &exportValue, qmlValue->metaObject()->exports()) { const QList<LanguageUtils::FakeMetaObject::Export> exports = qmlValue->metaObject()->exports();
for (const LanguageUtils::FakeMetaObject::Export &exportValue : exports) {
if (exportValue.package.toUtf8() != "<cpp>") { if (exportValue.package.toUtf8() != "<cpp>") {
found = true; found = true;
description.className = exportValue.package + '.' + exportValue.type; description.className = exportValue.package + '.' + exportValue.type;
@@ -1612,7 +1617,8 @@ bool NodeMetaInfo::isSubclassOf(const TypeName &type, int majorVersion, int mino
if (m_privateData->prototypeCacheNegatives().contains(Internal::stringIdentifier(type, majorVersion, minorVersion))) if (m_privateData->prototypeCacheNegatives().contains(Internal::stringIdentifier(type, majorVersion, minorVersion)))
return false; //take a shortcut - optimization return false; //take a shortcut - optimization
foreach (const NodeMetaInfo &superClass, superClasses()) { const QList<NodeMetaInfo> superClassList = superClasses();
for (const NodeMetaInfo &superClass : superClassList) {
if (superClass.m_privateData->cleverCheckType(type) if (superClass.m_privateData->cleverCheckType(type)
&& superClass.availableInVersion(majorVersion, minorVersion)) { && superClass.availableInVersion(majorVersion, minorVersion)) {
m_privateData->prototypeCachePositives().insert(Internal::stringIdentifier(type, majorVersion, minorVersion)); m_privateData->prototypeCachePositives().insert(Internal::stringIdentifier(type, majorVersion, minorVersion));

View File

@@ -173,7 +173,7 @@ void SubComponentManager::parseDirectories()
for (const auto &assetPath : assetPaths) for (const auto &assetPath : assetPaths)
parseDirectory(assetPath); parseDirectory(assetPath);
foreach (const Import &import, m_imports) { for (const Import &import : qAsConst(m_imports)) {
if (import.isFileImport()) { if (import.isFileImport()) {
QFileInfo dirInfo = QFileInfo(m_filePath.resolved(import.file()).toLocalFile()); QFileInfo dirInfo = QFileInfo(m_filePath.resolved(import.file()).toLocalFile());
if (dirInfo.exists() && dirInfo.isDir()) { if (dirInfo.exists() && dirInfo.isDir()) {
@@ -184,7 +184,8 @@ void SubComponentManager::parseDirectories()
QString url = import.url(); QString url = import.url();
url.replace(QLatin1Char('.'), QLatin1Char('/')); url.replace(QLatin1Char('.'), QLatin1Char('/'));
QFileInfo dirInfo = QFileInfo(url); QFileInfo dirInfo = QFileInfo(url);
foreach (const QString &path, importPaths()) { const QStringList paths = importPaths();
for (const QString &path : paths) {
QString fullUrl = path + QLatin1Char('/') + url; QString fullUrl = path + QLatin1Char('/') + url;
dirInfo = QFileInfo(fullUrl); dirInfo = QFileInfo(fullUrl);
@@ -222,7 +223,8 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
designerDir.setNameFilters(filter); designerDir.setNameFilters(filter);
QStringList metaFiles = designerDir.entryList(QDir::Files); QStringList metaFiles = designerDir.entryList(QDir::Files);
foreach (const QFileInfo &metaInfoFile, designerDir.entryInfoList(QDir::Files)) { const QFileInfoList metaInfoList = designerDir.entryInfoList(QDir::Files);
for (const QFileInfo &metaInfoFile : metaInfoList) {
if (model() && model()->metaInfo().itemLibraryInfo()) { if (model() && model()->metaInfo().itemLibraryInfo()) {
Internal::MetaInfoReader reader(model()->metaInfo()); Internal::MetaInfoReader reader(model()->metaInfo());
reader.setQualifcation(qualification); reader.setQualifcation(qualification);
@@ -250,7 +252,8 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
QFileInfoList monitoredList = watchedFiles(canonicalDirPath); QFileInfoList monitoredList = watchedFiles(canonicalDirPath);
QFileInfoList newList; QFileInfoList newList;
foreach (const QFileInfo &qmlFile, dir.entryInfoList()) { const QFileInfoList qmlFileList = dir.entryInfoList();
for (const QFileInfo &qmlFile : qmlFileList) {
if (QFileInfo(m_filePath.toLocalFile()) == qmlFile) { if (QFileInfo(m_filePath.toLocalFile()) == qmlFile) {
// do not parse main file // do not parse main file
continue; continue;
@@ -279,7 +282,8 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
continue; continue;
} }
if (oldFileInfo < newFileInfo) { if (oldFileInfo < newFileInfo) {
foreach (const QString &qualifier, m_dirToQualifier.value(canonicalDirPath)) const QString qualifiers = m_dirToQualifier.value(canonicalDirPath);
for (const QChar &qualifier : qualifiers)
unregisterQmlFile(oldFileInfo, qualifier); unregisterQmlFile(oldFileInfo, qualifier);
m_watcher.removePath(oldFileInfo.filePath()); m_watcher.removePath(oldFileInfo.filePath());
++oldIter; ++oldIter;
@@ -291,7 +295,8 @@ void SubComponentManager::parseDirectory(const QString &canonicalDirPath, bool a
} }
while (oldIter != monitoredList.constEnd()) { while (oldIter != monitoredList.constEnd()) {
foreach (const QString &qualifier, m_dirToQualifier.value(canonicalDirPath)) const QString qualifiers = m_dirToQualifier.value(canonicalDirPath);
for (const QChar &qualifier : qualifiers)
unregisterQmlFile(*oldIter, qualifier); unregisterQmlFile(*oldIter, qualifier);
++oldIter; ++oldIter;
} }
@@ -315,7 +320,8 @@ void SubComponentManager::parseFile(const QString &canonicalFilePath, bool addTo
const QFileInfo fi(canonicalFilePath); const QFileInfo fi(canonicalFilePath);
const QString dir = fi.path(); const QString dir = fi.path();
foreach (const QString &qualifier, m_dirToQualifier.values(dir)) { const QStringList qualifiers = m_dirToQualifier.values(dir);
for (const QString &qualifier : qualifiers) {
registerQmlFile(fi, qualifier, addToLibrary); registerQmlFile(fi, qualifier, addToLibrary);
} }
registerQmlFile(fi, qualification, addToLibrary); registerQmlFile(fi, qualification, addToLibrary);
@@ -331,7 +337,8 @@ QFileInfoList SubComponentManager::watchedFiles(const QString &canonicalDirPath)
{ {
QFileInfoList files; QFileInfoList files;
foreach (const QString &monitoredFile, m_watcher.files()) { const QStringList monitoredFiles = m_watcher.files();
for (const QString &monitoredFile : monitoredFiles) {
QFileInfo fileInfo(monitoredFile); QFileInfo fileInfo(monitoredFile);
if (fileInfo.dir().absolutePath() == canonicalDirPath) if (fileInfo.dir().absolutePath() == canonicalDirPath)
files.append(fileInfo); files.append(fileInfo);

View File

@@ -825,7 +825,8 @@ QmlTimeline AbstractView::currentTimeline() const
static int getMinorVersionFromImport(const Model *model) static int getMinorVersionFromImport(const Model *model)
{ {
foreach (const Import &import, model->imports()) { const QList<Import> imports = model->imports();
for (const Import &import : imports) {
if (import.isLibraryImport() && import.url() == "QtQuick") { if (import.isLibraryImport() && import.url() == "QtQuick") {
const QString versionString = import.version(); const QString versionString = import.version();
if (versionString.contains(".")) { if (versionString.contains(".")) {
@@ -840,7 +841,8 @@ static int getMinorVersionFromImport(const Model *model)
static int getMajorVersionFromImport(const Model *model) static int getMajorVersionFromImport(const Model *model)
{ {
foreach (const Import &import, model->imports()) { const QList<Import> imports = model->imports();
for (const Import &import : imports) {
if (import.isLibraryImport() && import.url() == QStringLiteral("QtQuick")) { if (import.isLibraryImport() && import.url() == QStringLiteral("QtQuick")) {
const QString versionString = import.version(); const QString versionString = import.version();
if (versionString.contains(QStringLiteral("."))) { if (versionString.contains(QStringLiteral("."))) {
@@ -870,7 +872,8 @@ static int getMajorVersionFromNode(const ModelNode &modelNode)
static int getMinorVersionFromNode(const ModelNode &modelNode) static int getMinorVersionFromNode(const ModelNode &modelNode)
{ {
if (modelNode.metaInfo().isValid()) { if (modelNode.metaInfo().isValid()) {
foreach (const NodeMetaInfo &info, modelNode.metaInfo().classHierarchy()) { const QList<NodeMetaInfo> infos = modelNode.metaInfo().classHierarchy();
for (const NodeMetaInfo &info : infos) {
if (info.typeName() == "QtQuick.QtObject" || info.typeName() == "QtQuick.Item") if (info.typeName() == "QtQuick.QtObject" || info.typeName() == "QtQuick.Item")
return info.minorVersion(); return info.minorVersion();
} }

View File

@@ -95,8 +95,9 @@ bool BaseTextEditModifier::renameId(const QString &oldId, const QString &newId)
if (auto document = qobject_cast<QmlJSEditor::QmlJSEditorDocument *>( if (auto document = qobject_cast<QmlJSEditor::QmlJSEditorDocument *>(
m_textEdit->textDocument())) { m_textEdit->textDocument())) {
Utils::ChangeSet changeSet; Utils::ChangeSet changeSet;
foreach (const QmlJS::SourceLocation &loc, const QList<QmlJS::SourceLocation> locations = document->semanticInfo()
document->semanticInfo().idLocations.value(oldId)) { .idLocations.value(oldId);
for (const QmlJS::SourceLocation &loc : locations) {
changeSet.replace(loc.begin(), loc.end(), newId); changeSet.replace(loc.begin(), loc.end(), newId);
} }
QTextCursor tc = textCursor(); QTextCursor tc = textCursor();

View File

@@ -142,9 +142,9 @@ ModelNode BindingProperty::resolveToModelNode() const
static inline QStringList commaSeparatedSimplifiedStringList(const QString &string) static inline QStringList commaSeparatedSimplifiedStringList(const QString &string)
{ {
QStringList stringList = string.split(QStringLiteral(",")); const QStringList stringList = string.split(QStringLiteral(","));
QStringList simpleList; QStringList simpleList;
foreach (const QString &simpleString, stringList) for (const QString &simpleString : stringList)
simpleList.append(simpleString.simplified()); simpleList.append(simpleString.simplified());
return simpleList; return simpleList;
} }
@@ -190,8 +190,8 @@ QList<ModelNode> BindingProperty::resolveToModelNodeList() const
QString string = expression(); QString string = expression();
string.chop(1); string.chop(1);
string.remove(0, 1); string.remove(0, 1);
QStringList simplifiedList = commaSeparatedSimplifiedStringList(string); const QStringList simplifiedList = commaSeparatedSimplifiedStringList(string);
foreach (const QString &nodeId, simplifiedList) { for (const QString &nodeId : simplifiedList) {
if (view()->hasId(nodeId)) if (view()->hasId(nodeId))
returnList.append(view()->modelNodeForId(nodeId)); returnList.append(view()->modelNodeForId(nodeId));
} }

View File

@@ -311,7 +311,8 @@ QList<InternalProperty::Pointer> InternalNode::propertyList() const
QList<InternalNodeAbstractProperty::Pointer> InternalNode::nodeAbstractPropertyList() const QList<InternalNodeAbstractProperty::Pointer> InternalNode::nodeAbstractPropertyList() const
{ {
QList<InternalNodeAbstractProperty::Pointer> abstractPropertyList; QList<InternalNodeAbstractProperty::Pointer> abstractPropertyList;
foreach (const InternalProperty::Pointer &property, propertyList()) { const QList<InternalProperty::Pointer> properties = propertyList();
for (const InternalProperty::Pointer &property : properties) {
if (property->isNodeAbstractProperty()) if (property->isNodeAbstractProperty())
abstractPropertyList.append(property->toNodeAbstractProperty()); abstractPropertyList.append(property->toNodeAbstractProperty());
} }
@@ -323,7 +324,8 @@ QList<InternalNodeAbstractProperty::Pointer> InternalNode::nodeAbstractPropertyL
QList<InternalNode::Pointer> InternalNode::allSubNodes() const QList<InternalNode::Pointer> InternalNode::allSubNodes() const
{ {
QList<InternalNode::Pointer> nodeList; QList<InternalNode::Pointer> nodeList;
foreach (const InternalNodeAbstractProperty::Pointer &property, nodeAbstractPropertyList()) { const QList<InternalNodeAbstractProperty::Pointer> properties = nodeAbstractPropertyList();
for (const InternalNodeAbstractProperty::Pointer &property : properties) {
nodeList.append(property->allSubNodes()); nodeList.append(property->allSubNodes());
} }
@@ -333,7 +335,8 @@ QList<InternalNode::Pointer> InternalNode::allSubNodes() const
QList<InternalNode::Pointer> InternalNode::allDirectSubNodes() const QList<InternalNode::Pointer> InternalNode::allDirectSubNodes() const
{ {
QList<InternalNode::Pointer> nodeList; QList<InternalNode::Pointer> nodeList;
foreach (const InternalNodeAbstractProperty::Pointer &property, nodeAbstractPropertyList()) { const QList<InternalNodeAbstractProperty::Pointer> properties = nodeAbstractPropertyList();
for (const InternalNodeAbstractProperty::Pointer &property : properties) {
nodeList.append(property->directSubNodes()); nodeList.append(property->directSubNodes());
} }