From f0a11ffecf3e9caa2f9aa3bb138c8600f54f9070 Mon Sep 17 00:00:00 2001
From: Joachim Wuttke <j.wuttke@fz-juelich.de>
Date: Wed, 29 Nov 2023 14:53:20 +0100
Subject: [PATCH] recommended by clang-tidy

---
 GUI/View/Plotter/ProjectionsPlot.cpp |  2 +-
 GUI/View/Plotter/RangeUtil.cpp       | 14 +++++++-------
 GUI/View/Plotter/SpecularPlot.cpp    | 20 ++++++++++----------
 GUI/View/Plotter/SpecularPlot.h      |  4 ++--
 GUI/View/ProShape/MaskUtil.cpp       |  8 ++++----
 5 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/GUI/View/Plotter/ProjectionsPlot.cpp b/GUI/View/Plotter/ProjectionsPlot.cpp
index 221508c6a5d..869a4a40791 100644
--- a/GUI/View/Plotter/ProjectionsPlot.cpp
+++ b/GUI/View/Plotter/ProjectionsPlot.cpp
@@ -176,7 +176,7 @@ void ProjectionsPlot::updateProjectionsData()
 void ProjectionsPlot::updateProjections()
 {
     ASSERT(m_data2DItem);
-    auto container_item = m_data2DItem->projectionContainerItem();
+    auto* container_item = m_data2DItem->projectionContainerItem();
     if (!container_item)
         return;
     auto projn_items = container_item->projectionsOfType(m_orientation);
diff --git a/GUI/View/Plotter/RangeUtil.cpp b/GUI/View/Plotter/RangeUtil.cpp
index cac9c4e5bb8..fe65fed449d 100644
--- a/GUI/View/Plotter/RangeUtil.cpp
+++ b/GUI/View/Plotter/RangeUtil.cpp
@@ -23,7 +23,7 @@ namespace {
 double commonMin(const QList<AmplitudeAxisItem*>& axes)
 {
     double min = +std::numeric_limits<double>::max();
-    for (auto axis : axes)
+    for (auto* axis : axes)
         if (min > axis->min())
             min = axis->min();
     return min;
@@ -32,7 +32,7 @@ double commonMin(const QList<AmplitudeAxisItem*>& axes)
 double commonMax(const QList<AmplitudeAxisItem*>& axes)
 {
     double max = -std::numeric_limits<double>::max();
-    for (auto axis : axes)
+    for (auto* axis : axes)
         if (max < axis->max())
             max = axis->max();
     return max;
@@ -40,13 +40,13 @@ double commonMax(const QList<AmplitudeAxisItem*>& axes)
 
 QCPRange commonRange(const QList<AmplitudeAxisItem*>& axes)
 {
-    return QCPRange(commonMin(axes), commonMax(axes));
+    return {commonMin(axes), commonMax(axes)};
 }
 
 QList<AmplitudeAxisItem*> valueAxesFromData1DItems(const QList<Data1DItem*>& items)
 {
     QList<AmplitudeAxisItem*> axes;
-    for (auto item : items)
+    for (auto* item : items)
         axes.append(item->axItemY());
     return axes;
 }
@@ -54,7 +54,7 @@ QList<AmplitudeAxisItem*> valueAxesFromData1DItems(const QList<Data1DItem*>& ite
 QList<AmplitudeAxisItem*> valueAxesFromData2DItems(const QList<Data2DItem*>& items)
 {
     QList<AmplitudeAxisItem*> axes;
-    for (auto item : items)
+    for (auto* item : items)
         axes.append(item->zAxisItem());
     return axes;
 }
@@ -64,13 +64,13 @@ QList<AmplitudeAxisItem*> valueAxesFromData2DItems(const QList<Data2DItem*>& ite
 void GUI::View::RangeUtil::setCommonRangeY(QList<Data1DItem*> items)
 {
     QCPRange range = commonRange(valueAxesFromData1DItems(items));
-    for (auto item : items)
+    for (auto* item : items)
         item->setYrange(range.lower, range.upper);
 }
 
 void GUI::View::RangeUtil::setCommonRangeZ(QList<Data2DItem*> items)
 {
     QCPRange range = commonRange(valueAxesFromData2DItems(items));
-    for (auto item : items)
+    for (auto* item : items)
         item->setZrange(range.lower, range.upper);
 }
diff --git a/GUI/View/Plotter/SpecularPlot.cpp b/GUI/View/Plotter/SpecularPlot.cpp
index 0826b967ebf..76f9dd60c74 100644
--- a/GUI/View/Plotter/SpecularPlot.cpp
+++ b/GUI/View/Plotter/SpecularPlot.cpp
@@ -74,7 +74,7 @@ QList<Data1DItem*> SpecularPlot::data1DItems() const
 
 Data1DItem* SpecularPlot::currentData1DItem() const
 {
-    if (data1DItems().size() == 0)
+    if (data1DItems().empty())
         return nullptr;
 
     return data1DItems().first();
@@ -104,18 +104,18 @@ void SpecularPlot::setLog()
     replot();
 }
 
-void SpecularPlot::onXaxisRangeChanged(QCPRange range)
+void SpecularPlot::onXaxisRangeChanged(QCPRange range) const
 {
-    for (auto item : data1DItems())
+    for (auto* item : data1DItems())
         item->setXrange(range.lower, range.upper);
     gProjectDocument.value()->setModified();
     if (currentData1DItem())
         emit currentData1DItem()->updateOtherPlots(currentData1DItem());
 }
 
-void SpecularPlot::onYaxisRangeChanged(QCPRange range)
+void SpecularPlot::onYaxisRangeChanged(QCPRange range) const
 {
-    for (auto item : data1DItems())
+    for (auto* item : data1DItems())
         item->setYrange(range.lower, range.upper);
     gProjectDocument.value()->setModified();
     if (currentData1DItem())
@@ -130,12 +130,12 @@ void SpecularPlot::onTimeToReplot()
 void SpecularPlot::connectItems()
 {
     // data
-    for (auto item : data1DItems())
+    for (auto* item : data1DItems())
         connect(item, &DataItem::datafieldChanged, this, &SpecularPlot::initPlot,
                 Qt::UniqueConnection);
 
     // units
-    for (auto item : data1DItems())
+    for (auto* item : data1DItems())
         connect(item, &DataItem::axesUnitsReplotRequested, this, &SpecularPlot::setPlot,
                 Qt::UniqueConnection);
 
@@ -161,7 +161,7 @@ void SpecularPlot::initPlot()
     m_qcp->clearPlottables(); // clear graphs and error bars
     m_graph_map.clear();
     m_errorbar_map.clear();
-    for (auto item : data1DItems()) {
+    for (auto* item : data1DItems()) {
         m_qcp->addGraph();
         m_graph_map.insert(item, m_qcp->graph());
         m_qcp->graph()->setLineStyle(item->lineStyle());
@@ -171,7 +171,7 @@ void SpecularPlot::initPlot()
         // create error bars
         const Datafield* data = item->c_field();
         if (data && data->hasErrorSigmas()) {
-            QCPErrorBars* errorBars = new QCPErrorBars(m_qcp->xAxis, m_qcp->yAxis);
+            auto* errorBars = new QCPErrorBars(m_qcp->xAxis, m_qcp->yAxis);
             m_errorbar_map.insert(item, errorBars);
             errorBars->removeFromLegend();
             errorBars->setAntialiased(false);
@@ -222,7 +222,7 @@ void SpecularPlot::setUpdateTimerConnected(bool isConnected)
 
 void SpecularPlot::setPlot()
 {
-    for (auto item : data1DItems())
+    for (auto* item : data1DItems())
         setDataFromItem(item);
     setAxes();
     setAxesLabels();
diff --git a/GUI/View/Plotter/SpecularPlot.h b/GUI/View/Plotter/SpecularPlot.h
index 28c38e4d723..2899850f855 100644
--- a/GUI/View/Plotter/SpecularPlot.h
+++ b/GUI/View/Plotter/SpecularPlot.h
@@ -51,10 +51,10 @@ public:
 
 private:
     //! Propagate xmin, xmax back to Data2DItem
-    void onXaxisRangeChanged(QCPRange range);
+    void onXaxisRangeChanged(QCPRange range) const;
 
     //! Propagate ymin, ymax back to Data2DItem
-    void onYaxisRangeChanged(QCPRange range);
+    void onYaxisRangeChanged(QCPRange range) const;
 
     //! Replots SpecularPlot.
     void onTimeToReplot();
diff --git a/GUI/View/ProShape/MaskUtil.cpp b/GUI/View/ProShape/MaskUtil.cpp
index 63a1a0dad1e..3b0df4040d2 100644
--- a/GUI/View/ProShape/MaskUtil.cpp
+++ b/GUI/View/ProShape/MaskUtil.cpp
@@ -25,21 +25,21 @@ QBrush MaskUtil::getSelectionMarkerBrush()
 
 QPen MaskUtil::getSelectionMarkerPen()
 {
-    return QPen(QColor(99, 162, 217));
+    return {QColor(99, 162, 217)};
 }
 
 QBrush MaskUtil::getMaskBrush(bool mask_value)
 {
     if (!mask_value)
         return Qt::NoBrush;
-    return QBrush(QColor(0, 0, 80)); // deep blue
+    return {QColor(0, 0, 80)}; // deep blue
 }
 
 QPen MaskUtil::getMaskPen(bool mask_value)
 {
     if (mask_value)
-        return QPen(QColor(165, 80, 76)); // dark red
-    return QPen(QColor(0, 140, 70));      // dark green
+        return {QColor(165, 80, 76)}; // dark red
+    return {QColor(0, 140, 70)};      // dark green
 }
 
 QRectF MaskUtil::getMarkerRectangle(const QPointF& pos)
-- 
GitLab