#7520 Undo framework: Improve local disabling of undo framework

This commit is contained in:
Magne Sjaastad
2021-03-29 08:46:14 +02:00
parent 7cf2ed2e8c
commit 5d45a8cec9
4 changed files with 21 additions and 19 deletions

View File

@@ -1121,6 +1121,17 @@ void RimWellRftPlot::onLegendDefinitionChanged()
syncCurvesFromUiSelection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimWellRftPlot::useUndoRedoForFieldChanged()
{
// m_selectedSources use data types that are not compatible with caf
// consider rewrite to caf object using ptrfield instead of pdmpointer
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -102,6 +102,7 @@ protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void onLoadDataAndUpdate() override;
void initAfterRead() override;
bool useUndoRedoForFieldChanged() override;
private:
std::map<QString, QStringList> findWellSources();

View File

@@ -102,13 +102,6 @@ void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHand
}
}
caf::PdmUiObjectHandle* uiOwnerObjectHandle = uiObj( fieldsToUpdate[0]->ownerObject() );
if ( uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoForFieldChanged() )
{
// Temporarily disable undo framework as requested by the PdmUiObjectHandle
m_disableUndoForFieldChange = true;
}
if ( commands.size() == 1 )
{
CmdExecCommandManager::instance()->processExecuteCommand( commands[0] );
@@ -117,12 +110,6 @@ void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHand
{
CmdExecCommandManager::instance()->processExecuteCommandsAsMacro( commands );
}
if ( uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoForFieldChanged() )
{
// Restore undo feature to normal operation
m_disableUndoForFieldChange = false;
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -104,15 +104,18 @@ void PdmUiCommandSystemProxy::setUiValueToField( PdmUiFieldHandle* uiFieldHandle
if ( m_commandInterface )
{
m_commandInterface->fieldChangedCommand( fieldsToUpdate, newUiValue );
}
else
{
for ( auto fieldHandle : fieldsToUpdate )
caf::PdmUiObjectHandle* uiOwnerObjectHandle = uiObj( editorField->ownerObject() );
if ( uiOwnerObjectHandle && uiOwnerObjectHandle->useUndoRedoForFieldChanged() )
{
fieldHandle->uiCapability()->setValueFromUiEditor( newUiValue );
m_commandInterface->fieldChangedCommand( fieldsToUpdate, newUiValue );
return;
}
}
for ( auto fieldHandle : fieldsToUpdate )
{
fieldHandle->uiCapability()->setValueFromUiEditor( newUiValue );
}
}
}