QmlDesigner: Remove foreach / Q_FOREACH usage in formeditor

Task-number: QTCREATORBUG-27464
Change-Id: Ib477df666eb798b302b7a6915bb98f798b7a04ed
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-10 13:42:51 +02:00
parent 59a77a4965
commit 597a9dccb3
18 changed files with 82 additions and 77 deletions

View File

@@ -75,7 +75,7 @@ QList<FormEditorItem *> AbstractFormEditorTool::toFormEditorItemList(const QList
{
QList<FormEditorItem *> formEditorItemList;
foreach (QGraphicsItem *graphicsItem, itemList) {
for (QGraphicsItem *graphicsItem : itemList) {
auto formEditorItem = qgraphicsitem_cast<FormEditorItem*>(graphicsItem);
if (formEditorItem)
formEditorItemList.append(formEditorItem);
@@ -105,7 +105,7 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem*
{
QList<ModelNode> selectedNodes = view()->selectedModelNodes();
foreach (QGraphicsItem *item, itemList) {
for (QGraphicsItem *item : itemList) {
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem
&& selectedNodes.contains(formEditorItem->qmlItemNode())
@@ -116,7 +116,7 @@ bool AbstractFormEditorTool::topSelectedItemIsMovable(const QList<QGraphicsItem*
return true;
}
foreach (QGraphicsItem *item, itemList) {
for (QGraphicsItem *item : itemList) {
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem
&& formEditorItem->qmlItemNode().isValid()
@@ -163,7 +163,7 @@ bool AbstractFormEditorTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &
QGraphicsItem *AbstractFormEditorTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList)
{
foreach (QGraphicsItem *item, itemList) {
for (QGraphicsItem *item : itemList) {
if (item->flags().testFlag(QGraphicsItem::ItemIsMovable))
return item;
}
@@ -173,7 +173,7 @@ QGraphicsItem *AbstractFormEditorTool::topMovableGraphicsItem(const QList<QGraph
FormEditorItem *AbstractFormEditorTool::topMovableFormEditorItem(const QList<QGraphicsItem*> &itemList, bool selectOnlyContentItems)
{
foreach (QGraphicsItem *item, itemList) {
for (QGraphicsItem *item : itemList) {
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem
&& formEditorItem->qmlItemNode().isValid()
@@ -221,7 +221,7 @@ QList<FormEditorItem *> AbstractFormEditorTool::filterSelectedModelNodes(const Q
{
QList<FormEditorItem *> filteredItemList;
foreach (FormEditorItem *item, itemList) {
for (FormEditorItem *item : itemList) {
if (view()->isSelectedModelNode(item->qmlItemNode()))
filteredItemList.append(item);
}
@@ -266,7 +266,7 @@ void AbstractFormEditorTool::mousePressEvent(const QList<QGraphicsItem*> & /*ite
static bool containsItemNode(const QList<QGraphicsItem*> & itemList, const QmlItemNode &itemNode)
{
foreach (QGraphicsItem *item, itemList) {
for (QGraphicsItem *item : itemList) {
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem && formEditorItem->qmlItemNode() == itemNode)
return true;
@@ -340,7 +340,7 @@ Snapper::Snapping AbstractFormEditorTool::generateUseSnapping(Qt::KeyboardModifi
static bool isNotAncestorOfItemInList(FormEditorItem *formEditorItem, const QList<FormEditorItem*> &itemList)
{
foreach (FormEditorItem *item, itemList) {
for (FormEditorItem *item : itemList) {
if (item
&& item->qmlItemNode().isValid()
&& item->qmlItemNode().isAncestorOf(formEditorItem->qmlItemNode()))
@@ -352,7 +352,7 @@ static bool isNotAncestorOfItemInList(FormEditorItem *formEditorItem, const QLis
FormEditorItem *AbstractFormEditorTool::containerFormEditorItem(const QList<QGraphicsItem *> &itemUnderMouseList, const QList<FormEditorItem *> &selectedItemList) const
{
foreach (QGraphicsItem* item, itemUnderMouseList) {
for (QGraphicsItem* item : itemUnderMouseList) {
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem
&& !selectedItemList.contains(formEditorItem)

View File

@@ -121,7 +121,7 @@ void AnchorIndicator::setItems(const QList<FormEditorItem *> &itemList)
void AnchorIndicator::updateItems(const QList<FormEditorItem *> &itemList)
{
foreach (FormEditorItem *formEditorItem, itemList) {
for (FormEditorItem *formEditorItem : itemList) {
if (formEditorItem == m_formEditorItem) {
QmlItemNode sourceQmlItemNode = m_formEditorItem->qmlItemNode();
if (!sourceQmlItemNode.modelNode().isRootNode()) {

View File

@@ -144,7 +144,7 @@ void BindingIndicator::setItems(const QList<FormEditorItem *> &itemList)
void BindingIndicator::updateItems(const QList<FormEditorItem *> &itemList)
{
foreach (FormEditorItem *formEditorItem, itemList) {
for (FormEditorItem *formEditorItem : itemList) {
if (formEditorItem == m_formEditorItem) {
const QmlItemNode qmlItemNode = m_formEditorItem->qmlItemNode();

View File

@@ -48,7 +48,7 @@ ContentNotEditableIndicator::~ContentNotEditableIndicator()
void ContentNotEditableIndicator::clear()
{
foreach (const EntryPair &entryPair, m_entryList) {
for (const EntryPair &entryPair : qAsConst(m_entryList)) {
delete entryPair.second;
entryPair.first->blurContent(false);
}
@@ -71,13 +71,15 @@ void ContentNotEditableIndicator::updateItems(const QList<FormEditorItem *> &ite
{
QSet<FormEditorItem*> affectedFormEditorItemItems;
affectedFormEditorItemItems.unite(Utils::toSet(itemList));
foreach (FormEditorItem *formEditorItem, itemList)
for (FormEditorItem *formEditorItem : itemList)
affectedFormEditorItemItems.unite(Utils::toSet(formEditorItem->offspringFormEditorItems()));
foreach (const EntryPair &entryPair, m_entryList) {
foreach (FormEditorItem *formEditorItem, affectedFormEditorItemItems) {
for (const EntryPair &entryPair : qAsConst(m_entryList)) {
for (FormEditorItem *formEditorItem : qAsConst(affectedFormEditorItemItems)) {
if (formEditorItem == entryPair.first) {
QRectF boundingRectangleInSceneSpace = formEditorItem->qmlItemNode().instanceSceneTransform().mapRect(formEditorItem->qmlItemNode().instanceBoundingRect());
QRectF boundingRectangleInSceneSpace
= formEditorItem->qmlItemNode().instanceSceneTransform().mapRect(
formEditorItem->qmlItemNode().instanceBoundingRect());
entryPair.second->setRect(boundingRectangleInSceneSpace);
entryPair.second->update();
}
@@ -87,7 +89,7 @@ void ContentNotEditableIndicator::updateItems(const QList<FormEditorItem *> &ite
void ContentNotEditableIndicator::addAddiationEntries(const QList<FormEditorItem *> &itemList)
{
foreach (FormEditorItem *formEditorItem, itemList) {
for (FormEditorItem *formEditorItem : itemList) {
const ModelNode modelNode = formEditorItem->qmlItemNode().modelNode();
if (modelNode.metaInfo().isValid() && modelNode.metaInfo().isSubclassOf("QtQuick.Loader")) {

View File

@@ -79,7 +79,8 @@ void FormEditorScene::setupScene()
void FormEditorScene::resetScene()
{
foreach (QGraphicsItem *item, m_manipulatorLayerItem->childItems()) {
const QList<QGraphicsItem *> items = m_manipulatorLayerItem->childItems();
for (QGraphicsItem *item : items) {
removeItem(item);
delete item;
}
@@ -116,7 +117,8 @@ QList<FormEditorItem*> FormEditorScene::allFormEditorItems() const
void FormEditorScene::updateAllFormEditorItems()
{
foreach (FormEditorItem *item, allFormEditorItems())
const QList<FormEditorItem *> items = allFormEditorItems();
for (FormEditorItem *item : items)
item->update();
}
@@ -134,8 +136,8 @@ AbstractFormEditorTool* FormEditorScene::currentTool() const
FormEditorItem* FormEditorScene::calulateNewParent(FormEditorItem *formEditorItem)
{
if (formEditorItem->qmlItemNode().isValid()) {
QList<QGraphicsItem *> list = items(formEditorItem->qmlItemNode().instanceBoundingRect().center());
foreach (QGraphicsItem *graphicsItem, list) {
const QList<QGraphicsItem *> list = items(formEditorItem->qmlItemNode().instanceBoundingRect().center());
for (QGraphicsItem *graphicsItem : list) {
if (qgraphicsitem_cast<FormEditorItem*>(graphicsItem) &&
graphicsItem->collidesWithItem(formEditorItem, Qt::ContainsItemShape))
return qgraphicsitem_cast<FormEditorItem*>(graphicsItem);
@@ -229,7 +231,7 @@ QList<QGraphicsItem *> FormEditorScene::removeLayerItems(const QList<QGraphicsIt
{
QList<QGraphicsItem *> itemListWithoutLayerItems;
foreach (QGraphicsItem *item, itemList)
for (QGraphicsItem *item : itemList)
if (item != manipulatorLayerItem() && item != formLayerItem())
itemListWithoutLayerItems.append(item);
@@ -422,16 +424,17 @@ void FormEditorScene::clearFormEditorItems()
const QList<FormEditorItem*> formEditorItems = Utils::filtered(formEditorItemsTransformed,
[](FormEditorItem *item) { return item; });
foreach (FormEditorItem *item, formEditorItems)
for (FormEditorItem *item : formEditorItems)
item->setParentItem(nullptr);
foreach (FormEditorItem *item, formEditorItems)
for (FormEditorItem *item : formEditorItems)
delete item;
}
void FormEditorScene::highlightBoundingRect(FormEditorItem *highlighItem)
{
foreach (FormEditorItem *item, allFormEditorItems()) {
QList<FormEditorItem *> items = allFormEditorItems();
for (FormEditorItem *item : items) {
if (item == highlighItem)
item->setHighlightBoundingRect(true);
else

View File

@@ -166,8 +166,8 @@ void FormEditorView::setupFormEditorItemTree(const QmlItemNode &qmlItemNode)
static void deleteWithoutChildren(const QList<FormEditorItem*> &items)
{
foreach (FormEditorItem *item, items) {
foreach (QGraphicsItem *child, item->childItems()) {
for (const FormEditorItem *item : items) {
for (QGraphicsItem *child : item->childItems()) {
child->setParentItem(item->scene()->rootFormEditorItem());
}
delete item;
@@ -286,11 +286,9 @@ void FormEditorView::nodeAboutToBeRemoved(const ModelNode &removedNode)
void FormEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/)
{
foreach (FormEditorItem *item, m_scene->allFormEditorItems()) {
const QList<FormEditorItem *> items = m_scene->allFormEditorItems();
for (FormEditorItem *item : items) {
item->setParentItem(nullptr);
}
foreach (FormEditorItem *item, m_scene->allFormEditorItems()) {
m_scene->removeItemFromHash(item);
delete item;
}
@@ -309,11 +307,12 @@ void FormEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVer
void FormEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList)
{
QList<FormEditorItem*> removedItems;
foreach (const AbstractProperty &property, propertyList) {
for (const AbstractProperty &property : propertyList) {
if (property.isNodeAbstractProperty()) {
NodeAbstractProperty nodeAbstractProperty = property.toNodeAbstractProperty();
foreach (const ModelNode &modelNode, nodeAbstractProperty.allSubNodes()) {
const QList<ModelNode> modelNodes = nodeAbstractProperty.allSubNodes();
for (const ModelNode &modelNode : modelNodes) {
const QmlItemNode qmlItemNode(modelNode);
if (qmlItemNode.isValid()){

View File

@@ -32,11 +32,11 @@ namespace QmlDesigner {
class FormEditorItem;
QRectF boundingRectForItemList(QList<FormEditorItem*> itemList)
QRectF boundingRectForItemList(const QList<FormEditorItem*> itemList)
{
QRectF boundingRect;
foreach (FormEditorItem *item, itemList)
for (FormEditorItem *item : itemList)
{
boundingRect = boundingRect.united(item->mapToScene(item->qmlItemNode().instanceBoundingRect()).boundingRect());
}

View File

@@ -69,8 +69,8 @@ QList<QGraphicsItem*> LayerItem::findAllChildItems(const QGraphicsItem *item) co
{
QList<QGraphicsItem*> itemList(item->childItems());
foreach (QGraphicsItem *childItem, item->childItems())
itemList += findAllChildItems(childItem);
for (int end = itemList.length(), i = 0; i < end; ++i)
itemList += findAllChildItems(itemList.at(i));
return itemList;
}

View File

@@ -88,7 +88,7 @@ void MoveManipulator::synchronizeParent(const QList<FormEditorItem*> &itemList,
{
bool snapperUpdated = false;
foreach (FormEditorItem *item, itemList) {
for (FormEditorItem *item : itemList) {
if (m_itemList.contains(item)) {
QmlItemNode parentItemNode = QmlItemNode(parentNode);
if (parentItemNode.isValid()) {
@@ -111,7 +111,7 @@ void MoveManipulator::synchronizeInstanceParent(const QList<FormEditorItem*> &it
bool MoveManipulator::itemsCanReparented() const
{
foreach (FormEditorItem* item, m_itemList) {
for (FormEditorItem* item : qAsConst(m_itemList)) {
if (item
&& item->qmlItemNode().isValid()
&& !item->qmlItemNode().instanceCanReparent())
@@ -123,7 +123,7 @@ bool MoveManipulator::itemsCanReparented() const
void MoveManipulator::setDirectUpdateInNodeInstances(bool directUpdate)
{
foreach (FormEditorItem* item, m_itemList) {
for (FormEditorItem* item : qAsConst(m_itemList)) {
if (item && item->qmlItemNode().isValid())
item->qmlItemNode().nodeInstance().setDirectUpdate(directUpdate);
}
@@ -136,7 +136,7 @@ void MoveManipulator::begin(const QPointF &beginPoint)
m_snapper.updateSnappingLines(m_itemList);
foreach (FormEditorItem* item, m_itemList) {
for (FormEditorItem* item : qAsConst(m_itemList)) {
if (item && item->qmlItemNode().isValid()) {
QTransform fromItemToSceneTransform = item->qmlItemNode().instanceSceneTransform();
m_beginItemRectInSceneSpaceHash.insert(item, fromItemToSceneTransform.mapRect(item->qmlItemNode().instanceBoundingRect()));
@@ -144,14 +144,14 @@ void MoveManipulator::begin(const QPointF &beginPoint)
}
QTransform fromContentItemToSceneTransform = m_snapper.containerFormEditorItem()->qmlItemNode().instanceSceneContentItemTransform();
foreach (FormEditorItem* item, m_itemList) {
for (FormEditorItem* item : qAsConst(m_itemList)) {
if (item && item->qmlItemNode().isValid()) {
QPointF positionInScenesSpace = fromContentItemToSceneTransform.map(item->instancePosition());
m_beginPositionInSceneSpaceHash.insert(item, positionInScenesSpace);
}
}
foreach (FormEditorItem* item, m_itemList) {
for (FormEditorItem* item : qAsConst(m_itemList)) {
if (item && item->qmlItemNode().isValid()) {
QmlAnchors anchors(item->qmlItemNode().anchors());
m_beginTopMarginHash.insert(item, anchors.instanceMargin(AnchorLineTop));
@@ -278,7 +278,7 @@ void MoveManipulator::update(const QPointF& updatePoint, Snapper::Snapping useSn
generateSnappingLines(tanslatedBoundingRects(m_beginItemRectInSceneSpaceHash, offsetVector, fromSceneToItemTransform));
}
foreach (FormEditorItem* item, m_itemList) {
for (FormEditorItem* item : qAsConst(m_itemList)) {
QPointF positionInContainerSpace(fromSceneToContentItemTransform.map(m_beginPositionInSceneSpaceHash.value(item)) + offsetVector);
if (!item || !item->qmlItemNode().isValid())
@@ -363,7 +363,7 @@ void MoveManipulator::reparentTo(FormEditorItem *newParent, ReparentFlag flag)
else
parentProperty = parentItemNode.nodeAbstractProperty("data");
foreach (FormEditorItem* item, m_itemList) {
for (FormEditorItem* item : qAsConst(m_itemList)) {
if (!item || !item->qmlItemNode().isValid())
continue;
@@ -372,7 +372,7 @@ void MoveManipulator::reparentTo(FormEditorItem *newParent, ReparentFlag flag)
}
foreach (const ModelNode &nodeToReparented, nodeReparentVector)
for (const ModelNode &nodeToReparented : qAsConst(nodeReparentVector))
parentProperty.reparentHere(nodeToReparented);
synchronizeParent(m_itemList, parentProperty.parentModelNode());
@@ -393,7 +393,7 @@ void MoveManipulator::end()
void MoveManipulator::end(Snapper::Snapping useSnapping)
{
if (useSnapping == Snapper::UseSnappingAndAnchoring) {
foreach (FormEditorItem *formEditorItem, m_itemList)
for (FormEditorItem* formEditorItem : qAsConst(m_itemList))
m_snapper.adjustAnchoringOfItem(formEditorItem);
}
@@ -402,7 +402,7 @@ void MoveManipulator::end(Snapper::Snapping useSnapping)
void MoveManipulator::moveBy(double deltaX, double deltaY)
{
foreach (FormEditorItem* item, m_itemList) {
for (FormEditorItem* item : qAsConst(m_itemList)) {
if (!item || !item->qmlItemNode().isValid())
continue;
@@ -444,14 +444,14 @@ void MoveManipulator::endRewriterTransaction()
void MoveManipulator::setOpacityForAllElements(qreal opacity)
{
foreach (FormEditorItem* item, m_itemList)
for (FormEditorItem* item : qAsConst(m_itemList))
item->setOpacity(opacity);
}
void MoveManipulator::deleteSnapLines()
{
if (m_layerItem) {
foreach (QGraphicsItem *item, m_graphicsLineList) {
for (QGraphicsItem *item : qAsConst(m_graphicsLineList)) {
m_layerItem->scene()->removeItem(item);
delete item;
}

View File

@@ -271,7 +271,7 @@ void MoveTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList, QGra
void MoveTool::itemsAboutToRemoved(const QList<FormEditorItem*> &removedItemList)
{
foreach (FormEditorItem* removedItem, removedItemList)
for (FormEditorItem* removedItem : removedItemList)
m_movingItems.removeOne(removedItem);
}
@@ -304,7 +304,7 @@ bool MoveTool::haveSameParent(const QList<FormEditorItem*> &itemList)
return false;
QGraphicsItem *firstParent = itemList.constFirst()->parentItem();
foreach (FormEditorItem* item, itemList)
for (FormEditorItem* item : itemList)
{
if (firstParent != item->parentItem())
return false;
@@ -316,7 +316,7 @@ bool MoveTool::haveSameParent(const QList<FormEditorItem*> &itemList)
bool MoveTool::isAncestorOfAllItems(FormEditorItem* maybeAncestorItem,
const QList<FormEditorItem*> &itemList)
{
foreach (FormEditorItem* item, itemList)
for (FormEditorItem* item : itemList)
{
if (!maybeAncestorItem->isAncestorOf(item) && item != maybeAncestorItem)
return false;
@@ -332,7 +332,7 @@ FormEditorItem* MoveTool::ancestorIfOtherItemsAreChild(const QList<FormEditorIte
return nullptr;
foreach (FormEditorItem* item, itemList)
for (FormEditorItem* item : itemList)
{
if (isAncestorOfAllItems(item, itemList))
return item;

View File

@@ -69,7 +69,7 @@ double OneDimensionalCluster::constFirst() const
QList<OneDimensionalCluster> OneDimensionalCluster::createOneDimensionalClusterList(const QList<double> & oneDimensionalCoordinateList)
{
QList<OneDimensionalCluster> oneDimensionalClusterList;
foreach (double coordinate, oneDimensionalCoordinateList)
for (double coordinate : oneDimensionalCoordinateList)
{
QList<double> initialList;
initialList.append(coordinate);
@@ -134,7 +134,7 @@ QList<double> OneDimensionalCluster::reduceLines(const QList<double> & oneDimens
clusterList = reduceOneDimensionalClusterList(clusterList, maximumDistance);
QList<double> lineList;
foreach (const OneDimensionalCluster &cluster, clusterList)
for (const OneDimensionalCluster &cluster : qAsConst(clusterList))
lineList.append(cluster.constFirst());
return lineList;

View File

@@ -71,7 +71,7 @@ void ResizeIndicator::setItems(const QList<FormEditorItem*> &itemList)
{
clear();
foreach (FormEditorItem* item, itemList) {
for (FormEditorItem* item : itemList) {
if (item && itemIsResizable(item->qmlItemNode())) {
ResizeController controller(m_layerItem, item);
m_itemControllerHash.insert(item, controller);
@@ -81,7 +81,7 @@ void ResizeIndicator::setItems(const QList<FormEditorItem*> &itemList)
void ResizeIndicator::updateItems(const QList<FormEditorItem*> &itemList)
{
foreach (FormEditorItem* item, itemList) {
for (FormEditorItem* item : itemList) {
if (m_itemControllerHash.contains(item)) {
if (!item || !itemIsResizable(item->qmlItemNode())) {
m_itemControllerHash.take(item);

View File

@@ -628,7 +628,7 @@ bool ResizeManipulator::isInvalidSize(const QSizeF & size)
void ResizeManipulator::deleteSnapLines()
{
if (m_layerItem) {
foreach (QGraphicsItem *item, m_graphicsLineList) {
for (QGraphicsItem *item : qAsConst(m_graphicsLineList)) {
m_layerItem->scene()->removeItem(item);
delete item;
}

View File

@@ -220,7 +220,7 @@ void RotationManipulator::end()
void RotationManipulator::deleteSnapLines()
{
if (m_layerItem) {
foreach (QGraphicsItem *item, m_graphicsLineList) {
for (QGraphicsItem *item : qAsConst(m_graphicsLineList)) {
m_layerItem->scene()->removeItem(item);
delete item;
}

View File

@@ -51,7 +51,7 @@ void RubberBandSelectionManipulator::clear()
FormEditorItem *RubberBandSelectionManipulator::topFormEditorItem(const QList<QGraphicsItem*> &itemList)
{
foreach (QGraphicsItem *item, itemList) {
for (QGraphicsItem *item : itemList) {
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem)

View File

@@ -54,7 +54,7 @@ SelectionIndicator::~SelectionIndicator()
void SelectionIndicator::show()
{
foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash)
for (QGraphicsPolygonItem *item : qAsConst(m_indicatorShapeHash))
item->show();
if (m_labelItem)
m_labelItem->show();
@@ -62,7 +62,7 @@ void SelectionIndicator::show()
void SelectionIndicator::hide()
{
foreach (QGraphicsPolygonItem *item, m_indicatorShapeHash)
for (QGraphicsPolygonItem *item : qAsConst(m_indicatorShapeHash))
item->hide();
if (m_labelItem)
m_labelItem->hide();
@@ -71,7 +71,7 @@ void SelectionIndicator::hide()
void SelectionIndicator::clear()
{
if (m_layerItem) {
foreach (QGraphicsItem *item, m_indicatorShapeHash) {
for (QGraphicsPolygonItem *item : qAsConst(m_indicatorShapeHash)) {
m_layerItem->scene()->removeItem(item);
delete item;
}
@@ -102,7 +102,7 @@ void SelectionIndicator::setItems(const QList<FormEditorItem*> &itemList)
static QColor selectionColor = Utils::creatorTheme()->color(Utils::Theme::QmlDesigner_FormEditorSelectionColor);
foreach (FormEditorItem *item, itemList) {
for (FormEditorItem *item : itemList) {
if (!item->qmlItemNode().isValid())
continue;
@@ -178,7 +178,7 @@ void SelectionIndicator::setItems(const QList<FormEditorItem*> &itemList)
void SelectionIndicator::updateItems(const QList<FormEditorItem*> &itemList)
{
foreach (FormEditorItem *item, itemList) {
for (FormEditorItem *item : itemList) {
if (m_indicatorShapeHash.contains(item)) {
QGraphicsPolygonItem *indicatorGraphicsItem = m_indicatorShapeHash.value(item);
indicatorGraphicsItem->setPolygon(boundingRectInLayerItemSpaceForItem(item, m_layerItem.data()));
@@ -207,7 +207,7 @@ void SelectionIndicator::setCursor(const QCursor &cursor)
{
m_cursor = cursor;
foreach (QGraphicsItem *item, m_indicatorShapeHash)
for (QGraphicsItem *item : qAsConst(m_indicatorShapeHash))
item->setCursor(cursor);
}

View File

@@ -453,7 +453,7 @@ static QLineF mergedHorizontalLine(const QList<QLineF> &lineList)
double minimumX = std::numeric_limits<double>::max();
double maximumX = std::numeric_limits<double>::min();
foreach (const QLineF &line, lineList) {
for (const QLineF &line : lineList) {
minimumX = qMin(minimumX, double(line.x1()));
minimumX = qMin(minimumX, double(line.x2()));
maximumX = qMax(maximumX, double(line.x1()));
@@ -471,7 +471,7 @@ static QLineF mergedVerticalLine(const QList<QLineF> &lineList)
double minimumY = std::numeric_limits<double>::max();
double maximumY = std::numeric_limits<double>::min();
foreach (const QLineF &line, lineList) {
for (const QLineF &line : lineList) {
minimumY = qMin(minimumY, double(line.y1()));
minimumY = qMin(minimumY, double(line.y2()));
maximumY = qMax(maximumY, double(line.y1()));
@@ -705,13 +705,13 @@ QList<QGraphicsItem*> Snapper::generateSnappingLines(const QList<QRectF> &boundi
{
QList<QGraphicsItem*> graphicsItemList;
QList<QLineF> lineList;
foreach (const QRectF &boundingRect, boundingRectList) {
for (const QRectF &boundingRect : boundingRectList) {
QList<QRectF> snappedBoundingRectList;
lineList += mergedHorizontalLines(horizontalSnappedLines(boundingRect, &snappedBoundingRectList));
lineList += mergedVerticalLines(verticalSnappedLines(boundingRect, &snappedBoundingRectList));
}
foreach (const QLineF &line, lineList) {
for (const QLineF &line : qAsConst(lineList)) {
QLineF lineInTransformationSpace = transform.map(line);
auto lineItem = new QGraphicsLineItem(lineInTransformationSpace, layerItem);
lineItem->setZValue(40);

View File

@@ -99,7 +99,8 @@ void SnappingLineCreator::generateLines(const QList<FormEditorItem*> &exceptionL
addLines(containerBoundingRectInTransformationSpace, m_formEditorItem);
}
foreach (FormEditorItem *item, m_formEditorItem->childFormEditorItems()) {
const QList<FormEditorItem *> items = m_formEditorItem->childFormEditorItems();
for (FormEditorItem *item : items) {
if (!item || !item->qmlItemNode().isValid())
continue;