diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp index 729e3113df..ae7b0604c3 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp @@ -88,16 +88,14 @@ void PdmUiEditorHandle::updateUi() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmUiEditorHandle::updateUiIncludingParent() +PdmUiEditorHandle* PdmUiEditorHandle::topMostContainingEditor() { - if (m_parentEditor) + if (m_containingEditor) { - m_parentEditor->updateUiIncludingParent(); - } - else - { - this->updateUi(); + return m_containingEditor->topMostContainingEditor(); } + + return this; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.h index c0252c9d91..b8d76f2dc5 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.h @@ -62,7 +62,7 @@ public: void updateUi(const QString& uiConfigName);; void updateUi(); - void updateUiIncludingParent(); + PdmUiEditorHandle* topMostContainingEditor(); signals: void uiUpdated(); @@ -80,14 +80,14 @@ protected: PdmUiItem* pdmItem() { return m_pdmItem; } const PdmUiItem* pdmItem() const { return m_pdmItem; } public: // PDM Internal - void setParentEditor(PdmUiEditorHandle* parentEditor) { m_parentEditor = parentEditor; } + void setContainingEditor(PdmUiEditorHandle* containingEditor) { m_containingEditor = containingEditor; } private: friend PdmUiItem::~PdmUiItem(); PdmUiItem* m_pdmItem; QString m_currentConfigName; - QPointer m_parentEditor; // Editor containing this editor. Will be asked to updateUi (instead of this) if it exists + QPointer m_containingEditor; // Editor containing this editor. Will be asked to updateUi (instead of this) if it exists bool m_isConfiguringUi; }; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp index 378af2aefa..316edec709 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldHandle.cpp @@ -4,6 +4,7 @@ #include "cafPdmFieldHandle.h" #include "cafPdmUiModelChangeDetector.h" #include "cafPdmUiObjectHandle.h" +#include "cafPdmUiEditorHandle.h" namespace caf { @@ -61,12 +62,31 @@ void PdmUiFieldHandle::notifyFieldChanged(const QVariant& oldFieldValue, const Q PdmObjectHandle* ownerObjectHandle = fieldHandle->ownerObject(); { + bool noOwnerObject = true; + + // Object editors + PdmUiObjectHandle* uiObjHandle = uiObj(ownerObjectHandle); if (uiObjHandle) { uiObjHandle->fieldChangedByUi(fieldHandle, oldFieldValue, newFieldValue); uiObjHandle->updateConnectedEditors(); + noOwnerObject = false; + } + + // Field editors + + for (const auto& editorForThisField : m_editors) + { + PdmUiEditorHandle* editorContainingThisField = editorForThisField->topMostContainingEditor(); + + bool editorContainingThisFieldIsNotUpdated = !uiObjHandle->hasEditor(editorContainingThisField); + + if (noOwnerObject || editorContainingThisFieldIsNotUpdated) + { + editorContainingThisField->updateUi(); + } } } @@ -81,9 +101,6 @@ void PdmUiFieldHandle::notifyFieldChanged(const QVariant& oldFieldValue, const Q } } - // Update connected field editors or their parent editors, to make the ui reflect the change - this->updateConnectedEditors(); - PdmUiModelChangeDetector::instance()->setModelChanged(); } } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp index 27e3e76ab1..12b9a015c8 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp @@ -613,8 +613,7 @@ void PdmUiItem::updateConnectedEditors() const std::set::iterator it; for (it = m_editors.begin(); it != m_editors.end(); ++it) { - (*it)->updateUiIncludingParent(); - //(*it)->updateUi(); + (*it)->updateUi(); } } @@ -673,6 +672,14 @@ std::vector PdmUiItem::connectedEditors() const return editors; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool PdmUiItem::hasEditor(PdmUiEditorHandle* editor) const +{ + return m_editors.count(editor) > 0; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h index 7d7cde26e7..c11c4b4028 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h @@ -276,6 +276,8 @@ public: std::vector connectedEditors() const; + bool hasEditor(PdmUiEditorHandle* editor) const; + static bool showExtraDebugText(); static void enableExtraDebugText(bool enable); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp index e3061e72c6..6031c76d05 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFormLayoutObjectEditor.cpp @@ -394,7 +394,7 @@ caf::PdmUiFieldEditorHandle* caf::PdmUiFormLayoutObjectEditor::findOrCreateField if (fieldEditor) { m_fieldViews[field->fieldHandle()] = fieldEditor; - fieldEditor->setParentEditor(this); + fieldEditor->setContainingEditor(this); fieldEditor->setUiField(field); fieldEditor->createWidgets(parent); }