From 0ee21b9e7a53e949b491b516a0e32186a7e25ee4 Mon Sep 17 00:00:00 2001 From: Mikhail Svechnikov Date: Tue, 14 Jun 2022 15:20:16 +0200 Subject: [PATCH 1/5] projections are reconnected --- GUI/Model/BaseItem/SessionItem.h | 1 + GUI/Model/Data/IntensityDataItem.cpp | 2 +- GUI/Model/Data/IntensityDataItem.h | 3 +- GUI/Model/Device/AxesItems.cpp | 2 +- GUI/Model/Device/AxesItems.h | 2 +- .../FitComparisonViewController.cpp | 7 +-- .../PlotUtil/IntensityDataPropertyWidget.cpp | 8 ++- GUI/View/Projection/ProjectionsEditor.cpp | 5 +- GUI/View/Projection/ProjectionsPlot.cpp | 53 ++++++++++++++++--- 9 files changed, 61 insertions(+), 22 deletions(-) diff --git a/GUI/Model/BaseItem/SessionItem.h b/GUI/Model/BaseItem/SessionItem.h index 114d989bfa..e2abe50a77 100644 --- a/GUI/Model/BaseItem/SessionItem.h +++ b/GUI/Model/BaseItem/SessionItem.h @@ -201,6 +201,7 @@ class GroupInfo; //! //! This code part again shows the (highly error-prone) string-based type checking. //#define USE_MAPPERS +#include class BA_CORE_API_ SessionItem { friend class SessionModel; diff --git a/GUI/Model/Data/IntensityDataItem.cpp b/GUI/Model/Data/IntensityDataItem.cpp index 99d4882bb3..48403c5165 100644 --- a/GUI/Model/Data/IntensityDataItem.cpp +++ b/GUI/Model/Data/IntensityDataItem.cpp @@ -331,7 +331,7 @@ void IntensityDataItem::setLogz(bool logz) void IntensityDataItem::setInterpolated(bool interp) { setItemValue(P_IS_INTERPOLATED, interp); - emit interpolationChanged(); + emit interpolationChanged(interp); } //! Sets zoom range of X,Y axes, if it was not yet defined. diff --git a/GUI/Model/Data/IntensityDataItem.h b/GUI/Model/Data/IntensityDataItem.h index 7b1c329eca..f49cfa755b 100644 --- a/GUI/Model/Data/IntensityDataItem.h +++ b/GUI/Model/Data/IntensityDataItem.h @@ -26,6 +26,7 @@ class ProjectionContainerItem; class BA_CORE_API_ IntensityDataItem : public DataItem { Q_OBJECT private: +// using DataItem::mapper; static constexpr auto P_PROJECTIONS{"Projections"}; static constexpr auto P_TITLE{"Title"}; static constexpr auto P_IS_INTERPOLATED{"Interpolation"}; @@ -123,7 +124,7 @@ public: signals: void gradientChanged(); - void interpolationChanged(); + void interpolationChanged(bool isInterpol); void axesRangeChangedFromPlot(); void updateOtherPlots(); void updateThisPlot(); diff --git a/GUI/Model/Device/AxesItems.cpp b/GUI/Model/Device/AxesItems.cpp index e4845490fc..3fa213675e 100644 --- a/GUI/Model/Device/AxesItems.cpp +++ b/GUI/Model/Device/AxesItems.cpp @@ -195,7 +195,7 @@ bool AmplitudeAxisItem::isLogScale() const void AmplitudeAxisItem::setLogScale(bool value) { setItemValue(P_IS_LOGSCALE, value); - emit logScaleChanged(); + emit logScaleChanged(value); } SessionItem* AmplitudeAxisItem::logScaleItem() const diff --git a/GUI/Model/Device/AxesItems.h b/GUI/Model/Device/AxesItems.h index f17244c1c0..cb100e772a 100644 --- a/GUI/Model/Device/AxesItems.h +++ b/GUI/Model/Device/AxesItems.h @@ -99,7 +99,7 @@ public: void setLocked(bool locked); signals: - void logScaleChanged(); + void logScaleChanged(bool isLog); }; diff --git a/GUI/View/PlotComparison/FitComparisonViewController.cpp b/GUI/View/PlotComparison/FitComparisonViewController.cpp index c865c740a3..7d5d721340 100644 --- a/GUI/View/PlotComparison/FitComparisonViewController.cpp +++ b/GUI/View/PlotComparison/FitComparisonViewController.cpp @@ -174,17 +174,14 @@ void DiffItemController::subscribe() void DiffItemController::unsubscribe() { -#ifdef USE_MAPPERS - m_diff_item->mapper()->unsubscribe(this); -#else - disconnect(m_diff_item, nullptr, this, nullptr); -#endif if (!m_current_item) return; #ifdef USE_MAPPERS m_current_item->dataItem()->mapper()->unsubscribe(this); + m_diff_item->mapper()->unsubscribe(this); #else disconnect(m_current_item->dataItem(), nullptr, this, nullptr); + disconnect(m_diff_item, nullptr, this, nullptr); #endif m_current_item = nullptr; } diff --git a/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp b/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp index 53ca1596d9..26a066234a 100644 --- a/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp +++ b/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp @@ -141,14 +141,12 @@ void IntensityDataPropertyWidget::setItem(QVector itemsVec) updateUIValues(); - // react on external changes (e.g. zooming in customplot shall update the axis values) - - - // update coordinates on axes units change #ifdef USE_MAPPERS + // react on external changes (e.g. zooming in customplot shall update the axis values) first_item->mapper()->setOnChildPropertyChange( [=](SessionItem*, const QString&) { updateUIValues(); }, this); + // update coordinates on axes units change first_item->mapper()->setOnPropertyChange( [this](SessionItem* item, const QString& name) { if(jobItem()) @@ -160,7 +158,7 @@ void IntensityDataPropertyWidget::setItem(QVector itemsVec) [&](SessionItem*) { item = nullptr; }, this); #else - // update values on panel + // react on external changes (e.g. zooming in customplot shall update the axis values) FOR_EACH_ITEM connect(item, &IntensityDataItem::axesRangeChangedFromPlot, this, [=](){ updateUIValues(); diff --git a/GUI/View/Projection/ProjectionsEditor.cpp b/GUI/View/Projection/ProjectionsEditor.cpp index e8cb68749e..6e93d5b5c1 100644 --- a/GUI/View/Projection/ProjectionsEditor.cpp +++ b/GUI/View/Projection/ProjectionsEditor.cpp @@ -101,7 +101,10 @@ JobItem* ProjectionsEditor::jobItem() IntensityDataItem* ProjectionsEditor::simulatedIntensity() { - return dynamic_cast(jobItem()->dataItem()); + if(jobItem()) + return dynamic_cast(jobItem()->dataItem()); + else + return nullptr; } IntensityDataItem* ProjectionsEditor::realIntensityDataItem() diff --git a/GUI/View/Projection/ProjectionsPlot.cpp b/GUI/View/Projection/ProjectionsPlot.cpp index 810cc383af..041b08a374 100644 --- a/GUI/View/Projection/ProjectionsPlot.cpp +++ b/GUI/View/Projection/ProjectionsPlot.cpp @@ -81,25 +81,64 @@ void ProjectionsPlot::subscribeToItem() this); // Values of intensity changed, regenerate everything. - intensityItem()->mapper()->setOnValueChange( - [this]() { +#ifdef USE_MAPPERS +// intensityItem()->mapper()->setOnValueChange( +// [this]() { +// updateProjectionsData(); +// updateProjections(); +// }, +// this); +#else + connect(intensityItem(), &IntensityDataItem::datafieldChanged, this, [=]() { updateProjectionsData(); updateProjections(); - }, - this); + }); +#endif - // IntensityItem property (e.g. interpolation changed) + // interpolation changed +#ifdef USE_MAPPERS intensityItem()->mapper()->setOnPropertyChange( [this](const QString& name) { onIntensityItemPropertyChanged(name); }, this); +#else + connect(intensityItem(), &IntensityDataItem::interpolationChanged, this, + &ProjectionsPlot::setInterpolate, Qt::UniqueConnection); +#endif - // Update to changed IntensityDataItem axes + // AXES +#ifdef USE_MAPPERS intensityItem()->mapper()->setOnChildPropertyChange( [this](SessionItem* item, const QString name) { if (item->modelType() == BasicAxisItem::M_TYPE - || item->modelType() == AmplitudeAxisItem::M_TYPE) + || item->modelType() == AmplitudeAxisItem::M_TYPE) { onAxisPropertyChanged(item->itemName(), name); + } }, this); +#else + // if the colormap is zoomed or dragged: + connect(intensityItem(), &IntensityDataItem::updateOtherPlots, this, + &ProjectionsPlot::updateAxesRange, Qt::UniqueConnection); + + // if axes are changed externally, from the properties panel: + + // axes range + connect(intensityItem()->xAxisItem(), &BasicAxisItem::axisRangeChanged, this, + &ProjectionsPlot::updateAxesRange, Qt::UniqueConnection); + connect(intensityItem()->yAxisItem(), &BasicAxisItem::axisRangeChanged, this, + &ProjectionsPlot::updateAxesRange, Qt::UniqueConnection); + connect(intensityItem()->zAxisItem(), &BasicAxisItem::axisRangeChanged, this, + &ProjectionsPlot::updateAxesRange, Qt::UniqueConnection); + + // axes title + connect(intensityItem()->xAxisItem(), &BasicAxisItem::axisTitleChanged, this, + &ProjectionsPlot::updateAxesTitle, Qt::UniqueConnection); + connect(intensityItem()->yAxisItem(), &BasicAxisItem::axisTitleChanged, this, + &ProjectionsPlot::updateAxesTitle, Qt::UniqueConnection); + + // z log scale + connect(intensityItem()->zAxisItem(), &AmplitudeAxisItem::logScaleChanged, this, + &ProjectionsPlot::setLogz, Qt::UniqueConnection); +#endif updateProjectionsData(); updateProjections(); -- GitLab From c7d5c163acfc8d7a67af5897f6b4c55d706e0d09 Mon Sep 17 00:00:00 2001 From: Mikhail Svechnikov Date: Tue, 14 Jun 2022 15:41:46 +0200 Subject: [PATCH 2/5] cleanup --- GUI/Model/Data/DataItem.cpp | 2 +- GUI/Model/Data/DataItem.h | 2 +- GUI/View/PlotComparison/FitComparisonController.cpp | 2 +- GUI/View/PlotComparison/FitComparisonViewController.cpp | 2 +- GUI/View/PlotComparison/Plot1D.cpp | 2 +- GUI/View/PlotUtil/ColorMap.cpp | 5 ++--- GUI/View/Projection/ProjectionsPlot.cpp | 1 - 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/GUI/Model/Data/DataItem.cpp b/GUI/Model/Data/DataItem.cpp index 14a00f8e6a..df4832af96 100644 --- a/GUI/Model/Data/DataItem.cpp +++ b/GUI/Model/Data/DataItem.cpp @@ -23,7 +23,7 @@ void DataItem::setDatafield(Datafield* data) m_data.reset(data); setLastModified(QDateTime::currentDateTime()); - emit datafieldChanged(data); + emit datafieldChanged(); #ifdef USE_MAPPERS emitDataChanged(); #endif diff --git a/GUI/Model/Data/DataItem.h b/GUI/Model/Data/DataItem.h index a5dda13c82..7ad4f7ca37 100644 --- a/GUI/Model/Data/DataItem.h +++ b/GUI/Model/Data/DataItem.h @@ -76,7 +76,7 @@ public: virtual void reset(ImportDataInfo data) = 0; signals: - void datafieldChanged(Datafield* data); + void datafieldChanged(); void rawDataVectorChanged(const std::vector& data); void fileNameChanged(const QString& filename); void axesUnitsChanged(); diff --git a/GUI/View/PlotComparison/FitComparisonController.cpp b/GUI/View/PlotComparison/FitComparisonController.cpp index 3a23142b7e..748850d1ec 100644 --- a/GUI/View/PlotComparison/FitComparisonController.cpp +++ b/GUI/View/PlotComparison/FitComparisonController.cpp @@ -177,7 +177,7 @@ void DiffItemController::subscribe() m_current_item->dataItem()->mapper()->setOnValueChange([this]() { updateDiffData(); }, this); #else connect(m_current_item->dataItem(), &DataItem::datafieldChanged, this, - [=](Datafield*) { updateDiffData(); }); + &DiffItemController::updateDiffData, Qt::UniqueConnection); #endif // on diff item units change diff --git a/GUI/View/PlotComparison/FitComparisonViewController.cpp b/GUI/View/PlotComparison/FitComparisonViewController.cpp index 7d5d721340..edcf973169 100644 --- a/GUI/View/PlotComparison/FitComparisonViewController.cpp +++ b/GUI/View/PlotComparison/FitComparisonViewController.cpp @@ -168,7 +168,7 @@ void DiffItemController::subscribe() m_current_item->dataItem()->mapper()->setOnValueChange([this]() { updateDiffData(); }, this); #else connect(m_current_item->dataItem(), &DataItem::datafieldChanged, this, - [=](Datafield*) { updateDiffData(); }); + &DiffItemController::updateDiffData, Qt::UniqueConnection); #endif } diff --git a/GUI/View/PlotComparison/Plot1D.cpp b/GUI/View/PlotComparison/Plot1D.cpp index c7d9acb45e..834b775163 100644 --- a/GUI/View/PlotComparison/Plot1D.cpp +++ b/GUI/View/PlotComparison/Plot1D.cpp @@ -134,7 +134,7 @@ void Plot1D::subscribeToItem() #else DataItem* dataItem = pair.first->dataItem(); connect(dataItem, &DataItem::datafieldChanged, caller, - [caller](Datafield*) { caller->refreshPlotData(); }); + [caller]() { caller->refreshPlotData(); }); #endif }); setConnected(true); diff --git a/GUI/View/PlotUtil/ColorMap.cpp b/GUI/View/PlotUtil/ColorMap.cpp index afe6b6f7e1..9393941ec0 100644 --- a/GUI/View/PlotUtil/ColorMap.cpp +++ b/GUI/View/PlotUtil/ColorMap.cpp @@ -225,9 +225,8 @@ void ColorMap::subscribeToItem() intensityItem()->mapper()->setOnValueChange([this]() { onIntensityModified(); }, this); #else // datafield - connect(intensityItem(), &IntensityDataItem::datafieldChanged, this, [=]() { - onIntensityModified(); - }); + connect(intensityItem(), &IntensityDataItem::datafieldChanged, this, + &ColorMap::onIntensityModified, Qt::UniqueConnection); // units connect(intensityItem(), &IntensityDataItem::axesUnitsReplotRequested, this, [=]() { setAxesRangeFromItem(intensityItem()); diff --git a/GUI/View/Projection/ProjectionsPlot.cpp b/GUI/View/Projection/ProjectionsPlot.cpp index 041b08a374..ad6524a685 100644 --- a/GUI/View/Projection/ProjectionsPlot.cpp +++ b/GUI/View/Projection/ProjectionsPlot.cpp @@ -120,7 +120,6 @@ void ProjectionsPlot::subscribeToItem() &ProjectionsPlot::updateAxesRange, Qt::UniqueConnection); // if axes are changed externally, from the properties panel: - // axes range connect(intensityItem()->xAxisItem(), &BasicAxisItem::axisRangeChanged, this, &ProjectionsPlot::updateAxesRange, Qt::UniqueConnection); -- GitLab From d366bc04e6e0c01d5e491db339130b7ebe658797 Mon Sep 17 00:00:00 2001 From: Mikhail Svechnikov Date: Tue, 14 Jun 2022 15:49:29 +0200 Subject: [PATCH 3/5] fix --- GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp b/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp index 26a066234a..34c30ba65a 100644 --- a/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp +++ b/GUI/View/PlotUtil/IntensityDataPropertyWidget.cpp @@ -28,7 +28,7 @@ #include #define FOR_EACH_ITEM \ - for(IntensityDataItem* item : m_items_vec) \ + for(IntensityDataItem*& item : m_items_vec) \ if(item) IntensityDataPropertyWidget::IntensityDataPropertyWidget(QWidget* parent) -- GitLab From 72d09161063567286fdc4acc0584fed5876073f5 Mon Sep 17 00:00:00 2001 From: Mikhail Svechnikov Date: Wed, 15 Jun 2022 11:59:35 +0200 Subject: [PATCH 4/5] rm QList::insert() warning --- GUI/Model/Data/Data1DViewItem.cpp | 1 + GUI/Model/Job/JobItem.cpp | 2 ++ GUI/View/Toplevel/SimulationView.cpp | 8 ++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/GUI/Model/Data/Data1DViewItem.cpp b/GUI/Model/Data/Data1DViewItem.cpp index a19bc4e948..3ee913332b 100644 --- a/GUI/Model/Data/Data1DViewItem.cpp +++ b/GUI/Model/Data/Data1DViewItem.cpp @@ -56,6 +56,7 @@ Data1DViewItem::Data1DViewItem() if (name != P_AXES_UNITS) return; setAxesRangeToData(); + qInfo() << "Data1DViewItem" << jobItem() << jobItem()->instrumentItem(); GUI::Model::DataViewUtils::updateAxesTitle(this); }); diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp index 744948c447..4ffbbb5cb3 100644 --- a/GUI/Model/Job/JobItem.cpp +++ b/GUI/Model/Job/JobItem.cpp @@ -367,6 +367,7 @@ void JobItem::writeNonSessionItems(QXmlStreamWriter* writer) const m_simulationOptionsItem.writeContentTo(writer); writer->writeEndElement(); + qInfo() << "write instr" << m_instrument.get(); Streamer(writer).write(Tags::Instrument, m_instrument.get()); writer->writeStartElement(Tags::Sample); @@ -395,6 +396,7 @@ void JobItem::readNonSessionItems(QXmlStreamReader* reader) } else if (reader->name() == Tags::Instrument) { InstrumentItem* p = nullptr; Streamer(reader).read(Tags::Instrument, p); + qInfo() << "read instr" << p; m_instrument.reset(p); } else if (reader->name() == Tags::ParameterContainer) { m_parameterContainer.readContentFrom(reader); diff --git a/GUI/View/Toplevel/SimulationView.cpp b/GUI/View/Toplevel/SimulationView.cpp index 3d0879fd33..13e4efa22d 100644 --- a/GUI/View/Toplevel/SimulationView.cpp +++ b/GUI/View/Toplevel/SimulationView.cpp @@ -193,8 +193,12 @@ void SimulationView::updateSelection(QComboBox* comboBox, QStringList itemList, return; } - if (allowNone) - itemList.insert(-1, "None"); + qInfo() << itemList.size(); + if (allowNone) { + itemList.prepend("None"); + qInfo() << itemList; + } + comboBox->addItems(itemList); if (itemList.contains(previousItem)) comboBox->setCurrentIndex(itemList.indexOf(previousItem)); -- GitLab From 8b4026542f0f2fb943ac2cc426e5692ff803310c Mon Sep 17 00:00:00 2001 From: Mikhail Svechnikov Date: Wed, 15 Jun 2022 15:57:44 +0200 Subject: [PATCH 5/5] use separate signal on adding a new job --- GUI/Model/Data/Data1DViewItem.cpp | 1 - GUI/Model/Job/JobItem.cpp | 2 -- GUI/Model/Model/JobFunctions.cpp | 1 + GUI/Model/Model/JobModel.cpp | 3 ++- GUI/Model/Model/JobModel.h | 1 + GUI/View/Job/JobListModel.cpp | 35 ++++++++-------------------- GUI/View/Job/JobListModel.h | 3 +-- GUI/View/Toplevel/SimulationView.cpp | 5 +--- 8 files changed, 16 insertions(+), 35 deletions(-) diff --git a/GUI/Model/Data/Data1DViewItem.cpp b/GUI/Model/Data/Data1DViewItem.cpp index 3ee913332b..a19bc4e948 100644 --- a/GUI/Model/Data/Data1DViewItem.cpp +++ b/GUI/Model/Data/Data1DViewItem.cpp @@ -56,7 +56,6 @@ Data1DViewItem::Data1DViewItem() if (name != P_AXES_UNITS) return; setAxesRangeToData(); - qInfo() << "Data1DViewItem" << jobItem() << jobItem()->instrumentItem(); GUI::Model::DataViewUtils::updateAxesTitle(this); }); diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp index 4ffbbb5cb3..744948c447 100644 --- a/GUI/Model/Job/JobItem.cpp +++ b/GUI/Model/Job/JobItem.cpp @@ -367,7 +367,6 @@ void JobItem::writeNonSessionItems(QXmlStreamWriter* writer) const m_simulationOptionsItem.writeContentTo(writer); writer->writeEndElement(); - qInfo() << "write instr" << m_instrument.get(); Streamer(writer).write(Tags::Instrument, m_instrument.get()); writer->writeStartElement(Tags::Sample); @@ -396,7 +395,6 @@ void JobItem::readNonSessionItems(QXmlStreamReader* reader) } else if (reader->name() == Tags::Instrument) { InstrumentItem* p = nullptr; Streamer(reader).read(Tags::Instrument, p); - qInfo() << "read instr" << p; m_instrument.reset(p); } else if (reader->name() == Tags::ParameterContainer) { m_parameterContainer.readContentFrom(reader); diff --git a/GUI/Model/Model/JobFunctions.cpp b/GUI/Model/Model/JobFunctions.cpp index fde7b61c05..5b122c3f7e 100644 --- a/GUI/Model/Model/JobFunctions.cpp +++ b/GUI/Model/Model/JobFunctions.cpp @@ -112,6 +112,7 @@ void GUI::Model::JobFunctions::initDataView(JobItem* job_item) // also triggers Data1DViewItem::setAxesRangeToData and // GUI::Model::DataViewUtils::updateAxesTitle by setting new value of P_AXES_UNITS. auto* converter = job_item->instrumentItem()->createCoordSystem(); + view_item->setAxesUnits(GUI::Model::JobItemUtils::availableUnits(*converter)); } diff --git a/GUI/Model/Model/JobModel.cpp b/GUI/Model/Model/JobModel.cpp index fcaede6d5a..782fe82ee6 100644 --- a/GUI/Model/Model/JobModel.cpp +++ b/GUI/Model/Model/JobModel.cpp @@ -55,7 +55,8 @@ JobItem* JobModel::addJob(const MultiLayerItem* sampleItem, const InstrumentItem ASSERT(sampleItem); ASSERT(instrumentItem); - auto* jobItem = insertItem(); + JobItem* jobItem = insertItem(); + emit jobAdded(); jobItem->setItemName(generateJobName()); jobItem->setIdentifier(QUuid::createUuid().toString()); diff --git a/GUI/Model/Model/JobModel.h b/GUI/Model/Model/JobModel.h index 27bcc68fbf..70877ed61a 100644 --- a/GUI/Model/Model/JobModel.h +++ b/GUI/Model/Model/JobModel.h @@ -53,6 +53,7 @@ public: signals: void focusRequest(JobItem* item); void globalProgress(int); + void jobAdded(); private: //! generates numbered job name with new/unused number diff --git a/GUI/View/Job/JobListModel.cpp b/GUI/View/Job/JobListModel.cpp index b5af7038fa..cdae3c9763 100644 --- a/GUI/View/Job/JobListModel.cpp +++ b/GUI/View/Job/JobListModel.cpp @@ -28,19 +28,16 @@ JobListModel::JobListModel(JobModel* jobs, QObject* parent) : QAbstractListModel(parent) , m_jobs(jobs) { - for (JobItem* job : m_jobs->jobItems()) + for (JobItem* job : m_jobs->jobItems()) { enableJobNotification(job); - - connect(jobs, &QAbstractItemModel::rowsAboutToBeInserted, this, - &JobListModel::onRowsAboutToBeInserted); - connect(jobs, &QAbstractItemModel::rowsInserted, this, &JobListModel::onRowsInserted); + } + connect(jobs, &JobModel::jobAdded, this, &JobListModel::onJobAdded, Qt::UniqueConnection); } JobListModel::~JobListModel() { - for (JobItem* job : m_jobs->jobItems()) { + for (JobItem* job : m_jobs->jobItems()) disableJobNotification(job); - } } int JobListModel::rowCount(const QModelIndex&) const @@ -111,20 +108,10 @@ void JobListModel::emitJobListModelChanged(JobItem* job) // private slots //-------------------------------------------------------------------------------------------------- -void JobListModel::onRowsAboutToBeInserted(const QModelIndex& parent, int start, int end) +void JobListModel::onJobAdded() { - if (!parent.isValid()) - beginInsertRows(QModelIndex(), start, end); -} - -void JobListModel::onRowsInserted(const QModelIndex& parent, int start, int end) -{ - if (!parent.isValid()) { - endInsertRows(); - QVector jobs = m_jobs->jobItems(); - for (int i = start; i <= end; i++) - enableJobNotification(jobs.at(i)); - } + for (JobItem* job : m_jobs->jobItems()) + enableJobNotification(job); } //-------------------------------------------------------------------------------------------------- @@ -134,15 +121,13 @@ void JobListModel::onRowsInserted(const QModelIndex& parent, int start, int end) void JobListModel::enableJobNotification(JobItem* job) { // name - connect(job, &JobItem::jobNameChanged, this, - [=](const QString&) { emitJobListModelChanged(job); }); + connect(job, &JobItem::jobNameChanged, this, [=]() { emitJobListModelChanged(job); }); // status - connect(job, &JobItem::jobStatusChanged, this, - [=](const JobStatus) { emitJobListModelChanged(job); }); + connect(job, &JobItem::jobStatusChanged, this, [=]() { emitJobListModelChanged(job); }); // progress - connect(job, &JobItem::jobProgressChanged, this, [=](int) { emitJobListModelChanged(job); }); + connect(job, &JobItem::jobProgressChanged, this, [=]() { emitJobListModelChanged(job); }); } void JobListModel::disableJobNotification(JobItem* job) diff --git a/GUI/View/Job/JobListModel.h b/GUI/View/Job/JobListModel.h index 202ab4203d..19cedddd74 100644 --- a/GUI/View/Job/JobListModel.h +++ b/GUI/View/Job/JobListModel.h @@ -40,8 +40,7 @@ public: private slots: void emitJobListModelChanged(JobItem* job); - void onRowsAboutToBeInserted(const QModelIndex& parent, int start, int end); - void onRowsInserted(const QModelIndex& parent, int start, int end); + void onJobAdded(); private: void enableJobNotification(JobItem* job); diff --git a/GUI/View/Toplevel/SimulationView.cpp b/GUI/View/Toplevel/SimulationView.cpp index 13e4efa22d..bca752e6bb 100644 --- a/GUI/View/Toplevel/SimulationView.cpp +++ b/GUI/View/Toplevel/SimulationView.cpp @@ -193,11 +193,8 @@ void SimulationView::updateSelection(QComboBox* comboBox, QStringList itemList, return; } - qInfo() << itemList.size(); - if (allowNone) { + if (allowNone) itemList.prepend("None"); - qInfo() << itemList; - } comboBox->addItems(itemList); if (itemList.contains(previousItem)) -- GitLab