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();
|
return m_containingEditor->topMostContainingEditor();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->updateUi();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
void updateUi(const QString& uiConfigName);;
|
void updateUi(const QString& uiConfigName);;
|
||||||
void updateUi();
|
void updateUi();
|
||||||
|
|
||||||
void updateUiIncludingParent();
|
PdmUiEditorHandle* topMostContainingEditor();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void uiUpdated();
|
void uiUpdated();
|
||||||
@ -80,14 +80,14 @@ protected:
|
|||||||
PdmUiItem* pdmItem() { return m_pdmItem; }
|
PdmUiItem* pdmItem() { return m_pdmItem; }
|
||||||
const PdmUiItem* pdmItem() const { return m_pdmItem; }
|
const PdmUiItem* pdmItem() const { return m_pdmItem; }
|
||||||
public: // PDM Internal
|
public: // PDM Internal
|
||||||
void setParentEditor(PdmUiEditorHandle* parentEditor) { m_parentEditor = parentEditor; }
|
void setContainingEditor(PdmUiEditorHandle* containingEditor) { m_containingEditor = containingEditor; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend PdmUiItem::~PdmUiItem();
|
friend PdmUiItem::~PdmUiItem();
|
||||||
PdmUiItem* m_pdmItem;
|
PdmUiItem* m_pdmItem;
|
||||||
QString m_currentConfigName;
|
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;
|
bool m_isConfiguringUi;
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "cafPdmFieldHandle.h"
|
#include "cafPdmFieldHandle.h"
|
||||||
#include "cafPdmUiModelChangeDetector.h"
|
#include "cafPdmUiModelChangeDetector.h"
|
||||||
#include "cafPdmUiObjectHandle.h"
|
#include "cafPdmUiObjectHandle.h"
|
||||||
|
#include "cafPdmUiEditorHandle.h"
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
@ -61,12 +62,31 @@ void PdmUiFieldHandle::notifyFieldChanged(const QVariant& oldFieldValue, const Q
|
|||||||
PdmObjectHandle* ownerObjectHandle = fieldHandle->ownerObject();
|
PdmObjectHandle* ownerObjectHandle = fieldHandle->ownerObject();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
bool noOwnerObject = true;
|
||||||
|
|
||||||
|
// Object editors
|
||||||
|
|
||||||
PdmUiObjectHandle* uiObjHandle = uiObj(ownerObjectHandle);
|
PdmUiObjectHandle* uiObjHandle = uiObj(ownerObjectHandle);
|
||||||
if (uiObjHandle)
|
if (uiObjHandle)
|
||||||
{
|
{
|
||||||
uiObjHandle->fieldChangedByUi(fieldHandle, oldFieldValue, newFieldValue);
|
uiObjHandle->fieldChangedByUi(fieldHandle, oldFieldValue, newFieldValue);
|
||||||
uiObjHandle->updateConnectedEditors();
|
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();
|
PdmUiModelChangeDetector::instance()->setModelChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,8 +613,7 @@ void PdmUiItem::updateConnectedEditors() const
|
|||||||
std::set<PdmUiEditorHandle*>::iterator it;
|
std::set<PdmUiEditorHandle*>::iterator it;
|
||||||
for (it = m_editors.begin(); it != m_editors.end(); ++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;
|
return editors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool PdmUiItem::hasEditor(PdmUiEditorHandle* editor) const
|
||||||
|
{
|
||||||
|
return m_editors.count(editor) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -276,6 +276,8 @@ public:
|
|||||||
std::vector<PdmUiEditorHandle*>
|
std::vector<PdmUiEditorHandle*>
|
||||||
connectedEditors() const;
|
connectedEditors() const;
|
||||||
|
|
||||||
|
bool hasEditor(PdmUiEditorHandle* editor) const;
|
||||||
|
|
||||||
static bool showExtraDebugText();
|
static bool showExtraDebugText();
|
||||||
static void enableExtraDebugText(bool enable);
|
static void enableExtraDebugText(bool enable);
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ caf::PdmUiFieldEditorHandle* caf::PdmUiFormLayoutObjectEditor::findOrCreateField
|
|||||||
if (fieldEditor)
|
if (fieldEditor)
|
||||||
{
|
{
|
||||||
m_fieldViews[field->fieldHandle()] = fieldEditor;
|
m_fieldViews[field->fieldHandle()] = fieldEditor;
|
||||||
fieldEditor->setParentEditor(this);
|
fieldEditor->setContainingEditor(this);
|
||||||
fieldEditor->setUiField(field);
|
fieldEditor->setUiField(field);
|
||||||
fieldEditor->createWidgets(parent);
|
fieldEditor->createWidgets(parent);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user