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:
parent
aea804b161
commit
24aa7fca3e
@ -52,10 +52,10 @@ public:
|
||||
|
||||
static QString findCollectionName( SelectionToggleType state );
|
||||
|
||||
static std::pair<caf::PdmObjectHandle*, caf::PdmChildArrayFieldHandle*> findOwnerAndChildArrayField( caf::PdmFieldHandle* fieldHandle );
|
||||
|
||||
private:
|
||||
static caf::PdmUiTreeView* findTreeView( const caf::PdmUiItem* uiItem );
|
||||
static caf::PdmUiTreeOrdering* findTreeItemFromSelectedUiItem( const caf::PdmUiItem* uiItem );
|
||||
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
|
||||
caf::PdmFieldHandle* commonParent = commonParentForAllSelections( selectedObjects );
|
||||
|
||||
caf::PdmFieldHandle* firstField = nullptr;
|
||||
|
||||
for ( caf::PdmObjectHandle* child : childObjects( commonParent ) )
|
||||
{
|
||||
caf::PdmField<bool>* field = objectToggleField( child );
|
||||
|
||||
if ( field )
|
||||
{
|
||||
if ( !firstField ) firstField = field;
|
||||
|
||||
// Avoid calling setValueWithFieldChanged() here, as this potentially can trigger heavy computations. Assume
|
||||
// that the update logic is sufficient when setting the selected objects.
|
||||
field->setValue( false );
|
||||
@ -74,6 +78,15 @@ void RicToggleItemsOnOthersOffFeature::onActionTriggered( bool isChecked )
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user