Salome HOME
Update comments
[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 /*!
8   Constructor.
9 */
10 SUIT_ActionOperation::SUIT_ActionOperation( SUIT_Application* app )
11 : SUIT_Operation( app ),
12 myAction( 0 )
13 {
14 }
15
16 /*!
17   Destructor.
18 */
19 SUIT_ActionOperation::~SUIT_ActionOperation()
20 {
21 }
22
23 /*!
24   Gets action.
25 */
26 QtxAction* SUIT_ActionOperation::action() const
27 {
28   return myAction;
29 }
30
31 /*!Set action.
32  * Create new instance of QtxAction and set.
33  */
34 void SUIT_ActionOperation::setAction( const QString& text, const QIconSet& icon,
35                                       const QString& menuText, QKeySequence accel,
36                                       QObject* parent, const char* name, bool toggle )
37 {
38   setAction( new QtxAction( text, icon, menuText, accel, parent, name, toggle ) );
39 }
40
41 /*!Set action.
42  * Create new instance of QtxAction and set.
43  */
44 void SUIT_ActionOperation::setAction( const QString& text, const QString& menuText,
45                                       QKeySequence accel, QObject* parent, const char* name, bool toggle )
46 {
47   setAction( new QtxAction(text, menuText, accel, parent, name, toggle ) );
48 }
49
50 /*!Set action.
51  */
52 void SUIT_ActionOperation::setAction( QtxAction* a )
53 {
54   if ( myAction == a )
55     return;
56
57   delete myAction;
58   myAction = a;
59
60   myAction->setEnabled( application()->activeStudy() );
61   connect( myAction, SIGNAL( activated() ), SLOT( start() ) );
62 }
63
64 /*! Add action to widget \a wid.
65  *\retval TRUE - successful, FALSE - not successful.
66  */
67 bool SUIT_ActionOperation::addTo( QWidget* wid )
68 {
69   if ( !action() )
70     return false;
71
72   return action()->addTo( wid );
73 }
74
75 /*! Add action to widget \a wid.
76  *\retval TRUE - successful, FALSE - not successful.
77  */
78 bool SUIT_ActionOperation::addTo( QWidget* wid, int idx )
79 {
80   if ( !action() )
81     return false;
82
83   return action()->addTo( wid, idx );
84 }
85
86 /*! Set status tip for action.
87 */
88 void SUIT_ActionOperation::setStatusTip( const QString& tip )
89 {
90   if ( action() )
91     action()->setStatusTip( tip );
92 }