diff --git a/GUI/Model/Detector/DetectorItem.cpp b/GUI/Model/Detector/DetectorItem.cpp index 184f5d7e1283f1fe7ce08866d82b44810db8d171..ed71841f80fbdb7f573dfa3a879d6aee5ccb3e23 100644 --- a/GUI/Model/Detector/DetectorItem.cpp +++ b/GUI/Model/Detector/DetectorItem.cpp @@ -101,6 +101,7 @@ void DetectorItem::setMasks(MasksSet* item) { m_masks.reset(item); } + std::unique_ptr<IResolutionFunction2D> DetectorItem::createResolutionFunction() const { return m_resolution_function->createResolutionFunction(); diff --git a/GUI/Model/Device/InstrumentItems.h b/GUI/Model/Device/InstrumentItems.h index ae7ea96981f13fe19fa96bae402bfabd3abf1081..9b417351366f84f707bc629149a196d8724f211a 100644 --- a/GUI/Model/Device/InstrumentItems.h +++ b/GUI/Model/Device/InstrumentItems.h @@ -146,7 +146,7 @@ class DepthprobeInstrumentItem : public InstrumentItem, public ScanningFunctiona public: DepthprobeInstrumentItem(); - QString instrumentType() const override { return "Depth probe"; } + QString instrumentType() const override { return "Depthprobe"; } std::vector<int> axdims() const override; void updateToRealData(const DatafileItem* dfileItem) override; std::unique_ptr<Frame> createFrame() const override; @@ -165,7 +165,7 @@ class OffspecInstrumentItem : public InstrumentItem, public ScanningFunctionalit public: OffspecInstrumentItem(); - QString instrumentType() const override { return "Off specular"; } + QString instrumentType() const override { return "Offspecular"; } std::vector<int> axdims() const override; void updateToRealData(const DatafileItem* dfileItem) override; std::unique_ptr<Frame> createFrame() const override; @@ -184,7 +184,7 @@ class GISASInstrumentItem : public InstrumentItem { public: GISASInstrumentItem(); - QString instrumentType() const override { return "GISAS"; } + QString instrumentType() const override { return "Scatter2D"; } std::vector<int> axdims() const override; void updateToRealData(const DatafileItem* dfileItem) override; std::unique_ptr<Frame> createFrame() const override; diff --git a/GUI/View/Canvas/MaskEditorCanvas.cpp b/GUI/View/Canvas/MaskEditorCanvas.cpp index 55506cc0fb8abdd6e69d7e4d09bc2a6eef6bd193..50b231e47e09af63e9747820c89e466d20a71941 100644 --- a/GUI/View/Canvas/MaskEditorCanvas.cpp +++ b/GUI/View/Canvas/MaskEditorCanvas.cpp @@ -16,7 +16,6 @@ #include "Device/Data/Datafield.h" #include "GUI/Model/Data/Data2DItem.h" #include "GUI/Model/Mask/MaskItems.h" -#include "GUI/Model/Mask/MasksQModel.h" #include "GUI/Model/Mask/MasksSet.h" #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Canvas/SavePlotAssistant.h" diff --git a/GUI/View/Data/DatafilesQModel.cpp b/GUI/View/Data/DatafilesQModel.cpp index 6b3e1cf3ef1c1fd22e7787e0194da7ae215b7649..ff6c187f44fae252aa53a50171bbbf16834f8ff5 100644 --- a/GUI/View/Data/DatafilesQModel.cpp +++ b/GUI/View/Data/DatafilesQModel.cpp @@ -15,7 +15,7 @@ #include "GUI/View/Data/DatafilesQModel.h" #include "GUI/Model/Device/DatafileItem.h" #include "GUI/Model/Files/DatafilesSet.h" -#include "GUI/View/Manager/ProjectManager.h" +#include "GUI/Model/Project/ProjectDocument.h" DatafilesQModel::DatafilesQModel(QObject* parent) : QAbstractListModel(parent) diff --git a/GUI/View/Data/DatafilesQModel.h b/GUI/View/Data/DatafilesQModel.h index 7ce29b8cab4127024f1e6e4aa1ac4f360cf2bc54..1b7213d176f583b9da26d256ac1c331b41ab7f96 100644 --- a/GUI/View/Data/DatafilesQModel.h +++ b/GUI/View/Data/DatafilesQModel.h @@ -18,7 +18,6 @@ #include <QAbstractListModel> class DatafileItem; -class DatafilesSet; //! Tree representation of DatafilesSet, for use in DatafilesSelector. diff --git a/GUI/View/Data/DatafilesSelector.cpp b/GUI/View/Data/DatafilesSelector.cpp index 51b98908342ce86925bba24c523dc13612365fe6..5e36e55922ad29ffd020846f5f2aeaede71c2706 100644 --- a/GUI/View/Data/DatafilesSelector.cpp +++ b/GUI/View/Data/DatafilesSelector.cpp @@ -69,7 +69,7 @@ DatafilesSelector::DatafilesSelector(StackedDataFrames* data_frames) , m_import2dData_action(new QAction(this)) , m_rename_data_action(new QAction(this)) , m_remove_data_action(new QAction(this)) - , m_qview(new QTreeView(this)) + , m_qview(new QListView(this)) , m_qmodel(new DatafilesQModel(this)) , m_editor(new DatafileEditor) , m_data_frames(data_frames) @@ -116,9 +116,6 @@ DatafilesSelector::DatafilesSelector(StackedDataFrames* data_frames) // m_qview->setAttribute(Qt::WA_MacShowFocusRect, false); // TODO/Mac: needed? m_qview->setSelectionMode(QAbstractItemView::SingleSelection); - m_qview->setItemsExpandable(false); - m_qview->setRootIsDecorated(false); - m_qview->setHeaderHidden(true); m_qview->setContextMenuPolicy(Qt::CustomContextMenu); m_qview->setModel(m_qmodel); @@ -135,17 +132,12 @@ DatafilesSelector::DatafilesSelector(StackedDataFrames* data_frames) }); // TODO rm ?? - connect(m_qview, &QTreeView::customContextMenuRequested, this, + connect(m_qview, &QListView::customContextMenuRequested, this, &DatafilesSelector::onContextMenuRequest); - connect(m_qmodel, &QAbstractItemModel::modelReset, [this] { m_qview->expandAll(); }); - - connect(m_qmodel, &QAbstractItemModel::rowsInserted, [this] { m_qview->expandAll(); }); - connect(m_qview->selectionModel(), &QItemSelectionModel::selectionChanged, this, &DatafilesSelector::onSelectionChanged); - m_qview->expandAll(); updateActionEnabling(); restoreSelection(); diff --git a/GUI/View/Data/DatafilesSelector.h b/GUI/View/Data/DatafilesSelector.h index 096f6f0a32ba2e8434471dcddfc0b9b2495a1e98..8ac99c0db7bd765dda22b60656b530d3efef3265 100644 --- a/GUI/View/Data/DatafilesSelector.h +++ b/GUI/View/Data/DatafilesSelector.h @@ -15,8 +15,8 @@ #ifndef BORNAGAIN_GUI_VIEW_DATA_DATAFILESSELECTOR_H #define BORNAGAIN_GUI_VIEW_DATA_DATAFILESSELECTOR_H +#include <QListView> #include <QModelIndex> -#include <QTreeView> #include <QWidget> class DatafileEditor; @@ -62,7 +62,7 @@ private: QAction* m_rename_data_action; QAction* m_remove_data_action; - QTreeView* m_qview; + QListView* m_qview; DatafilesQModel* m_qmodel; DatafileEditor* m_editor; StackedDataFrames* m_data_frames; diff --git a/GUI/View/Job/JobsListing.cpp b/GUI/View/Job/JobsListing.cpp index 973ca73adb2cead0f44d28180e9c66712201195d..81d2d2a697b805133696f9e5c56f78663c520d75 100644 --- a/GUI/View/Job/JobsListing.cpp +++ b/GUI/View/Job/JobsListing.cpp @@ -44,11 +44,11 @@ bool row_ascending(const QModelIndex& idx1, const QModelIndex& idx2) // public member functions // ------------------------------------------------------------------------------------------------ -JobsListing::JobsListing(JobsSet* jobs, QWidget* parent, Qt::WindowFlags f) +JobsListing::JobsListing(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f) , m_list_view(new QListView(this)) , m_progress_delegate(new JobProgressDelegate(this)) - , m_model(new JobsQModel(jobs, this)) + , m_model(new JobsQModel(this)) { auto* layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); @@ -105,10 +105,10 @@ JobsListing::JobsListing(JobsSet* jobs, QWidget* parent, Qt::WindowFlags f) QVector<JobItem*> JobsListing::selectedJobItems() const { - QVector<JobItem*> jobs; + QVector<JobItem*> result; for (const QModelIndex& index : m_list_view->selectionModel()->selectedIndexes()) - jobs.push_back(m_model->jobItemForIndex(index)); - return jobs; + result.push_back(m_model->jobItemForIndex(index)); + return result; } void JobsListing::selectJob(JobItem* job) diff --git a/GUI/View/Job/JobsListing.h b/GUI/View/Job/JobsListing.h index 8b51241d96719d5d01c7cc1e7193176c91d2d6c9..c0d1510a555932f7ae1f92b7ad3da18d529e2e50 100644 --- a/GUI/View/Job/JobsListing.h +++ b/GUI/View/Job/JobsListing.h @@ -24,14 +24,13 @@ class JobItem; class JobProgressDelegate; class JobsQModel; -class JobsSet; //! List of jobs on the top left side of JobView. class JobsListing : public QWidget { Q_OBJECT public: - JobsListing(JobsSet* jobs, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + JobsListing(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); QVector<JobItem*> selectedJobItems() const; void selectJob(JobItem* job); diff --git a/GUI/View/Job/JobsPanel.cpp b/GUI/View/Job/JobsPanel.cpp index 50851ca9741051afe947f3f38343d67335dd2a09..4f2e114dcee8670b101831e82d8a6effe4cf82c6 100644 --- a/GUI/View/Job/JobsPanel.cpp +++ b/GUI/View/Job/JobsPanel.cpp @@ -42,11 +42,10 @@ QVector<int> qVariantToList(const QVariant& var) } // namespace -JobsPanel::JobsPanel(JobsSet* jobs, QWidget* parent) +JobsPanel::JobsPanel(QWidget* parent) : QWidget(parent) , m_splitter(new QSplitter(Qt::Vertical, this)) , m_job_editor(new JobEditor(this)) - , m_jobs(jobs) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding); setMinimumWidth(80); @@ -61,7 +60,7 @@ JobsPanel::JobsPanel(JobsSet* jobs, QWidget* parent) m_splitter->setChildrenCollapsible(true); layout->addWidget(m_splitter); - m_listing = new JobsListing(m_jobs, m_splitter); + m_listing = new JobsListing(m_splitter); m_splitter->addWidget(m_listing); m_splitter->setCollapsible(0, false); m_splitter->setStretchFactor(0, 1); diff --git a/GUI/View/Job/JobsPanel.h b/GUI/View/Job/JobsPanel.h index f52207e825fdeb3d213e550580c36c697d35bd19..7021878f4292db247f9d23f22865b9f46a6257af 100644 --- a/GUI/View/Job/JobsPanel.h +++ b/GUI/View/Job/JobsPanel.h @@ -21,14 +21,13 @@ class JobEditor; class JobItem; class JobsListing; -class JobsSet; //! A panel with a JobsListing on top and a JobEditor an bottom. class JobsPanel : public QWidget { Q_OBJECT public: - explicit JobsPanel(JobsSet* jobs, QWidget* parent = nullptr); + explicit JobsPanel(QWidget* parent = nullptr); ~JobsPanel(); void resizeEvent(QResizeEvent* event) override; @@ -50,7 +49,6 @@ private: QSplitter* m_splitter; JobsListing* m_listing; JobEditor* m_job_editor; - JobsSet* m_jobs; }; #endif // BORNAGAIN_GUI_VIEW_JOB_JOBSPANEL_H diff --git a/GUI/View/Job/JobsQModel.cpp b/GUI/View/Job/JobsQModel.cpp index 081d8db99936c413694bec52c65602a599ef36af..e3defd3f974f39d6ac4724cecdd0a8e22af41924 100644 --- a/GUI/View/Job/JobsQModel.cpp +++ b/GUI/View/Job/JobsQModel.cpp @@ -22,31 +22,30 @@ // public member functions //-------------------------------------------------------------------------------------------------- -JobsQModel::JobsQModel(JobsSet* jobs, QObject* parent) +JobsQModel::JobsQModel(QObject* parent) : QAbstractListModel(parent) - , m_jobs(jobs) { - connect(jobs, &JobsSet::jobAdded, this, &JobsQModel::onJobAdded); + connect(gDoc->jobsModifier(), &JobsSet::jobAdded, this, &JobsQModel::onJobAdded); onJobAdded(); } JobsQModel::~JobsQModel() { - for (JobItem* job : *m_jobs) + for (JobItem* job : *gDoc->jobsModifier()) disconnect(job, nullptr, this, nullptr); } int JobsQModel::rowCount(const QModelIndex&) const { - return m_jobs->size(); + return gDoc->jobs()->size(); } QVariant JobsQModel::data(const QModelIndex& index, int role) const { - if (!index.isValid() || index.row() >= (int)m_jobs->size() || index.row() < 0) + if (!index.isValid() || (size_t)index.row() >= gDoc->jobs()->size()) return {}; - const JobItem* item = m_jobs->at(index.row()); + const JobItem* item = gDoc->jobs()->at(index.row()); if (role == Qt::DisplayRole) return item->batchInfo()->jobName(); @@ -55,14 +54,14 @@ QVariant JobsQModel::data(const QModelIndex& index, int role) const JobItem* JobsQModel::jobItemForIndex(const QModelIndex& index) const { - if (index.row() >= 0 && index.row() < (int)m_jobs->size()) - return m_jobs->at(index.row()); + if (index.row() >= 0 && index.row() < (int)gDoc->jobs()->size()) + return gDoc->jobsModifier()->at(index.row()); return nullptr; } QModelIndex JobsQModel::indexForJob(JobItem* job) { - int idx = m_jobs->index_of(job); + int idx = gDoc->jobs()->index_of(job); if (idx != -1) return index(idx, 0); return {}; @@ -70,7 +69,7 @@ QModelIndex JobsQModel::indexForJob(JobItem* job) void JobsQModel::launchJob(const QModelIndex& index) { - m_jobs->runJob(jobItemForIndex(index)); + gDoc->jobsModifier()->runJob(jobItemForIndex(index)); } void JobsQModel::removeJob(const QModelIndex& index) @@ -78,13 +77,13 @@ void JobsQModel::removeJob(const QModelIndex& index) beginRemoveRows(QModelIndex(), index.row(), index.row()); JobItem* job = jobItemForIndex(index); disconnect(job, nullptr, this, nullptr); - m_jobs->removeJob(job); + gDoc->jobsModifier()->removeJob(job); endRemoveRows(); } void JobsQModel::cancelJob(const QModelIndex& index) { - m_jobs->cancelJob(jobItemForIndex(index)); + gDoc->jobsModifier()->cancelJob(jobItemForIndex(index)); } //-------------------------------------------------------------------------------------------------- @@ -93,7 +92,7 @@ void JobsQModel::cancelJob(const QModelIndex& index) void JobsQModel::emitJobsQModelChanged(JobItem* job) { - const int i = m_jobs->index_of(job); + const int i = gDoc->jobs()->index_of(job); if (i != -1) { const QModelIndex idx = index(i, 0); emit dataChanged(idx, idx); @@ -103,7 +102,7 @@ void JobsQModel::emitJobsQModelChanged(JobItem* job) void JobsQModel::onJobAdded() { - for (JobItem* job : *m_jobs) { + for (JobItem* job : *gDoc->jobsModifier()) { connect(job->batchInfo(), &BatchInfo::jobStatusChanged, [this, job] { emitJobsQModelChanged(job); }); connect(job->batchInfo(), &BatchInfo::jobNameChanged, diff --git a/GUI/View/Job/JobsQModel.h b/GUI/View/Job/JobsQModel.h index a03d537daa95063dfa1ce708758cbbd89e4bc23c..c513e88f83accbf42228837ca62b3eb12ef19e20 100644 --- a/GUI/View/Job/JobsQModel.h +++ b/GUI/View/Job/JobsQModel.h @@ -18,16 +18,14 @@ #include <QAbstractListModel> class JobItem; -class JobsSet; class JobsQModel : public QAbstractListModel { Q_OBJECT public: - JobsQModel(JobsSet* jobs, QObject* parent = nullptr); + JobsQModel(QObject* parent = nullptr); ~JobsQModel() override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; JobItem* jobItemForIndex(const QModelIndex& index) const; @@ -40,9 +38,6 @@ public: private slots: void emitJobsQModelChanged(JobItem* job); void onJobAdded(); - -private: - JobsSet* m_jobs; }; #endif // BORNAGAIN_GUI_VIEW_JOB_JOBSQMODEL_H diff --git a/GUI/View/List/SamplesQListView.cpp b/GUI/View/List/SamplesQListView.cpp index d67299ee0b53323fbebc79c6841e82d998337b37..78f0d3be4ab02a65ccfbda4e80a5bb347b1cd120 100644 --- a/GUI/View/List/SamplesQListView.cpp +++ b/GUI/View/List/SamplesQListView.cpp @@ -98,6 +98,7 @@ SampleItem* SamplesQListView::currentSampleItem() { return m_model->itemForIndex(currentIndex()); } + QSize SamplesQListView::sizeHint() const { QSize s = QListView::sizeHint(); diff --git a/GUI/View/List/SamplesQModel.h b/GUI/View/List/SamplesQModel.h index 6379fd6fb03f7c4cd58e50bde004483523e1ce4f..c92752a0d0ee8d0456ea1882c104ddc860157b5f 100644 --- a/GUI/View/List/SamplesQModel.h +++ b/GUI/View/List/SamplesQModel.h @@ -15,7 +15,7 @@ #ifndef BORNAGAIN_GUI_VIEW_LIST_SAMPLESQMODEL_H #define BORNAGAIN_GUI_VIEW_LIST_SAMPLESQMODEL_H -#include <QAbstractItemModel> +#include <QAbstractListModel> class SampleItem; diff --git a/GUI/View/Plotter/ProjectionsPlot.cpp b/GUI/View/Plotter/ProjectionsPlot.cpp index 435676c935ace2164e8bf298dd8f4ac17b7ef264..f2d98cb9b571484979e7047af5cb85fe80304ca9 100644 --- a/GUI/View/Plotter/ProjectionsPlot.cpp +++ b/GUI/View/Plotter/ProjectionsPlot.cpp @@ -19,7 +19,6 @@ #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Axis/BasicAxisItem.h" #include "GUI/Model/Data/Data2DItem.h" -#include "GUI/Model/Data/RangeUtil.h" #include "GUI/Model/Mask/MaskItems.h" #include "GUI/Model/Mask/MasksSet.h" #include "GUI/Support/Style/QCP_Util.h" diff --git a/GUI/View/Views/InstrumentView.cpp b/GUI/View/Views/InstrumentView.cpp index 74b812428439782018a853f9059d59849c2b4581..5137ef6ad96a05d4b1c7618e6ea70b3c605f5818 100644 --- a/GUI/View/Views/InstrumentView.cpp +++ b/GUI/View/Views/InstrumentView.cpp @@ -157,16 +157,16 @@ void InstrumentView::createWidgetsForCurrentInstrument() void InstrumentView::onInstrumentNameEdited(const QString& newName) { - auto* currentInstrument = m_listing->currentInstrumentItem(); - if (currentInstrument && currentInstrument->instrumentName() != newName) - gDoc->instrumentsModifier()->setInstrumentName(currentInstrument, newName); + InstrumentItem* t = m_listing->currentInstrumentItem(); + if (t && t->instrumentName() != newName) + gDoc->instrumentsModifier()->setInstrumentName(t, newName); } -void InstrumentView::onInstrumentdescriptionEdited(const QString& t) +void InstrumentView::onInstrumentdescriptionEdited(const QString& s) { - auto* currentInstrument = m_listing->currentInstrumentItem(); - if (currentInstrument && currentInstrument->description() != t) { - currentInstrument->setDescription(t); + InstrumentItem* t = m_listing->currentInstrumentItem(); + if (t && t->description() != s) { + t->setDescription(s); onInstrumentChangedByEditor(); } } diff --git a/GUI/View/Views/JobView.cpp b/GUI/View/Views/JobView.cpp index f63cc6ac5b90283186fbdcf6f244f4c7ff3cf1bc..63cef1334e1cc5a526a1f0e27e2aa465c5aacbea 100644 --- a/GUI/View/Views/JobView.cpp +++ b/GUI/View/Views/JobView.cpp @@ -56,7 +56,7 @@ JobView::JobView(QProgressBar* progressBar) //... Subwindows - m_jobs_panel = new JobsPanel(gDoc->jobsModifier(), this); + m_jobs_panel = new JobsPanel(this); m_job_real_time_widget = new JobRealTimeWidget(gDoc->jobsModifier(), this); m_docks->addWidget(JobViewFlags::JOB_LIST_DOCK, m_jobs_panel, Qt::LeftDockWidgetArea);