#7347 Property Editor : Enable undo/redo of field changed operations

This commit is contained in:
Magne Sjaastad
2021-02-09 13:31:27 +01:00
parent 14c09f30cf
commit bcdba1bb8f
22 changed files with 265 additions and 74 deletions

View File

@@ -103,6 +103,7 @@
#include "RiuViewer.h"
#include "cafAppEnum.h"
#include "cafCmdExecCommandManager.h"
#include "cafEffectGenerator.h"
#include "cafFixedAtlasFont.h"
#include "cafPdmUiModelChangeDetector.h"
@@ -944,6 +945,12 @@ RiuPlotMainWindow* RiaGuiApplication::getOrCreateMainPlotWindow()
void RiaGuiApplication::createMainWindow()
{
CVF_ASSERT( m_mainWindow == nullptr );
if ( RiaPreferences::current()->useUndoRedo() )
{
caf::CmdExecCommandManager::instance()->enableUndoCommandSystem( true );
}
m_mainWindow = new RiuMainWindow;
QString platform = cvf::System::is64Bit() ? "(64bit)" : "(32bit)";
m_mainWindow->setWindowTitle( "ResInsight " + platform );
@@ -973,6 +980,11 @@ void RiaGuiApplication::createMainPlotWindow()
{
CVF_ASSERT( m_mainPlotWindow == nullptr );
if ( RiaPreferences::current()->useUndoRedo() )
{
caf::CmdExecCommandManager::instance()->enableUndoCommandSystem( true );
}
m_mainPlotWindow = new RiuPlotMainWindow;
m_mainPlotWindow->setWindowTitle( "Plots - ResInsight" );
m_mainPlotWindow->setDefaultWindowSize();

View File

@@ -337,6 +337,9 @@ RiaPreferences::RiaPreferences( void )
CAF_PDM_InitField( &m_showProgressBar, "showProgressBar", true, "Show Progress Bar", "", "", "" );
m_showProgressBar.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitField( &m_useUndoRedo, "useUndoRedo", false, "Use Undo/Redo", "", "", "" );
m_useUndoRedo.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN );
CAF_PDM_InitFieldNoDefault( &m_plotTemplateFolders, "plotTemplateFolders", "Plot Template Folder(s)", "", "", "" );
m_plotTemplateFolders.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_searchPlotTemplateFoldersRecursively,
@@ -448,7 +451,7 @@ void RiaPreferences::defineEditorAttribute( const caf::PdmFieldHandle* field,
field == &m_showLegendBackground || field == &m_showSummaryTimeAsLongString ||
field == &m_showViewIdInProjectTree || field == &m_useMultipleThreadsWhenLoadingSummaryData ||
field == &m_enableFaultsByDefault || field == &m_showProgressBar || field == &m_openExportedPdfInViewer ||
field == &m_showInfoBox || field == &m_showGridBox )
field == &m_showInfoBox || field == &m_showGridBox || field == &m_useUndoRedo )
{
caf::PdmUiCheckBoxEditorAttribute* myAttr = dynamic_cast<caf::PdmUiCheckBoxEditorAttribute*>( attribute );
if ( myAttr )
@@ -622,6 +625,7 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
uiOrdering.add( &m_showTestToolbar );
uiOrdering.add( &m_includeFractureDebugInfoFile );
uiOrdering.add( &m_holoLensExportFolder );
uiOrdering.add( &m_useUndoRedo );
}
uiOrdering.skipRemainingFields( true );
@@ -906,6 +910,14 @@ QString RiaPreferences::gtestFilter() const
return m_gtestFilter();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaPreferences::useUndoRedo() const
{
return m_useUndoRedo();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -96,6 +96,7 @@ public:
bool useShaders() const;
bool show3dInformation() const;
QString gtestFilter() const;
bool useUndoRedo() const;
const QString& dateFormat() const;
const QString& timeFormat() const;
@@ -216,6 +217,7 @@ private:
caf::PdmField<bool> m_useMultipleThreadsWhenLoadingSummaryData;
caf::PdmField<bool> m_showProgressBar;
caf::PdmField<QString> m_gtestFilter;
caf::PdmField<bool> m_useUndoRedo;
caf::PdmField<caf::AppEnum<RiaDefines::ThemeEnum>> m_guiTheme;