mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4388 AppFwk : Rename and rewrite of PdmUiFieldHandle::notifyFieldChanged
This commit is contained in:
parent
50ee79f6c3
commit
a852d1a50e
@ -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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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<PdmUiEditorHandle> m_parentEditor; // Editor containing this editor. Will be asked to updateUi (instead of this) if it exists
|
||||
QPointer<PdmUiEditorHandle> m_containingEditor; // Editor containing this editor. Will be asked to updateUi (instead of this) if it exists
|
||||
|
||||
bool m_isConfiguringUi;
|
||||
};
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -613,8 +613,7 @@ void PdmUiItem::updateConnectedEditors() const
|
||||
std::set<PdmUiEditorHandle*>::iterator it;
|
||||
for (it = m_editors.begin(); it != m_editors.end(); ++it)
|
||||
{
|
||||
(*it)->updateUiIncludingParent();
|
||||
//(*it)->updateUi();
|
||||
(*it)->updateUi();
|
||||
|
||||
}
|
||||
}
|
||||
@ -673,6 +672,14 @@ std::vector<PdmUiEditorHandle*> PdmUiItem::connectedEditors() const
|
||||
return editors;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool PdmUiItem::hasEditor(PdmUiEditorHandle* editor) const
|
||||
{
|
||||
return m_editors.count(editor) > 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -276,6 +276,8 @@ public:
|
||||
std::vector<PdmUiEditorHandle*>
|
||||
connectedEditors() const;
|
||||
|
||||
bool hasEditor(PdmUiEditorHandle* editor) const;
|
||||
|
||||
static bool showExtraDebugText();
|
||||
static void enableExtraDebugText(bool enable);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user