cleanup: replace Q_FOREACH by range-based for in profile code

With Qt-containers, this might be a small pessimization, because
it might lead to a deep copy. This can be "fixed" by
   for (const Type &item: qAsConst(container))
But frankly, I don't care. Ultimately it is probably best to
replace the Qt containers by standard containers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2023-02-15 09:56:18 +01:00 committed by Dirk Hohndel
parent 4128fec1ea
commit 3f2e4e8b16
3 changed files with 8 additions and 11 deletions

View file

@ -826,7 +826,7 @@ void PartialPressureGasItem::paint(QPainter *painter, const QStyleOptionGraphics
QPolygonF poly;
painter->setPen(QPen(alertColor, pWidth));
Q_FOREACH (const QPolygonF &poly, alertPolygons)
for (const QPolygonF &poly: alertPolygons)
painter->drawPolyline(poly);
painter->restore();
}

View file

@ -14,12 +14,10 @@ void ToolTipItem::addToolTip(const QString &toolTip, const QPixmap &pixmap)
QGraphicsPixmapItem *iconItem = 0;
double yValue = title->boundingRect().height() + iconMetrics.spacing;
Q_FOREACH (ToolTip t, toolTips) {
for (ToolTip t: toolTips)
yValue += t.second->boundingRect().height();
}
if (entryToolTip.second) {
if (entryToolTip.second)
yValue += entryToolTip.second->boundingRect().height();
}
iconItem = new QGraphicsPixmapItem(this);
if (!pixmap.isNull())
iconItem->setPixmap(pixmap);
@ -36,7 +34,7 @@ void ToolTipItem::addToolTip(const QString &toolTip, const QPixmap &pixmap)
void ToolTipItem::clear()
{
Q_FOREACH (ToolTip t, toolTips) {
for (ToolTip t: toolTips) {
delete t.first;
delete t.second;
}
@ -78,7 +76,7 @@ void ToolTipItem::expand()
const IconMetrics &iconMetrics = defaultIconMetrics();
double width = 0, height = title->boundingRect().height() + iconMetrics.spacing;
Q_FOREACH (const ToolTip &t, toolTips) {
for (const ToolTip &t: toolTips) {
QRectF sRect = t.second->boundingRect();
if (sRect.width() > width)
width = sRect.width();
@ -186,9 +184,8 @@ void ToolTipItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
persistPos();
QGraphicsRectItem::mouseReleaseEvent(event);
Q_FOREACH (QGraphicsItem *item, oldSelection) {
for (QGraphicsItem *item: oldSelection)
item->setSelected(true);
}
}
void ToolTipItem::persistPos() const

View file

@ -689,7 +689,7 @@ void ProfileWidget2::hideEvents(DiveEventItem *item)
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
if (!empty_string(event->name)) {
hide_event(event->name);
Q_FOREACH (DiveEventItem *evItem, profileScene->eventItems) {
for (DiveEventItem *evItem: profileScene->eventItems) {
if (same_string(evItem->getEvent()->name, event->name))
evItem->hide();
}
@ -702,7 +702,7 @@ void ProfileWidget2::hideEvents(DiveEventItem *item)
void ProfileWidget2::unhideEvents()
{
show_all_events();
Q_FOREACH (DiveEventItem *item, profileScene->eventItems)
for (DiveEventItem *item: profileScene->eventItems)
item->show();
}