From 983ce000e8a5ef0a62635cd1c5169991aad3f1d1 Mon Sep 17 00:00:00 2001 From: Tobias Knopff <t.knopff@fz-juelich.de> Date: Tue, 1 Jun 2021 12:55:37 +0200 Subject: [PATCH] Make JobItem::P_PRESENTATION_TYPE private --- GUI/Models/JobItem.cpp | 10 ++++++++++ GUI/Models/JobItem.h | 5 ++++- GUI/Views/JobWidgets/JobResultsPresenter.cpp | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/GUI/Models/JobItem.cpp b/GUI/Models/JobItem.cpp index 3e2826a7aa9..ac380a38b4d 100644 --- a/GUI/Models/JobItem.cpp +++ b/GUI/Models/JobItem.cpp @@ -288,6 +288,16 @@ bool JobItem::isCommentsPropertyName(const QString& name) return name == P_COMMENTS; } +const QString JobItem::presentationType() const +{ + return getItemValue(P_PRESENTATION_TYPE).toString(); +} + +void JobItem::setPresentationType(const QString& type) +{ + setItemValue(P_PRESENTATION_TYPE, type); +} + //! Updates the name of file to store intensity data. void JobItem::updateIntensityDataFileName() diff --git a/GUI/Models/JobItem.h b/GUI/Models/JobItem.h index 96c691a4787..66740d6808b 100644 --- a/GUI/Models/JobItem.h +++ b/GUI/Models/JobItem.h @@ -43,9 +43,9 @@ private: static const QString P_DURATION; static const QString P_COMMENTS; static const QString P_PROGRESS; + static const QString P_PRESENTATION_TYPE; public: - static const QString P_PRESENTATION_TYPE; static const QString T_SAMPLE; static const QString T_MATERIAL_CONTAINER; static const QString T_INSTRUMENT; @@ -116,6 +116,9 @@ public: static bool isCommentsPropertyName(const QString& name); + const QString presentationType() const; + void setPresentationType(const QString& type); + private: void updateIntensityDataFileName(); const SimulationOptionsItem* simulationOptionsItem() const; diff --git a/GUI/Views/JobWidgets/JobResultsPresenter.cpp b/GUI/Views/JobWidgets/JobResultsPresenter.cpp index 124e4a1feef..0c2d0743461 100644 --- a/GUI/Views/JobWidgets/JobResultsPresenter.cpp +++ b/GUI/Views/JobWidgets/JobResultsPresenter.cpp @@ -36,8 +36,8 @@ QString JobResultsPresenter::itemPresentation() const if (!currentItem()) return {}; - const auto& value = currentItem()->getItemValue(JobItem::P_PRESENTATION_TYPE); - return value.isValid() ? value.toString() : selectedPresentation(); + const QString value = dynamic_cast<const JobItem*>(currentItem())->presentationType(); + return value.isEmpty() ? selectedPresentation() : value; } void JobResultsPresenter::setPresentation(const QString& presentationType) @@ -46,7 +46,7 @@ void JobResultsPresenter::setPresentation(const QString& presentationType) return; ItemComboWidget::setPresentation(presentationType); - currentItem()->setItemValue(JobItem::P_PRESENTATION_TYPE, presentationType); + dynamic_cast<JobItem*>(currentItem())->setPresentationType(presentationType); } void JobResultsPresenter::setPresentation(JobViewFlags::EActivities activity) -- GitLab