#922 AppFwk : Added setValueWithFieldChanged

This commit is contained in:
Magne Sjaastad 2016-10-19 15:04:30 +02:00
parent 522ae9998f
commit 96e532696e

View File

@ -74,6 +74,7 @@ public:
DataType value() const { return m_fieldValue; } DataType value() const { return m_fieldValue; }
void setValue(const DataType& fieldValue) { assert(isInitializedByInitFieldMacro()); m_fieldValue = fieldValue; } void setValue(const DataType& fieldValue) { assert(isInitializedByInitFieldMacro()); m_fieldValue = fieldValue; }
void setValueWithFieldChanged(const DataType& fieldValue);
// Implementation of PdmValueField interface // Implementation of PdmValueField interface
@ -106,4 +107,30 @@ protected:
}; };
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename DataType >
void caf::PdmDataValueField<DataType>::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 } // End of namespace caf