Commit 8b402654 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

use separate signal on adding a new job

parent 72d09161
Pipeline #67304 failed with stage
in 5 minutes and 31 seconds
...@@ -56,7 +56,6 @@ Data1DViewItem::Data1DViewItem() ...@@ -56,7 +56,6 @@ Data1DViewItem::Data1DViewItem()
if (name != P_AXES_UNITS) if (name != P_AXES_UNITS)
return; return;
setAxesRangeToData(); setAxesRangeToData();
qInfo() << "Data1DViewItem" << jobItem() << jobItem()->instrumentItem();
GUI::Model::DataViewUtils::updateAxesTitle(this); GUI::Model::DataViewUtils::updateAxesTitle(this);
}); });
......
...@@ -367,7 +367,6 @@ void JobItem::writeNonSessionItems(QXmlStreamWriter* writer) const ...@@ -367,7 +367,6 @@ void JobItem::writeNonSessionItems(QXmlStreamWriter* writer) const
m_simulationOptionsItem.writeContentTo(writer); m_simulationOptionsItem.writeContentTo(writer);
writer->writeEndElement(); writer->writeEndElement();
qInfo() << "write instr" << m_instrument.get();
Streamer(writer).write<InstrumentItemCatalog>(Tags::Instrument, m_instrument.get()); Streamer(writer).write<InstrumentItemCatalog>(Tags::Instrument, m_instrument.get());
writer->writeStartElement(Tags::Sample); writer->writeStartElement(Tags::Sample);
...@@ -396,7 +395,6 @@ void JobItem::readNonSessionItems(QXmlStreamReader* reader) ...@@ -396,7 +395,6 @@ void JobItem::readNonSessionItems(QXmlStreamReader* reader)
} else if (reader->name() == Tags::Instrument) { } else if (reader->name() == Tags::Instrument) {
InstrumentItem* p = nullptr; InstrumentItem* p = nullptr;
Streamer(reader).read<InstrumentItemCatalog>(Tags::Instrument, p); Streamer(reader).read<InstrumentItemCatalog>(Tags::Instrument, p);
qInfo() << "read instr" << p;
m_instrument.reset(p); m_instrument.reset(p);
} else if (reader->name() == Tags::ParameterContainer) { } else if (reader->name() == Tags::ParameterContainer) {
m_parameterContainer.readContentFrom(reader); m_parameterContainer.readContentFrom(reader);
......
...@@ -112,6 +112,7 @@ void GUI::Model::JobFunctions::initDataView(JobItem* job_item) ...@@ -112,6 +112,7 @@ void GUI::Model::JobFunctions::initDataView(JobItem* job_item)
// also triggers Data1DViewItem::setAxesRangeToData and // also triggers Data1DViewItem::setAxesRangeToData and
// GUI::Model::DataViewUtils::updateAxesTitle by setting new value of P_AXES_UNITS. // GUI::Model::DataViewUtils::updateAxesTitle by setting new value of P_AXES_UNITS.
auto* converter = job_item->instrumentItem()->createCoordSystem(); auto* converter = job_item->instrumentItem()->createCoordSystem();
view_item->setAxesUnits(GUI::Model::JobItemUtils::availableUnits(*converter)); view_item->setAxesUnits(GUI::Model::JobItemUtils::availableUnits(*converter));
} }
......
...@@ -55,7 +55,8 @@ JobItem* JobModel::addJob(const MultiLayerItem* sampleItem, const InstrumentItem ...@@ -55,7 +55,8 @@ JobItem* JobModel::addJob(const MultiLayerItem* sampleItem, const InstrumentItem
ASSERT(sampleItem); ASSERT(sampleItem);
ASSERT(instrumentItem); ASSERT(instrumentItem);
auto* jobItem = insertItem<JobItem>(); JobItem* jobItem = insertItem<JobItem>();
emit jobAdded();
jobItem->setItemName(generateJobName()); jobItem->setItemName(generateJobName());
jobItem->setIdentifier(QUuid::createUuid().toString()); jobItem->setIdentifier(QUuid::createUuid().toString());
......
...@@ -53,6 +53,7 @@ public: ...@@ -53,6 +53,7 @@ public:
signals: signals:
void focusRequest(JobItem* item); void focusRequest(JobItem* item);
void globalProgress(int); void globalProgress(int);
void jobAdded();
private: private:
//! generates numbered job name with new/unused number //! generates numbered job name with new/unused number
......
...@@ -28,19 +28,16 @@ JobListModel::JobListModel(JobModel* jobs, QObject* parent) ...@@ -28,19 +28,16 @@ JobListModel::JobListModel(JobModel* jobs, QObject* parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
, m_jobs(jobs) , m_jobs(jobs)
{ {
for (JobItem* job : m_jobs->jobItems()) for (JobItem* job : m_jobs->jobItems()) {
enableJobNotification(job); enableJobNotification(job);
}
connect(jobs, &QAbstractItemModel::rowsAboutToBeInserted, this, connect(jobs, &JobModel::jobAdded, this, &JobListModel::onJobAdded, Qt::UniqueConnection);
&JobListModel::onRowsAboutToBeInserted);
connect(jobs, &QAbstractItemModel::rowsInserted, this, &JobListModel::onRowsInserted);
} }
JobListModel::~JobListModel() JobListModel::~JobListModel()
{ {
for (JobItem* job : m_jobs->jobItems()) { for (JobItem* job : m_jobs->jobItems())
disableJobNotification(job); disableJobNotification(job);
}
} }
int JobListModel::rowCount(const QModelIndex&) const int JobListModel::rowCount(const QModelIndex&) const
...@@ -111,20 +108,10 @@ void JobListModel::emitJobListModelChanged(JobItem* job) ...@@ -111,20 +108,10 @@ void JobListModel::emitJobListModelChanged(JobItem* job)
// private slots // private slots
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void JobListModel::onRowsAboutToBeInserted(const QModelIndex& parent, int start, int end) void JobListModel::onJobAdded()
{ {
if (!parent.isValid()) for (JobItem* job : m_jobs->jobItems())
beginInsertRows(QModelIndex(), start, end); enableJobNotification(job);
}
void JobListModel::onRowsInserted(const QModelIndex& parent, int start, int end)
{
if (!parent.isValid()) {
endInsertRows();
QVector<JobItem*> jobs = m_jobs->jobItems();
for (int i = start; i <= end; i++)
enableJobNotification(jobs.at(i));
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
...@@ -134,15 +121,13 @@ void JobListModel::onRowsInserted(const QModelIndex& parent, int start, int end) ...@@ -134,15 +121,13 @@ void JobListModel::onRowsInserted(const QModelIndex& parent, int start, int end)
void JobListModel::enableJobNotification(JobItem* job) void JobListModel::enableJobNotification(JobItem* job)
{ {
// name // name
connect(job, &JobItem::jobNameChanged, this, connect(job, &JobItem::jobNameChanged, this, [=]() { emitJobListModelChanged(job); });
[=](const QString&) { emitJobListModelChanged(job); });
// status // status
connect(job, &JobItem::jobStatusChanged, this, connect(job, &JobItem::jobStatusChanged, this, [=]() { emitJobListModelChanged(job); });
[=](const JobStatus) { emitJobListModelChanged(job); });
// progress // progress
connect(job, &JobItem::jobProgressChanged, this, [=](int) { emitJobListModelChanged(job); }); connect(job, &JobItem::jobProgressChanged, this, [=]() { emitJobListModelChanged(job); });
} }
void JobListModel::disableJobNotification(JobItem* job) void JobListModel::disableJobNotification(JobItem* job)
......
...@@ -40,8 +40,7 @@ public: ...@@ -40,8 +40,7 @@ public:
private slots: private slots:
void emitJobListModelChanged(JobItem* job); void emitJobListModelChanged(JobItem* job);
void onRowsAboutToBeInserted(const QModelIndex& parent, int start, int end); void onJobAdded();
void onRowsInserted(const QModelIndex& parent, int start, int end);
private: private:
void enableJobNotification(JobItem* job); void enableJobNotification(JobItem* job);
......
...@@ -193,11 +193,8 @@ void SimulationView::updateSelection(QComboBox* comboBox, QStringList itemList, ...@@ -193,11 +193,8 @@ void SimulationView::updateSelection(QComboBox* comboBox, QStringList itemList,
return; return;
} }
qInfo() << itemList.size(); if (allowNone)
if (allowNone) {
itemList.prepend("None"); itemList.prepend("None");
qInfo() << itemList;
}
comboBox->addItems(itemList); comboBox->addItems(itemList);
if (itemList.contains(previousItem)) if (itemList.contains(previousItem))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment