Salome HOME
Copyrights update
[modules/gui.git] / src / SUIT / SUIT_PopupClient.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #include "SUIT_PopupClient.h"
20
21 #include <qevent.h>
22
23 /*! constructor. initialize mySignal.*/
24 SUIT_PopupClient::SUIT_PopupClient()
25 : mySignal( 0 )
26 {
27 }
28
29 /*! destructor. delete mySignal*/
30 SUIT_PopupClient::~SUIT_PopupClient()
31 {
32   delete mySignal;
33 }
34
35 /*!
36   Connect popup request.
37 */
38 bool SUIT_PopupClient::connectPopupRequest( QObject* reciever, const char* slot )
39 {
40   if ( !reciever || !slot )
41     return false;
42   if ( !mySignal )
43     mySignal = new Signal();
44   return QObject::connect( mySignal, SIGNAL( contextMenuRequest( SUIT_PopupClient*, QContextMenuEvent* ) ),
45                            reciever, slot );
46 }
47
48 /*!
49   Disconnect popup request.
50 */
51 bool SUIT_PopupClient::disconnectPopupRequest( QObject* reciever, const char* slot )
52 {
53   if ( !reciever || !slot || !mySignal )
54     return false;
55   return QObject::disconnect( mySignal, SIGNAL( contextMenuRequest( SUIT_PopupClient*, QContextMenuEvent* ) ),
56                               reciever, slot );
57 }
58
59 /*!
60   Send signal on context menu request.
61 */
62 void SUIT_PopupClient::contextMenuRequest( QContextMenuEvent* e )
63 {
64   if ( mySignal )
65     mySignal->sendSignal( this, e );
66 }
67
68 /*!
69  *  \class SUIT_PopupClient::Signal
70  * Descr: invoke signal which is connected to reciever in SUIT_PopupClient
71  */
72
73 /*! constructor*/
74 SUIT_PopupClient::Signal::Signal()
75 : QObject( 0 )
76 {
77 }
78
79 /*! destructor. do nothing*/
80 SUIT_PopupClient::Signal::~Signal()
81 {}
82
83 /*! Send signal to \a client on context menu request \a e.
84  */
85 void SUIT_PopupClient::Signal::sendSignal( SUIT_PopupClient* client, QContextMenuEvent* e )
86 {
87   emit contextMenuRequest( client, e );
88 }