mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7347 Property Editor : Enable undo/redo of field changed operations
This commit is contained in:
@@ -137,7 +137,7 @@ QUndoStack* CmdExecCommandManager::undoStack()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdExecCommandManager::processExecuteCommand( CmdExecuteCommand* executeCommand )
|
||||
{
|
||||
if ( isUndoEnabledForCurrentCommand( executeCommand ) )
|
||||
if ( isUndoEnabledForCommand( executeCommand ) )
|
||||
{
|
||||
// Transfer ownership of execute command to wrapper object
|
||||
UndoRedoWrapper* undoRedoWrapper = new UndoRedoWrapper( executeCommand );
|
||||
@@ -156,34 +156,33 @@ void CmdExecCommandManager::processExecuteCommand( CmdExecuteCommand* executeCom
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void CmdExecCommandManager::processExecuteCommandsAsMacro( const QString& macroName,
|
||||
std::vector<CmdExecuteCommand*>& commands )
|
||||
void CmdExecCommandManager::processExecuteCommandsAsMacro( const std::vector<CmdExecuteCommand*>& commands )
|
||||
{
|
||||
if ( commands.size() == 0 )
|
||||
if ( !commands.empty() && isUndoEnabledForCommand( commands.front() ) )
|
||||
{
|
||||
return;
|
||||
auto firstCommand = commands.front();
|
||||
if ( isUndoEnabledForCommand( firstCommand ) )
|
||||
{
|
||||
QString macroName = firstCommand->name() + " (multiple objects)";
|
||||
|
||||
m_undoStack->beginMacro( macroName );
|
||||
for ( auto command : commands )
|
||||
{
|
||||
UndoRedoWrapper* undoRedoWrapper = new UndoRedoWrapper( command );
|
||||
m_undoStack->push( undoRedoWrapper );
|
||||
}
|
||||
m_undoStack->endMacro();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isUndoEnabledForCurrentCommand( commands[0] ) )
|
||||
for ( caf::CmdExecuteCommand* executeCommand : commands )
|
||||
{
|
||||
m_undoStack->beginMacro( macroName );
|
||||
for ( size_t i = 0; i < commands.size(); i++ )
|
||||
if ( executeCommand )
|
||||
{
|
||||
UndoRedoWrapper* undoRedoWrapper = new UndoRedoWrapper( commands[i] );
|
||||
m_undoStack->push( undoRedoWrapper );
|
||||
}
|
||||
m_undoStack->endMacro();
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( size_t i = 0; i < commands.size(); i++ )
|
||||
{
|
||||
CmdExecuteCommand* executeCommand = commands[i];
|
||||
if ( executeCommand )
|
||||
{
|
||||
executeCommand->redo();
|
||||
delete executeCommand;
|
||||
}
|
||||
executeCommand->redo();
|
||||
delete executeCommand;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +190,7 @@ void CmdExecCommandManager::processExecuteCommandsAsMacro( const QString&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool CmdExecCommandManager::isUndoEnabledForCurrentCommand( CmdExecuteCommand* command )
|
||||
bool CmdExecCommandManager::isUndoEnabledForCommand( CmdExecuteCommand* command )
|
||||
{
|
||||
bool useUndo = false;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
// If undo is not possible (undo system not enabled, or pdm object has disabled undo),
|
||||
// the PdmExecuteCommand is executed and deleted
|
||||
void processExecuteCommand( CmdExecuteCommand* executeCommand );
|
||||
void processExecuteCommandsAsMacro( const QString& macroName, std::vector<CmdExecuteCommand*>& commands );
|
||||
void processExecuteCommandsAsMacro( const std::vector<CmdExecuteCommand*>& commands );
|
||||
|
||||
private:
|
||||
CmdExecCommandManager();
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
void activateCommandSystem();
|
||||
void deactivateCommandSystem();
|
||||
|
||||
bool isUndoEnabledForCurrentCommand( CmdExecuteCommand* command );
|
||||
bool isUndoEnabledForCommand( CmdExecuteCommand* command );
|
||||
|
||||
friend class CmdExecCommandSystemActivator;
|
||||
friend class CmdExecCommandSystemDeactivator;
|
||||
|
||||
@@ -212,6 +212,7 @@ void CmdFieldChangeExec::readFieldValueFromValidXmlDocument( QXmlStreamReader& x
|
||||
tt = xmlStream.readNext();
|
||||
}
|
||||
xmlFieldHandle->readFieldData( xmlStream, PdmDefaultObjectFactory::instance() );
|
||||
xmlFieldHandle->resolveReferences();
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
||||
@@ -115,7 +115,7 @@ void CmdUiCommandSystemImpl::fieldChangedCommand( const std::vector<PdmFieldHand
|
||||
}
|
||||
else
|
||||
{
|
||||
CmdExecCommandManager::instance()->processExecuteCommandsAsMacro( "Multiple Field Change", commands );
|
||||
CmdExecCommandManager::instance()->processExecuteCommandsAsMacro( commands );
|
||||
}
|
||||
|
||||
if ( uiOwnerObjectHandle && !uiOwnerObjectHandle->useUndoRedoForFieldChanged() )
|
||||
|
||||
Reference in New Issue
Block a user