Salome HOME
c9e532793a28a7e78954c495d2a0429d5aea29d6
[modules/gui.git] / src / SUIT / SUIT_PopupClient.cxx
1 #include "SUIT_PopupClient.h"
2
3 #include <qevent.h>
4
5 /*! constructor. initialize mySignal.*/
6 SUIT_PopupClient::SUIT_PopupClient()
7 : mySignal( 0 )
8 {
9 }
10
11 /*! destructor. delete mySignal*/
12 SUIT_PopupClient::~SUIT_PopupClient()
13 {
14   delete mySignal;
15 }
16
17 /*!
18   Connect popup request.
19 */
20 bool SUIT_PopupClient::connectPopupRequest( QObject* reciever, const char* slot )
21 {
22   if ( !reciever || !slot )
23     return false;
24   if ( !mySignal )
25     mySignal = new Signal();
26   return QObject::connect( mySignal, SIGNAL( contextMenuRequest( SUIT_PopupClient*, QContextMenuEvent* ) ),
27                            reciever, slot );
28 }
29
30 /*!
31   Disconnect popup request.
32 */
33 bool SUIT_PopupClient::disconnectPopupRequest( QObject* reciever, const char* slot )
34 {
35   if ( !reciever || !slot || !mySignal )
36     return false;
37   return QObject::disconnect( mySignal, SIGNAL( contextMenuRequest( SUIT_PopupClient*, QContextMenuEvent* ) ),
38                               reciever, slot );
39 }
40
41 /*!
42   Send signal on context menu request.
43 */
44 void SUIT_PopupClient::contextMenuRequest( QContextMenuEvent* e )
45 {
46   if ( mySignal )
47     mySignal->sendSignal( this, e );
48 }
49
50 /*!
51  *  \class SUIT_PopupClient::Signal
52  * Descr: invoke signal which is connected to reciever in SUIT_PopupClient
53  */
54
55 /*! constructor*/
56 SUIT_PopupClient::Signal::Signal()
57 : QObject( 0 )
58 {
59 }
60
61 /*! destructor. do nothing*/
62 SUIT_PopupClient::Signal::~Signal()
63 {}
64
65 /*! Send signal to \a client on context menu request \a e.
66  */
67 void SUIT_PopupClient::Signal::sendSignal( SUIT_PopupClient* client, QContextMenuEvent* e )
68 {
69   emit contextMenuRequest( client, e );
70 }