#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

@@ -50,6 +50,7 @@
#include "RiuTreeViewEventFilter.h"
#include "RiuWellAllocationPlot.h"
#include "cafCmdExecCommandManager.h"
#include "cafCmdFeatureManager.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmUiPropertyView.h"
@@ -65,6 +66,8 @@
#include <QMenuBar>
#include <QToolBar>
#include <QTreeView>
#include <QUndoStack>
#include <QUndoView>
//--------------------------------------------------------------------------------------------------
///
@@ -86,9 +89,10 @@ RiuPlotMainWindow::RiuPlotMainWindow()
m_dragDropInterface = std::unique_ptr<caf::PdmUiDragDropInterface>( new RiuDragDrop() );
// Enabling the line below will activate the undo stack
// When enableUndoCommandSystem is set false, all commands are executed and deleted immediately
// caf::CmdExecCommandManager::instance()->enableUndoCommandSystem(true);
m_undoView->setStack( caf::CmdExecCommandManager::instance()->undoStack() );
connect( caf::CmdExecCommandManager::instance()->undoStack(),
SIGNAL( indexChanged( int ) ),
SLOT( slotRefreshUndoRedoActions() ) );
}
//--------------------------------------------------------------------------------------------------
@@ -306,6 +310,15 @@ void RiuPlotMainWindow::createMenus()
editMenu->addSeparator();
editMenu->addAction( cmdFeatureMgr->action( "RicEditPreferencesFeature" ) );
if ( RiaPreferences::current()->useUndoRedo() )
{
editMenu->addSeparator();
editMenu->addAction( m_undoAction );
editMenu->addAction( m_redoAction );
}
connect( editMenu, SIGNAL( aboutToShow() ), SLOT( slotRefreshUndoRedoActions() ) );
// View menu
QMenu* viewMenu = menuBar()->addMenu( "&View" );
viewMenu->addAction( cmdFeatureMgr->action( "RicViewZoomAllFeature" ) );
@@ -399,6 +412,14 @@ void RiuPlotMainWindow::createToolBars()
m_multiPlotToolBarEditor = new caf::PdmUiToolBarEditor( "Multi Plot", this );
m_multiPlotToolBarEditor->hide();
if ( RiaPreferences::current()->useUndoRedo() )
{
QToolBar* toolbar = addToolBar( tr( "Edit" ) );
toolbar->setObjectName( toolbar->windowTitle() );
toolbar->addAction( m_undoAction );
toolbar->addAction( m_redoAction );
}
}
//--------------------------------------------------------------------------------------------------
@@ -474,6 +495,18 @@ void RiuPlotMainWindow::createDockPanels()
dockWidget->hide();
}
if ( RiaPreferences::current()->useUndoRedo() )
{
QDockWidget* dockWidget = new QDockWidget( "Undo Stack", this );
dockWidget->setObjectName( RiuDockWidgetTools::plotMainWindowUndoStackName() );
dockWidget->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
dockWidget->setWidget( m_undoView );
addDockWidget( Qt::RightDockWidgetArea, dockWidget );
dockWidget->hide();
}
setCorner( Qt::BottomLeftCorner, Qt::LeftDockWidgetArea );
setCorner( Qt::BottomRightCorner, Qt::BottomDockWidgetArea );