+// 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 "CAF_Study.h"
#include "CAF_Tools.h"
#include <TDF_Delta.hxx>
#include <TDF_ListIteratorOfDeltaList.hxx>
+#include <Standard_ErrorHandler.hxx>
+
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
return status && SUIT_Study::saveDocumentAs( fname );
}
-bool CAF_Study::startOperation()
+bool CAF_Study::openTransaction()
{
if ( myStdDoc.IsNull() )
return false;
return res;
}
-void CAF_Study::abortOperation()
+bool CAF_Study::abortTransaction()
{
if ( myStdDoc.IsNull() )
- return;
+ return false;
+ bool res = true;
try {
myStdDoc->AbortCommand();
update();
}
catch ( Standard_Failure ) {
+ res = false;
}
+ return res;
}
-void CAF_Study::commitOperation()
+bool CAF_Study::commitTransaction( const QString& name )
{
if ( myStdDoc.IsNull() )
- return;
+ return false;
+ bool res = true;
try {
myStdDoc->CommitCommand();
if ( canUndo() )
{
- CAF_Operation* cafOp = 0;
- if ( activeOperation() && activeOperation()->inherits( "CAF_Operation" ) )
- cafOp = (CAF_Operation*)activeOperation();
-
Handle(TDF_Delta) d = myStdDoc->GetUndos().Last();
- if ( cafOp && !d.IsNull() )
- d->SetName( CAF_Tools::toExtString( cafOp->getName() ) );
+ if ( !d.IsNull() )
+ d->SetName( CAF_Tools::toExtString( name ) );
}
}
catch ( Standard_Failure ) {
+ res = false;
}
+ return res;
+}
+
+bool CAF_Study::hasTransaction() const
+{
+ if ( myStdDoc.IsNull() )
+ return false;
+
+ return myStdDoc->HasOpenCommand();
}
/*!