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"
10 * Support study management. Object management. Operation management.
14 SUIT_Study::SUIT_Study( SUIT_Application* app )
18 myIsModified( false ),
25 myRoot = new SUIT_DataObject();
26 myOperations.setAutoDelete( false );
30 SUIT_Study::~SUIT_Study()
39 int SUIT_Study::id() const
45 *\retval root data object.
47 SUIT_DataObject* SUIT_Study::root() const
55 SUIT_Application* SUIT_Study::application() const
63 QString SUIT_Study::studyName() const
69 *\retval active operation.
71 SUIT_Operation* SUIT_Study::activeOperation() const
73 return myOperations.current();
77 *\retval TRUE - if study saved, else FALSE.
79 bool SUIT_Study::isSaved() const
85 *\retval TRUE - if study modified, else FALSE.
87 bool SUIT_Study::isModified() const
93 *Close document. NOT IMPLEMENTED.
95 void SUIT_Study::closeDocument(bool permanently)
99 void SUIT_Study::createDocument()
101 /*! Custom document initialization to be performed \n
102 * within onNewDoc() handler can be put here
107 * Open document. Sets file name. return true.
109 bool SUIT_Study::openDocument( const QString& fileName )
113 myIsModified = false;
119 * Save document as \a fileName. Set file name.
121 bool SUIT_Study::saveDocumentAs( const QString& fileName )
125 myIsModified = false;
131 *\retval TRUE - if document saved successful, else FALSE.
133 bool SUIT_Study::saveDocument()
135 return saveDocumentAs( myName );
139 *Abort all operations.
141 void SUIT_Study::abortAllOperations()
143 SUIT_Operation* aOperation = 0;
144 while ( aOperation = myOperations.current() )
152 Update study. NOT IMPLEMENTED HERE.
154 void SUIT_Study::update()
161 void SUIT_Study::sendChangesNotification()
163 emit studyModified( this );
167 Set study saved to \a on.
169 void SUIT_Study::setIsSaved( const bool on )
175 Set study modified to \a on.
177 void SUIT_Study::setIsModified( const bool on )
185 void SUIT_Study::setRoot( SUIT_DataObject* obj )
197 void SUIT_Study::setStudyName( const QString& name )
205 void SUIT_Study::stopOperation()
208 if ( myOperations.current() )
209 myOperations.current()->resume();
214 * Set can start operation \a theOperation.
215 *\retval FALSE - if can't start.
217 bool SUIT_Study::canStartOperation( SUIT_Operation* theOperation )
219 SUIT_Operation* anActiveOperation = (SUIT_Operation*)activeOperation();
220 if ( anActiveOperation )
222 if ( !theOperation->isGranted() )
224 if ( !anActiveOperation->isValid( theOperation ) )
226 // Ask user about existing operation
227 int anAnsw = SUIT_MessageBox::warn2( application()->desktop(), tr( "Operation launch" ),
228 tr( "Previous operation is not finished and will be aborted." ),
229 tr( "Continue" ), tr( "Cancel" ), 0, 1, 1 );
233 anActiveOperation->abort();
235 myOperations.push( theOperation );
239 anActiveOperation->suspend();
241 myOperations.push( theOperation );