mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Make sure onChildrenUpdated is called in RicToggleItemsOnOthersOffFeature
This commit is contained in:
@@ -52,10 +52,10 @@ public:
|
|||||||
|
|
||||||
static QString findCollectionName( SelectionToggleType state );
|
static QString findCollectionName( SelectionToggleType state );
|
||||||
|
|
||||||
|
static std::pair<caf::PdmObjectHandle*, caf::PdmChildArrayFieldHandle*> findOwnerAndChildArrayField( caf::PdmFieldHandle* fieldHandle );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static caf::PdmUiTreeView* findTreeView( const caf::PdmUiItem* uiItem );
|
static caf::PdmUiTreeView* findTreeView( const caf::PdmUiItem* uiItem );
|
||||||
static caf::PdmUiTreeOrdering* findTreeItemFromSelectedUiItem( const caf::PdmUiItem* uiItem );
|
static caf::PdmUiTreeOrdering* findTreeItemFromSelectedUiItem( const caf::PdmUiItem* uiItem );
|
||||||
static std::vector<caf::PdmField<bool>*> findToggleFieldsFromSelection( SelectionToggleType state );
|
static std::vector<caf::PdmField<bool>*> findToggleFieldsFromSelection( SelectionToggleType state );
|
||||||
|
|
||||||
static std::pair<caf::PdmObjectHandle*, caf::PdmChildArrayFieldHandle*> findOwnerAndChildArrayField( caf::PdmFieldHandle* fieldHandle );
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,12 +55,16 @@ void RicToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked )
|
|||||||
// First toggle off all siblings
|
// First toggle off all siblings
|
||||||
caf::PdmFieldHandle* commonParent = commonParentForAllSelections( selectedObjects );
|
caf::PdmFieldHandle* commonParent = commonParentForAllSelections( selectedObjects );
|
||||||
|
|
||||||
|
caf::PdmFieldHandle* firstField = nullptr;
|
||||||
|
|
||||||
for ( caf::PdmObjectHandle* child : childObjects( commonParent ) )
|
for ( caf::PdmObjectHandle* child : childObjects( commonParent ) )
|
||||||
{
|
{
|
||||||
caf::PdmField<bool>* field = objectToggleField( child );
|
caf::PdmField<bool>* field = objectToggleField( child );
|
||||||
|
|
||||||
if ( field )
|
if ( field )
|
||||||
{
|
{
|
||||||
|
if ( !firstField ) firstField = field;
|
||||||
|
|
||||||
// Avoid calling setValueWithFieldChanged() here, as this potentially can trigger heavy computations. Assume
|
// Avoid calling setValueWithFieldChanged() here, as this potentially can trigger heavy computations. Assume
|
||||||
// that the update logic is sufficient when setting the selected objects.
|
// that the update logic is sufficient when setting the selected objects.
|
||||||
field->setValue( false );
|
field->setValue( false );
|
||||||
@@ -74,6 +78,15 @@ void RicToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked )
|
|||||||
|
|
||||||
field->setValueWithFieldChanged( true );
|
field->setValueWithFieldChanged( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If multiple fields are updated, we call onChildrenUpdated() on the owner of the first field
|
||||||
|
// Example: Trigger replot of curves when multiple curves are toggled
|
||||||
|
auto [ownerOfChildArrayField, childArrayFieldHandle] = RicToggleItemsFeatureImpl::findOwnerAndChildArrayField( firstField );
|
||||||
|
if ( ownerOfChildArrayField && childArrayFieldHandle )
|
||||||
|
{
|
||||||
|
std::vector<caf::PdmObjectHandle*> objs;
|
||||||
|
ownerOfChildArrayField->onChildrenUpdated( childArrayFieldHandle, objs );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user