From 48250a8d4c8b439fb71703859a515acf1cc94aad Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (l)" <j.wuttke@fz-juelich.de>
Date: Fri, 5 Nov 2021 14:39:28 +0100
Subject: [PATCH] decouple ItemFileNameUtils from items

---
 GUI/Models/Data/IntensityDataItem.cpp         |  2 +-
 GUI/Models/Data/MaskUnitsConverter.cpp        |  2 +-
 GUI/Models/Data/RealDataItem.cpp              |  4 ++--
 GUI/Models/Fit/FitParameterHelper.cpp         |  2 +-
 GUI/Models/Fit/FitParameterItems.cpp          |  2 +-
 GUI/Models/Instrument/InstrumentItems.cpp     |  4 ++--
 GUI/Models/Job/JobItem.cpp                    | 10 ++++-----
 GUI/Models/Job/JobModel.cpp                   |  2 +-
 GUI/Models/Job/JobModelFunctions.cpp          |  8 +++----
 GUI/Models/Job/ParameterTreeUtils.cpp         |  2 +-
 GUI/Models/Session/SessionItem.cpp            |  2 +-
 GUI/Models/Varia/ItemCatalog.cpp              |  4 ++--
 GUI/Views/FitWidgets/FitParameterWidget.cpp   |  2 +-
 .../FitWidgets/ParameterTuningWidget.cpp      |  4 ++--
 GUI/Views/MaskWidgets/MaskContainerView.cpp   |  2 +-
 GUI/Views/MaskWidgets/MaskGraphicsScene.cpp   |  2 +-
 GUI/Views/MaskWidgets/MaskViewFactory.cpp     |  2 +-
 .../ProjectionsWidgets/ProjectionsPlot.cpp    |  2 +-
 .../SaveProjectionsAssistant.cpp              |  2 +-
 .../Varia => utils}/ItemFileNameUtils.cpp     | 22 +++++++++----------
 .../Varia => utils}/ItemFileNameUtils.h       | 20 +++++++----------
 Tests/Unit/GUI/TestMapperForItem.cpp          |  2 +-
 Tests/Unit/GUI/TestProjectUtils.cpp           |  2 +-
 Tests/Unit/GUI/TestSavingSpecularData.cpp     |  6 ++---
 24 files changed, 53 insertions(+), 59 deletions(-)
 rename GUI/{Models/Varia => utils}/ItemFileNameUtils.cpp (75%)
 rename GUI/{Models/Varia => utils}/ItemFileNameUtils.h (63%)

diff --git a/GUI/Models/Data/IntensityDataItem.cpp b/GUI/Models/Data/IntensityDataItem.cpp
index 9264114dd31..5bcf51dd9f4 100644
--- a/GUI/Models/Data/IntensityDataItem.cpp
+++ b/GUI/Models/Data/IntensityDataItem.cpp
@@ -16,10 +16,10 @@
 #include "GUI/Models/Data/AxesItems.h"
 #include "GUI/Models/Data/ImportDataInfo.h"
 #include "GUI/Models/Data/MaskUnitsConverter.h"
+#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Models/Job/JobItemUtils.h"
 #include "GUI/Models/Session/SessionModel.h"
-#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/utils/Error.h"
 
 namespace {
diff --git a/GUI/Models/Data/MaskUnitsConverter.cpp b/GUI/Models/Data/MaskUnitsConverter.cpp
index 3fcbfe96f97..07b63a98bf0 100644
--- a/GUI/Models/Data/MaskUnitsConverter.cpp
+++ b/GUI/Models/Data/MaskUnitsConverter.cpp
@@ -15,8 +15,8 @@
 #include "GUI/Models/Data/MaskUnitsConverter.h"
 #include "Device/Data/DataUtils.h"
 #include "GUI/Models/Data/IntensityDataItem.h"
-#include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Models/Data/ProjectionItems.h"
+#include "GUI/Models/Instrument/MaskItems.h"
 
 #include <boost/polymorphic_cast.hpp>
 using boost::polymorphic_downcast;
diff --git a/GUI/Models/Data/RealDataItem.cpp b/GUI/Models/Data/RealDataItem.cpp
index e72946856d2..fe70d7369fd 100644
--- a/GUI/Models/Data/RealDataItem.cpp
+++ b/GUI/Models/Data/RealDataItem.cpp
@@ -19,6 +19,7 @@
 #include "GUI/Models/Data/DataLoaders1D.h"
 #include "GUI/Models/Data/ImportDataInfo.h"
 #include "GUI/Models/Data/IntensityDataItem.h"
+#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Models/Data/RealDataModel.h"
 #include "GUI/Models/Data/SpecularDataItem.h"
 #include "GUI/Models/Instrument/InstrumentItems.h"
@@ -27,11 +28,10 @@
 #include "GUI/Models/Job/JobItem.h"
 #include "GUI/Models/Job/JobItemUtils.h"
 #include "GUI/Models/Job/JobModelFunctions.h"
-#include "GUI/Models/Data/ProjectionItems.h"
-#include "GUI/Models/Varia/ItemFileNameUtils.h"
 #include "GUI/Session/SessionData.h"
 #include "GUI/utils/DeserializationException.h"
 #include "GUI/utils/Error.h"
+#include "GUI/utils/ItemFileNameUtils.h"
 #include <QtCore/QXmlStreamReader>
 #include <QtCore/QXmlStreamWriter>
 
diff --git a/GUI/Models/Fit/FitParameterHelper.cpp b/GUI/Models/Fit/FitParameterHelper.cpp
index 6eea751ef82..21f5b409b26 100644
--- a/GUI/Models/Fit/FitParameterHelper.cpp
+++ b/GUI/Models/Fit/FitParameterHelper.cpp
@@ -14,9 +14,9 @@
 
 #include "GUI/Models/Fit/FitParameterHelper.h"
 #include "GUI/Models/Fit/FitParameterItems.h"
+#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Job/JobItem.h"
 #include "GUI/Models/Job/JobModel.h"
-#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Session/ModelPath.h"
 
 //! Creates fit parameter from given ParameterItem, sets starting value to the value
diff --git a/GUI/Models/Fit/FitParameterItems.cpp b/GUI/Models/Fit/FitParameterItems.cpp
index dc6d982ecd5..5e05f4a4129 100644
--- a/GUI/Models/Fit/FitParameterItems.cpp
+++ b/GUI/Models/Fit/FitParameterItems.cpp
@@ -15,9 +15,9 @@
 #include "GUI/Models/Fit/FitParameterItems.h"
 #include "Base/Utils/Assert.h"
 #include "Fit/Param/Parameters.h"
+#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Group/ComboProperty.h"
 #include "GUI/Models/Job/JobItem.h"
-#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Session/ModelPath.h"
 #include "GUI/utils/Error.h"
 #include <cmath>
diff --git a/GUI/Models/Instrument/InstrumentItems.cpp b/GUI/Models/Instrument/InstrumentItems.cpp
index ef627995768..9ef52a4f3c3 100644
--- a/GUI/Models/Instrument/InstrumentItems.cpp
+++ b/GUI/Models/Instrument/InstrumentItems.cpp
@@ -32,9 +32,9 @@
 #include "GUI/Models/Instrument/SphericalDetectorItem.h"
 #include "GUI/Models/Job/JobItemUtils.h"
 #include "GUI/Models/Types/VectorItem.h"
-#include "GUI/Models/Varia/ItemFileNameUtils.h"
 #include "GUI/utils/Error.h"
 #include "GUI/utils/Helpers.h"
+#include "GUI/utils/ItemFileNameUtils.h"
 
 namespace {
 
@@ -231,7 +231,7 @@ SpecularInstrumentItem::SpecularInstrumentItem() : InstrumentItem(M_TYPE)
 
     initBackgroundGroup();
     beam<SpecularBeamItem>()->updateFileName(
-        GUI::Model::FilenameUtils::instrumentDataFileName(*this));
+        GUI::Model::FilenameUtils::instrumentDataFileName(id()));
 }
 
 SpecularBeamItem* SpecularInstrumentItem::beamItem() const
diff --git a/GUI/Models/Job/JobItem.cpp b/GUI/Models/Job/JobItem.cpp
index dda6863069e..19a8b953948 100644
--- a/GUI/Models/Job/JobItem.cpp
+++ b/GUI/Models/Job/JobItem.cpp
@@ -19,14 +19,14 @@
 #include "GUI/Models/Data/RealDataItem.h"
 #include "GUI/Models/Data/SpecularDataItem.h"
 #include "GUI/Models/Fit/FitSuiteItem.h"
+#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Instrument/InstrumentItems.h"
 #include "GUI/Models/Job/JobItemUtils.h"
 #include "GUI/Models/Material/MaterialItemContainer.h"
-#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Sample/MultiLayerItem.h"
-#include "GUI/Models/Varia/ItemFileNameUtils.h"
 #include "GUI/Models/Varia/SimulationOptionsItem.h"
 #include "GUI/utils/Error.h"
+#include "GUI/utils/ItemFileNameUtils.h"
 
 JobItem::JobItem() : SessionItem(M_TYPE)
 {
@@ -383,14 +383,14 @@ void JobItem::setPresentationType(const QString& type)
 void JobItem::updateIntensityDataFileName()
 {
     if (DataItem* item = dataItem())
-        item->setFileName(GUI::Model::FilenameUtils::jobResultsFileName(*this));
+        item->setFileName(GUI::Model::FilenameUtils::jobResultsFileName(itemName()));
 
     if (RealDataItem* realItem = realDataItem()) {
         if (DataItem* item = realItem->dataItem())
-            item->setFileName(GUI::Model::FilenameUtils::jobReferenceFileName(*this));
+            item->setFileName(GUI::Model::FilenameUtils::jobReferenceFileName(itemName()));
 
         if (DataItem* item = realItem->nativeData())
-            item->setFileName(GUI::Model::FilenameUtils::jobNativeDataFileName(*this));
+            item->setFileName(GUI::Model::FilenameUtils::jobNativeDataFileName(getIdentifier()));
     }
 }
 
diff --git a/GUI/Models/Job/JobModel.cpp b/GUI/Models/Job/JobModel.cpp
index 735951f5a24..8d084a1534d 100644
--- a/GUI/Models/Job/JobModel.cpp
+++ b/GUI/Models/Job/JobModel.cpp
@@ -16,13 +16,13 @@
 #include "GUI/Models/Data/IntensityDataItem.h"
 #include "GUI/Models/Data/PointwiseAxisItem.h"
 #include "GUI/Models/Data/RealDataItem.h"
+#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Group/GroupItem.h"
 #include "GUI/Models/Instrument/InstrumentItems.h"
 #include "GUI/Models/Job/JobItem.h"
 #include "GUI/Models/Job/JobModelFunctions.h"
 #include "GUI/Models/Job/JobQueueData.h"
 #include "GUI/Models/Job/ParameterTreeUtils.h"
-#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Sample/MultiLayerItem.h"
 #include "GUI/utils/Helpers.h"
 
diff --git a/GUI/Models/Job/JobModelFunctions.cpp b/GUI/Models/Job/JobModelFunctions.cpp
index 251436cafd5..110cdb959c1 100644
--- a/GUI/Models/Job/JobModelFunctions.cpp
+++ b/GUI/Models/Job/JobModelFunctions.cpp
@@ -31,10 +31,10 @@
 #include "GUI/Models/Material/MaterialItemContainer.h"
 #include "GUI/Models/Material/MaterialItemUtils.h"
 #include "GUI/Models/Sample/MultiLayerItem.h"
-#include "GUI/Models/Varia/ItemFileNameUtils.h"
 #include "GUI/Models/Varia/ItemWithMaterial.h"
 #include "GUI/utils/Error.h"
 #include "GUI/utils/Helpers.h"
+#include "GUI/utils/ItemFileNameUtils.h"
 #include <map>
 
 namespace {
@@ -160,7 +160,7 @@ void GUI::Model::JobFunctions::setupJobItemInstrument(JobItem* jobItem, const In
         return;
 
     // updating filename
-    const auto filename = GUI::Model::FilenameUtils::instrumentDataFileName(*spec_to);
+    const auto filename = GUI::Model::FilenameUtils::instrumentDataFileName(spec_to->id());
     spec_to->beamItem()->updateFileName(filename);
 
     // copying axis data
@@ -233,7 +233,7 @@ void GUI::Model::JobFunctions::copyRealDataItem(JobItem* jobItem, const RealData
 
     // adapting the name to job name
     realDataItemCopy->dataItem()->setFileName(
-        GUI::Model::FilenameUtils::jobReferenceFileName(*jobItem));
+        GUI::Model::FilenameUtils::jobReferenceFileName(jobItem->itemName()));
 
     // #baimport ++ copy members of realDataItem?
 
@@ -242,7 +242,7 @@ void GUI::Model::JobFunctions::copyRealDataItem(JobItem* jobItem, const RealData
 
     realDataItemCopy->setNativeOutputData(realDataItem->nativeOutputData()->clone());
     realDataItemCopy->nativeData()->setFileName(
-        GUI::Model::FilenameUtils::jobNativeDataFileName(*jobItem));
+        GUI::Model::FilenameUtils::jobNativeDataFileName(jobItem->getIdentifier()));
 }
 
 const JobItem* GUI::Model::JobFunctions::findJobItem(const SessionItem* item)
diff --git a/GUI/Models/Job/ParameterTreeUtils.cpp b/GUI/Models/Job/ParameterTreeUtils.cpp
index 0535ee4a225..40f9e7ee9f6 100644
--- a/GUI/Models/Job/ParameterTreeUtils.cpp
+++ b/GUI/Models/Job/ParameterTreeUtils.cpp
@@ -13,11 +13,11 @@
 //  ************************************************************************************************
 
 #include "GUI/Models/Job/ParameterTreeUtils.h"
+#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Group/GroupItem.h"
 #include "GUI/Models/Instrument/InstrumentItems.h"
 #include "GUI/Models/Job/JobItem.h"
 #include "GUI/Models/Material/MaterialItemContainer.h"
-#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Parameter/PropertyItem.h"
 #include "GUI/Models/Sample/MultiLayerItem.h"
 #include "GUI/Models/Session/ModelPath.h"
diff --git a/GUI/Models/Session/SessionItem.cpp b/GUI/Models/Session/SessionItem.cpp
index db36d6b0dfb..90cbdd28f85 100644
--- a/GUI/Models/Session/SessionItem.cpp
+++ b/GUI/Models/Session/SessionItem.cpp
@@ -12,8 +12,8 @@
 //
 //  ************************************************************************************************
 
-#include "GUI/Models/Group/GroupItem.h"
 #include "GUI/Models/Fit/ParameterTreeItems.h"
+#include "GUI/Models/Group/GroupItem.h"
 #include "GUI/Models/Parameter/PropertyItem.h"
 #include "GUI/Models/Session/SessionItemData.h"
 #include "GUI/Models/Session/SessionItemTags.h"
diff --git a/GUI/Models/Varia/ItemCatalog.cpp b/GUI/Models/Varia/ItemCatalog.cpp
index a03e2a92a94..cc82c8aabbc 100644
--- a/GUI/Models/Varia/ItemCatalog.cpp
+++ b/GUI/Models/Varia/ItemCatalog.cpp
@@ -19,11 +19,13 @@
 #include "GUI/Models/Data/DataPropertyContainer.h"
 #include "GUI/Models/Data/IntensityDataItem.h"
 #include "GUI/Models/Data/PointwiseAxisItem.h"
+#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Models/Data/RealDataItem.h"
 #include "GUI/Models/Data/SpecularDataItem.h"
 #include "GUI/Models/Fit/FitParameterItems.h"
 #include "GUI/Models/Fit/FitSuiteItem.h"
 #include "GUI/Models/Fit/MinimizerItem.h"
+#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Group/GroupItem.h"
 #include "GUI/Models/Instrument/BackgroundItems.h"
 #include "GUI/Models/Instrument/BeamAngleItems.h"
@@ -38,7 +40,6 @@
 #include "GUI/Models/Material/MaterialDataItems.h"
 #include "GUI/Models/Material/MaterialItem.h"
 #include "GUI/Models/Material/MaterialItemContainer.h"
-#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Parameter/PropertyItem.h"
 #include "GUI/Models/Sample/FTDecayFunctionItems.h"
 #include "GUI/Models/Sample/FTDistributionItems.h"
@@ -54,7 +55,6 @@
 #include "GUI/Models/Sample/ParticleItem.h"
 #include "GUI/Models/Sample/ParticleLayoutItem.h"
 #include "GUI/Models/Sample/ResolutionFunctionItems.h"
-#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Models/Trafo/RotationItems.h"
 #include "GUI/Models/Trafo/TransformationItem.h"
 #include "GUI/Models/Types/VectorItem.h"
diff --git a/GUI/Views/FitWidgets/FitParameterWidget.cpp b/GUI/Views/FitWidgets/FitParameterWidget.cpp
index c05178960f0..40ae6ab05a9 100644
--- a/GUI/Views/FitWidgets/FitParameterWidget.cpp
+++ b/GUI/Views/FitWidgets/FitParameterWidget.cpp
@@ -17,10 +17,10 @@
 #include "GUI/Models/Fit/FitParameterItems.h"
 #include "GUI/Models/Fit/FitParameterProxyModel.h"
 #include "GUI/Models/Fit/FitSuiteItem.h"
+#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Job/JobItem.h"
 #include "GUI/Models/Job/JobModel.h"
 #include "GUI/Models/Parameter/FilterPropertyProxy.h"
-#include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Views/FitWidgets/ParameterTuningWidget.h"
 #include "GUI/Views/PropertyEditor/SessionModelDelegate.h"
 #include "GUI/Widgets/Info/OverlayLabelController.h"
diff --git a/GUI/Views/FitWidgets/ParameterTuningWidget.cpp b/GUI/Views/FitWidgets/ParameterTuningWidget.cpp
index db102ce55ac..84e5900e1ac 100644
--- a/GUI/Views/FitWidgets/ParameterTuningWidget.cpp
+++ b/GUI/Views/FitWidgets/ParameterTuningWidget.cpp
@@ -14,10 +14,10 @@
 
 #include "GUI/Views/FitWidgets/ParameterTuningWidget.h"
 #include "GUI/Models/Data/IntensityDataItem.h"
-#include "GUI/Models/Job/JobItem.h"
-#include "GUI/Models/Job/JobModel.h"
 #include "GUI/Models/Fit/ParameterTreeItems.h"
 #include "GUI/Models/Fit/ParameterTuningModel.h"
+#include "GUI/Models/Job/JobItem.h"
+#include "GUI/Models/Job/JobModel.h"
 #include "GUI/Views/FitWidgets/JobRealTimeToolBar.h"
 #include "GUI/Views/FitWidgets/ParameterTuningDelegate.h"
 #include "GUI/Views/FitWidgets/SliderSettingsWidget.h"
diff --git a/GUI/Views/MaskWidgets/MaskContainerView.cpp b/GUI/Views/MaskWidgets/MaskContainerView.cpp
index 8c2f894265f..04d17815781 100644
--- a/GUI/Views/MaskWidgets/MaskContainerView.cpp
+++ b/GUI/Views/MaskWidgets/MaskContainerView.cpp
@@ -13,8 +13,8 @@
 //  ************************************************************************************************
 
 #include "GUI/Views/MaskWidgets/MaskContainerView.h"
-#include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Models/Data/ProjectionItems.h"
+#include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Views/MaskWidgets/ISceneAdaptor.h"
 #include <QBrush>
 #include <QPainter>
diff --git a/GUI/Views/MaskWidgets/MaskGraphicsScene.cpp b/GUI/Views/MaskWidgets/MaskGraphicsScene.cpp
index 1cb302d8eac..8cb5ea7656a 100644
--- a/GUI/Views/MaskWidgets/MaskGraphicsScene.cpp
+++ b/GUI/Views/MaskWidgets/MaskGraphicsScene.cpp
@@ -13,11 +13,11 @@
 //  ************************************************************************************************
 
 #include "GUI/Views/MaskWidgets/MaskGraphicsScene.h"
+#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Models/Group/GroupItem.h"
 #include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Models/Parameter/PropertyItem.h"
 #include "GUI/Models/Session/SessionModel.h"
-#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Views/MaskWidgets/ColorMapSceneAdaptor.h"
 #include "GUI/Views/MaskWidgets/MaskGraphicsProxy.h"
 #include "GUI/Views/MaskWidgets/MaskViewFactory.h"
diff --git a/GUI/Views/MaskWidgets/MaskViewFactory.cpp b/GUI/Views/MaskWidgets/MaskViewFactory.cpp
index 56ef4e07394..16d4f6bb09e 100644
--- a/GUI/Views/MaskWidgets/MaskViewFactory.cpp
+++ b/GUI/Views/MaskWidgets/MaskViewFactory.cpp
@@ -13,9 +13,9 @@
 //  ************************************************************************************************
 
 #include "GUI/Views/MaskWidgets/MaskViewFactory.h"
+#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Models/Session/SessionItem.h"
-#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Views/MaskWidgets/EllipseView.h"
 #include "GUI/Views/MaskWidgets/LineViews.h"
 #include "GUI/Views/MaskWidgets/MaskAllView.h"
diff --git a/GUI/Views/ProjectionsWidgets/ProjectionsPlot.cpp b/GUI/Views/ProjectionsWidgets/ProjectionsPlot.cpp
index 25bf88d389d..83b6293aabc 100644
--- a/GUI/Views/ProjectionsWidgets/ProjectionsPlot.cpp
+++ b/GUI/Views/ProjectionsWidgets/ProjectionsPlot.cpp
@@ -17,8 +17,8 @@
 #include "Device/Histo/Histogram2D.h"
 #include "GUI/Models/Data/AxesItems.h"
 #include "GUI/Models/Data/IntensityDataItem.h"
-#include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Models/Data/ProjectionItems.h"
+#include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Views/IntensityDataWidgets/ColorMapUtils.h"
 #include "GUI/Views/IntensityDataWidgets/PlotConstants.h"
 #include <qcustomplot.h>
diff --git a/GUI/Views/ProjectionsWidgets/SaveProjectionsAssistant.cpp b/GUI/Views/ProjectionsWidgets/SaveProjectionsAssistant.cpp
index a45ad5b737f..41489bf44b4 100644
--- a/GUI/Views/ProjectionsWidgets/SaveProjectionsAssistant.cpp
+++ b/GUI/Views/ProjectionsWidgets/SaveProjectionsAssistant.cpp
@@ -18,8 +18,8 @@
 #include "Device/Histo/Histogram2D.h"
 #include "GUI/Application/GlobalSettings.h"
 #include "GUI/Models/Data/IntensityDataItem.h"
-#include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Models/Data/ProjectionItems.h"
+#include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Views/Main/ProjectManager.h"
 #include "GUI/utils/Error.h"
 #include <QFileDialog>
diff --git a/GUI/Models/Varia/ItemFileNameUtils.cpp b/GUI/utils/ItemFileNameUtils.cpp
similarity index 75%
rename from GUI/Models/Varia/ItemFileNameUtils.cpp
rename to GUI/utils/ItemFileNameUtils.cpp
index 5e1f3b86399..5f418d154f4 100644
--- a/GUI/Models/Varia/ItemFileNameUtils.cpp
+++ b/GUI/utils/ItemFileNameUtils.cpp
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      GUI/Models/Varia/ItemFileNameUtils.cpp
+//! @file      GUI/utils/ItemFileNameUtils.cpp
 //! @brief     Defines auxiliary functions in ItemFileNameUtils namespace.
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,9 +12,7 @@
 //
 //  ************************************************************************************************
 
-#include "GUI/Models/Varia/ItemFileNameUtils.h"
-#include "GUI/Models/Instrument/InstrumentItems.h"
-#include "GUI/Models/Job/JobItem.h"
+#include "GUI/utils/ItemFileNameUtils.h"
 #include "GUI/utils/Helpers.h"
 
 namespace {
@@ -37,21 +35,21 @@ QString intensityDataFileName(const QString& itemName, const QString& prefix)
 
 //! Constructs the name of the file with simulated intensities.
 
-QString GUI::Model::FilenameUtils::jobResultsFileName(const JobItem& jobItem)
+QString GUI::Model::FilenameUtils::jobResultsFileName(const QString& itemName)
 {
-    return intensityDataFileName(jobItem.itemName(), jobdata_file_prefix);
+    return intensityDataFileName(itemName, jobdata_file_prefix);
 }
 
 //! Constructs the name of the file with reference data.
 
-QString GUI::Model::FilenameUtils::jobReferenceFileName(const JobItem& jobItem)
+QString GUI::Model::FilenameUtils::jobReferenceFileName(const QString& itemName)
 {
-    return intensityDataFileName(jobItem.itemName(), refdata_file_prefix);
+    return intensityDataFileName(itemName, refdata_file_prefix);
 }
 
-QString GUI::Model::FilenameUtils::jobNativeDataFileName(const JobItem& jobItem)
+QString GUI::Model::FilenameUtils::jobNativeDataFileName(const QString& id)
 {
-    return intensityDataFileName(jobItem.getIdentifier(), nativedata_file_prefix);
+    return intensityDataFileName(id, nativedata_file_prefix);
 }
 
 //! Constructs the name of the intensity file belonging to real data item.
@@ -66,9 +64,9 @@ QString GUI::Model::FilenameUtils::nativeDataFileName(const QString& dataName)
     return intensityDataFileName(dataName, nativedata_file_prefix);
 }
 
-QString GUI::Model::FilenameUtils::instrumentDataFileName(const InstrumentItem& instrumentItem)
+QString GUI::Model::FilenameUtils::instrumentDataFileName(const QString& id)
 {
-    return intensityDataFileName(instrumentItem.id(), instrument_file_prefix);
+    return intensityDataFileName(id, instrument_file_prefix);
 }
 
 //! Returns list of fileName filters related to nonXML data stored by JobModel and RealDataModel.
diff --git a/GUI/Models/Varia/ItemFileNameUtils.h b/GUI/utils/ItemFileNameUtils.h
similarity index 63%
rename from GUI/Models/Varia/ItemFileNameUtils.h
rename to GUI/utils/ItemFileNameUtils.h
index 9cab1f5607a..29ca435c89a 100644
--- a/GUI/Models/Varia/ItemFileNameUtils.h
+++ b/GUI/utils/ItemFileNameUtils.h
@@ -2,7 +2,7 @@
 //
 //  BornAgain: simulate and fit reflection and scattering
 //
-//! @file      GUI/Models/Varia/ItemFileNameUtils.h
+//! @file      GUI/utils/ItemFileNameUtils.h
 //! @brief     Defines namespace GUI::Model::FilenameUtils
 //!
 //! @homepage  http://www.bornagainproject.org
@@ -12,33 +12,29 @@
 //
 //  ************************************************************************************************
 
-#ifndef BORNAGAIN_GUI_MODELS_VARIA_ITEMFILENAMEUTILS_H
-#define BORNAGAIN_GUI_MODELS_VARIA_ITEMFILENAMEUTILS_H
+#ifndef BORNAGAIN_GUI_UTILS_ITEMFILENAMEUTILS_H
+#define BORNAGAIN_GUI_UTILS_ITEMFILENAMEUTILS_H
 
 #include <QString>
 
-class InstrumentItem;
-class JobItem;
-class RealDataItem;
-
 //! Contains set of convenience methods for JobItem and its children.
 
 namespace GUI::Model::FilenameUtils {
 
-QString jobResultsFileName(const JobItem& jobItem);
+QString jobResultsFileName(const QString& itemName);
 
-QString jobReferenceFileName(const JobItem& jobItem);
+QString jobReferenceFileName(const QString& itemName);
 
-QString jobNativeDataFileName(const JobItem& jobItem);
+QString jobNativeDataFileName(const QString& id);
 
 QString realDataFileName(const QString& dataName);
 
 QString nativeDataFileName(const QString& dataName);
 
-QString instrumentDataFileName(const InstrumentItem& instrumentItem);
+QString instrumentDataFileName(const QString& id);
 
 QStringList nonXMLFileNameFilters();
 
 } // namespace GUI::Model::FilenameUtils
 
-#endif // BORNAGAIN_GUI_MODELS_VARIA_ITEMFILENAMEUTILS_H
+#endif // BORNAGAIN_GUI_UTILS_ITEMFILENAMEUTILS_H
diff --git a/Tests/Unit/GUI/TestMapperForItem.cpp b/Tests/Unit/GUI/TestMapperForItem.cpp
index 0c1680c5575..41b59689946 100644
--- a/Tests/Unit/GUI/TestMapperForItem.cpp
+++ b/Tests/Unit/GUI/TestMapperForItem.cpp
@@ -1,9 +1,9 @@
+#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Models/Instrument/MaskItems.h"
 #include "GUI/Models/Sample/LayerItem.h"
 #include "GUI/Models/Sample/MultiLayerItem.h"
 #include "GUI/Models/Sample/SampleModel.h"
 #include "GUI/Models/Session/SessionItemUtils.h"
-#include "GUI/Models/Data/ProjectionItems.h"
 #include "GUI/Models/Types/DoubleDescriptor.h"
 #include "Tests/GTestWrapper/google_test.h"
 #include <memory>
diff --git a/Tests/Unit/GUI/TestProjectUtils.cpp b/Tests/Unit/GUI/TestProjectUtils.cpp
index 84fd4212e71..91706f3ebc2 100644
--- a/Tests/Unit/GUI/TestProjectUtils.cpp
+++ b/Tests/Unit/GUI/TestProjectUtils.cpp
@@ -1,6 +1,6 @@
 #include "GUI/Models/Project/ProjectUtils.h"
-#include "GUI/Models/Varia/ItemFileNameUtils.h"
 #include "GUI/utils/Error.h"
+#include "GUI/utils/ItemFileNameUtils.h"
 #include "Tests/GTestWrapper/google_test.h"
 #include "Utils.h"
 #include <QDir>
diff --git a/Tests/Unit/GUI/TestSavingSpecularData.cpp b/Tests/Unit/GUI/TestSavingSpecularData.cpp
index d8f398a3b51..69f1c2d86b3 100644
--- a/Tests/Unit/GUI/TestSavingSpecularData.cpp
+++ b/Tests/Unit/GUI/TestSavingSpecularData.cpp
@@ -13,8 +13,8 @@
 #include "GUI/Models/Job/JobModelFunctions.h"
 #include "GUI/Models/Project/OutputDataIOService.h"
 #include "GUI/Models/Project/ProjectUtils.h"
-#include "GUI/Models/Varia/ItemFileNameUtils.h"
 #include "GUI/utils/Error.h"
+#include "GUI/utils/ItemFileNameUtils.h"
 #include "Tests/GTestWrapper/google_test.h"
 #include "Tests/Unit/GUI/Utils.h"
 #include <QTest>
@@ -265,9 +265,9 @@ TEST_F(TestSavingSpecularData, test_CopyInstrumentToJobItem)
 
     // checking filenames
     EXPECT_EQ(pointwise_axis_item->fileName(),
-              GUI::Model::FilenameUtils::instrumentDataFileName(*instrument));
+              GUI::Model::FilenameUtils::instrumentDataFileName(instrument->id()));
     EXPECT_EQ(job_axis_item->fileName(),
-              GUI::Model::FilenameUtils::instrumentDataFileName(*job_instrument));
+              GUI::Model::FilenameUtils::instrumentDataFileName(job_instrument->id()));
 
     // Saving
     OutputDataIOService service(&models);
-- 
GitLab