mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-24 15:26:48 -06:00
caf: notifyFieldChange now uses the QVariant content data when checking for equality
This commit is contained in:
parent
11e73a76fc
commit
2784f5ce11
@ -22,6 +22,8 @@ public:
|
||||
QVariant toUiBasedQVariant() const override;
|
||||
|
||||
private:
|
||||
bool isQVariantDataEqual(const QVariant& oldUiBasedQVariant, const QVariant& newUiBasedQVariant) const override;
|
||||
|
||||
mutable QList<PdmOptionItemInfo> m_optionEntryCache;
|
||||
|
||||
private:
|
||||
|
@ -247,6 +247,15 @@ QVariant caf::PdmFieldUiCap<FieldType>::toUiBasedQVariant() const
|
||||
return PdmUiFieldSpecialization<typename FieldType::FieldDataType>::convert(m_field->value());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template < typename FieldType>
|
||||
bool caf::PdmFieldUiCap<FieldType>::isQVariantDataEqual(const QVariant& oldUiBasedQVariant, const QVariant& newUiBasedQVariant) const
|
||||
{
|
||||
return PdmUiFieldSpecialization<typename FieldType::FieldDataType>::isDataElementEqual(oldUiBasedQVariant, newUiBasedQVariant);
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace caf
|
||||
|
||||
|
@ -52,9 +52,8 @@ QList<caf::PdmOptionItemInfo> PdmUiFieldHandle::valueOptions(bool* useOptionsOnl
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiFieldHandle::notifyFieldChanged(const QVariant& oldFieldValue, const QVariant& newFieldValue)
|
||||
{
|
||||
// Todo : Should use a virtual version of isElementEqual. The variant != operation will not work on user types
|
||||
|
||||
if (oldFieldValue != newFieldValue)
|
||||
if (!this->isQVariantDataEqual( oldFieldValue, newFieldValue))
|
||||
{
|
||||
PdmFieldHandle* fieldHandle = this->fieldHandle();
|
||||
CAF_ASSERT(fieldHandle && fieldHandle->ownerObject());
|
||||
@ -126,6 +125,15 @@ void PdmUiFieldHandle::setAutoAddingOptionFromValue(bool isAddingValue)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiFieldHandle::setValueFromUiEditor(const QVariant& uiValue) {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool PdmUiFieldHandle::isQVariantDataEqual(const QVariant& oldUiBasedQVariant, const QVariant& newUiBasedQVariant) const
|
||||
{
|
||||
CAF_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Implementation of uiCapability() defined in cafPdmFieldHandle.h
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -31,6 +31,8 @@ private:
|
||||
friend class PdmUiCommandSystemProxy;
|
||||
friend class CmdFieldChangeExec;
|
||||
virtual void setValueFromUiEditor(const QVariant& uiValue);
|
||||
// This is needed to handle custom types in QVariants since operator == between QVariant does not work when they use custom types.
|
||||
virtual bool isQVariantDataEqual(const QVariant& oldUiBasedQVariant, const QVariant& newUiBasedQVariant) const;
|
||||
|
||||
private:
|
||||
PdmFieldHandle* m_owner;
|
||||
|
Loading…
Reference in New Issue
Block a user