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()
if (name != P_AXES_UNITS)
return;
setAxesRangeToData();
qInfo() << "Data1DViewItem" << jobItem() << jobItem()->instrumentItem();
GUI::Model::DataViewUtils::updateAxesTitle(this);
});
......
......@@ -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<InstrumentItemCatalog>(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<InstrumentItemCatalog>(Tags::Instrument, p);
qInfo() << "read instr" << p;
m_instrument.reset(p);
} else if (reader->name() == Tags::ParameterContainer) {
m_parameterContainer.readContentFrom(reader);
......
......@@ -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));
}
......
......@@ -55,7 +55,8 @@ JobItem* JobModel::addJob(const MultiLayerItem* sampleItem, const InstrumentItem
ASSERT(sampleItem);
ASSERT(instrumentItem);
auto* jobItem = insertItem<JobItem>();
JobItem* jobItem = insertItem<JobItem>();
emit jobAdded();
jobItem->setItemName(generateJobName());
jobItem->setIdentifier(QUuid::createUuid().toString());
......
......@@ -53,6 +53,7 @@ public:
signals:
void focusRequest(JobItem* item);
void globalProgress(int);
void jobAdded();
private:
//! generates numbered job name with new/unused number
......
......@@ -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<JobItem*> 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)
......
......@@ -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);
......
......@@ -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))
......
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