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(bool permanently)
69 void SUIT_Study::createDocument()
71 /*! Custom document initialization to be performed \n
72 * within onNewDoc() handler can be put here
76 bool SUIT_Study::openDocument( const QString& fileName )
85 bool SUIT_Study::saveDocumentAs( const QString& fileName )
94 bool SUIT_Study::saveDocument()
96 return saveDocumentAs( myName );
99 void SUIT_Study::abortAllOperations()
101 SUIT_Operation* aOperation = 0;
102 while ( aOperation = myOperations.current() )
109 void SUIT_Study::update()
113 void SUIT_Study::sendChangesNotification()
115 emit studyModified( this );
118 void SUIT_Study::setIsSaved( const bool on )
123 void SUIT_Study::setIsModified( const bool on )
128 void SUIT_Study::setRoot( SUIT_DataObject* obj )
137 void SUIT_Study::setStudyName( const QString& name )
142 void SUIT_Study::stopOperation()
145 if ( myOperations.current() )
146 myOperations.current()->resume();
150 bool SUIT_Study::canStartOperation( SUIT_Operation* theOperation )
152 SUIT_Operation* anActiveOperation = (SUIT_Operation*)activeOperation();
153 if ( anActiveOperation )
155 if ( !theOperation->isGranted() )
157 if ( !anActiveOperation->isValid( theOperation ) )
159 // Ask user about existing operation
160 int anAnsw = SUIT_MessageBox::warn2( application()->desktop(), tr( "Operation launch" ),
161 tr( "Previous operation is not finished and will be aborted." ),
162 tr( "Continue" ), tr( "Cancel" ), 0, 1, 1 );
166 anActiveOperation->abort();
168 myOperations.push( theOperation );
172 anActiveOperation->suspend();
174 myOperations.push( theOperation );