From c7401a010afc1b77c159e8c253fc2e9e4f7676f7 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Fri, 1 Mar 2024 11:54:16 +0100
Subject: [PATCH] rm DatafileEditor

---
 GUI/View/Data/DatafileEditor.cpp    | 116 ----------------------------
 GUI/View/Data/DatafileEditor.h      |  55 -------------
 GUI/View/List/DatafilesSelector.cpp |   9 +--
 GUI/View/List/DatafilesSelector.h   |   9 +--
 4 files changed, 2 insertions(+), 187 deletions(-)
 delete mode 100644 GUI/View/Data/DatafileEditor.cpp
 delete mode 100644 GUI/View/Data/DatafileEditor.h

diff --git a/GUI/View/Data/DatafileEditor.cpp b/GUI/View/Data/DatafileEditor.cpp
deleted file mode 100644
index a4c8e586b06..00000000000
--- a/GUI/View/Data/DatafileEditor.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-//  ************************************************************************************************
-//
-//  BornAgain: simulate and fit reflection and scattering
-//
-//! @file      GUI/View/Data/DatafileEditor.cpp
-//! @brief     Implements class DatafileEditor.
-//!
-//! @homepage  http://www.bornagainproject.org
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2021
-//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
-//
-//  ************************************************************************************************
-
-#include "GUI/View/Data/DatafileEditor.h"
-#include "GUI/Model/Device/DatafileItem.h"
-#include "GUI/Model/Device/InstrumentsSet.h"
-#include "GUI/Model/Project/LinkInstrumentManager.h"
-#include "GUI/Model/Project/ProjectDocument.h"
-#include "GUI/View/Tool/Globals.h"
-#include <QLabel>
-#include <QVBoxLayout>
-
-DatafileEditor::DatafileEditor()
-    : m_instrument_combo(new QComboBox)
-    , m_current_datafile_item(nullptr)
-{
-    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
-    setWindowTitle("DatafileEditor");
-
-    auto* layout = new QVBoxLayout;
-    layout->setContentsMargins(5, 5, 5, 5);
-    layout->setSpacing(2);
-
-    m_instrument_combo->setToolTip("Select instrument to link with real data");
-
-    layout->addWidget(new QLabel("Linked instrument"));
-    layout->addWidget(m_instrument_combo);
-
-    layout->addStretch();
-    setLayout(layout);
-
-    updateInstrumentComboEntries();
-    setEnabled(false);
-
-    connect(m_instrument_combo, &QComboBox::currentIndexChanged, this,
-            &DatafileEditor::onInstrumentComboIndexChanged);
-
-    connect(gDoc->instruments(), &InstrumentsSet::setChanged, this,
-            &DatafileEditor::updateInstrumentComboEntries);
-
-    connect(gDoc->linkInstrumentManager(), &LinkInstrumentManager::linkToInstrumentChanged, this,
-            &DatafileEditor::updateInstrumentComboIndex);
-}
-
-void DatafileEditor::setDatafileItem(DatafileItem* dfile_item)
-{
-    m_current_datafile_item = dfile_item;
-    updateInstrumentComboIndex();
-    setEnabled(m_current_datafile_item != nullptr);
-}
-
-void DatafileEditor::onInstrumentComboIndexChanged(int /*index*/)
-{
-    if (!m_current_datafile_item)
-        return;
-
-    const QString newSelectedInstrumentId = m_instrument_combo->currentData().toString();
-
-    if (newSelectedInstrumentId == m_current_datafile_item->instrumentId())
-        return;
-
-    if (gDoc->linkInstrumentManager()->canLinkDataToInstrument(
-            m_current_datafile_item, newSelectedInstrumentId, GUI::Global::mainWindow)) {
-        const auto* newSelectedInstrument =
-            gDoc->instruments()->findInstrumentItemById(newSelectedInstrumentId);
-        m_current_datafile_item->linkToInstrument(newSelectedInstrument);
-        gDoc->setModified();
-    }
-
-    // If linking was impossible or denied --> set combo to previous state.
-    // Otherwise keep combobox updated to the current data after unlinking other data
-    updateInstrumentComboIndex();
-
-    emit instrumentUpdated(m_current_datafile_item);
-}
-
-//! Updates instrument selector for new instruments and their names.
-//! Current selection will be preserved.
-
-void DatafileEditor::updateInstrumentComboEntries()
-{
-    QSignalBlocker b(m_instrument_combo);
-
-    m_instrument_combo->clear();
-
-    // fill the combo. Userdata contains instrument's uid
-    m_instrument_combo->addItem("Undefined", ""); // undefined instrument
-    for (auto* t : *gDoc->instruments())
-        m_instrument_combo->addItem(t->name(), t->id());
-
-    updateInstrumentComboIndex();
-
-    emit instrumentUpdated(m_current_datafile_item);
-}
-
-//! Sets instrument combo selector to the state corresponding to given instrument identifier.
-
-void DatafileEditor::updateInstrumentComboIndex()
-{
-    const QString instrumentId =
-        m_current_datafile_item != nullptr ? m_current_datafile_item->instrumentId() : "";
-
-    QSignalBlocker b(m_instrument_combo);
-    m_instrument_combo->setCurrentIndex(m_instrument_combo->findData(instrumentId));
-}
diff --git a/GUI/View/Data/DatafileEditor.h b/GUI/View/Data/DatafileEditor.h
deleted file mode 100644
index 97e3a6de368..00000000000
--- a/GUI/View/Data/DatafileEditor.h
+++ /dev/null
@@ -1,55 +0,0 @@
-//  ************************************************************************************************
-//
-//  BornAgain: simulate and fit reflection and scattering
-//
-//! @file      GUI/View/Data/DatafileEditor.h
-//! @brief     Defines class DatafileEditor.
-//!
-//! @homepage  http://www.bornagainproject.org
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2018
-//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
-//
-//  ************************************************************************************************
-
-#ifndef BORNAGAIN_GUI_VIEW_DATA_DATAFILEEDITOR_H
-#define BORNAGAIN_GUI_VIEW_DATA_DATAFILEEDITOR_H
-
-#include <QComboBox>
-#include <QWidget>
-
-class DatafileItem;
-
-//! For viewing and changing properties of a loaded datafile.
-//!
-//! Shown at the bottom of DatafilesSelector.
-//!
-//! Currently provides one single button, for linking the file to an instrument model.
-
-class DatafileEditor : public QWidget {
-    Q_OBJECT
-public:
-    DatafileEditor();
-
-    QSize sizeHint() const override { return {64, 135}; }
-    QSize minimumSizeHint() const override { return {64, 128}; }
-
-    //! Set current DatafileItem to display in instrument selector.
-    void setDatafileItem(DatafileItem* dfile_item);
-
-signals:
-    void instrumentUpdated(DatafileItem* dfile_item);
-
-private:
-    //! Processes user interaction with instrument selector combo. If there is dfile_item,
-    //! it will be linked with selected instrument.
-    void onInstrumentComboIndexChanged(int index);
-
-    void updateInstrumentComboEntries();
-    void updateInstrumentComboIndex();
-
-    QComboBox* m_instrument_combo;
-    DatafileItem* m_current_datafile_item;
-};
-
-#endif // BORNAGAIN_GUI_VIEW_DATA_DATAFILEEDITOR_H
diff --git a/GUI/View/List/DatafilesSelector.cpp b/GUI/View/List/DatafilesSelector.cpp
index c33d5dcc8a1..c22edc93b66 100644
--- a/GUI/View/List/DatafilesSelector.cpp
+++ b/GUI/View/List/DatafilesSelector.cpp
@@ -17,7 +17,6 @@
 #include "GUI/Model/Data/DataItem.h"
 #include "GUI/Model/Device/DatafileItem.h"
 #include "GUI/Model/Files/DatafilesSet.h"
-#include "GUI/View/Data/DatafileEditor.h"
 #include "GUI/View/Frame/StackedFrames.h"
 #include "GUI/View/Loader/DataLoader.h"
 #include "GUI/View/Manager/ProjectManager.h"
@@ -32,7 +31,6 @@
 DatafilesSelector::DatafilesSelector()
     : m_set(gDoc->datafilesModifier())
     , m_qlistview(new SetView(m_set))
-    , m_editor(new DatafileEditor)
 {
     setMinimumWidth(200);
     setMaximumWidth(300);
@@ -49,12 +47,7 @@ DatafilesSelector::DatafilesSelector()
     toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
     setToolbarActions(toolbar);
 
-    auto* splitter = new QSplitter;
-    layout->addWidget(splitter);
-    splitter->setOrientation(Qt::Vertical);
-    splitter->addWidget(m_qlistview);
-    splitter->addWidget(m_editor);
-    splitter->setChildrenCollapsible(true);
+    layout->addWidget(m_qlistview);
 
     connect(m_set, &AbstractSetModel::setChanged, this, &DatafilesSelector::updateActions);
     updateActions();
diff --git a/GUI/View/List/DatafilesSelector.h b/GUI/View/List/DatafilesSelector.h
index 20a216c9510..242965af4d9 100644
--- a/GUI/View/List/DatafilesSelector.h
+++ b/GUI/View/List/DatafilesSelector.h
@@ -17,17 +17,11 @@
 
 #include <QWidget>
 
-class DatafileEditor;
 class DatafilesSet;
 class QToolBar;
 class SetView;
 
-//! For viewing and selecting loaded datafiles.
-//!
-//! Shown as left panel in DataView.
-//!
-//! Contains a listing of loaded datafiles (m_qlistview & m_qlistmodel)
-//! and an editor for acting on the currently selected datafile (DatafileEditor).
+//! A list of loaded datafiles, shown as left panel in DataView.
 
 class DatafilesSelector : public QWidget {
     Q_OBJECT
@@ -40,7 +34,6 @@ private:
 
     DatafilesSet* m_set;
     SetView* m_qlistview;
-    DatafileEditor* m_editor;
 
     QAction* m_rm_action;
 };
-- 
GitLab