Salome HOME
Initial version
[modules/gui.git] / src / SUIT / SUIT_ActionOperation.cxx
1 #include "SUIT_ActionOperation.h"
2
3 #include "SUIT_Application.h"
4
5 #include <QtxAction.h>
6
7 SUIT_ActionOperation::SUIT_ActionOperation( SUIT_Application* app )
8 : SUIT_Operation( app ),
9 myAction( 0 )
10 {
11 }
12
13 SUIT_ActionOperation::~SUIT_ActionOperation()
14 {
15 }
16
17 QtxAction* SUIT_ActionOperation::action() const
18 {
19   return myAction;
20 }
21
22 void SUIT_ActionOperation::setAction( const QString& text, const QIconSet& icon,
23                                                               const QString& menuText, QKeySequence accel,
24                                       QObject* parent, const char* name, bool toggle )
25 {
26   setAction( new QtxAction( text, icon, menuText, accel, parent, name, toggle ) );
27 }
28
29 void SUIT_ActionOperation::setAction( const QString& text, const QString& menuText,
30                                                               QKeySequence accel, QObject* parent, const char* name, bool toggle )
31 {
32   setAction( new QtxAction(text, menuText, accel, parent, name, toggle ) );
33 }
34
35 void SUIT_ActionOperation::setAction( QtxAction* a )
36 {
37   if ( myAction == a )
38     return;
39
40   delete myAction;
41   myAction = a;
42
43   myAction->setEnabled( application()->activeStudy() );
44   connect( myAction, SIGNAL( activated() ), SLOT( start() ) );
45 }
46
47 bool SUIT_ActionOperation::addTo( QWidget* wid )
48 {
49   if ( !action() )
50     return false;
51
52   return action()->addTo( wid );
53 }
54
55 bool SUIT_ActionOperation::addTo( QWidget* wid, int idx )
56 {
57   if ( !action() )
58     return false;
59
60   return action()->addTo( wid, idx );
61 }
62
63 void SUIT_ActionOperation::setStatusTip( const QString& tip )
64 {
65         if ( action() )
66                 action()->setStatusTip( tip );
67 }