From c4c8094e32ad78dee558a80584470172f48c45b1 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 1 Apr 2019 22:15:19 +0200 Subject: get rid of some foreach and Q_FOREACH constructs See https://www.kdab.com/goodbye-q_foreach/ This is reduced to the places where the container is const or can be made const without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7) and std::as_const (C++17) are not available in all supported setups. Also do some minor cleanups along the way. Signed-off-by: Rolf Eike Beer --- profile-widget/divetooltipitem.cpp | 5 +++-- profile-widget/profilewidget2.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'profile-widget') diff --git a/profile-widget/divetooltipitem.cpp b/profile-widget/divetooltipitem.cpp index 0d3e6728c..f88d3b769 100644 --- a/profile-widget/divetooltipitem.cpp +++ b/profile-widget/divetooltipitem.cpp @@ -272,8 +272,9 @@ void ToolTipItem::refresh(const QPointF &pos) } entryToolTip.first->setPixmap(tissues); - Q_FOREACH (QGraphicsItem *item, scene()->items(pos, Qt::IntersectsItemBoundingRect - ,Qt::DescendingOrder, scene()->views().first()->transform())) { + const auto l = scene()->items(pos, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder, + scene()->views().first()->transform()); + for (QGraphicsItem *item: l) { if (!item->toolTip().isEmpty()) addToolTip(item->toolTip()); } diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 157ab9fcd..236afb850 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -1101,9 +1101,9 @@ bool ProfileWidget2::eventFilter(QObject *object, QEvent *event) #endif template -static void hideAll(T &container) +static void hideAll(const T &container) { - Q_FOREACH (auto *item, container) + for (auto *item: container) item->setVisible(false); } -- cgit v1.2.3-70-g09d2