Salome HOME
Update comments
[modules/gui.git] / src / SUIT / SUIT_Operation.cxx
1 #include "SUIT_Operation.h"
2
3 #include "SUIT_Study.h"
4 #include "SUIT_Application.h"
5
6 /*! Constructor. Initialize myApp, myStudy, myState.*/
7 SUIT_Operation::SUIT_Operation( SUIT_Application* app )
8 : QObject(),
9 myApp( app ),
10 myStudy( 0 ),
11 myState( Waiting )
12 {
13 }
14
15 /*! Destructor*/
16 SUIT_Operation::~SUIT_Operation()
17 {
18 }
19
20 /*! \retval Return myStudy.*/
21 SUIT_Study* SUIT_Operation::study() const
22 {
23   return myStudy;
24 }
25
26 /*! \retval Return myApp*/
27 SUIT_Application* SUIT_Operation::application() const
28 {
29   return myApp;
30 }
31
32 /*! \retval Return myState*/
33 SUIT_Operation::OperationState SUIT_Operation::state() const
34 {
35   return myState;
36 }
37
38 /*! Set started operation status*/
39 void SUIT_Operation::start()
40 {
41         myStudy = myApp->activeStudy();
42         if ( myStudy )
43   {
44                 if ( myStudy->canStartOperation( this ) )
45     {
46       if ( !isReadyToStart() )
47       {
48         myStudy->stopOperation();
49         return;
50       }
51                         startOperation();
52                         myState = Running;
53
54                         emit started( this );
55                 }
56         }
57 }
58
59 /*! Set aborted operation status*/
60 void SUIT_Operation::abort()
61 {
62         abortOperation();
63         myStudy->stopOperation();
64         myState = Waiting;
65
66   emit aborted( this );
67 }
68
69 /*! Set commited operation status*/
70 void SUIT_Operation::commit()
71 {
72         commitOperation();
73         myStudy->stopOperation();
74         myState = Waiting;
75
76         emit commited( this );
77
78   myStudy->sendChangesNotification();
79 }
80
81 /*! Set resumed operation status*/
82 void SUIT_Operation::resume()
83 {
84         resumeOperation();
85         myState = Running;
86
87         emit resumed( this );
88 }
89
90 /*! Set suspended operation status*/
91 void SUIT_Operation::suspend()
92 {
93         suspendOperation();
94         myState = Suspended;
95
96         emit suspended( this );
97 }
98
99 /*! \retval Return true*/
100 bool SUIT_Operation::isReadyToStart()
101 {
102         return true;
103 }
104
105 /*! start operation.\n
106  *  emitting callSlot() signal \n
107  *  calling commit() function.
108  */
109 void SUIT_Operation::startOperation()
110 {
111         emit callSlot();
112
113         commit();
114 }
115
116 /*! Do nothing*/
117 void SUIT_Operation::abortOperation()
118 {
119 }
120
121 /*! Do nothing*/
122 void SUIT_Operation::resumeOperation()
123 {
124 }
125
126 /*! Do nothing*/
127 void SUIT_Operation::suspendOperation()
128 {
129 }
130
131 /*! Do nothing*/
132 void SUIT_Operation::commitOperation()
133 {
134 }
135
136 /*! Setting slot.*/
137 bool SUIT_Operation::setSlot( const QObject* theReceiver, const char* theSlot )
138 {
139         return connect( this, SIGNAL( callSlot() ), theReceiver, theSlot );
140 }
141
142 /*! \retval Return false*/
143 bool SUIT_Operation::isValid( SUIT_Operation* ) const
144 {
145   return false;
146 }
147
148 /*! \retval Return false*/
149 bool SUIT_Operation::isGranted() const
150 {
151   return false;
152 }
153
154 /*! Setting study.*/
155 void SUIT_Operation::setStudy( SUIT_Study* s )
156 {
157   myStudy = s;
158 }
159
160 /*! Setting application.*/
161 void SUIT_Operation::setApplication( SUIT_Application* app )
162 {
163   myApp = app;
164 }