From 4eba90c9228423c82729c8678b9737ecf79974d7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 May 2020 10:49:56 +0200 Subject: [PATCH] QGraphicsGridLayout: simplify a loop over Qt::Orientation values Instead of selecting a Qt::Orientation value based on the integer loop variable, just loop over the possible Qt::Orientation values directly. Change-Id: I25b6f0d49c9b5a7e16e974dcc37668f801e65224 Reviewed-by: Giuseppe D'Angelo --- src/widgets/graphicsview/qgraphicsgridlayout.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp index 260e1861c7..79cba74a93 100644 --- a/src/widgets/graphicsview/qgraphicsgridlayout.cpp +++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp @@ -587,9 +587,7 @@ void QGraphicsGridLayout::removeAt(int index) d->engine.removeItem(gridItem); // recalculate rowInfo.count if we remove an item that is on the right/bottommost row - for (int j = 0; j < NOrientations; ++j) { - // 0: Hor, 1: Ver - const Qt::Orientation orient = (j == 0 ? Qt::Horizontal : Qt::Vertical); + for (const Qt::Orientation orient : {Qt::Horizontal, Qt::Vertical}) { const int oldCount = d->engine.rowCount(orient); if (gridItem->lastRow(orient) == oldCount - 1) { const int newCount = d->engine.effectiveLastRow(orient) + 1;