+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
#include "SUIT_Study.h"
#include "SUIT_Desktop.h"
myRoot = new SUIT_DataObject();
myOperations.setAutoDelete( false );
-
- connect( this, SIGNAL( changeOperationState( bool ) ), this, SLOT( onChangeOperationState( bool ) ) );
-
myOperations.setAutoDelete( false );
}
if ( myRoot == obj )
return;
+ // This is necessary in order not to destroy the complete tree of objects
+ if ( obj )
+ obj->reparentChildren( myRoot );
+
delete myRoot;
myRoot = obj;
}
while( SUIT_Operation* anOp = blockingOperation( theOp ) )
{
int anAnsw = SUIT_MessageBox::warn2( application()->desktop(),
- tr( "OPERATION_LAUNCH" ), tr( "PREVIOUS_NOT_FINISHED" ),
- tr( "CONTINUE" ), tr( "CANCEL" ), 0, 1, 1 );
+ tr( "OPERATION_LAUNCH" ), tr( "PREVIOUS_NOT_FINISHED" ),
+ tr( "CONTINUE" ), tr( "CANCEL" ), 0, 1, 1 );
- if( anAnsw == 1 )
+ if ( anAnsw == 1 )
return false;
else
anOp->abort();
theOp->setState( SUIT_Operation::Running );
myOperations.append( theOp );
+
emit theOp->started( theOp );
+ operationStarted( theOp );
theOp->startOperation();
-
+
return true;
}
if ( !theOp || myOperations.find( theOp ) == -1 )
return false;
- theOp->abortOperation();
theOp->setExecStatus( SUIT_Operation::Rejected );
+
+ theOp->abortOperation();
+ operationAborted( theOp );
emit theOp->aborted( theOp );
+
stop( theOp );
+
return true;
}
if ( !theOp || myOperations.find( theOp ) == -1 )
return false;
- theOp->commitOperation();
theOp->setExecStatus( SUIT_Operation::Accepted );
+
+ theOp->commitOperation();
+ operationCommited( theOp );
emit theOp->committed( theOp );
+
stop( theOp );
+
emit studyModified( this );
+
return true;
}
// get last operation which can be resumed
SUIT_Operation* anOp, *aResultOp = 0;
- for( anOp = myOperations.last(); anOp; anOp = myOperations.prev() )
+ for ( anOp = myOperations.last(); anOp; anOp = myOperations.prev() )
+ {
if ( anOp && anOp != theOp && blockingOperation( anOp ) == 0 )
{
aResultOp = anOp;
break;
}
+ }
+ theOp->stopOperation();
+ operationStopped( theOp );
emit theOp->stopped( theOp );
+
if ( aResultOp )
resume( aResultOp );
}
return myOperations;
}
+/*!
+ * \brief Perform some actions when operation starting
+*/
+void SUIT_Study::operationStarted( SUIT_Operation* op )
+{
+ if ( !op )
+ return;
+ if ( op->testFlags( SUIT_Operation::Transaction ) )
+ op->openTransaction();
+}
+/*!
+ * \brief Perform some actions when operation aborted
+*/
+void SUIT_Study::operationAborted( SUIT_Operation* op )
+{
+ if ( op->testFlags( SUIT_Operation::Transaction ) )
+ op->abortTransaction();
+}
+/*!
+ * \brief Perform some actions when operation commited
+*/
+void SUIT_Study::operationCommited( SUIT_Operation* op )
+{
+ if ( op->testFlags( SUIT_Operation::Transaction ) )
+ op->commitTransaction( op->operationName() );
+}
+/*!
+ * \brief Perform some actions when operation stopped
+*/
+void SUIT_Study::operationStopped( SUIT_Operation* )
+{
+}
+/*!
+ * \brief Opens transaction for data modifications.
+*/
+bool SUIT_Study::openTransaction()
+{
+ return true;
+}
+/*!
+ * \brief Aborts transaction and all performed data modifications.
+*/
+bool SUIT_Study::abortTransaction()
+{
+ return true;
+}
+/*!
+ * \brief Commits transaction and all performed data modifications.
+*/
+bool SUIT_Study::commitTransaction( const QString& )
+{
+ return true;
+}
-
+/*!
+ * \brief Returns TRUE if transaction is opened.
+*/
+bool SUIT_Study::hasTransaction() const
+{
+ return false;
+}