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:
@@ -92,6 +92,14 @@ QString RiuDockWidgetTools::mohrsCirclePlotName()
|
||||
return "dockMohrsCirclePlot";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuDockWidgetTools::undoStackName()
|
||||
{
|
||||
return "dockUndoStack";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -116,6 +124,14 @@ QString RiuDockWidgetTools::plotMainWindowMessagesName()
|
||||
return "plotMainWindow_dockMessages";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuDockWidgetTools::plotMainWindowUndoStackName()
|
||||
{
|
||||
return "plotMainWindow_dockUndoStack";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -139,6 +155,7 @@ QMap<QString, QVariant> RiuDockWidgetTools::widgetVisibilitiesForEclipse()
|
||||
widgetVisibility[RiuDockWidgetTools::relPermPlotName()] = true;
|
||||
widgetVisibility[RiuDockWidgetTools::pvtPlotName()] = true;
|
||||
widgetVisibility[RiuDockWidgetTools::messagesName()] = true;
|
||||
widgetVisibility[RiuDockWidgetTools::undoStackName()] = false;
|
||||
|
||||
widgetVisibility[RiuDockWidgetTools::mohrsCirclePlotName()] = false;
|
||||
|
||||
@@ -160,6 +177,7 @@ QMap<QString, QVariant> RiuDockWidgetTools::widgetVisibilitiesForGeoMech()
|
||||
widgetVisibility[RiuDockWidgetTools::relPermPlotName()] = false;
|
||||
widgetVisibility[RiuDockWidgetTools::pvtPlotName()] = false;
|
||||
widgetVisibility[RiuDockWidgetTools::messagesName()] = true;
|
||||
widgetVisibility[RiuDockWidgetTools::undoStackName()] = false;
|
||||
|
||||
widgetVisibility[RiuDockWidgetTools::mohrsCirclePlotName()] = true;
|
||||
|
||||
|
||||
@@ -45,10 +45,12 @@ public:
|
||||
static QString pvtPlotName();
|
||||
static QString messagesName();
|
||||
static QString mohrsCirclePlotName();
|
||||
static QString undoStackName();
|
||||
|
||||
static QString plotMainWindowProjectTreeName();
|
||||
static QString plotMainWindowPropertyEditorName();
|
||||
static QString plotMainWindowMessagesName();
|
||||
static QString plotMainWindowUndoStackName();
|
||||
|
||||
static QAction* toggleActionForWidget( const QObject* parent, const QString& dockWidgetName );
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
#include <QToolButton>
|
||||
#include <QTreeView>
|
||||
#include <QUndoStack>
|
||||
#include <QUndoView>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@@ -132,11 +133,12 @@ RiuMainWindow::RiuMainWindow()
|
||||
|
||||
m_dragDropInterface = std::unique_ptr<caf::PdmUiDragDropInterface>( new RiuDragDrop() );
|
||||
|
||||
initializeGuiNewProjectLoaded();
|
||||
m_undoView->setStack( caf::CmdExecCommandManager::instance()->undoStack() );
|
||||
connect( caf::CmdExecCommandManager::instance()->undoStack(),
|
||||
SIGNAL( indexChanged( int ) ),
|
||||
SLOT( slotRefreshUndoRedoActions() ) );
|
||||
|
||||
// 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);
|
||||
initializeGuiNewProjectLoaded();
|
||||
|
||||
m_memoryCriticalWarning = new QLabel( "" );
|
||||
m_memoryUsedButton = new QToolButton( nullptr );
|
||||
@@ -203,7 +205,7 @@ void RiuMainWindow::initializeGuiNewProjectLoaded()
|
||||
}
|
||||
|
||||
slotRefreshFileActions();
|
||||
slotRefreshEditActions();
|
||||
slotRefreshUndoRedoActions();
|
||||
slotRefreshViewActions();
|
||||
refreshAnimationActions();
|
||||
refreshDrawStyleActions();
|
||||
@@ -502,7 +504,14 @@ void RiuMainWindow::createMenus()
|
||||
editMenu->addSeparator();
|
||||
editMenu->addAction( cmdFeatureMgr->action( "RicEditPreferencesFeature" ) );
|
||||
|
||||
connect( editMenu, SIGNAL( aboutToShow() ), SLOT( slotRefreshEditActions() ) );
|
||||
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" );
|
||||
@@ -574,6 +583,14 @@ void RiuMainWindow::createToolBars()
|
||||
toolbar->addAction( cmdFeatureMgr->action( "RicSaveProjectFeature" ) );
|
||||
}
|
||||
|
||||
if ( RiaPreferences::current()->useUndoRedo() )
|
||||
{
|
||||
QToolBar* toolbar = addToolBar( tr( "Edit" ) );
|
||||
toolbar->setObjectName( toolbar->windowTitle() );
|
||||
toolbar->addAction( m_undoAction );
|
||||
toolbar->addAction( m_redoAction );
|
||||
}
|
||||
|
||||
{
|
||||
QToolBar* toolbar = addToolBar( tr( "Import" ) );
|
||||
toolbar->setObjectName( toolbar->windowTitle() );
|
||||
@@ -822,6 +839,17 @@ void RiuMainWindow::createDockPanels()
|
||||
dockWidget->hide();
|
||||
}
|
||||
|
||||
if ( RiaPreferences::current()->useUndoRedo() )
|
||||
{
|
||||
QDockWidget* dockWidget = new QDockWidget( "Undo Stack", this );
|
||||
dockWidget->setObjectName( RiuDockWidgetTools::undoStackName() );
|
||||
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 );
|
||||
|
||||
@@ -880,15 +908,6 @@ void RiuMainWindow::slotRefreshFileActions()
|
||||
cmdFeatureMgr->refreshStates( commandIdList );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::slotRefreshEditActions()
|
||||
{
|
||||
// RiaApplication* app = RiaApplication::instance();
|
||||
// RISceneManager* proj = app->project();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1389,6 +1408,7 @@ void RiuMainWindow::slotBuildWindowActions()
|
||||
appendToggleActionForDockingWidget( m_windowMenu, this, RiuDockWidgetTools::propertyEditorName() );
|
||||
appendToggleActionForDockingWidget( m_windowMenu, this, RiuDockWidgetTools::messagesName() );
|
||||
appendToggleActionForDockingWidget( m_windowMenu, this, RiuDockWidgetTools::processMonitorName() );
|
||||
appendToggleActionForDockingWidget( m_windowMenu, this, RiuDockWidgetTools::undoStackName() );
|
||||
|
||||
m_windowMenu->addSeparator();
|
||||
|
||||
@@ -1472,7 +1492,7 @@ void RiuMainWindow::selectedObjectsChanged()
|
||||
refreshDrawStyleActions();
|
||||
refreshAnimationActions();
|
||||
slotRefreshFileActions();
|
||||
slotRefreshEditActions();
|
||||
slotRefreshUndoRedoActions();
|
||||
slotRefreshViewActions();
|
||||
|
||||
// The only way to get to this code is by selection change initiated from the project tree view
|
||||
|
||||
@@ -195,7 +195,6 @@ private slots:
|
||||
void slotRefreshFileActions();
|
||||
|
||||
// Edit slots
|
||||
void slotRefreshEditActions();
|
||||
void slotNewObjectPropertyView();
|
||||
|
||||
// View slots
|
||||
@@ -250,8 +249,6 @@ public:
|
||||
private:
|
||||
std::unique_ptr<caf::PdmUiDragDropInterface> m_dragDropInterface;
|
||||
|
||||
QUndoView* m_undoView;
|
||||
|
||||
caf::PdmObject* m_pdmRoot;
|
||||
caf::PdmUiPropertyView* m_pdmUiPropertyView;
|
||||
|
||||
|
||||
@@ -30,10 +30,14 @@
|
||||
#include "cafPdmUiTreeView.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QDockWidget>
|
||||
#include <QMdiArea>
|
||||
#include <QMdiSubWindow>
|
||||
#include <QSettings>
|
||||
#include <QUndoStack>
|
||||
#include <QUndoView>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -46,6 +50,16 @@ RiuMainWindowBase::RiuMainWindowBase()
|
||||
, m_blockSubWindowProjectTreeSelection( false )
|
||||
{
|
||||
setDockNestingEnabled( true );
|
||||
|
||||
m_undoView = new QUndoView( this );
|
||||
|
||||
m_undoAction = new QAction( QIcon( ":/undo.png" ), tr( "Undo" ), this );
|
||||
m_undoAction->setShortcut( QKeySequence::Undo );
|
||||
connect( m_undoAction, SIGNAL( triggered() ), SLOT( slotUndo() ) );
|
||||
|
||||
m_redoAction = new QAction( QIcon( ":/redo.png" ), tr( "Redo" ), this );
|
||||
m_redoAction->setShortcut( QKeySequence::Redo );
|
||||
connect( m_redoAction, SIGNAL( triggered() ), SLOT( slotRedo() ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -410,3 +424,34 @@ void RiuMainWindowBase::slotRefreshHelpActions()
|
||||
{
|
||||
caf::CmdFeatureManager::instance()->action( "RicSearchHelpFeature" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindowBase::slotRedo()
|
||||
{
|
||||
if ( m_undoView->stack() && m_undoView->stack()->canRedo() )
|
||||
{
|
||||
m_undoView->stack()->redo();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindowBase::slotUndo()
|
||||
{
|
||||
if ( m_undoView->stack() && m_undoView->stack()->canUndo() )
|
||||
{
|
||||
m_undoView->stack()->undo();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindowBase::slotRefreshUndoRedoActions()
|
||||
{
|
||||
m_redoAction->setDisabled( !m_undoView->stack()->canRedo() );
|
||||
m_undoAction->setDisabled( !m_undoView->stack()->canUndo() );
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ class PdmUiItem;
|
||||
|
||||
class QMdiArea;
|
||||
class QMdiSubWindow;
|
||||
class QUndoView;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -94,10 +95,19 @@ protected slots:
|
||||
void slotDockWidgetToggleViewActionTriggered();
|
||||
void slotRefreshHelpActions();
|
||||
|
||||
void slotRedo();
|
||||
void slotUndo();
|
||||
void slotRefreshUndoRedoActions();
|
||||
|
||||
protected:
|
||||
caf::PdmUiTreeView* m_projectTreeView;
|
||||
bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control
|
||||
// whether to select the corresponding active view or not
|
||||
|
||||
QAction* m_undoAction;
|
||||
QAction* m_redoAction;
|
||||
QUndoView* m_undoView;
|
||||
|
||||
private:
|
||||
QString registryFolderName();
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user