From 96e532696e89dbfb6c743d9eb53e9f13fb36c60d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 19 Oct 2016 15:04:30 +0200 Subject: [PATCH] #922 AppFwk : Added setValueWithFieldChanged --- .../cafPdmCore/cafPdmDataValueField.h | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmDataValueField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmDataValueField.h index fce38c1108..3da0046afa 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmDataValueField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmDataValueField.h @@ -74,6 +74,7 @@ public: DataType value() const { return m_fieldValue; } void setValue(const DataType& fieldValue) { assert(isInitializedByInitFieldMacro()); m_fieldValue = fieldValue; } + void setValueWithFieldChanged(const DataType& fieldValue); // Implementation of PdmValueField interface @@ -106,4 +107,30 @@ protected: }; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void caf::PdmDataValueField::setValueWithFieldChanged(const DataType& fieldValue) +{ + assert(isInitializedByInitFieldMacro()); + + PdmUiFieldHandle* uiFieldHandle = uiCapability(); + if (uiFieldHandle) + { + QVariant oldValue = uiFieldHandle->toUiBasedQVariant(); + + m_fieldValue = fieldValue; + + QVariant newUiBasedQVariant = uiFieldHandle->toUiBasedQVariant(); + + uiFieldHandle->notifyFieldChanged(oldValue, newUiBasedQVariant); + } + else + { + m_fieldValue = fieldValue; + } +} + } // End of namespace caf