Salome HOME
Initial version
[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 SUIT_Operation::SUIT_Operation( SUIT_Application* app )
7 : QObject(),
8 myApp( app ),
9 myStudy( 0 ),
10 myState( Waiting )
11 {
12 }
13
14 SUIT_Operation::~SUIT_Operation()
15 {
16 }
17
18 SUIT_Study* SUIT_Operation::study() const
19 {
20   return myStudy;
21 }
22
23 SUIT_Application* SUIT_Operation::application() const
24 {
25   return myApp;
26 }
27
28 SUIT_Operation::OperationState SUIT_Operation::state() const
29 {
30   return myState;
31 }
32
33 void SUIT_Operation::start()
34 {
35         myStudy = myApp->activeStudy();
36         if ( myStudy )
37   {
38                 if ( myStudy->canStartOperation( this ) )
39     {
40       if ( !isReadyToStart() )
41       {
42         myStudy->stopOperation();
43         return;
44       }
45                         startOperation();
46                         myState = Running;
47
48                         emit started( this );
49                 }
50         }
51 }
52
53 void SUIT_Operation::abort()
54 {
55         abortOperation();
56         myStudy->stopOperation();
57         myState = Waiting;
58
59   emit aborted( this );
60 }
61
62 void SUIT_Operation::commit()
63 {
64         commitOperation();
65         myStudy->stopOperation();
66         myState = Waiting;
67
68         emit commited( this );
69
70   myStudy->sendChangesNotification();
71 }
72
73 void SUIT_Operation::resume()
74 {
75         resumeOperation();
76         myState = Running;
77
78         emit resumed( this );
79 }
80
81 void SUIT_Operation::suspend()
82 {
83         suspendOperation();
84         myState = Suspended;
85
86         emit suspended( this );
87 }
88
89 bool SUIT_Operation::isReadyToStart()
90 {
91         return true;
92 }
93
94 void SUIT_Operation::startOperation()
95 {
96         emit callSlot();
97
98         commit();
99 }
100
101 void SUIT_Operation::abortOperation()
102 {
103 }
104
105 void SUIT_Operation::resumeOperation()
106 {
107 }
108
109 void SUIT_Operation::suspendOperation()
110 {
111 }
112
113 void SUIT_Operation::commitOperation()
114 {
115 }
116
117 bool SUIT_Operation::setSlot( const QObject* theReceiver, const char* theSlot )
118 {
119         return connect( this, SIGNAL( callSlot() ), theReceiver, theSlot );
120 }
121
122 bool SUIT_Operation::isValid( SUIT_Operation* ) const
123 {
124   return false;
125 }
126
127 bool SUIT_Operation::isGranted() const
128 {
129   return false;
130 }
131
132 void SUIT_Operation::setStudy( SUIT_Study* s )
133 {
134   myStudy = s;
135 }
136
137 void SUIT_Operation::setApplication( SUIT_Application* app )
138 {
139   myApp = app;
140 }