From 429ee5e4fd4569e3a7599cb1ace55ad41cb68c91 Mon Sep 17 00:00:00 2001
From: Joachim Wuttke <j.wuttke@fz-juelich.de>
Date: Mon, 29 Aug 2022 12:10:54 +0200
Subject: [PATCH] GUI: rm Qt5 version switches (#304)

This resolves 04
---
 GUI/View/Common/DocksController.cpp              | 3 ---
 GUI/View/Instrument/DistributionPlot.cpp         | 8 --------
 GUI/View/Main/MainWindow.cpp                     | 5 -----
 GUI/View/Mask/MaskEditorToolbar.cpp              | 9 ---------
 GUI/View/Mask/MaskGraphicsView.cpp               | 4 ----
 GUI/View/Project/ProjectManager.cpp              | 4 ----
 GUI/View/Projection/ProjectionsPlot.cpp          | 5 -----
 GUI/View/Projection/ProjectionsToolbar.cpp       | 6 ------
 GUI/View/Projection/SaveProjectionsAssistant.cpp | 7 -------
 GUI/View/Tool/StyleUtils.cpp                     | 4 ----
 GUI/ba3d/def.cpp                                 | 3 ---
 11 files changed, 58 deletions(-)

diff --git a/GUI/View/Common/DocksController.cpp b/GUI/View/Common/DocksController.cpp
index 4dd93abacbb..f63cffa9f02 100644
--- a/GUI/View/Common/DocksController.cpp
+++ b/GUI/View/Common/DocksController.cpp
@@ -104,11 +104,8 @@ void DocksController::resetLayout()
     for (auto& it : m_docks)
         m_mainWindow->addDockWidget(it.second.area(), it.second.dock());
 
-        // Fixes issue: https://bugreports.qt.io/browse/QTBUG-65592
-#if QT_VERSION >= 0x050600
     if (!dockWidgets().empty())
         m_mainWindow->resizeDocks({dockWidgets().first()}, {10}, Qt::Horizontal);
-#endif
 
     for (auto* dockWidget : dockWidgets())
         dockWidget->show();
diff --git a/GUI/View/Instrument/DistributionPlot.cpp b/GUI/View/Instrument/DistributionPlot.cpp
index baab54333ea..03c7b7886d9 100644
--- a/GUI/View/Instrument/DistributionPlot.cpp
+++ b/GUI/View/Instrument/DistributionPlot.cpp
@@ -193,11 +193,7 @@ void DistributionPlot::plot_multiple_values()
     double sumOfWeights = std::accumulate(yp.begin(), yp.end(), 0.0);
     ASSERT(sumOfWeights != 0.0);
 
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
     QVector<double> xBar(xp.begin(), xp.end());
-#else
-    QVector<double> xBar = QVector<double>::fromStdVector(xp);
-#endif
 
     QVector<double> yBar(xBar.size());
     std::transform(yp.begin(), yp.end(), yBar.begin(),
@@ -214,11 +210,7 @@ void DistributionPlot::plot_multiple_values()
     std::transform(xf.begin(), xf.end(), yf.begin(),
                    [&](double value) { return dist->probabilityDensity(value); });
 
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
     QVector<double> xFunc(xf.begin(), xf.end());
-#else
-    QVector<double> xFunc = QVector<double>::fromStdVector(xf);
-#endif
     QVector<double> yFunc(xFunc.size());
     std::transform(yf.begin(), yf.end(), yFunc.begin(),
                    [&](double value) { return value / sumOfWeights; });
diff --git a/GUI/View/Main/MainWindow.cpp b/GUI/View/Main/MainWindow.cpp
index 87400e62cea..3e7992ee842 100644
--- a/GUI/View/Main/MainWindow.cpp
+++ b/GUI/View/Main/MainWindow.cpp
@@ -72,12 +72,7 @@ MainWindow::MainWindow()
     fillerButton->setEnabled(false);
     m_viewSelectionButtonsLayout->insertWidget(-1, fillerButton);
 
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
     connect(m_viewSelectionButtons, &QButtonGroup::idClicked, this, &MainWindow::raiseView);
-#else
-    connect(m_viewSelectionButtons, QOverload<int>::of(&QButtonGroup::buttonClicked), this,
-            &MainWindow::raiseView);
-#endif
 
     auto* vlayout = new QVBoxLayout;
     vlayout->setContentsMargins(0, 0, 0, 0);
diff --git a/GUI/View/Mask/MaskEditorToolbar.cpp b/GUI/View/Mask/MaskEditorToolbar.cpp
index 62cdd7a9539..eb04bfdad95 100644
--- a/GUI/View/Mask/MaskEditorToolbar.cpp
+++ b/GUI/View/Mask/MaskEditorToolbar.cpp
@@ -38,19 +38,10 @@ MaskEditorToolbar::MaskEditorToolbar(MaskEditorActions* editorActions, QWidget*
     setup_maskmodify_group();
     setup_extratools_group();
 
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
     connect(m_activityButtonGroup, &QButtonGroup::idClicked, this,
             &MaskEditorToolbar::onActivityGroupChange);
     connect(m_maskValueGroup, &QButtonGroup::idClicked, this,
             &MaskEditorToolbar::onMaskValueGroupChange);
-#else
-    connect(m_activityButtonGroup,
-            static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this,
-            &MaskEditorToolbar::onActivityGroupChange);
-    connect(m_maskValueGroup,
-            static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this,
-            &MaskEditorToolbar::onMaskValueGroupChange);
-#endif
 
     m_previousActivity = currentActivity();
 }
diff --git a/GUI/View/Mask/MaskGraphicsView.cpp b/GUI/View/Mask/MaskGraphicsView.cpp
index 51f62dfb98e..4afd3d44ac1 100644
--- a/GUI/View/Mask/MaskGraphicsView.cpp
+++ b/GUI/View/Mask/MaskGraphicsView.cpp
@@ -49,11 +49,7 @@ void MaskGraphicsView::wheelEvent(QWheelEvent* event)
 {
     // hold control button
     if (isControlButtonIsPressed(event)) {
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
         centerOn(mapToScene(event->position().toPoint()));
-#else
-        centerOn(mapToScene(event->pos())); // TODO upon Qt5.14: pos() -> position().toPoint()
-#endif
         if (event->angleDelta().y() > 0) {
             // Zoom in
             increazeZoomValue();
diff --git a/GUI/View/Project/ProjectManager.cpp b/GUI/View/Project/ProjectManager.cpp
index 7c1510f86f2..a542173934b 100644
--- a/GUI/View/Project/ProjectManager.cpp
+++ b/GUI/View/Project/ProjectManager.cpp
@@ -428,11 +428,7 @@ QString ProjectManager::untitledProjectName()
     if (projectDir.exists()) {
         for (size_t i = 1; i < 99; ++i) {
             result = QString("Untitled") + QString::number(i);
-#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
             projectDir.setPath(workingDirectory() + "/" + result);
-#else
-            projectDir = workingDirectory() + "/" + result;
-#endif
             if (!projectDir.exists())
                 break;
         }
diff --git a/GUI/View/Projection/ProjectionsPlot.cpp b/GUI/View/Projection/ProjectionsPlot.cpp
index ba5fb60e966..167121aed92 100644
--- a/GUI/View/Projection/ProjectionsPlot.cpp
+++ b/GUI/View/Projection/ProjectionsPlot.cpp
@@ -250,15 +250,10 @@ void ProjectionsPlot::setGraphFromItem(QCPGraph* graph, SessionItem* item)
         field.reset(m_field->yProjection(value));
     }
 
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
     auto centers = field->axis(0).binCenters();
     auto values = field->flatVector();
     graph->setData(QVector<double>(centers.begin(), centers.end()),
                    QVector<double>(values.begin(), values.end()));
-#else
-    graph->setData(QVector<double>::fromStdVector(hist->binCenters()),
-                   QVector<double>::fromStdVector(hist->binValues()));
-#endif
 }
 
 void ProjectionsPlot::setInterpolate(bool isInterpolated)
diff --git a/GUI/View/Projection/ProjectionsToolbar.cpp b/GUI/View/Projection/ProjectionsToolbar.cpp
index cb5d2ecee7b..9ee9b8ea96c 100644
--- a/GUI/View/Projection/ProjectionsToolbar.cpp
+++ b/GUI/View/Projection/ProjectionsToolbar.cpp
@@ -49,14 +49,8 @@ ProjectionsToolbar::ProjectionsToolbar(ProjectionsEditorActions* editorActions,
     setup_shapes_group();
     setup_extratools_group();
 
-#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
     connect(m_activityButtonGroup, &QButtonGroup::idClicked, this,
             &ProjectionsToolbar::onActivityGroupChange);
-#else
-    connect(m_activityButtonGroup,
-            static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this,
-            &ProjectionsToolbar::onActivityGroupChange);
-#endif
 
     m_previousActivity = currentActivity();
 }
diff --git a/GUI/View/Projection/SaveProjectionsAssistant.cpp b/GUI/View/Projection/SaveProjectionsAssistant.cpp
index af422077b40..e87e94eadfe 100644
--- a/GUI/View/Projection/SaveProjectionsAssistant.cpp
+++ b/GUI/View/Projection/SaveProjectionsAssistant.cpp
@@ -145,18 +145,11 @@ SaveProjectionsAssistant::projectionsData(const QString& projectionsType,
             field.reset(m_field->yProjection(data.axis_value));
         }
 
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
         auto values = field->flatVector();
         auto centers = field->axis(0).binCenters();
         data.bin_values = QVector<double>(values.begin(), values.end());
         if (result.bin_centers.isEmpty())
             result.bin_centers = QVector<double>(centers.begin(), centers.end());
-#else
-        data.bin_values = QVector<double>::fromStdVector(hist->binValues());
-        if (result.bin_centers.isEmpty())
-            result.bin_centers = QVector<double>::fromStdVector(hist->binCenters());
-#endif
-
         result.projections.push_back(data);
     }
     return result;
diff --git a/GUI/View/Tool/StyleUtils.cpp b/GUI/View/Tool/StyleUtils.cpp
index 9d9bd46bf3a..40785391028 100644
--- a/GUI/View/Tool/StyleUtils.cpp
+++ b/GUI/View/Tool/StyleUtils.cpp
@@ -27,11 +27,7 @@ namespace {
 QSize FindSizeOfLetterM(const QWidget* widget)
 {
     QFontMetrics fontMetric(widget->font());
-#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
     auto em = fontMetric.horizontalAdvance('M');
-#else
-    auto em = fontMetric.width('M');
-#endif
     auto fontAscent = fontMetric.ascent();
 
     return QSize(em, fontAscent);
diff --git a/GUI/ba3d/def.cpp b/GUI/ba3d/def.cpp
index 970de1ea69b..261f58e742a 100644
--- a/GUI/ba3d/def.cpp
+++ b/GUI/ba3d/def.cpp
@@ -14,9 +14,6 @@
 
 #include "GUI/ba3d/def.h"
 
-static_assert(QT_VERSION >= QT_VERSION_CHECK(5, 5, 1),
-              "requires Qt >= 5.5.1, have " QT_VERSION_STR);
-
 namespace GUI::RealSpace {
 
 Vector3D::Vector3D()
-- 
GitLab