diff --git a/GUI/View/Data/DataView.cpp b/GUI/View/Data/DataView.cpp index 7c8f3570b17f40439904a04ce9fad5008b7a110f..702994a5ef7ed663efcd1910ece8edf3271b9fbf 100644 --- a/GUI/View/Data/DataView.cpp +++ b/GUI/View/Data/DataView.cpp @@ -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); diff --git a/GUI/View/Data/DataView.h b/GUI/View/Data/DataView.h index c8da164af852a16759678d738f1525be75e568b3..966ce3d1d598b44cdbe78552b0ea6b638d8a730e 100644 --- a/GUI/View/Data/DataView.h +++ b/GUI/View/Data/DataView.h @@ -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 diff --git a/GUI/View/Data/DatafileEditor.cpp b/GUI/View/Data/DatafileEditor.cpp index 70867599e290b23a6863ab4a0a8d97e252db9df1..8603422764419433abac12fc280219c3f4c7e49c 100644 --- a/GUI/View/Data/DatafileEditor.cpp +++ b/GUI/View/Data/DatafileEditor.cpp @@ -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,14 +45,14 @@ 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, - this, &DatafileEditor::updateInstrumentComboIndex); + connect(gDoc->linkInstrumentManager(), &LinkInstrumentManager::linkToInstrumentChanged, this, + &DatafileEditor::updateInstrumentComboIndex); } void DatafileEditor::setDatafileItem(DatafileItem* realItem) @@ -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(); diff --git a/GUI/View/Data/DatafileEditor.h b/GUI/View/Data/DatafileEditor.h index 24247aba14214cc856ace9ee0d0a0b2e10025532..c7d47b6ded50bf9a9118e84f93a2e96921acd602 100644 --- a/GUI/View/Data/DatafileEditor.h +++ b/GUI/View/Data/DatafileEditor.h @@ -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 diff --git a/GUI/View/Data/DatafilesSelector.cpp b/GUI/View/Data/DatafilesSelector.cpp index a229474bdeeeb0e4b4e55c654aca6f5c00d1c579..271a285e4897f57460f598063d3862b7c7357a46 100644 --- a/GUI/View/Data/DatafilesSelector.cpp +++ b/GUI/View/Data/DatafilesSelector.cpp @@ -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()); diff --git a/GUI/View/Data/DatafilesSelector.h b/GUI/View/Data/DatafilesSelector.h index 64c0f12f6550ef0816887bb2231bc8c26bcf8cd4..dd8270bbd083ce961699305b71684cc5763414ec 100644 --- a/GUI/View/Data/DatafilesSelector.h +++ b/GUI/View/Data/DatafilesSelector.h @@ -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 diff --git a/GUI/View/Instrument/InstrumentListModel.cpp b/GUI/View/Instrument/InstrumentListModel.cpp index 45c3058cc386553397941ac9f52a06d705aad1f5..850af5be94020a17689f4bb7722aa821f4ffd8d8 100644 --- a/GUI/View/Instrument/InstrumentListModel.cpp +++ b/GUI/View/Instrument/InstrumentListModel.cpp @@ -16,6 +16,7 @@ #include "Base/Util/Assert.h" #include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Model/Device/MultiInstrumentNotifier.h" +#include "GUI/Model/Project/ProjectDocument.h" namespace { @@ -48,9 +49,8 @@ template <> QString defaultInstrumentName<OffspecInstrumentItem>() } // namespace -InstrumentListModel::InstrumentListModel(QObject* parent, MultiInstrumentNotifier* notifier) - : QAbstractListModel(parent) - , m_notifier(notifier) +InstrumentListModel::InstrumentListModel() + : m_notifier(gDoc->multiNotifier()) { m_gisasIcon.addPixmap(QPixmap(":/images/gisas_instrument.svg"), QIcon::Selected); m_gisasIcon.addPixmap(QPixmap(":/images/gisas_instrument_shaded.svg"), QIcon::Normal); @@ -61,7 +61,7 @@ InstrumentListModel::InstrumentListModel(QObject* parent, MultiInstrumentNotifie m_depthProbeIcon.addPixmap(QPixmap(":/images/depth_instrument.svg"), QIcon::Selected); m_depthProbeIcon.addPixmap(QPixmap(":/images/depth_instrument_shaded.svg"), QIcon::Normal); - connect(notifier, &MultiInstrumentNotifier::instrumentNameChanged, this, + connect(m_notifier, &MultiInstrumentNotifier::instrumentNameChanged, this, &InstrumentListModel::onInstrumentNameChanged); } diff --git a/GUI/View/Instrument/InstrumentListModel.h b/GUI/View/Instrument/InstrumentListModel.h index 8e13984d7ac2f14df14df7ebdaecc81784226939..93fe0a38a7fe81fc3e78f5d8e9be74ce4868ed99 100644 --- a/GUI/View/Instrument/InstrumentListModel.h +++ b/GUI/View/Instrument/InstrumentListModel.h @@ -27,7 +27,7 @@ class MultiInstrumentNotifier; class InstrumentListModel : public QAbstractListModel { Q_OBJECT public: - InstrumentListModel(QObject* parent, MultiInstrumentNotifier* notifier); + InstrumentListModel(); int rowCount(const QModelIndex& parent = QModelIndex()) const override; diff --git a/GUI/View/Instrument/InstrumentListing.cpp b/GUI/View/Instrument/InstrumentListing.cpp index 031792d7af2184218ca62753edf16c37657ab920..03ac6b4ab929e8eba771e7efb75b0944320a490d 100644 --- a/GUI/View/Instrument/InstrumentListing.cpp +++ b/GUI/View/Instrument/InstrumentListing.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/View/Instrument/InstrumentListing.h" +#include "GUI/Model/Device/InstrumentLibrary.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Instrument/InstrumentLibraryEditor.h" #include "GUI/View/Instrument/InstrumentListModel.h" @@ -21,13 +22,13 @@ #include <QMessageBox> #include <QVBoxLayout> -InstrumentListing::InstrumentListing(ProjectDocument* document) - : m_document(document) - , m_model(new InstrumentListModel(this, m_document->multiNotifier())) +InstrumentListing::InstrumentListing() + : m_instrumentLibrary(std::make_unique<InstrumentLibrary>()) + , m_model(new InstrumentListModel) , m_separatorAction1(new QAction(this)) , m_separatorAction2(new QAction(this)) { - m_instrumentLibrary.load(); + m_instrumentLibrary->load(); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); setViewMode(QListView::IconMode); @@ -105,7 +106,7 @@ InstrumentListing::InstrumentListing(ProjectDocument* document) InstrumentListing::~InstrumentListing() { - m_instrumentLibrary.saveIfModified(); + m_instrumentLibrary->saveIfModified(); } QSize InstrumentListing::sizeHint() const @@ -141,7 +142,7 @@ void InstrumentListing::onItemSelectionChanged() QModelIndexList indexes = selectionModel()->selectedIndexes(); if (!indexes.empty()) { QModelIndex current = indexes.front(); - m_document->instrumentModel()->setSelectedIndex(current.row()); + gDoc->instrumentModel()->setSelectedIndex(current.row()); emit instrumentSelected(m_model->instrumentItemForIndex(current)); } else emit instrumentSelected(nullptr); @@ -200,19 +201,19 @@ void InstrumentListing::onStoreInLibrary() QModelIndex idx = selectionModel()->selectedIndexes().front(); InstrumentItem* instrument = m_model->instrumentItemForIndex(idx); - InstrumentLibraryEditor dlg(GUI::Global::mainWindow, &m_instrumentLibrary); + InstrumentLibraryEditor dlg(GUI::Global::mainWindow, m_instrumentLibrary.get()); dlg.execAdd(*instrument); } void InstrumentListing::onLoadFromLibrary() { - if (m_instrumentLibrary.isEmpty()) { + if (m_instrumentLibrary->isEmpty()) { QMessageBox::information(GUI::Global::mainWindow, "Select from library", "The library does not contain instruments so far."); return; } - InstrumentLibraryEditor dlg(GUI::Global::mainWindow, &m_instrumentLibrary); + InstrumentLibraryEditor dlg(GUI::Global::mainWindow, m_instrumentLibrary.get()); auto* instrumentToCopy = dlg.execChoose(); if (instrumentToCopy == nullptr) @@ -240,7 +241,7 @@ void InstrumentListing::ensureItemSelected() void InstrumentListing::restoreSelection() { - int lastUsed = m_document->instrumentModel()->selectedIndex(); + int lastUsed = gDoc->instrumentModel()->selectedIndex(); if (lastUsed >= 0 && lastUsed < m_model->rowCount()) { QModelIndex lastUsedIndex = m_model->index(lastUsed, 0, QModelIndex()); selectionModel()->select(lastUsedIndex, QItemSelectionModel::ClearAndSelect); diff --git a/GUI/View/Instrument/InstrumentListing.h b/GUI/View/Instrument/InstrumentListing.h index 8e9af7cd2c55848c7a94a90396b49f88fb6b81be..f0f44adea1b3e013714ae6cc509990350b6a3f18 100644 --- a/GUI/View/Instrument/InstrumentListing.h +++ b/GUI/View/Instrument/InstrumentListing.h @@ -15,19 +15,18 @@ #ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H #define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTLISTING_H -#include "GUI/Model/Device/InstrumentLibrary.h" #include <QListView> class InstrumentItem; +class InstrumentLibrary; class InstrumentListModel; -class ProjectDocument; //! Instrument selector on the left side of InstrumentView. class InstrumentListing : public QListView { Q_OBJECT public: - InstrumentListing(ProjectDocument* document); + InstrumentListing(); ~InstrumentListing(); QSize sizeHint() const override; @@ -59,8 +58,7 @@ private: void restoreSelection(); private: - InstrumentLibrary m_instrumentLibrary; - ProjectDocument* m_document; + std::unique_ptr<InstrumentLibrary> m_instrumentLibrary; InstrumentListModel* m_model; QAction* m_newGisasAction; QAction* m_newOffspecAction; diff --git a/GUI/View/Instrument/InstrumentView.cpp b/GUI/View/Instrument/InstrumentView.cpp index 06b58a97e28c7e3df42b7c5238b378221266eda1..b1de60967de0e91b3ebaa10a138b6f15289aa262 100644 --- a/GUI/View/Instrument/InstrumentView.cpp +++ b/GUI/View/Instrument/InstrumentView.cpp @@ -14,6 +14,7 @@ #include "GUI/View/Instrument/InstrumentView.h" #include "GUI/Model/Device/InstrumentItems.h" +#include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Instrument/DepthprobeInstrumentEditor.h" #include "GUI/View/Instrument/GISASInstrumentEditor.h" #include "GUI/View/Instrument/InstrumentListing.h" @@ -24,14 +25,10 @@ #include "GUI/View/Widget/StyledToolbar.h" #include <QFormLayout> #include <QLineEdit> -#include <QMessageBox> #include <QTextEdit> -#include <QWidgetAction> -InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) - : QWidget(parent) - , m_listing(new InstrumentListing(document)) - , m_document(document) +InstrumentView::InstrumentView() + : m_listing(new InstrumentListing) , m_scrollArea(new QScrollArea) { auto* layout = new QVBoxLayout(this); @@ -53,8 +50,7 @@ InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) hLayout->addWidget(m_scrollArea); m_scrollArea->setWidgetResizable(true); - m_scrollArea->setMinimumWidth( - 1000); // setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + m_scrollArea->setMinimumWidth(1000); hLayout->addStretch(1); @@ -72,7 +68,7 @@ InstrumentView::InstrumentView(QWidget* parent, ProjectDocument* document) void InstrumentView::subscribeOnExternalUpdates() { - connect(m_document->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this, + connect(gDoc->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this, &InstrumentView::onInstrumentChangedFromExternal, Qt::UniqueConnection); } @@ -81,7 +77,7 @@ void InstrumentView::showEvent(QShowEvent*) // disconnect because when this view is visible, no other instance is modifying instruments. By // disconnecting, no additional logic is necessary to avoid recursive calls (recursive since // this view also causes instrumentChanged to be emitted). - disconnect(m_document->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this, + disconnect(gDoc->multiNotifier(), &MultiInstrumentNotifier::instrumentChanged, this, &InstrumentView::onInstrumentChangedFromExternal); } @@ -130,7 +126,7 @@ void InstrumentView::createWidgetsForCurrentInstrument() //... All remaining content depends on instrument type - auto* ec = m_document->multiNotifier(); + auto* ec = gDoc->multiNotifier(); if (auto* ii = dynamic_cast<SpecularInstrumentItem*>(currentInstrument)) { auto* editor = new SpecularInstrumentEditor(m_scrollArea, ii, ec); connect(editor, &SpecularInstrumentEditor::dataChanged, this, @@ -165,7 +161,7 @@ void InstrumentView::onInstrumentNameEdited(const QString& newName) { auto* currentInstrument = m_listing->currentInstrumentItem(); if (currentInstrument && currentInstrument->instrumentName() != newName) - m_document->multiNotifier()->setInstrumentName(currentInstrument, newName); + gDoc->multiNotifier()->setInstrumentName(currentInstrument, newName); } void InstrumentView::onInstrumentdescriptionEdited(const QString& t) @@ -182,7 +178,7 @@ void InstrumentView::onInstrumentChangedByEditor() // uses 'MultiInstrumentNotifier::instrumentChanged' signal for two purposes: // 1) notify 'ProjectDocument' that user has changed data ==> mark project with '*' // 2) notify 'LinkInstrumentManager' ==> unlink instrument from data if they are incompatible - m_document->multiNotifier()->notifyInstrumentChanged(m_listing->currentInstrumentItem()); + gDoc->multiNotifier()->notifyInstrumentChanged(m_listing->currentInstrumentItem()); } void InstrumentView::onInstrumentChangedFromExternal(const InstrumentItem* instrument) diff --git a/GUI/View/Instrument/InstrumentView.h b/GUI/View/Instrument/InstrumentView.h index 34a67c1bb76646bb341766bdd7782799990e30fe..aac435d6cb0fa908aa1bf5cc239821da85f314bd 100644 --- a/GUI/View/Instrument/InstrumentView.h +++ b/GUI/View/Instrument/InstrumentView.h @@ -15,20 +15,17 @@ #ifndef BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTVIEW_H #define BORNAGAIN_GUI_VIEW_INSTRUMENT_INSTRUMENTVIEW_H -#include "GUI/Model/Project/ProjectDocument.h" // ProjectDocument::Functionalities #include <QCheckBox> -#include <QMenu> #include <QScrollArea> #include <QWidget> class InstrumentItem; class InstrumentListing; -class ProjectDocument; class InstrumentView : public QWidget { Q_OBJECT public: - InstrumentView(QWidget* parent, ProjectDocument* document); + InstrumentView(); private: void showEvent(QShowEvent*) override; @@ -43,7 +40,6 @@ private: void onSingleInstrumentModeChanged(bool newState); InstrumentListing* m_listing; - ProjectDocument* m_document; QScrollArea* m_scrollArea; QCheckBox* gisasCheck; QCheckBox* offspecCheck; diff --git a/GUI/View/Job/JobProgressAssistant.cpp b/GUI/View/Job/JobProgressAssistant.cpp deleted file mode 100644 index 92abc75eb6c278b68d1c82e2288f8ad2dc52f80c..0000000000000000000000000000000000000000 --- a/GUI/View/Job/JobProgressAssistant.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Job/JobProgressAssistant.cpp -//! @brief Implements class JobProgressAssistant. -//! -//! @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) -// -// ************************************************************************************************ - -#include "GUI/View/Job/JobProgressAssistant.h" -#include "Base/Util/Assert.h" -#include "GUI/Model/Model/JobModel.h" - -JobProgressAssistant::JobProgressAssistant(QProgressBar* progressBar, JobModel* jobModel) - : m_progressBar(progressBar) -{ - connect(jobModel, &JobModel::globalProgress, this, &JobProgressAssistant::onGlobalProgress); -} - -void JobProgressAssistant::onGlobalProgress(int progress) -{ - ASSERT(m_progressBar); - if (progress < 0 || progress >= 100) - m_progressBar->hide(); - else { - m_progressBar->show(); - m_progressBar->setValue(progress); - } -} diff --git a/GUI/View/Job/JobProgressAssistant.h b/GUI/View/Job/JobProgressAssistant.h deleted file mode 100644 index 2f0d30b7b44b6d638c33f6d279ae256aa01f9362..0000000000000000000000000000000000000000 --- a/GUI/View/Job/JobProgressAssistant.h +++ /dev/null @@ -1,38 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/View/Job/JobProgressAssistant.h -//! @brief Defines class JobProgressAssistant. -//! -//! @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_JOB_JOBPROGRESSASSISTANT_H -#define BORNAGAIN_GUI_VIEW_JOB_JOBPROGRESSASSISTANT_H - -#include <QObject> -#include <QProgressBar> - -class JobModel; -class MainWindow; - -//! The JobProgressAssistant class helps JobView to visualize current progress. - -class JobProgressAssistant : public QObject { - Q_OBJECT -public: - JobProgressAssistant(QProgressBar* progressBar, JobModel* jobModel); - -private slots: - void onGlobalProgress(int progress); - -private: - QProgressBar* m_progressBar; -}; - -#endif // BORNAGAIN_GUI_VIEW_JOB_JOBPROGRESSASSISTANT_H diff --git a/GUI/View/Job/JobView.cpp b/GUI/View/Job/JobView.cpp index 45ec16ea80730a65e9810ae4eb925c57bf697bff..92f825b0fdde630eedd7e2ad13736f6ff1082445 100644 --- a/GUI/View/Job/JobView.cpp +++ b/GUI/View/Job/JobView.cpp @@ -18,7 +18,6 @@ #include "GUI/View/Dock/DocksController.h" #include "GUI/View/Fit/FitActivityPanel.h" #include "GUI/View/FitMessage/JobMessagePanel.h" -#include "GUI/View/Job/JobProgressAssistant.h" #include "GUI/View/Job/JobResultsPresenter.h" #include "GUI/View/Job/JobViewActivities.h" #include "GUI/View/JobControl/JobSelector.h" @@ -26,14 +25,12 @@ #include "GUI/View/Tuning/JobRealTimeWidget.h" #include <QMenu> -JobView::JobView(QProgressBar* progressBar, ProjectDocument* document) +JobView::JobView(QProgressBar* progressBar) : m_docks(new DocksController(this)) - , m_progressAssistant(new JobProgressAssistant(progressBar, document->jobModel())) , m_jobResultsPresenter(new JobResultsPresenter) , m_fitActivityPanel(new FitActivityPanel) , m_jobMessagePanel(new JobMessagePanel) , m_activityActions(this) - , m_document(document) { setObjectName("JobView"); @@ -57,8 +54,8 @@ JobView::JobView(QProgressBar* progressBar, ProjectDocument* document) //... Subwindows - m_jobSelector = new JobSelector(m_document->jobModel(), this); - m_jobRealTimeWidget = new JobRealTimeWidget(m_document->jobModel(), this); + m_jobSelector = new JobSelector(gDoc->jobModel(), this); + m_jobRealTimeWidget = new JobRealTimeWidget(gDoc->jobModel(), this); m_docks->addWidget(JobViewFlags::JOB_LIST_DOCK, m_jobSelector, Qt::LeftDockWidgetArea); m_docks->addWidget(JobViewFlags::REAL_TIME_DOCK, m_jobRealTimeWidget, Qt::RightDockWidgetArea); @@ -74,13 +71,22 @@ JobView::JobView(QProgressBar* progressBar, ProjectDocument* document) //... Connects signals related to JobItem // Focus request: JobModel -> this - connect(m_document->jobModel(), &JobModel::focusRequest, this, &JobView::onFocusRequest); + connect(gDoc->jobModel(), &JobModel::focusRequest, this, &JobView::onFocusRequest); // JobItem selection: JobSelector -> this connect(m_jobSelector, &JobSelector::selectedJobsChanged, this, &JobView::onSelectionChanged); connect(m_fitActivityPanel, &FitActivityPanel::showLog, m_jobMessagePanel, &JobMessagePanel::setLog); + + connect(gDoc->jobModel(), &JobModel::globalProgress, [pb = progressBar](int progress) { + if (progress < 0 || progress >= 100) + pb->hide(); + else { + pb->show(); + pb->setValue(progress); + } + }); } void JobView::fillViewMenu(QMenu* menu) diff --git a/GUI/View/Job/JobView.h b/GUI/View/Job/JobView.h index 58cdb131611129b56d96fe0f0524e6ef0d114e72..5cd07fae908d31403bf551463b40c8628a4b1823 100644 --- a/GUI/View/Job/JobView.h +++ b/GUI/View/Job/JobView.h @@ -25,12 +25,10 @@ class DocksController; class FitActivityPanel; class JobItem; class JobMessagePanel; -class JobProgressAssistant; class JobRealTimeWidget; class JobResultsPresenter; class JobSelector; class JobView; -class ProjectDocument; //! The JobView class is a main view to show list of jobs, job results and widgets for real time //! and fitting activities. @@ -38,7 +36,7 @@ class ProjectDocument; class JobView : public QMainWindow { Q_OBJECT public: - JobView(QProgressBar* progressBar, ProjectDocument* document); + JobView(QProgressBar* progressBar); void fillViewMenu(QMenu* menu); @@ -57,7 +55,6 @@ private: void resetLayout(); DocksController* m_docks; - JobProgressAssistant* m_progressAssistant; JobSelector* m_jobSelector = nullptr; JobResultsPresenter* m_jobResultsPresenter = nullptr; @@ -66,7 +63,6 @@ private: JobMessagePanel* m_jobMessagePanel = nullptr; QActionGroup m_activityActions; - ProjectDocument* m_document; }; #endif // BORNAGAIN_GUI_VIEW_JOB_JOBVIEW_H diff --git a/GUI/View/Main/MainWindow.cpp b/GUI/View/Main/MainWindow.cpp index 428b2349cf3604d917fe0d353d35d53650c641dd..f11f7ef02942a143e0f5fd55127fa4d18bf86cb2 100644 --- a/GUI/View/Main/MainWindow.cpp +++ b/GUI/View/Main/MainWindow.cpp @@ -225,11 +225,11 @@ void MainWindow::initViews() resetView(GUI::ID::ViewId::Projects, m_projectsView); if (gDoc) { - m_instrumentView = new InstrumentView(this, gDoc.get()); - m_sampleView = new SampleView(this, gDoc.get()); - m_importDataView = new DataView(this, gDoc.get()); - m_simulationView = new SimulationView(this, gDoc.get()); - m_jobView = new JobView(progressBar(), gDoc.get()); + m_instrumentView = new InstrumentView; + m_sampleView = new SampleView; + m_importDataView = new DataView; + m_simulationView = new SimulationView; + m_jobView = new JobView(progressBar()); resetView(GUI::ID::ViewId::Instrument, m_instrumentView); diff --git a/GUI/View/Manager/ProjectLoadProblemDialog.cpp b/GUI/View/Manager/ProjectLoadProblemDialog.cpp index 7cbfbfa49cb1cbfc2f5d1b55ba89c9e8a9c55149..ed49466f2bd8c86bd5b8827c54ca8b5a90983f32 100644 --- a/GUI/View/Manager/ProjectLoadProblemDialog.cpp +++ b/GUI/View/Manager/ProjectLoadProblemDialog.cpp @@ -13,6 +13,8 @@ // ************************************************************************************************ #include "GUI/View/Manager/ProjectLoadProblemDialog.h" +#include "Base/Util/Assert.h" +#include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Support/Style/Style.h" #include "GUI/Support/Util/Path.h" #include <QGridLayout> @@ -23,12 +25,10 @@ namespace { const int top_panel_height = 80; + } // namespace -ProjectLoadProblemDialog::ProjectLoadProblemDialog(QWidget* parent, const QStringList& details, - QString documentVersion) - : QDialog(parent) - , m_projectDocumentVersion(std::move(documentVersion)) +ProjectLoadProblemDialog::ProjectLoadProblemDialog(const QStringList& details) { setMinimumSize(256, 256); resize(520, 620); @@ -119,18 +119,20 @@ QLayout* ProjectLoadProblemDialog::buttonLayout() //! Returns explanations what went wrong. QString ProjectLoadProblemDialog::explanationText() const { - if (m_projectDocumentVersion != GUI::Path::getBornAgainVersionString()) { + ASSERT(gDoc); + const QString& doc_version = gDoc->documentVersion(); + + if (doc_version != GUI::Path::getBornAgainVersionString()) return QString( "Given project was created using BornAgain version %1 " " which is different from version %2 you are currently using. " "At the moment we provide only limited support for import from older versions.") - .arg(m_projectDocumentVersion) + .arg(doc_version) .arg(GUI::Path::getBornAgainVersionString()); - } return QString("Given project was created using BornAgain version %1 " "which is the same as the current version of the framework. " "Strangely enough, some parts were not loaded correctly due to format mismatch. " "Please contact the developers.") - .arg(m_projectDocumentVersion); + .arg(doc_version); } diff --git a/GUI/View/Manager/ProjectLoadProblemDialog.h b/GUI/View/Manager/ProjectLoadProblemDialog.h index 6af31a2f4511e196f126b1afe947ddb5164f104d..e06afe647c9ec692b850967c5a28a732d1220550 100644 --- a/GUI/View/Manager/ProjectLoadProblemDialog.h +++ b/GUI/View/Manager/ProjectLoadProblemDialog.h @@ -23,14 +23,12 @@ class ProjectLoadProblemDialog : public QDialog { Q_OBJECT public: - ProjectLoadProblemDialog(QWidget* parent, const QStringList& details, QString documentVersion); + ProjectLoadProblemDialog(const QStringList& details); private: QWidget* createWarningWidget(); QLayout* buttonLayout(); QString explanationText() const; - - QString m_projectDocumentVersion; }; #endif // BORNAGAIN_GUI_VIEW_MANAGER_PROJECTLOADPROBLEMDIALOG_H diff --git a/GUI/View/Manager/ProjectManager.cpp b/GUI/View/Manager/ProjectManager.cpp index 1ca3b03fe5fb6eb979087eb73dd8d5ec60e3dc59..e35f6f68ce21ae0a3bf34a3447526c4a71ed4801 100644 --- a/GUI/View/Manager/ProjectManager.cpp +++ b/GUI/View/Manager/ProjectManager.cpp @@ -423,10 +423,7 @@ void ProjectManager::riseProjectLoadFailedDialog(const MessageService& messageSe void ProjectManager::riseProjectLoadProblemDialog(const MessageService& messageService) { - ASSERT(gDoc); - auto* problemDialog = new ProjectLoadProblemDialog( - GUI::Global::mainWindow, messageService.warnings(true), gDoc->documentVersion()); - + auto* problemDialog = new ProjectLoadProblemDialog(messageService.warnings(true)); problemDialog->show(); problemDialog->raise(); } diff --git a/GUI/View/Project/SimulationView.cpp b/GUI/View/Project/SimulationView.cpp index ddcd94e66e398ecd63a3a610ad61d1b241c24850..db238e6b9d6db0658571a32b9c74c4c48ca18646 100644 --- a/GUI/View/Project/SimulationView.cpp +++ b/GUI/View/Project/SimulationView.cpp @@ -33,10 +33,8 @@ #include <QVBoxLayout> #include <thread> -SimulationView::SimulationView(QWidget* parent, ProjectDocument* document) - : QWidget(parent) - , m_document(document) - , m_instrumentCombo(new QComboBox) +SimulationView::SimulationView() + : m_instrumentCombo(new QComboBox) , m_sampleCombo(new QComboBox) , m_realDataCombo(new QComboBox) , m_numberOfMonteCarloPoints(new QSpinBox) @@ -179,11 +177,11 @@ void SimulationView::writeOptionsToUI() QSignalBlocker b6(m_includeSpecularCheck); // -- selection group - updateSelection(m_instrumentCombo, m_document->instrumentModel()->instrumentNames(), + updateSelection(m_instrumentCombo, gDoc->instrumentModel()->instrumentNames(), optionsItem()->selectedInstrumentIndex()); - updateSelection(m_sampleCombo, m_document->sampleModel()->sampleNames(), + updateSelection(m_sampleCombo, gDoc->sampleModel()->sampleNames(), optionsItem()->selectedSampleIndex()); - updateSelection(m_realDataCombo, m_document->realModel()->realItemNames(), + updateSelection(m_realDataCombo, gDoc->realModel()->realItemNames(), optionsItem()->selectedDataIndex(), true); // -- options group @@ -214,7 +212,7 @@ void SimulationView::hideEvent(QHideEvent*) void SimulationView::updateStateFromUI() { readOptionsFromUI(); - m_document->setModified(); + gDoc->setModified(); } void SimulationView::simulate() @@ -225,7 +223,7 @@ void SimulationView::simulate() "Cannot run the job with current settings\n\n" + msg); return; } - JobModel* jobModel = m_document->jobModel(); + JobModel* jobModel = gDoc->jobModel(); JobItem* jobItem = jobModel->addJobItem(selectedSampleItem(), selectedInstrumentItem(), selectedDatafileItem(), *optionsItem()); jobModel->runJob(jobItem); @@ -321,22 +319,22 @@ QString SimulationView::validateSimulationSetup(bool validateRealData) const SimulationOptionsItem* SimulationView::optionsItem() const { - return m_document->simulationOptionsItem(); + return gDoc->simulationOptionsItem(); } const SampleItem* SimulationView::selectedSampleItem() const { - return m_document->sampleModel()->sampleItems().value(m_sampleCombo->currentIndex(), nullptr); + return gDoc->sampleModel()->sampleItems().value(m_sampleCombo->currentIndex(), nullptr); } const InstrumentItem* SimulationView::selectedInstrumentItem() const { - return m_document->instrumentModel()->instrumentItems().value(m_instrumentCombo->currentIndex(), - nullptr); + return gDoc->instrumentModel()->instrumentItems().value(m_instrumentCombo->currentIndex(), + nullptr); } const DatafileItem* SimulationView::selectedDatafileItem() const { - return m_document->realModel()->realItems().value(m_realDataCombo->currentIndex() - 1, - nullptr); // -1: "None" + return gDoc->realModel()->realItems().value(m_realDataCombo->currentIndex() - 1, + nullptr); // -1: "None" } diff --git a/GUI/View/Project/SimulationView.h b/GUI/View/Project/SimulationView.h index c07f2bc5bd461084ad2c6e151a6aad11d10f9de1..a124a3f7ee592a1969b8c4458ecf47eaefdb5938 100644 --- a/GUI/View/Project/SimulationView.h +++ b/GUI/View/Project/SimulationView.h @@ -25,7 +25,6 @@ class DatafileItem; class InstrumentItem; class MainWindow; -class ProjectDocument; class SampleItem; class SimulationOptionsItem; @@ -37,7 +36,7 @@ class SimulationOptionsItem; class SimulationView : public QWidget { Q_OBJECT public: - SimulationView(QWidget* parent, ProjectDocument* document); + SimulationView(); void simulate(); void exportPythonScript(); @@ -79,8 +78,6 @@ private: //! Returns empty string if valid, otherwise the error text. QString validateSimulationSetup(bool validateRealData) const; - ProjectDocument* m_document; - QLabel* m_instrumentLabel; QComboBox* m_instrumentCombo; QComboBox* m_sampleCombo; diff --git a/GUI/View/Sample/SampleEditor.cpp b/GUI/View/Sample/SampleEditor.cpp index 47cde94bc516916cf7672edbbce184d4d37f370f..1a8717df8d514e25e0e70ac1a14a19b087aceb5e 100644 --- a/GUI/View/Sample/SampleEditor.cpp +++ b/GUI/View/Sample/SampleEditor.cpp @@ -25,10 +25,8 @@ #include <QBoxLayout> #include <QPushButton> -SampleEditor::SampleEditor(QWidget* parent, ProjectDocument* document) - : QScrollArea(parent) - , m_currentSampleWidget(nullptr) - , m_document(document) +SampleEditor::SampleEditor() + : m_currentSampleWidget(nullptr) { QScrollArea::setWidgetResizable(true); QScrollArea::setWidget(new QWidget()); @@ -54,8 +52,7 @@ void SampleEditor::setCurrentSample(SampleItem* sampleItem) } if (!m_editControllers.contains(m_currentSample)) - m_editControllers.insert(m_currentSample, - new SampleEditorController(m_document, m_currentSample)); + m_editControllers.insert(m_currentSample, new SampleEditorController(m_currentSample)); auto* ec = m_editControllers[m_currentSample]; connect(ec, &SampleEditorController::requestViewInRealspace, this, &SampleEditor::requestViewInRealspace); diff --git a/GUI/View/Sample/SampleEditor.h b/GUI/View/Sample/SampleEditor.h index 5fd3420b6183bbe456bf7fe98849163f06857c04..8a1be88cb6c89fd1da00a823891000459bcd003f 100644 --- a/GUI/View/Sample/SampleEditor.h +++ b/GUI/View/Sample/SampleEditor.h @@ -19,7 +19,6 @@ #include <QScrollArea> class Item3D; -class ProjectDocument; class SampleEditorController; class SampleForm; class SampleItem; @@ -28,7 +27,7 @@ class SampleItem; class SampleEditor : public QScrollArea { Q_OBJECT public: - SampleEditor(QWidget* parent, ProjectDocument* document); + SampleEditor(); ~SampleEditor() override; void setCurrentSample(SampleItem* sampleItem); @@ -45,7 +44,6 @@ private: SampleForm* m_currentSampleWidget; SampleItem* m_currentSample = nullptr; QMap<SampleItem*, SampleEditorController*> m_editControllers; - ProjectDocument* m_document; }; diff --git a/GUI/View/Sample/SampleEditorController.cpp b/GUI/View/Sample/SampleEditorController.cpp index 6aa5076c20ee071a33122ed93d19fff05040942a..5e09295a31c96f5ad5f81ebdfda61c8818604aa3 100644 --- a/GUI/View/Sample/SampleEditorController.cpp +++ b/GUI/View/Sample/SampleEditorController.cpp @@ -35,10 +35,9 @@ #include "GUI/View/Sample/ParticleLayoutForm.h" #include "GUI/View/Sample/SampleForm.h" -SampleEditorController::SampleEditorController(ProjectDocument* document, SampleItem* multi) +SampleEditorController::SampleEditorController(SampleItem* multi) : m_sampleItem(multi) , m_sampleForm(nullptr) - , m_document(document) { } diff --git a/GUI/View/Sample/SampleEditorController.h b/GUI/View/Sample/SampleEditorController.h index 6e22907e20ed5f3bb1823a8c53592dffda0454b6..822f083dd5b2f31bb0a918cb269373cab0857323 100644 --- a/GUI/View/Sample/SampleEditorController.h +++ b/GUI/View/Sample/SampleEditorController.h @@ -35,7 +35,6 @@ class LayerItem; class MaterialModel; class MesocrystalForm; class ParticleLayoutItem; -class ProjectDocument; class SampleForm; class SampleItem; class SelectionContainerForm; @@ -50,7 +49,7 @@ class SelectionContainerForm; class SampleEditorController : public QObject { Q_OBJECT public: - SampleEditorController(ProjectDocument* document, SampleItem* multi); + SampleEditorController(SampleItem* multi); //! Set the current form. //! @@ -64,9 +63,6 @@ public: //! The materials of the current document MaterialModel* materialModel() const; - //! The current document - ProjectDocument* projectDocument() const { return m_document; } - void addLayerItem(LayerItem* before); QColor findColor(int atIndex); void onLayerAdded(LayerItem* layer); @@ -131,7 +127,6 @@ private: SampleItem* m_sampleItem; SampleForm* m_sampleForm; - ProjectDocument* m_document; }; #endif // BORNAGAIN_GUI_VIEW_SAMPLE_SAMPLEEDITORCONTROLLER_H diff --git a/GUI/View/Sample/SampleListModel.cpp b/GUI/View/Sample/SampleListModel.cpp index 7918aec2b4213662ac3499c951c6a36acdadcfa2..31932a16bd85378ee4121120b41d6b41c011365c 100644 --- a/GUI/View/Sample/SampleListModel.cpp +++ b/GUI/View/Sample/SampleListModel.cpp @@ -16,6 +16,7 @@ #include "Base/Util/Assert.h" #include "GUI/Model/FromCore/GUIExamplesFactory.h" #include "GUI/Model/FromCore/ItemizeSample.h" +#include "GUI/Model/Project/ProjectDocument.h" #include "GUI/Model/Sample/SampleItem.h" #include "GUI/Model/Sample/SampleModel.h" #include "GUI/Support/Util/String.h" @@ -23,9 +24,8 @@ #include "Sample/Multilayer/MultiLayer.h" #include <QIcon> -SampleListModel::SampleListModel(QObject* parent, SampleModel* model) - : QAbstractListModel(parent) - , m_sampleItems(model) +SampleListModel::SampleListModel() + : m_sampleItems(gDoc->sampleModel()) { } diff --git a/GUI/View/Sample/SampleListModel.h b/GUI/View/Sample/SampleListModel.h index d87098f6aa2e06667289d435015976f8a47fa1a2..d17a908a3d9cf1faec6a41d41540649ab3d5b975 100644 --- a/GUI/View/Sample/SampleListModel.h +++ b/GUI/View/Sample/SampleListModel.h @@ -24,7 +24,7 @@ class SampleModel; class SampleListModel : public QAbstractListModel { Q_OBJECT public: - SampleListModel(QObject* parent, SampleModel* model); + SampleListModel(); int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; diff --git a/GUI/View/Sample/SampleListing.cpp b/GUI/View/Sample/SampleListing.cpp index 8d8188762a298c88156ad672dad8349b01da1a84..34da1c79e30a60c12fba9560dd370988b9da2158 100644 --- a/GUI/View/Sample/SampleListing.cpp +++ b/GUI/View/Sample/SampleListing.cpp @@ -62,17 +62,14 @@ protected: } // namespace -SampleListing::SampleListing(QWidget* parent, ProjectDocument* document) - : QListView(parent) - , m_model(new SampleListModel(this, document->sampleModel())) - , m_document(document) +SampleListing::SampleListing() + : m_model(new SampleListModel) , m_newSampleAction(new QAction(this)) , m_importSampleAction(new QAction(this)) , m_chooseFromLibraryAction(new QAction(this)) { setMaximumWidth(200); - setContextMenuPolicy(Qt::CustomContextMenu); setModel(m_model); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); @@ -156,7 +153,7 @@ void SampleListing::createNewSample() { const QModelIndex newIndex = m_model->createSample(); setCurrentIndex(newIndex); - m_document->setModified(); + gDoc->setModified(); } void SampleListing::createSampleFromLibrary(const QString& classname, const QString& title, @@ -165,7 +162,7 @@ void SampleListing::createSampleFromLibrary(const QString& classname, const QStr const QModelIndex newIndex = m_model->createSampleFromExamples(classname, title, description); if (newIndex.isValid()) { setCurrentIndex(newIndex); - m_document->setModified(); + gDoc->setModified(); } } @@ -175,7 +172,7 @@ void SampleListing::importSampleFromPython() const QModelIndex newIndex = m_model->createSampleFromPython(); if (newIndex.isValid()) { setCurrentIndex(newIndex); - m_document->setModified(); + gDoc->setModified(); } #endif } @@ -194,33 +191,33 @@ QList<QAction*> SampleListing::getOverlayActions(const QModelIndex& index, bool void SampleListing::onCurrentChanged(const QModelIndex& index) { - m_document->sampleModel()->setSelectedIndex(index.row()); + gDoc->sampleModel()->setSelectedIndex(index.row()); emit currentSampleChanged(m_model->itemForIndex(index)); } void SampleListing::restoreSelection() { - int selected = m_document->sampleModel()->selectedIndex(); + int selected = gDoc->sampleModel()->selectedIndex(); if (selected < 0 || selected >= m_model->rowCount()) selected = m_model->rowCount() - 1; QModelIndex selectedIndex = m_model->index(selected, 0, QModelIndex()); if (selectedIndex.isValid()) { selectionModel()->select(selectedIndex, QItemSelectionModel::ClearAndSelect); - setCurrentSample(m_document->sampleModel()->sampleItems()[selected]); + setCurrentSample(gDoc->sampleModel()->sampleItems()[selected]); } } void SampleListing::removeSample(SampleItem* item) { m_model->removeSample(item); - m_document->setModified(); + gDoc->setModified(); } void SampleListing::copySample(SampleItem* item) { m_model->copySample(item); - m_document->setModified(); + gDoc->setModified(); } QAction* SampleListing::createRemoveAction(QObject* parent, SampleItem* item) diff --git a/GUI/View/Sample/SampleListing.h b/GUI/View/Sample/SampleListing.h index 21c0855a96df49ea796d9e23e053a8243ac0de00..a9062347164cdf6f06be17516eae719a8e59e4a0 100644 --- a/GUI/View/Sample/SampleListing.h +++ b/GUI/View/Sample/SampleListing.h @@ -17,7 +17,6 @@ #include <QListView> -class ProjectDocument; class SampleItem; class SampleListModel; @@ -25,7 +24,7 @@ class SampleListModel; class SampleListing : public QListView { Q_OBJECT public: - SampleListing(QWidget* parent, ProjectDocument* document); + SampleListing(); void setCurrentSample(SampleItem* sample); SampleItem* currentSampleItem(); @@ -59,9 +58,7 @@ private: void showContextMenu(const QPoint& pos); -private: SampleListModel* m_model; - ProjectDocument* m_document; QAction* m_newSampleAction; QAction* m_importSampleAction; QAction* m_chooseFromLibraryAction; diff --git a/GUI/View/Sample/SampleView.cpp b/GUI/View/Sample/SampleView.cpp index 0cc769fc89baac6afaff053980911e78477ed5ce..f4fdaab400cc95aedc4e59c6456dbb425af38dcf 100644 --- a/GUI/View/Sample/SampleView.cpp +++ b/GUI/View/Sample/SampleView.cpp @@ -35,11 +35,9 @@ #include <QToolButton> #include <QWidgetAction> -SampleView::SampleView(QWidget* parent, ProjectDocument* document) - : QWidget(parent) - , m_document(document) - , m_realspacePanel(new RealspacePanel(this)) - , m_listing(new SampleListing(this, m_document)) +SampleView::SampleView() + : m_realspacePanel(new RealspacePanel(this)) + , m_listing(new SampleListing) { auto* layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); @@ -64,7 +62,7 @@ SampleView::SampleView(QWidget* parent, ProjectDocument* document) vSplitter->setOrientation(Qt::Vertical); hLayout->addWidget(vSplitter); - auto* editor = new SampleEditor(this, document); + auto* editor = new SampleEditor; vSplitter->addWidget(editor); //... Below central widget: realspace and script panels @@ -125,7 +123,7 @@ SampleView::SampleView(QWidget* parent, ProjectDocument* document) connect(editor, &SampleEditor::modified, m_realspacePanel->widget(), &RealspaceWidget::updateScene); - connect(editor, &SampleEditor::modified, m_document, &ProjectDocument::setModified, + connect(editor, &SampleEditor::modified, gDoc.get(), &ProjectDocument::setModified, Qt::UniqueConnection); } diff --git a/GUI/View/Sample/SampleView.h b/GUI/View/Sample/SampleView.h index 25f246891902f6635b4c49424c21c72338d66aea..1646723a08f76801140b953dd36aa39196f3f063 100644 --- a/GUI/View/Sample/SampleView.h +++ b/GUI/View/Sample/SampleView.h @@ -15,18 +15,17 @@ #ifndef BORNAGAIN_GUI_VIEW_SAMPLE_SAMPLEVIEW_H #define BORNAGAIN_GUI_VIEW_SAMPLE_SAMPLEVIEW_H -#include <QMenu> +#include <QShowEvent> #include <QWidget> class Item3D; -class ProjectDocument; class RealspacePanel; class SampleListing; class SampleView : public QWidget { Q_OBJECT public: - SampleView(QWidget* parent, ProjectDocument* document); + SampleView(); ~SampleView(); private: @@ -42,7 +41,6 @@ private: void applySplitterPos(); void saveSplitterPos(); - ProjectDocument* m_document; RealspacePanel* m_realspacePanel; SampleListing* m_listing; };