Salome HOME
Merge from OCC_development_generic_2006
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_ManagePortsDlg.h
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SUPERVGUI_ManagePortsDlg.h
8 //  Author : Alexander SLADKOV
9 //  Module : SUPERV
10
11 #ifndef SUPERVGUI_ManagePortsDlg_H
12 #define SUPERVGUI_ManagePortsDlg_H
13
14 #include "SUPERVGUI.h"
15
16 #include <qdialog.h>
17 #include <qlistbox.h>
18 #include <qstringlist.h>
19 #include <qlineedit.h>
20 #include <qcombobox.h>
21 #include <qpair.h>
22
23 class SUPERVGUI_CanvasNode;
24
25 /** 
26  * Simple redefinition of ListBoxItem for storing ports name and type without having to parce it
27  */
28 class PortListItem : QListBoxText {
29 public:
30   PortListItem ( QListBox* lb, const QString& name, const QString& type )
31   : QListBoxText( lb/*, QString( "%1 (%2)" ).arg( name ).arg( type )*/ ),
32     PortName( name ),
33     PortType( type ) {}
34   QString PortName;
35   QString PortType;
36   virtual QString text() const { return QString( "%1 (%2)" ).arg( PortName ).arg( PortType ); }
37 };
38
39 /**
40  * The dialog class
41  */
42 class SUPERVGUI_ManagePortsDlg: public QDialog {
43   
44   Q_OBJECT
45
46 public:
47   SUPERVGUI_ManagePortsDlg( SUPERVGUI_CanvasNode* theNode );
48   virtual ~SUPERVGUI_ManagePortsDlg();
49
50 protected slots:
51   void accept();
52   void reject();
53
54   void addInput()     { addPort( myInList ); }    
55   void addOutput()    { addPort( myOutList );}
56   void removeInput()  { removePort( myInList ); }
57   void removeOutput() { removePort( myOutList );}
58   void upInput()      { moveUp( myInList ); }
59   void upOutput()     { moveUp( myOutList );}
60   void downInput()    { moveDown( myInList ); }
61   void downOutput()   { moveDown( myOutList );}
62
63   void nameChanged( const QString& name );
64   void typeChanged( const QString& type );
65   void itemChanged( QListBoxItem * item );
66
67 protected:
68   virtual void showEvent( QShowEvent* theEvent );
69   void addPort( QListBox* );
70   void removePort( QListBox* );
71   void moveUp( QListBox* );
72   void moveDown( QListBox* );
73   void moveItem( QListBox* theLB, const int from, const int to );
74   // mkr : PAL8060
75   void createLinkEngine( SUPERV::Port_ptr thePort, 
76                          QValueList< QPair< QString,QString > >& theOwnList, 
77                          QValueList< QPair< QString,QString > >& theCorrespList );
78   
79 private:
80   void init();
81   void init( const SUPERVGUI_CanvasNode* theNode );
82
83   SUPERVGUI_CanvasNode*         myNode;
84
85   QLineEdit*                    myNameEdt;
86   QComboBox*                    myTypeCombo;
87   QListBox*                     myInList;
88   QListBox*                     myOutList;
89   QListBoxItem*                 myLastItem;
90 };
91
92 /*!
93  * Port parameters dialog definition (taken from SUPERVGUI_Node.h without change)
94  */
95 class SUPERVGUI_PortParamsDlg: public QDialog {
96   Q_OBJECT
97     
98  public:
99   SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames);
100   ~SUPERVGUI_PortParamsDlg() {};
101
102   QString getName() { return myNameTxt->text(); }
103   QString getType() { return myTypeTxt->currentText(); }
104
105  public slots:
106   void clickOnOk();
107     
108    
109  private:
110   QLineEdit* myNameTxt;
111   QComboBox* myTypeTxt;
112   QStringList myPortsNames;
113 };
114
115
116 #endif