Skip to content
Snippets Groups Projects
Commit 748b0958 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

DataView ...

parent fd6f2148
No related branches found
No related tags found
1 merge request!2263make full use of gDoc being global
......@@ -22,8 +22,7 @@
#include <QSplitter>
#include <QVBoxLayout>
DataView::DataView(QWidget* parent, ProjectDocument* document)
: QWidget(parent)
DataView::DataView()
{
auto* mainLayout = new QVBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
......@@ -32,7 +31,7 @@ DataView::DataView(QWidget* parent, ProjectDocument* document)
auto* splitter = new QSplitter;
mainLayout->addWidget(splitter);
auto* selector = new DatafilesSelector(this, document);
auto* selector = new DatafilesSelector;
splitter->addWidget(selector);
selector->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
......
......@@ -17,14 +17,12 @@
#include <QWidget>
class ProjectDocument;
//! The DataView class is a main view for importing experimental data.
class DataView : public QWidget {
Q_OBJECT
public:
DataView(QWidget* parent, ProjectDocument* document);
DataView();
};
#endif // BORNAGAIN_GUI_VIEW_DATA_DATAVIEW_H
......@@ -20,11 +20,9 @@
#include <QLabel>
#include <QVBoxLayout>
DatafileEditor::DatafileEditor(QWidget* parent, ProjectDocument* document)
: QWidget(parent)
, m_instrumentCombo(new QComboBox)
DatafileEditor::DatafileEditor()
: m_instrumentCombo(new QComboBox)
, m_currentDatafileItem(nullptr)
, m_document(document)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
setWindowTitle("DatafileEditor");
......@@ -47,13 +45,13 @@ DatafileEditor::DatafileEditor(QWidget* parent, ProjectDocument* document)
connect(m_instrumentCombo, &QComboBox::currentIndexChanged, this,
&DatafileEditor::onInstrumentComboIndexChanged);
connect(m_document->multiNotifier(), &MultiInstrumentNotifier::instrumentAddedOrRemoved, this,
connect(gDoc->multiNotifier(), &MultiInstrumentNotifier::instrumentAddedOrRemoved, this,
&DatafileEditor::updateInstrumentComboEntries);
connect(m_document->multiNotifier(), &MultiInstrumentNotifier::instrumentNameChanged, this,
connect(gDoc->multiNotifier(), &MultiInstrumentNotifier::instrumentNameChanged, this,
&DatafileEditor::updateInstrumentComboEntries);
connect(m_document->linkInstrumentManager(), &LinkInstrumentManager::linkToInstrumentChanged,
connect(gDoc->linkInstrumentManager(), &LinkInstrumentManager::linkToInstrumentChanged,
this, &DatafileEditor::updateInstrumentComboIndex);
}
......@@ -74,12 +72,12 @@ void DatafileEditor::onInstrumentComboIndexChanged(int /*index*/)
if (newSelectedInstrumentId == m_currentDatafileItem->instrumentId())
return;
if (m_document->linkInstrumentManager()->canLinkDataToInstrument(
if (gDoc->linkInstrumentManager()->canLinkDataToInstrument(
m_currentDatafileItem, newSelectedInstrumentId, GUI::Global::mainWindow)) {
const auto* newSelectedInstrument =
m_document->instrumentModel()->findInstrumentItemById(newSelectedInstrumentId);
gDoc->instrumentModel()->findInstrumentItemById(newSelectedInstrumentId);
m_currentDatafileItem->linkToInstrument(newSelectedInstrument);
m_document->setModified();
gDoc->setModified();
}
// If linking was impossible or denied --> set combo to previous state.
......@@ -100,7 +98,7 @@ void DatafileEditor::updateInstrumentComboEntries()
// fill the combo. Userdata contains instrument's uid
m_instrumentCombo->addItem("Undefined", ""); // undefined instrument
for (auto* instrumentItem : m_document->instrumentModel()->instrumentItems())
for (auto* instrumentItem : gDoc->instrumentModel()->instrumentItems())
m_instrumentCombo->addItem(instrumentItem->instrumentName(), instrumentItem->id());
updateInstrumentComboIndex();
......
......@@ -19,7 +19,6 @@
#include <QWidget>
class DatafileItem;
class ProjectDocument;
//! For viewing and changing properties of a loaded datafile.
//!
......@@ -30,7 +29,7 @@ class ProjectDocument;
class DatafileEditor : public QWidget {
Q_OBJECT
public:
DatafileEditor(QWidget* parent, ProjectDocument* document);
DatafileEditor();
QSize sizeHint() const override { return {64, 135}; }
QSize minimumSizeHint() const override { return {64, 128}; }
......@@ -51,7 +50,6 @@ private:
QComboBox* m_instrumentCombo;
DatafileItem* m_currentDatafileItem;
ProjectDocument* m_document;
};
#endif // BORNAGAIN_GUI_VIEW_DATA_DATAFILEEDITOR_H
......@@ -58,16 +58,14 @@ T filterkey2type(std::vector<std::pair<const QString, T>> _nomap, const QString&
} // namespace
DatafilesSelector::DatafilesSelector(QWidget* parent, ProjectDocument* document)
: QWidget(parent)
, m_import1dDataAction(new QAction(this))
DatafilesSelector::DatafilesSelector()
: m_import1dDataAction(new QAction(this))
, m_import2dDataAction(new QAction(this))
, m_renameDataAction(new QAction(this))
, m_removeDataAction(new QAction(this))
, m_treeView(new QTreeView(this))
, m_treeModel(new DatafilesTree(this, document->realModel()))
, m_editor(new DatafileEditor(this, document))
, m_document(document)
, m_treeModel(new DatafilesTree(this, gDoc->realModel()))
, m_editor(new DatafileEditor)
{
setMinimumSize(250, 600);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
......@@ -164,8 +162,8 @@ void DatafilesSelector::setCurrentItem(DatafileItem* item)
void DatafilesSelector::restoreSelection()
{
int lastIndex = m_document->realModel()->selectedIndex();
int lastRank = m_document->realModel()->selectedRank();
int lastIndex = gDoc->realModel()->selectedIndex();
int lastRank = gDoc->realModel()->selectedRank();
QModelIndex lastUsedIndex =
m_treeModel->index(lastIndex, 0, m_treeModel->indexOfHeadline(lastRank));
......@@ -220,8 +218,8 @@ void DatafilesSelector::onSelectionChanged()
{
updateActionEnabling();
m_document->realModel()->setSelectedIndex(currentIndex().row());
m_document->realModel()->setSelectedRank(currentIndex().parent().row() + 1);
gDoc->realModel()->setSelectedIndex(currentIndex().row());
gDoc->realModel()->setSelectedRank(currentIndex().parent().row() + 1);
m_editor->setDatafileItem(currentItem());
emit selectionChanged(currentItem());
......
......@@ -22,7 +22,6 @@
class DatafileEditor;
class DatafileItem;
class DatafilesTree;
class ProjectDocument;
//! For viewing and selecting loaded datafiles.
//!
......@@ -34,7 +33,7 @@ class ProjectDocument;
class DatafilesSelector : public QWidget {
Q_OBJECT
public:
DatafilesSelector(QWidget* parent, ProjectDocument* document);
DatafilesSelector();
QSize sizeHint() const override;
QSize minimumSizeHint() const override;
......@@ -69,8 +68,6 @@ private:
QTreeView* m_treeView;
DatafilesTree* m_treeModel;
DatafileEditor* m_editor;
ProjectDocument* m_document;
};
#endif // BORNAGAIN_GUI_VIEW_DATA_DATAFILESSELECTOR_H
......@@ -227,7 +227,7 @@ void MainWindow::initViews()
if (gDoc) {
m_instrumentView = new InstrumentView;
m_sampleView = new SampleView;
m_importDataView = new DataView(this, gDoc.get());
m_importDataView = new DataView;
m_simulationView = new SimulationView(this, gDoc.get());
m_jobView = new JobView(progressBar(), gDoc.get());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment