1 #include "SUIT_Study.h"
3 #include "SUIT_Desktop.h"
4 #include "SUIT_Operation.h"
5 #include "SUIT_DataObject.h"
6 #include "SUIT_MessageBox.h"
7 #include "SUIT_Application.h"
9 SUIT_Study::SUIT_Study( SUIT_Application* app )
13 myIsModified( false ),
20 myRoot = new SUIT_DataObject();
21 myOperations.setAutoDelete( false );
24 SUIT_Study::~SUIT_Study()
30 int SUIT_Study::id() const
35 SUIT_DataObject* SUIT_Study::root() const
40 SUIT_Application* SUIT_Study::application() const
45 QString SUIT_Study::studyName() const
50 SUIT_Operation* SUIT_Study::activeOperation() const
52 return myOperations.current();
55 bool SUIT_Study::isSaved() const
60 bool SUIT_Study::isModified() const
65 void SUIT_Study::closeDocument()
69 void SUIT_Study::createDocument()
71 // Custom document initialization to be performed
72 // within onNewDoc() handler can be put here
75 bool SUIT_Study::openDocument( const QString& fileName )
84 bool SUIT_Study::saveDocumentAs( const QString& fileName )
93 bool SUIT_Study::saveDocument()
95 return saveDocumentAs( myName );
98 void SUIT_Study::abortAllOperations()
100 SUIT_Operation* aOperation = 0;
101 while ( aOperation = myOperations.current() )
108 void SUIT_Study::update()
112 void SUIT_Study::sendChangesNotification()
114 emit studyModified( this );
117 void SUIT_Study::setIsSaved( const bool on )
122 void SUIT_Study::setIsModified( const bool on )
127 void SUIT_Study::setRoot( SUIT_DataObject* obj )
136 void SUIT_Study::setStudyName( const QString& name )
141 void SUIT_Study::stopOperation()
144 if ( myOperations.current() )
145 myOperations.current()->resume();
149 bool SUIT_Study::canStartOperation( SUIT_Operation* theOperation )
151 SUIT_Operation* anActiveOperation = (SUIT_Operation*)activeOperation();
152 if ( anActiveOperation )
154 if ( !theOperation->isGranted() )
156 if ( !anActiveOperation->isValid( theOperation ) )
158 // Ask user about existing operation
159 int anAnsw = SUIT_MessageBox::warn2( application()->desktop(), tr( "Operation launch" ),
160 tr( "Previous operation is not finished and will be aborted." ),
161 tr( "Continue" ), tr( "Cancel" ), 0, 1, 1 );
165 anActiveOperation->abort();
167 myOperations.push( theOperation );
171 anActiveOperation->suspend();
173 myOperations.push( theOperation );