From 0541628737c5936d9c5649aaeb37575433d0320a Mon Sep 17 00:00:00 2001 From: Matthias Puchner <github@mpuchner.de> Date: Mon, 7 Feb 2022 15:18:44 +0100 Subject: [PATCH] reduce SessionItem exposure --- GUI/Model/Item/JobFunctions.cpp | 2 +- GUI/Model/Item/JobItem.cpp | 10 ++++++++++ GUI/Model/Item/JobItem.h | 5 ++++- GUI/View/Job/JobListModel.cpp | 2 +- GUI/View/Job/JobListView.cpp | 2 +- GUI/View/Job/JobListViewDelegate.cpp | 3 +-- GUI/View/Job/JobPropertiesTableModel.cpp | 4 ++-- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/GUI/Model/Item/JobFunctions.cpp b/GUI/Model/Item/JobFunctions.cpp index 925ad6c0ef9..2377acbdbad 100644 --- a/GUI/Model/Item/JobFunctions.cpp +++ b/GUI/Model/Item/JobFunctions.cpp @@ -172,7 +172,7 @@ void GUI::Model::JobFunctions::copyRealDataItem(JobItem* jobItem, const RealData // adapting the name to job name realDataItemCopy->dataItem()->setFileName( - GUI::Model::FilenameUtils::jobReferenceFileName(jobItem->itemName())); + GUI::Model::FilenameUtils::jobReferenceFileName(jobItem->jobName())); // #baimport ++ copy members of realDataItem? diff --git a/GUI/Model/Item/JobItem.cpp b/GUI/Model/Item/JobItem.cpp index 3b074f319d1..25a8e8e8597 100644 --- a/GUI/Model/Item/JobItem.cpp +++ b/GUI/Model/Item/JobItem.cpp @@ -87,6 +87,16 @@ void JobItem::setIdentifier(const QString& identifier) setItemValue(JobItem::P_IDENTIFIER, identifier); } +QString JobItem::jobName() const +{ + return itemName(); +} + +void JobItem::setJobName(const QString& name) +{ + setItemName(name); +} + IntensityDataItem* JobItem::intensityDataItem() { return dynamic_cast<IntensityDataItem*>(getItem(T_OUTPUT)); diff --git a/GUI/Model/Item/JobItem.h b/GUI/Model/Item/JobItem.h index 30761c46a5f..3d29e7cde98 100644 --- a/GUI/Model/Item/JobItem.h +++ b/GUI/Model/Item/JobItem.h @@ -17,9 +17,9 @@ #include "GUI/Model/BaseItem/SessionItem.h" #include "GUI/Model/Item/InstrumentItems.h" +#include "GUI/Model/Item/MaterialItems.h" #include "GUI/Model/Item/MultiLayerItem.h" #include "GUI/Model/Item/ParameterTreeItems.h" -#include "GUI/Model/Item/MaterialItems.h" #include "GUI/Model/Model/SessionModel.h" // call to model() from templated fct #include "GUI/Support/Data/JobStatus.h" // enum cannot be forward declared #include "GUI/Support/Data/SimulationOptionsItem.h" @@ -64,6 +64,9 @@ public: QString getIdentifier() const; void setIdentifier(const QString& identifier); + QString jobName() const; + void setJobName(const QString& name); + IntensityDataItem* intensityDataItem(); DataItem* dataItem(); template <typename T> T* setDataType(); diff --git a/GUI/View/Job/JobListModel.cpp b/GUI/View/Job/JobListModel.cpp index bdd5838026e..e69395a86b8 100644 --- a/GUI/View/Job/JobListModel.cpp +++ b/GUI/View/Job/JobListModel.cpp @@ -55,7 +55,7 @@ QVariant JobListModel::data(const QModelIndex& index, int role) const JobItem* item = jobs[index.row()]; if (role == Qt::DisplayRole) - return item->itemName(); + return item->jobName(); return {}; } diff --git a/GUI/View/Job/JobListView.cpp b/GUI/View/Job/JobListView.cpp index dd09a20745e..72fd803d422 100644 --- a/GUI/View/Job/JobListView.cpp +++ b/GUI/View/Job/JobListView.cpp @@ -207,7 +207,7 @@ void JobListView::showContextMenu(const QPoint&) std::sort(indexes.begin(), indexes.end(), row_ascending); for (const QModelIndex& index : indexes) { JobItem* job = m_model->jobForIndex(index); - QAction* action = m_equalizeMenu->addAction(QString("to ").append(job->itemName())); + QAction* action = m_equalizeMenu->addAction(QString("to ").append(job->jobName())); connect(action, &QAction::triggered, this, [this, job] { equalizeSelectedToJob(job); }); } m_equalizeMenu->setEnabled(true); diff --git a/GUI/View/Job/JobListViewDelegate.cpp b/GUI/View/Job/JobListViewDelegate.cpp index 5254735e3bf..c9911c9a6ff 100644 --- a/GUI/View/Job/JobListViewDelegate.cpp +++ b/GUI/View/Job/JobListViewDelegate.cpp @@ -49,9 +49,8 @@ void JobListViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o painter->setRenderHint(QPainter::Antialiasing, true); - QString text = item->itemName(); QRect textRect = getTextRect(option.rect); - painter->drawText(textRect, text); + painter->drawText(textRect, item->jobName()); drawCustomProjectBar(item, painter, option); diff --git a/GUI/View/Job/JobPropertiesTableModel.cpp b/GUI/View/Job/JobPropertiesTableModel.cpp index 78523d95a4d..52c695d1441 100644 --- a/GUI/View/Job/JobPropertiesTableModel.cpp +++ b/GUI/View/Job/JobPropertiesTableModel.cpp @@ -83,7 +83,7 @@ QVariant JobPropertiesTableModel::data(const QModelIndex& index, int role) const case Column::Value: { switch (index.row()) { case Row::Name: - return m_item->itemName(); + return m_item->jobName(); case Row::Sample: return m_item->sampleName(); case Row::Instrument: @@ -135,7 +135,7 @@ bool JobPropertiesTableModel::setData(const QModelIndex& index, const QVariant& if (role != Qt::EditRole || index.column() != Column::Value || index.row() != Row::Name || !m_item) return false; - m_item->setItemName(value.toString()); + m_item->setJobName(value.toString()); emit dataChanged(index, index, {role}); return true; } -- GitLab