App::AutoTransaction Class Reference

Helper class to manager transaction (i.e. undo/redo) More...

#include <AutoTransaction.h>

Public Member Functions

 AutoTransaction (const char *name=nullptr, bool tmpName=false)
 Constructor. More...
 
void close (bool abort=false)
 Close or abort the transaction. More...
 
 ~AutoTransaction ()
 Destructor. More...
 

Static Public Member Functions

static void setEnable (bool enable)
 Enable/Disable any AutoTransaction instance in the current stack. More...
 

Detailed Description

Helper class to manager transaction (i.e. undo/redo)

Constructor & Destructor Documentation

◆ AutoTransaction()

AutoTransaction::AutoTransaction ( const char *  name = nullptr,
bool  tmpName = false 
)

Constructor.

Parameters
nameoptional new transaction name on construction
tmpNameif true and a new transaction is setup, the name given is considered as temporary, and subsequent construction of this class (or calling Application::setActiveTransaction()) can override the transaction name.

The constructor increments an internal counter (Application::_activeTransactionGuard). The counter prevents any new active transaction being setup. It also prevents close (i.e. commits) the current active transaction until it reaches zero. It does not have any effect on aborting transaction, though.

References App::GetApplication().

◆ ~AutoTransaction()

AutoTransaction::~AutoTransaction ( )

Destructor.

This destructor decrease an internal counter (Application::_activeTransactionGuard), and will commit any current active transaction when the counter reaches zero.

References App::GetApplication().

Member Function Documentation

◆ close()

void AutoTransaction::close ( bool  abort = false)

Close or abort the transaction.

This function can be used to explicitly close (i.e. commit) the transaction, if the current transaction ID matches the one created inside the constructor. For aborting, it will abort any current transaction

References App::Application::closeActiveTransaction(), and App::GetApplication().

Referenced by Gui::TreeWidget::dropEvent(), femexamples.examplesgui.FemExamples::reject(), and setEnable().

◆ setEnable()

void AutoTransaction::setEnable ( bool  enable)
static

Enable/Disable any AutoTransaction instance in the current stack.

Once disabled, any empty temporary named transaction is closed. If there are non-empty or non-temporary named active transaction, it will not be auto closed.

This function may be used in, for example, Gui::Document::setEdit() to allow a transaction live past any command scope.

References close(), and App::GetApplication().

Referenced by Gui::TreeWidget::mouseDoubleClickEvent(), App::Application::setActiveTransaction(), Gui::Document::setEdit(), and Gui::ControlSingleton::showDialog().


The documentation for this class was generated from the following files: